Skip to content

Commit

Permalink
Merge pull request #313 from Mangopay/improvement/add-reference-to-pa…
Browse files Browse the repository at this point in the history
…ypal

improvement/ Add reference to the new Paypal implementation
  • Loading branch information
iulian03 authored Nov 2, 2023
2 parents d3b3eab + ee4790a commit e5343a9
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public PayIn deserialize(JsonElement json, Type typeOfT, JsonDeserializationCont
if (object.has("ShippingPreference") && !object.get("ShippingPreference").isJsonNull()) {
payInPaymentDetailsPayPal.setShippingPreference(ShippingPreference.valueOf(object.get("ShippingPreference").getAsString()));
}
if (object.has("Reference") && !object.get("Reference").isJsonNull()) {
payInPaymentDetailsPayPal.setReference(object.get("Reference").getAsString());
}
payIn.setPaymentDetails(payInPaymentDetailsPayPal);
break;
case PAYCONIQ:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public JsonElement serialize(PayIn src, Type typeOfSrc, JsonSerializationContext
object.add("Shipping", context.serialize(((PayInPaymentDetailsPayPal) src.getPaymentDetails()).getShipping()));
object.add("LineItems", context.serialize(((PayInPaymentDetailsPayPal) src.getPaymentDetails()).getLineItems()));
object.add("ShippingPreference", context.serialize(((PayInPaymentDetailsPayPal) src.getPaymentDetails()).getShippingPreference()));
object.add("Reference", context.serialize(((PayInPaymentDetailsPayPal) src.getPaymentDetails()).getReference()));
break;
case "PayInPaymentDetailsPayconiq":
object.add("Country", context.serialize(((PayInPaymentDetailsPayconiq) src.getPaymentDetails()).getCountry()));
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/mangopay/entities/Refund.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class Refund extends Transaction {
@SerializedName("RefundReason")
private RefundReason refundReason;

@SerializedName("Reference")
private String reference;

public String getInitialTransactionId() {
return initialTransactionId;
}
Expand Down Expand Up @@ -83,6 +86,14 @@ public void setRefundReason(com.mangopay.core.RefundReason refundReason) {
this.refundReason = refundReason;
}

public String getReference() {
return reference;
}

public void setReference(String reference) {
this.reference = reference;
}

/**
* Gets map which property is an object and what type of object.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public class PayInPaymentDetailsPayPal extends Dto implements PayInPaymentDetail
@SerializedName("ShippingPreference")
private ShippingPreference shippingPreference;

@SerializedName("Reference")
private String reference;

public ShippingAddress getShippingAddress() {
return shippingAddress;
}
Expand Down Expand Up @@ -104,4 +107,12 @@ public ShippingPreference getShippingPreference() {
public void setShippingPreference(ShippingPreference shippingPreference) {
this.shippingPreference = shippingPreference;
}

public String getReference() {
return reference;
}

public void setReference(String reference) {
this.reference = reference;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/com/mangopay/core/mangopay.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Fri Sep 29 15:15:35 EEST 2023
#Wed Oct 18 10:44:26 EEST 2023
version=2.31.0
1 change: 1 addition & 0 deletions src/test/java/com/mangopay/core/BaseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -997,6 +997,7 @@ protected Refund getNewRefundForPayIn(PayIn payIn) throws Exception {
refund.setFees(new Money());
refund.getFees().setAmount(payIn.getFees().getAmount());
refund.getFees().setCurrency(payIn.getFees().getCurrency());
refund.setReference("Reference");

return this.api.getPayInApi().createRefund(payIn.getId(), refund);
}
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/mangopay/core/PayInApiImplTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ public void createPayPalWebV2() throws Exception {
));
paymentDetails.setLineItems(lineItems);
paymentDetails.setShippingPreference(ShippingPreference.GET_FROM_FILE);
paymentDetails.setReference("Reference");
paymentDetails.setStatementDescriptor("sttm");

payIn.setPaymentDetails(paymentDetails);
Expand Down

0 comments on commit e5343a9

Please sign in to comment.