Search in sources :

Example 41 with Charge

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

Example 42 with Charge

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

the class RefundTest method testChargeRefundListAndRetrieve.

@Test
public void testChargeRefundListAndRetrieve() 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).getData().get(0);
    Refund retrieved = ch.getRefunds().retrieve(created.getId());
    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 43 with Charge

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

the class ChargeTest method testInvalidAddressLine1Test.

@Test
public void testInvalidAddressLine1Test() throws StripeException {
    Map<String, Object> invalidChargeParams = new HashMap<String, Object>();
    invalidChargeParams.putAll(defaultChargeParams);
    invalidChargeParams.put("source", "tok_avsLine1Fail");
    Charge charge = Charge.create(invalidChargeParams, supportedRequestOptions);
    assertEquals(charge.getPaid(), true);
    assertThat(charge.getSource(), instanceOf(Card.class));
    Card card = (Card) charge.getSource();
    assertEquals(card.getAddressLine1Check(), "fail");
}
Also used : HashMap(java.util.HashMap) Charge(com.stripe.model.Charge) Card(com.stripe.model.Card) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 44 with Charge

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

the class ChargeTest method testChargeCreate.

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

Example 45 with Charge

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

the class ChargeTest method testChargeCreateWithStatementDescriptor.

@Test
public void testChargeCreateWithStatementDescriptor() throws StripeException {
    Map<String, Object> chargeWithStatementDescriptorParams = new HashMap<String, Object>();
    chargeWithStatementDescriptorParams.putAll(defaultChargeParams);
    chargeWithStatementDescriptorParams.put("description", "hahaha1234");
    chargeWithStatementDescriptorParams.put("statement_descriptor", "Stripe");
    chargeWithStatementDescriptorParams.put("alternate_statement_descriptors[kana]", "ストライプ");
    chargeWithStatementDescriptorParams.put("alternate_statement_descriptors[kanji]", "ストライプジャパン株式会社");
    Charge createdCharge = Charge.create(chargeWithStatementDescriptorParams);
    assertEquals("Stripe", createdCharge.getStatementDescriptor());
    assertEquals("ストライプ", createdCharge.getAlternateStatementDescriptors().getKana());
    assertEquals("ストライプジャパン株式会社", createdCharge.getAlternateStatementDescriptors().getKanji());
}
Also used : 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