Skip to content

Commit a17becc

Browse files
AustinMRookephillipuniverse
authored andcommitted
BroadleafCommerce/QA#977 Implemented Final Payment Enhancement, this enhancement adds a new boolean which reveals if it is a final payment type or not.
(cherry picked from commit c3c69c2b692ba8ad474200cc8bcbc9d21ee53233)
1 parent badf8f4 commit a17becc

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

common/src/main/java/org/broadleafcommerce/common/payment/PaymentType.java

+24-12
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,16 @@ public class PaymentType implements Serializable, BroadleafEnumerationType {
3838

3939
private static final Map<String, PaymentType> TYPES = new LinkedHashMap<String, PaymentType>();
4040

41-
public static final PaymentType GIFT_CARD = new PaymentType("GIFT_CARD", "Gift Card");
42-
public static final PaymentType CREDIT_CARD = new PaymentType("CREDIT_CARD", "Credit Card");
43-
public static final PaymentType BANK_ACCOUNT = new PaymentType("BANK_ACCOUNT", "Bank Account");
44-
public static final PaymentType CHECK = new PaymentType("CHECK", "Check");
45-
public static final PaymentType ELECTRONIC_CHECK = new PaymentType("ELECTRONIC_CHECK", "Electronic Check");
46-
public static final PaymentType WIRE = new PaymentType("WIRE", "Wire Transfer");
47-
public static final PaymentType MONEY_ORDER = new PaymentType("MONEY_ORDER", "Money Order");
48-
public static final PaymentType CUSTOMER_CREDIT = new PaymentType("CUSTOMER_CREDIT", "Customer Credit");
49-
public static final PaymentType COD = new PaymentType("COD", "Collect On Delivery");
50-
public static final PaymentType CUSTOMER_PAYMENT = new PaymentType("CUSTOMER_PAYMENT", "Customer Payment");
41+
public static final PaymentType GIFT_CARD = new PaymentType("GIFT_CARD", "Gift Card", false);
42+
public static final PaymentType CREDIT_CARD = new PaymentType("CREDIT_CARD", "Credit Card", true);
43+
public static final PaymentType BANK_ACCOUNT = new PaymentType("BANK_ACCOUNT", "Bank Account", false);
44+
public static final PaymentType CHECK = new PaymentType("CHECK", "Check", false);
45+
public static final PaymentType ELECTRONIC_CHECK = new PaymentType("ELECTRONIC_CHECK", "Electronic Check", false);
46+
public static final PaymentType WIRE = new PaymentType("WIRE", "Wire Transfer", false);
47+
public static final PaymentType MONEY_ORDER = new PaymentType("MONEY_ORDER", "Money Order", false);
48+
public static final PaymentType CUSTOMER_CREDIT = new PaymentType("CUSTOMER_CREDIT", "Customer Credit", false);
49+
public static final PaymentType COD = new PaymentType("COD", "Collect On Delivery", false);
50+
public static final PaymentType CUSTOMER_PAYMENT = new PaymentType("CUSTOMER_PAYMENT", "Customer Payment", false);
5151
/**
5252
* Intended for modules like PayPal Express Checkout
5353
*
@@ -58,14 +58,15 @@ public class PaymentType implements Serializable, BroadleafEnumerationType {
5858
* Note that not all third party gateways support this feature described above.
5959
* Make sure to the gateway does before assigning this type to your Order Payment.
6060
*/
61-
public static final PaymentType THIRD_PARTY_ACCOUNT = new PaymentType("THIRD_PARTY_ACCOUNT", "3rd-Party Account");
61+
public static final PaymentType THIRD_PARTY_ACCOUNT = new PaymentType("THIRD_PARTY_ACCOUNT", "3rd-Party Account", true);
6262

6363
public static PaymentType getInstance(final String type) {
6464
return TYPES.get(type);
6565
}
6666

6767
private String type;
6868
private String friendlyType;
69+
private boolean isFinalPayment;
6970

7071
public PaymentType() {
7172
//do nothing
@@ -74,8 +75,19 @@ public PaymentType() {
7475
public PaymentType(final String type, final String friendlyType) {
7576
this.friendlyType = friendlyType;
7677
setType(type);
78+
this.isFinalPayment = false;
7779
}
78-
80+
81+
public PaymentType(final String type, final String friendlyType, final boolean isFinalPayment) {
82+
this.friendlyType = friendlyType;
83+
this.isFinalPayment = isFinalPayment;
84+
setType(type);
85+
}
86+
87+
public boolean getIsFinalPayment() {
88+
return isFinalPayment;
89+
}
90+
7991
@Override
8092
public String getType() {
8193
return type;

core/broadleaf-framework/src/main/java/org/broadleafcommerce/core/payment/domain/OrderPaymentImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ public boolean isConfirmed() {
303303

304304
@Override
305305
public boolean isFinalPayment() {
306-
return PaymentType.CREDIT_CARD.equals(getType()) || PaymentType.THIRD_PARTY_ACCOUNT.equals(getType());
306+
return getType().getIsFinalPayment();
307307
}
308308

309309
@Override

0 commit comments

Comments
 (0)