transaction.setPaymentType(PaymentType.CREDITCARD); transaction.getTransactionDetails().put("TRANSACTIONID", transaction.getTransactionDetails().get("TRANSACTIONID")); transaction.getTransactionDetails().put("TRNAPPROVED", re.getReason()); transaction.getTransactionDetails().put("TRNORDERNUMBER", re.getId()); transaction.getTransactionDetails().put("MESSAGETEXT", null);
final Refund refund = ApiResource.GSON.fromJson(data, Refund.class); assertNotNull(refund); final BalanceTransaction balanceTransaction = refund.getBalanceTransactionObject(); assertNotNull(balanceTransaction); assertNotNull(balanceTransaction.getId()); assertEquals(refund.getBalanceTransaction(), balanceTransaction.getId()); final Charge charge = refund.getChargeObject(); assertNotNull(charge); assertNotNull(charge.getId()); assertEquals(refund.getCharge(), charge.getId()); final BalanceTransaction failureBalanceTransaction = refund.getFailureBalanceTransactionObject(); assertNotNull(failureBalanceTransaction); assertNotNull(failureBalanceTransaction.getId()); assertEquals(refund.getFailureBalanceTransaction(), failureBalanceTransaction.getId()); final Reversal sourceTransferReversal = refund.getSourceTransferReversalObject(); assertNotNull(sourceTransferReversal); assertNotNull(sourceTransferReversal.getId()); assertEquals(refund.getSourceTransferReversal(), sourceTransferReversal.getId()); final Reversal transferReversal = refund.getTransferReversalObject(); assertNotNull(transferReversal); assertNotNull(transferReversal.getId()); assertEquals(refund.getTransferReversal(), transferReversal.getId());
public void setDestinationPaymentRefundObject(Refund c) { this.destinationPaymentRefund = new ExpandableField<>(c.getId(), c); } // </editor-fold>
@Test public void testUpdate() throws StripeException { final Refund refund = getRefundFixture(); Map<String, String> metadata = new HashMap<>(); metadata.put("key", "value"); Map<String, Object> params = new HashMap<>(); params.put("metadata", metadata); final Refund updatedRefund = refund.update(params); assertNotNull(updatedRefund); verifyRequest( ApiResource.RequestMethod.POST, String.format("/v1/refunds/%s", refund.getId()), params ); }
/** * Retrieve a refund. */ public static Refund retrieve(String id) throws StripeException { return retrieve(id, null); }
/** * Create a refund. */ public static Refund create(Map<String, Object> params) throws StripeException { return create(params, null); }
/** * List all refunds. */ public static RefundCollection list(Map<String, Object> params) throws StripeException { return list(params, null); }
/** * Update a refund. */ @Override public Refund update(Map<String, Object> params) throws StripeException { return update(params, (RequestOptions) null); }
/** * List all refunds. */ public static RefundCollection list(Map<String, Object> params, RequestOptions options) throws StripeException { return requestCollection(classUrl(Refund.class), params, RefundCollection.class, options); } // </editor-fold>
public void setSourceRefundObject(Refund c) { this.sourceRefund = new ExpandableField<>(c.getId(), c); } // </editor-fold>
/** * Retrieve a refund. */ public static Refund retrieve(String id, RequestOptions options) throws StripeException { return retrieve(id, null, options); }
@Test public void testCreate() throws StripeException { final Map<String, Object> params = new HashMap<>(); params.put("charge", "ch_123"); final Refund refund = Refund.create(params); assertNotNull(refund); verifyRequest( ApiResource.RequestMethod.POST, String.format("/v1/refunds"), params ); }
@Test public void testList() throws StripeException { final Map<String, Object> params = new HashMap<>(); params.put("limit", 1); final RefundCollection refunds = Refund.list(params); assertNotNull(refunds); verifyRequest( ApiResource.RequestMethod.GET, String.format("/v1/refunds"), params ); } }
public void setRefundObject(Refund refund) { this.refund = new ExpandableField<>(refund.getId(), refund); } // </editor-fold>
private Refund getRefundFixture() throws StripeException { final Refund refund = Refund.retrieve(REFUND_ID); resetNetworkSpy(); return refund; }
@Test public void testDeserializeWithExpansions() throws Exception { final String[] expansions = { "order", "refund", }; final String data = getFixture("/v1/order_returns/orret_123", expansions); final OrderReturn orderReturn = ApiResource.GSON.fromJson(data, OrderReturn.class); assertNotNull(orderReturn); final Order order = orderReturn.getOrderObject(); assertNotNull(order); assertNotNull(order.getId()); assertEquals(orderReturn.getOrder(), order.getId()); final Refund refund = orderReturn.getRefundObject(); assertNotNull(refund); assertNotNull(refund.getId()); assertEquals(orderReturn.getRefund(), refund.getId()); } }
@Test public void testRetrieve() throws StripeException { final Refund refund = Refund.retrieve(REFUND_ID); assertNotNull(refund); verifyRequest( ApiResource.RequestMethod.GET, String.format("/v1/refunds/%s", REFUND_ID) ); }