Skip to content

Commit

Permalink
Add new properties to TransferReversal
Browse files Browse the repository at this point in the history
Support `destination_payment_refund` and `source_refund`.
  • Loading branch information
remi-stripe committed Jan 25, 2019
1 parent 7385495 commit 227ef3e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -28,7 +28,7 @@ before_install:
env:
global:
- STRIPE_MOCK_VERSION=0.40.1
- STRIPE_MOCK_VERSION=0.43.0

matrix:
include:
Expand Down
40 changes: 40 additions & 0 deletions src/main/java/com/stripe/model/Reversal.java
Expand Up @@ -22,7 +22,11 @@ public class Reversal extends ApiResource implements MetadataStore<Transfer>, Ha
ExpandableField<BalanceTransaction> balanceTransaction;
Long created;
String currency;
@Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE)
ExpandableField<Refund> destinationPaymentRefund;
@Getter(onMethod = @__({@Override})) Map<String, String> metadata;
@Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE)
ExpandableField<Refund> sourceRefund;
@Getter(AccessLevel.NONE) @Setter(AccessLevel.NONE) ExpandableField<Transfer> transfer;

// <editor-fold desc="balanceTransaction">
Expand All @@ -43,6 +47,42 @@ public void setBalanceTransactionObject(BalanceTransaction c) {
}
// </editor-fold>

// <editor-fold desc="destinationPaymentRefund">
public String getDestinationPaymentRefund() {
return (this.destinationPaymentRefund != null) ? this.destinationPaymentRefund.getId() : null;
}

public void setDestinationPaymentRefund(String destinationPaymentRefundId) {
this.destinationPaymentRefund = setExpandableFieldId(destinationPaymentRefundId, this.destinationPaymentRefund);
}

public Refund getDestinationPaymentRefundObject() {
return (this.destinationPaymentRefund != null) ? this.destinationPaymentRefund.getExpanded() : null;
}

public void setDestinationPaymentRefundObject(Refund c) {
this.destinationPaymentRefund = new ExpandableField<>(c.getId(), c);
}
// </editor-fold>

// <editor-fold desc="sourceRefund">
public String getSourceRefund() {
return (this.sourceRefund != null) ? this.sourceRefund.getId() : null;
}

public void setSourceRefund(String sourceRefundId) {
this.sourceRefund = setExpandableFieldId(sourceRefundId, this.sourceRefund);
}

public Refund getSourceRefundObject() {
return (this.sourceRefund != null) ? this.sourceRefund.getExpanded() : null;
}

public void setSourceRefundObject(Refund c) {
this.sourceRefund = new ExpandableField<>(c.getId(), c);
}
// </editor-fold>

// <editor-fold desc="transfer">
public String getTransfer() {
return (this.transfer != null) ? this.transfer.getId() : null;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/com/stripe/BaseStripeTest.java
Expand Up @@ -35,7 +35,7 @@

public class BaseStripeTest {
// If changing this number, please also change it in `.travis.yml`.
private static final String MOCK_MINIMUM_VERSION = "0.40.1";
private static final String MOCK_MINIMUM_VERSION = "0.43.0";

private static String port;

Expand Down
15 changes: 15 additions & 0 deletions src/test/java/com/stripe/model/ReversalTest.java
Expand Up @@ -25,15 +25,30 @@ public void testDeserialize() throws Exception {
public void testDeserializeWithExpansions() throws Exception {
final String[] expansions = {
"balance_transaction",
"destination_payment_refund",
"source_refund",
"transfer",
};
final String data = getFixture("/v1/transfers/tr_123/reversals/trr_123", expansions);
final Reversal reversal = ApiResource.GSON.fromJson(data, Reversal.class);
assertNotNull(reversal);

final BalanceTransaction balanceTransaction = reversal.getBalanceTransactionObject();
assertNotNull(balanceTransaction);
assertNotNull(balanceTransaction.getId());
assertEquals(reversal.getBalanceTransaction(), balanceTransaction.getId());

final Refund destinationPaymentRefund = reversal.getDestinationPaymentRefundObject();
assertNotNull(destinationPaymentRefund);
assertNotNull(destinationPaymentRefund.getId());
assertEquals(reversal.getDestinationPaymentRefund(), destinationPaymentRefund.getId());

final Refund sourceRefund = reversal.getSourceRefundObject();
assertNotNull(sourceRefund);
assertNotNull(sourceRefund.getId());
assertEquals(reversal.getSourceRefund(), sourceRefund.getId());


final Transfer transfer = reversal.getTransferObject();
assertNotNull(transfer);
assertNotNull(transfer.getId());
Expand Down

0 comments on commit 227ef3e

Please sign in to comment.