Search in sources :

Example 6 with Charge

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

the class ChargeTest method testChargeRetrieveWithBalanceTransaction.

@Test
public void testChargeRetrieveWithBalanceTransaction() throws StripeException {
    Charge createdCharge = Charge.create(defaultChargeParams);
    Map<String, Object> retrieveParams = new HashMap<String, Object>();
    retrieveParams.put("expand[]", "balance_transaction");
    Charge retrievedCharge = Charge.retrieve(createdCharge.getId(), retrieveParams, supportedRequestOptions);
    // Check basics
    assertEquals(retrievedCharge.getCreated(), retrievedCharge.getCreated());
    assertEquals(retrievedCharge.getId(), retrievedCharge.getId());
    // Check expanded BT
    assertEquals(retrievedCharge.getBalanceTransactionObject().getId(), createdCharge.getBalanceTransaction());
}
Also used : HashMap(java.util.HashMap) Charge(com.stripe.model.Charge) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 7 with Charge

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

the class ChargeTest method testChargeExpandBalanceTransaction.

@Test
public void testChargeExpandBalanceTransaction() throws StripeException {
    Map<String, Object> createParams = defaultChargeParams;
    createParams.put("expand[]", "balance_transaction");
    Charge createdCharge = Charge.create(createParams);
    assertEquals(createdCharge.getBalanceTransactionObject().getId(), createdCharge.getBalanceTransaction());
    Map<String, Object> retrieveParams = new HashMap<String, Object>();
    retrieveParams.put("expand[]", "balance_transaction");
    Charge retrievedCharge = Charge.retrieve(createdCharge.getId(), retrieveParams, null);
    assertEquals(retrievedCharge.getBalanceTransactionObject().getId(), retrievedCharge.getBalanceTransaction());
}
Also used : HashMap(java.util.HashMap) Charge(com.stripe.model.Charge) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 8 with Charge

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

the class ChargeTest method testChargeRefundPerCallAPIKey.

@Test
public void testChargeRefundPerCallAPIKey() throws StripeException {
    Charge createdCharge = Charge.create(defaultChargeParams, Stripe.apiKey);
    Charge refundedCharge = createdCharge.refund(Stripe.apiKey);
    assertTrue(refundedCharge.getRefunded());
}
Also used : Charge(com.stripe.model.Charge) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 9 with Charge

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

the class ChargeTest method testChargeCreatePerCallAPIKey.

@Test
public void testChargeCreatePerCallAPIKey() throws StripeException {
    Charge createdCharge = Charge.create(defaultChargeParams, Stripe.apiKey);
    assertFalse(createdCharge.getRefunded());
}
Also used : Charge(com.stripe.model.Charge) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 10 with Charge

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

the class ChargeTest method testChargeRetrievePerCallAPIKey.

@Test
public void testChargeRetrievePerCallAPIKey() throws StripeException {
    Charge createdCharge = Charge.create(defaultChargeParams, Stripe.apiKey);
    Charge retrievedCharge = Charge.retrieve(createdCharge.getId(), Stripe.apiKey);
    assertEquals(createdCharge.getCreated(), retrievedCharge.getCreated());
    assertEquals(createdCharge.getId(), retrievedCharge.getId());
}
Also used : 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