// Path: web/javamoney-payment-cdi-event/src/main/java/org/javamoney/examples/cdi/payment/events/PaymentEvent.java
// public class PaymentEvent {
// 	private PaymentType type;  //credit or debit
// 	private Date datetime;
// 	private MonetaryAmount money;
// 	
// 	public PaymentType getType() {
// 		return type;
// 	}
// 	public void setType(PaymentType type) {
// 		this.type = type;
// 	}
// 
// 	public Date getDatetime() {
// 		return datetime;
// 	}
// 	public void setDatetime(Date datetime) {
// 		this.datetime = datetime;
// 	}
// 
// 	public String toString(){
//         return String.format("EVT: %s:%s:%s", getDatetime(), getMoney(), getType());
// 	}
// 	public MonetaryAmount getMoney() {
// 		return money;
// 	}
// 	public void setMoney(MonetaryAmount money) {
// 		this.money = money;
// 	}
// }
// 
// Path: web/javamoney-payment-cdi-event/src/main/java/org/javamoney/examples/cdi/payment/events/PaymentType.java
// public enum PaymentType {
// 
// 	CREDIT("1"), DEBIT("2");
// 
// 	private final String value;
// 
// 	static final Map<String, PaymentType> map = new HashMap<String, PaymentType>();
// 
// 	static {
// 		for (PaymentType paymentType : PaymentType.values()) {
// 			map.put(paymentType.getValue(), paymentType);
// 		}
// 	}
// 
// 	private PaymentType(String value) {
// 		this.value = value;
// 	}
// 
// 	public String getValue() {
// 		return value;
// 	}
// 
// 	public static PaymentType of(String value) {
// 		return map.get(value);
// 	}
// }


import javax.money.Monetary;
import org.javamoney.examples.cdi.payment.events.PaymentEvent;
import org.javamoney.examples.cdi.payment.events.PaymentType;
import org.javamoney.examples.cdi.payment.qualifiers.Amount;
import org.javamoney.examples.cdi.payment.qualifiers.Credit;
import org.javamoney.examples.cdi.payment.qualifiers.Debit;
import org.javamoney.moneta.Money;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.logging.Logger;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.inject.Named;
import javax.money.CurrencyUnit;
import javax.money.MonetaryAmount;
	@Amount
	private MonetaryAmount money = Money.of(amount, CURRENCY);

	public MonetaryAmount getMoney() {
		return money;
	}

	public void setMoney(MonetaryAmount money) {
		this.money = money;
	}

	private String paymentOption = PaymentType.DEBIT.toString();

	// Pay Action
	public String pay() {
		PaymentEvent currentEvtPayload = new PaymentEvent();
		currentEvtPayload.setType(PaymentType.of(paymentOption));
		currentEvtPayload.setMoney(money);
		currentEvtPayload.setDatetime(new Date());

		switch (currentEvtPayload.getType()) {
		case DEBIT:
			debitEventProducer.fire(currentEvtPayload);
			break;

		case CREDIT:
			creditEventProducer.fire(currentEvtPayload);
			break;

		default:
// Path: web/javamoney-payment-cdi-event/src/main/java/org/javamoney/examples/cdi/payment/events/PaymentEvent.java
// public class PaymentEvent {
// 	private PaymentType type;  //credit or debit
// 	private Date datetime;
// 	private MonetaryAmount money;
// 	
// 	public PaymentType getType() {
// 		return type;
// 	}
// 	public void setType(PaymentType type) {
// 		this.type = type;
// 	}
// 
// 	public Date getDatetime() {
// 		return datetime;
// 	}
// 	public void setDatetime(Date datetime) {
// 		this.datetime = datetime;
// 	}
// 
// 	public String toString(){
//         return String.format("EVT: %s:%s:%s", getDatetime(), getMoney(), getType());
// 	}
// 	public MonetaryAmount getMoney() {
// 		return money;
// 	}
// 	public void setMoney(MonetaryAmount money) {
// 		this.money = money;
// 	}
// }
// 
// Path: web/javamoney-payment-cdi-event/src/main/java/org/javamoney/examples/cdi/payment/events/PaymentType.java
// public enum PaymentType {
// 
// 	CREDIT("1"), DEBIT("2");
// 
// 	private final String value;
// 
// 	static final Map<String, PaymentType> map = new HashMap<String, PaymentType>();
// 
// 	static {
// 		for (PaymentType paymentType : PaymentType.values()) {
// 			map.put(paymentType.getValue(), paymentType);
// 		}
// 	}
// 
// 	private PaymentType(String value) {
// 		this.value = value;
// 	}
// 
// 	public String getValue() {
// 		return value;
// 	}
// 
// 	public static PaymentType of(String value) {
// 		return map.get(value);
// 	}
// }


// Path: web/javamoney-payment-cdi-event/src/main/java/org/javamoney/examples/cdi/payment/beans/PaymentBean.java
import javax.money.Monetary;
import org.javamoney.examples.cdi.payment.events.PaymentEvent;
import org.javamoney.examples.cdi.payment.events.PaymentType;
import org.javamoney.examples.cdi.payment.qualifiers.Amount;
import org.javamoney.examples.cdi.payment.qualifiers.Credit;
import org.javamoney.examples.cdi.payment.qualifiers.Debit;
import org.javamoney.moneta.Money;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.logging.Logger;
import javax.enterprise.context.SessionScoped;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.inject.Named;
import javax.money.CurrencyUnit;
import javax.money.MonetaryAmount;

	@Amount
	private MonetaryAmount money = Money.of(amount, CURRENCY);

	public MonetaryAmount getMoney() {
		return money;
	}

	public void setMoney(MonetaryAmount money) {
		this.money = money;
	}

	private String paymentOption = PaymentType.DEBIT.toString();

	// Pay Action
	public String pay() {
		PaymentEvent currentEvtPayload = new PaymentEvent();
		currentEvtPayload.setType(PaymentType.of(paymentOption));
		currentEvtPayload.setMoney(money);
		currentEvtPayload.setDatetime(new Date());

		switch (currentEvtPayload.getType()) {
		case DEBIT:
			debitEventProducer.fire(currentEvtPayload);
			break;

		case CREDIT:
			creditEventProducer.fire(currentEvtPayload);
			break;

		default:
			log.severe("invalid payment option");