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);
}
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™.)
}
}
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");
}
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());
}
Aggregations