Search in sources :

Example 36 with Charge

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

the class DisputeTest method testRetrieveDisputeWithExpand.

@Test
public void testRetrieveDisputeWithExpand() throws StripeException, InterruptedException {
    int chargeValueCents = 100;
    Charge disputedCharge = createDisputedCharge(chargeValueCents, null);
    Dispute dispute = disputedCharge.getDisputeObject();
    List<String> expandList = new LinkedList<String>();
    expandList.add("charge");
    Map<String, Object> retrieveParams = new HashMap<String, Object>();
    retrieveParams.put("expand", expandList);
    Dispute retrievedDispute = Dispute.retrieve(dispute.getId(), retrieveParams, null);
    assertEquals(dispute.getId(), retrievedDispute.getId());
    Charge expandedCharge = retrievedDispute.getChargeObject();
    assertNotNull(expandedCharge);
    assertEquals(disputedCharge.getId(), expandedCharge.getId());
    Card card = (Card) expandedCharge.getSource();
    assertEquals("0259", card.getLast4());
}
Also used : HashMap(java.util.HashMap) Charge(com.stripe.model.Charge) Dispute(com.stripe.model.Dispute) EvidenceSubObject(com.stripe.model.EvidenceSubObject) LinkedList(java.util.LinkedList) Card(com.stripe.model.Card) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 37 with Charge

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

the class IdempotentTest method testClearingIdempotentcyActuallyWorks.

@Test
public void testClearingIdempotentcyActuallyWorks() throws CardException, APIException, AuthenticationException, InvalidRequestException, APIConnectionException {
    RequestOptions options = RequestOptions.builder().setIdempotencyKey(UUID.randomUUID().toString()).clearIdempotencyKey().build();
    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 38 with Charge

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

the class IdempotentTest method testIdempotentRequestSent.

@Test
public void testIdempotentRequestSent() throws CardException, APIException, AuthenticationException, InvalidRequestException, APIConnectionException {
    RequestOptions options = RequestOptions.builder().setIdempotencyKey(UUID.randomUUID().toString()).build();
    Charge firstCharge = Charge.create(defaultChargeParams, options);
    Charge secondCharge = Charge.create(defaultChargeParams, options);
    assertEquals(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 39 with Charge

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

the class RefundTest method testRefundMetadata.

@Test
public void testRefundMetadata() throws StripeException {
    Charge createdCharge = Charge.create(defaultChargeParams);
    Charge refundedCharge = createdCharge.refund();
    testMetadata(refundedCharge.getRefunds().getData().get(0));
}
Also used : Charge(com.stripe.model.Charge) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 40 with Charge

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

the class RefundTest method testChargeRefundListAndRetrievePerCallAPIKey.

@Test
public void testChargeRefundListAndRetrievePerCallAPIKey() throws StripeException {
    Charge ch = Charge.create(defaultChargeParams);
    ch = ch.refund();
    Map<String, Object> listParams = new HashMap<String, Object>();
    listParams.put("count", 1);
    Refund created = ch.getRefunds().all(listParams, Stripe.apiKey).getData().get(0);
    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)

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