Skip to content

Commit debb542

Browse files
iulian03Iulian Masar
and
Iulian Masar
authored
added new url & method for payconiq (#360)
Co-authored-by: Iulian Masar <iulian.masar@codegile.com>
1 parent 51b7c13 commit debb542

File tree

7 files changed

+68
-5
lines changed

7 files changed

+68
-5
lines changed

src/main/java/com/mangopay/core/APIs/ApiBase.java

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ protected MangoPayApi getRoot() {
7474
// pay ins URLs
7575
put("payins_paypal-web_create", new String[]{"/payins/paypal/web/", RequestType.POST.toString()});
7676
put("payins_payconiq-web_create", new String[]{"/payins/payconiq/web/", RequestType.POST.toString()});
77+
put("payins_payconiqv2-web_create", new String[]{"/payins/payment-methods/payconiq/", RequestType.POST.toString()});
7778
put("payins_card-web_create", new String[]{"/payins/card/web/", RequestType.POST.toString()});
7879
put("payins_card-direct_create", new String[]{"/payins/card/direct/", RequestType.POST.toString()});
7980
put("payins_preauthorized-direct_create", new String[]{"/payins/preauthorized/direct/", RequestType.POST.toString()});

src/main/java/com/mangopay/core/APIs/PayInApi.java

+10
Original file line numberDiff line numberDiff line change
@@ -156,4 +156,14 @@ public interface PayInApi {
156156
* @return {PayIn} object returned by the API
157157
*/
158158
PayIn addPayPalTrackingInformation(String payInId, PayPalWebTracking trackingData) throws Exception;
159+
160+
/**
161+
* Creates a Payconiq Web PayIn using the latest API url (payins/payment-methods/payconiq)
162+
*
163+
* @param idempotencyKey Idempotency key for this request. Can be null.
164+
* @param payIn The PayIn object to be created.
165+
* @return Created PayIn object returned by API.
166+
* @throws Exception
167+
*/
168+
PayIn createPayconiq(PayIn payIn, String idempotencyKey) throws Exception;
159169
}

src/main/java/com/mangopay/core/APIs/implementation/PayInApiImpl.java

+5
Original file line numberDiff line numberDiff line change
@@ -140,4 +140,9 @@ public PaymentMethodMetadata getPaymentMethodMetadata(PaymentMethodMetadata meta
140140
public PayIn addPayPalTrackingInformation(String payInId, PayPalWebTracking trackingData) throws Exception {
141141
return this.updateObject(PayIn.class, "add_tracking_info", trackingData, payInId);
142142
}
143+
144+
@Override
145+
public PayIn createPayconiq(PayIn payIn, String idempotencyKey) throws Exception {
146+
return this.createObject(PayIn.class, idempotencyKey, "payins_payconiqv2-web_create", payIn);
147+
}
143148
}

src/main/java/com/mangopay/core/deserializer/PayInDeserializer.java

+4
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ public PayIn deserialize(JsonElement json, Type typeOfT, JsonDeserializationCont
125125
payInPaymentDetailsPayconiq.setDebitedWalletId(object.get("DebitedWalletId").getAsString());
126126
if (object.has("DeepLinkURL") && !object.get("DeepLinkURL").isJsonNull())
127127
payInPaymentDetailsPayconiq.setDeepLinkUrl(object.get("DeepLinkURL").getAsString());
128+
if (object.has("StatementDescriptor") && !object.get("StatementDescriptor").isJsonNull())
129+
payInPaymentDetailsPayconiq.setStatementDescriptor(object.get("StatementDescriptor").getAsString());
130+
if (object.has("QRCodeURL") && !object.get("QRCodeURL").isJsonNull())
131+
payInPaymentDetailsPayconiq.setQrCodeUrl(object.get("QRCodeURL").getAsString());
128132
payIn.setPaymentDetails(payInPaymentDetailsPayconiq);
129133
break;
130134
case APPLEPAY:

src/main/java/com/mangopay/core/serializer/PayInSerializer.java

+1
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ public JsonElement serialize(PayIn src, Type typeOfSrc, JsonSerializationContext
6363
break;
6464
case "PayInPaymentDetailsPayconiq":
6565
object.add("Country", context.serialize(((PayInPaymentDetailsPayconiq) src.getPaymentDetails()).getCountry()));
66+
object.add("StatementDescriptor", context.serialize(((PayInPaymentDetailsPayconiq) src.getPaymentDetails()).getStatementDescriptor()));
6667
break;
6768
case "PayInPaymentDetailsDirectDebit":
6869
object.add("DirectDebitType", context.serialize(((PayInPaymentDetailsDirectDebit) src.getPaymentDetails()).getDirectDebitType()));

src/main/java/com/mangopay/entities/subentities/PayInPaymentDetailsPayconiq.java

+25
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ public class PayInPaymentDetailsPayconiq extends Dto implements PayInPaymentDeta
1818
@SerializedName("DeepLinkURL")
1919
private String deepLinkUrl;
2020

21+
22+
// v2 //
23+
24+
@SerializedName("StatementDescriptor")
25+
private String statementDescriptor;
26+
27+
@SerializedName("QRCodeURL")
28+
private String qrCodeUrl;
29+
2130
public void setCountry(String country) {
2231
this.country = country;
2332
}
@@ -49,4 +58,20 @@ public void setExpirationDate(String expirationDate) {
4958
public void setDeepLinkUrl(String deepLinkUrl) {
5059
this.deepLinkUrl = deepLinkUrl;
5160
}
61+
62+
public String getStatementDescriptor() {
63+
return statementDescriptor;
64+
}
65+
66+
public void setStatementDescriptor(String statementDescriptor) {
67+
this.statementDescriptor = statementDescriptor;
68+
}
69+
70+
public String getQrCodeUrl() {
71+
return qrCodeUrl;
72+
}
73+
74+
public void setQrCodeUrl(String qrCodeUrl) {
75+
this.qrCodeUrl = qrCodeUrl;
76+
}
5277
}

src/test/java/com/mangopay/core/PayInApiImplTest.java

+22-5
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,27 @@ public void createPayPalWebV2() throws Exception {
644644

645645
@Test
646646
public void createPayconiqWeb() throws Exception {
647+
PayIn payIn = newPayconiqWebPayIn();
648+
PayIn createdPayIn = api.getPayInApi().create(payIn);
649+
650+
assertNotNull(createdPayIn);
651+
assertEqualInputProps(payIn, createdPayIn);
652+
assertNotNull(createdPayIn.getPaymentDetails());
653+
}
654+
655+
@Test
656+
public void createPayconiqWebV2() throws Exception {
657+
PayIn payIn = newPayconiqWebPayIn();
658+
PayIn createdPayIn = api.getPayInApi().createPayconiq(newPayconiqWebPayIn(), null);
659+
660+
assertNotNull(createdPayIn);
661+
assertEqualInputProps(payIn, createdPayIn);
662+
assertNotNull(createdPayIn.getPaymentDetails());
663+
assertNotNull(((PayInPaymentDetailsPayconiq) createdPayIn.getPaymentDetails()).getQrCodeUrl());
664+
assertNotNull(((PayInPaymentDetailsPayconiq) createdPayIn.getPaymentDetails()).getDeepLinkUrl());
665+
}
666+
667+
private PayIn newPayconiqWebPayIn() throws Exception {
647668
UserNatural john = getJohn();
648669
Wallet wallet = getJohnsWallet();
649670

@@ -664,11 +685,7 @@ public void createPayconiqWeb() throws Exception {
664685
executionDetails.setReturnUrl("http://www.my-site.com/returnURL");
665686
payIn.setExecutionDetails(executionDetails);
666687

667-
PayIn createdPayIn = api.getPayInApi().create(payIn);
668-
669-
assertNotNull(createdPayIn);
670-
assertEqualInputProps(payIn, createdPayIn);
671-
assertNotNull(createdPayIn.getPaymentDetails());
688+
return payIn;
672689
}
673690

674691
@Test

0 commit comments

Comments
 (0)