Search in sources :

Example 46 with Charge

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

the class ChargeTest method testChargePartialRefundPerCallAPIKey.

@Test
public void testChargePartialRefundPerCallAPIKey() 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, Stripe.apiKey);
    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 47 with Charge

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

the class ChargeTest method testPerCallAPIUsage.

@Test
public void testPerCallAPIUsage() throws StripeException {
    Charge createdCharge = Charge.create(defaultChargeParams, Stripe.apiKey);
    assertFalse(createdCharge.getRefunded());
    try {
        Charge.create(defaultChargeParams, "INVALID_KEY_HERE");
        fail();
    } catch (Exception e) {
    // An exception is expected, so do nothing.
    // (This test is pretty bad, but it's going away Soon™.)
    }
}
Also used : Charge(com.stripe.model.Charge) CardException(com.stripe.exception.CardException) InvalidRequestException(com.stripe.exception.InvalidRequestException) StripeException(com.stripe.exception.StripeException) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 48 with Charge

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

the class ChargeTest method testInvalidAddressZipTest.

@Test
public void testInvalidAddressZipTest() throws StripeException {
    Map<String, Object> invalidChargeParams = new HashMap<String, Object>();
    invalidChargeParams.putAll(defaultChargeParams);
    invalidChargeParams.put("source", "tok_avsZipFail");
    Charge charge = Charge.create(invalidChargeParams, supportedRequestOptions);
    assertEquals(charge.getPaid(), true);
    assertThat(charge.getSource(), instanceOf(Card.class));
    Card card = (Card) charge.getSource();
    assertEquals(card.getAddressZipCheck(), "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 49 with Charge

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

the class CountrySpecTest method testChargeCreationSourceAsCard.

@Test
public void testChargeCreationSourceAsCard() throws StripeException {
    Charge charge = Charge.create(defaultChargeParams);
    assertTrue(charge.getSource() instanceof Card);
    assertNotNull(charge.getSource().getId());
}
Also used : Charge(com.stripe.model.Charge) Card(com.stripe.model.Card) 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