Search in sources :

Example 1 with ChargeRefundCollection

use of com.stripe.model.ChargeRefundCollection in project stripe-java by stripe.

the class RefundTest method testChargeRefundUpdateApiKey.

@Test
public void testChargeRefundUpdateApiKey() throws StripeException {
    Charge createdCharge = Charge.create(defaultChargeParams);
    ChargeRefundCollection refunds = createdCharge.refund().getRefunds();
    Refund refund = refunds.getData().get(0);
    Map<String, String> metadata = new HashMap<String, String>();
    metadata.put("foo", "bar");
    Map<String, Object> updateParams = new HashMap<String, Object>();
    updateParams.put("metadata", metadata);
    refund = refund.update(updateParams, Stripe.apiKey);
    assertEquals("bar", refund.getMetadata().get("foo"));
}
Also used : ChargeRefundCollection(com.stripe.model.ChargeRefundCollection) Refund(com.stripe.model.Refund) HashMap(java.util.HashMap) Charge(com.stripe.model.Charge) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 2 with ChargeRefundCollection

use of com.stripe.model.ChargeRefundCollection in project stripe-java by stripe.

the class RefundTest method testChargeRefund.

@Test
public void testChargeRefund() throws StripeException {
    Charge createdCharge = Charge.create(defaultChargeParams);
    Charge refundedCharge = createdCharge.refund();
    assertTrue(refundedCharge.getRefunded());
    ChargeRefundCollection refunds = refundedCharge.getRefunds();
    assertTrue(refunds.getData() instanceof List);
    assertEquals(1, refunds.getData().size());
    assertTrue(refunds.getData().get(0) instanceof Refund);
}
Also used : ChargeRefundCollection(com.stripe.model.ChargeRefundCollection) Refund(com.stripe.model.Refund) Charge(com.stripe.model.Charge) List(java.util.List) LinkedList(java.util.LinkedList) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 3 with ChargeRefundCollection

use of com.stripe.model.ChargeRefundCollection in project stripe-java by stripe.

the class RefundTest method testChargeRefundCreate.

@Test
public void testChargeRefundCreate() throws StripeException {
    Charge ch = Charge.create(defaultChargeParams);
    Map<String, Object> params = new HashMap<String, Object>();
    params.put("amount", 10);
    ChargeRefundCollection refunds = ch.getRefunds();
    Refund created = refunds.create(params);
    Refund retrieved = ch.getRefunds().retrieve(created.getId());
    assertEquals(created.getId(), retrieved.getId());
}
Also used : ChargeRefundCollection(com.stripe.model.ChargeRefundCollection) Refund(com.stripe.model.Refund) HashMap(java.util.HashMap) Charge(com.stripe.model.Charge) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Aggregations

BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)3 Charge (com.stripe.model.Charge)3 ChargeRefundCollection (com.stripe.model.ChargeRefundCollection)3 Refund (com.stripe.model.Refund)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)2 LinkedList (java.util.LinkedList)1 List (java.util.List)1