File tree Expand file tree Collapse file tree 4 files changed +74
-4
lines changed
Expand file tree Collapse file tree 4 files changed +74
-4
lines changed Original file line number Diff line number Diff line change 1+ package com .shift4 .enums ;
2+
3+ import com .fasterxml .jackson .annotation .JsonCreator ;
4+ import com .fasterxml .jackson .annotation .JsonValue ;
5+
6+ public enum ChargeType {
7+ FIRST_RECURRING ("first_recurring" ),
8+ SUBSEQUENT_RECURRING ("subsequent_recurring" ),
9+ MERCHANT_INITIATED ("merchant_initiated" ),
10+ CUSTOMER_INITIATED ("customer_initiated" ),
11+
12+ /**
13+ * Used when received value can't be mapped to this enumeration.
14+ */
15+ UNRECOGNIZED ("unrecognized" ),
16+ ;
17+
18+ private final String value ;
19+
20+ ChargeType (String value ) {
21+ this .value = value ;
22+ }
23+
24+ @ JsonCreator
25+ public static ChargeType fromValue (String value ) {
26+ if (value == null ) {
27+ return null ;
28+ }
29+ for (ChargeType type : values ()) {
30+ if (type .value .equalsIgnoreCase (value )) {
31+ return type ;
32+ }
33+ }
34+
35+ return UNRECOGNIZED ;
36+ }
37+
38+ @ JsonValue
39+ public String getValue () {
40+ return value ;
41+ }
42+ }
Original file line number Diff line number Diff line change 55import com .fasterxml .jackson .annotation .JsonIgnore ;
66import com .fasterxml .jackson .annotation .JsonInclude ;
77import com .fasterxml .jackson .annotation .JsonInclude .Include ;
8+ import com .shift4 .enums .ChargeType ;
89import com .shift4 .response .Customer ;
910
1011import java .util .HashMap ;
@@ -20,6 +21,7 @@ public class ChargeRequest {
2021 private CardRequest card ;
2122 private PaymentMethodRequest paymentMethod ;
2223 private ChargeFlowRequest flow ;
24+ private ChargeType type ;
2325 private Boolean captured ;
2426 private ShippingRequest shipping ;
2527 private BillingRequest billing ;
@@ -65,7 +67,11 @@ public ChargeFlowRequest getFlow() {
6567 return flow ;
6668 }
6769
68- public Boolean getCaptured () {
70+ public ChargeType getType () {
71+ return type ;
72+ }
73+
74+ public Boolean getCaptured () {
6975 return captured ;
7076 }
7177
@@ -128,7 +134,12 @@ public ChargeRequest flow(ChargeFlowRequest flow) {
128134 return this ;
129135 }
130136
131- public ChargeRequest captured (Boolean captured ) {
137+ public ChargeRequest type (ChargeType type ) {
138+ this .type = type ;
139+ return this ;
140+ }
141+
142+ public ChargeRequest captured (Boolean captured ) {
132143 this .captured = captured ;
133144 return this ;
134145 }
Original file line number Diff line number Diff line change 33import com .fasterxml .jackson .annotation .JsonAnySetter ;
44import com .fasterxml .jackson .annotation .JsonIgnore ;
55import com .shift4 .enums .ChargeStatus ;
6+ import com .shift4 .enums .ChargeType ;
67import com .shift4 .enums .ErrorCode ;
78import com .shift4 .util .Shift4Utils ;
89
@@ -20,7 +21,8 @@ public class Charge {
2021 private String currency ;
2122 private String description ;
2223 private ChargeStatus status ;
23- private Card card ;
24+ private ChargeType type ;
25+ private Card card ;
2426 private PaymentMethod paymentMethod ;
2527 private ChargeFlow flow ;
2628 private String customerId ;
@@ -80,7 +82,11 @@ public ChargeStatus getStatus() {
8082 return status ;
8183 }
8284
83- public Card getCard () {
85+ public ChargeType getType () {
86+ return type ;
87+ }
88+
89+ public Card getCard () {
8490 return card ;
8591 }
8692
Original file line number Diff line number Diff line change 22
33import com .fasterxml .jackson .databind .SerializationFeature ;
44import com .shift4 .enums .ChargeStatus ;
5+ import com .shift4 .enums .ChargeType ;
56import com .shift4 .enums .ErrorType ;
67import com .shift4 .exception .Shift4Exception ;
78import com .shift4 .request .ChargeListRequest ;
@@ -141,4 +142,14 @@ void shouldCreateChargeUsingExplicitMerchant() {
141142 assertThat (retrievedCharge .getCurrency ()).isEqualTo (request .getCurrency ());
142143 assertThat (retrievedCharge .getFailureCode ()).isNull ();
143144 }
145+
146+ @ Test
147+ void shouldSendChargeType () {
148+ // given
149+ ChargeRequest request = charge ().card (successCard ()).type (ChargeType .CUSTOMER_INITIATED );
150+ // when
151+ Charge charge = gateway .createCharge (request );
152+ // then
153+ assertThat (charge .getType ()).isEqualTo (ChargeType .CUSTOMER_INITIATED );
154+ }
144155}
You can’t perform that action at this time.
0 commit comments