Search in sources :

Example 16 with Charge

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

the class IdempotentTest method testDefaultOptionsHaveUnsetIdempotentRequest.

@Test
public void testDefaultOptionsHaveUnsetIdempotentRequest() throws CardException, APIException, AuthenticationException, InvalidRequestException, APIConnectionException {
    RequestOptions options = RequestOptions.getDefault();
    Charge firstCharge = Charge.create(defaultChargeParams, options);
    Charge secondCharge = Charge.create(defaultChargeParams, options);
    assertNotSame(firstCharge.getId(), secondCharge.getId());
}
Also used : RequestOptions(com.stripe.net.RequestOptions) Charge(com.stripe.model.Charge) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 17 with Charge

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

the class RefundTest method testChargeRefundCreateApiKey.

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

Example 18 with Charge

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

the class RefundTest method testChargeRefundListWithExpand.

@Test
public void testChargeRefundListWithExpand() throws StripeException {
    Charge ch = Charge.create(defaultChargeParams);
    ch = ch.refund();
    List<String> expandList = new LinkedList<String>();
    expandList.add("data.balance_transaction");
    expandList.add("data.balance_transaction.source");
    expandList.add("data.charge");
    Map<String, Object> listParams = new HashMap<String, Object>();
    listParams.put("charge", ch.getId());
    listParams.put("count", 1);
    listParams.put("expand", expandList);
    Refund refund = Refund.list(listParams).getData().get(0);
    Charge expCharge = refund.getChargeObject();
    assertNotNull(expCharge);
    assertEquals(ch.getId(), expCharge.getId());
    BalanceTransaction expBT = refund.getBalanceTransactionObject();
    assertNotNull(expBT);
    Refund expRefundInBT = (Refund) expBT.getSourceObject();
    assertEquals(refund.getId(), expRefundInBT.getId());
}
Also used : Refund(com.stripe.model.Refund) HashMap(java.util.HashMap) Charge(com.stripe.model.Charge) BalanceTransaction(com.stripe.model.BalanceTransaction) LinkedList(java.util.LinkedList) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 19 with Charge

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

the class RefundTest method testChargePartialRefund.

@Test
public void testChargePartialRefund() throws StripeException {
    Charge createdCharge = Charge.create(defaultChargeParams);
    Map<String, Object> refundParams = new HashMap<String, Object>();
    final Long refundAmount = 50L;
    refundParams.put("amount", refundAmount);
    Charge refundedCharge = createdCharge.refund(refundParams);
    assertFalse(refundedCharge.getRefunded());
    assertEquals(refundedCharge.getAmountRefunded(), refundAmount);
}
Also used : HashMap(java.util.HashMap) Charge(com.stripe.model.Charge) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 20 with Charge

use of com.stripe.model.Charge 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)

Aggregations

Charge (com.stripe.model.Charge)49 BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)36 Test (org.junit.Test)36 HashMap (java.util.HashMap)19 RequestOptions (com.stripe.net.RequestOptions)12 Refund (com.stripe.model.Refund)8 Dispute (com.stripe.model.Dispute)7 Card (com.stripe.model.Card)5 EvidenceSubObject (com.stripe.model.EvidenceSubObject)5 Environment (org.springframework.core.env.Environment)5 PaymentResult (alfio.manager.support.PaymentResult)4 PaymentInformation (alfio.model.PaymentInformation)4 StripeException (com.stripe.exception.StripeException)3 BalanceTransaction (com.stripe.model.BalanceTransaction)3 ConfigurationManager (alfio.manager.system.ConfigurationManager)2 PurchaseContext (alfio.model.PurchaseContext)2 ConfigurationKeys (alfio.model.system.ConfigurationKeys)2 StripeCreditCardToken (alfio.model.transaction.token.StripeCreditCardToken)2 ConfigurationRepository (alfio.repository.system.ConfigurationRepository)2 Stripe (com.stripe.Stripe)2