use of com.stripe.model.Charge in project stripe-java by stripe.
the class IdempotentTest method testDefaultOptionsHaveUnsetIdempotentRequest.
@Test
public void testDefaultOptionsHaveUnsetIdempotentRequest() throws CardException, APIException, AuthenticationException, InvalidRequestException, APIConnectionException {
RequestOptions options = RequestOptions.getDefault();
Charge firstCharge = Charge.create(defaultChargeParams, options);
Charge secondCharge = Charge.create(defaultChargeParams, options);
assertNotSame(firstCharge.getId(), secondCharge.getId());
}
use of com.stripe.model.Charge in project stripe-java by stripe.
the class RefundTest method testChargeRefundCreateApiKey.
@Test
public void testChargeRefundCreateApiKey() throws StripeException {
Charge ch = Charge.create(defaultChargeParams);
Map<String, Object> params = new HashMap<String, Object>();
params.put("amount", 10);
Refund created = ch.getRefunds().create(params, Stripe.apiKey);
Refund retrieved = ch.getRefunds().retrieve(created.getId(), Stripe.apiKey);
assertEquals(created.getId(), retrieved.getId());
}
use of com.stripe.model.Charge in project stripe-java by stripe.
the class RefundTest method testChargeRefundListWithExpand.
@Test
public void testChargeRefundListWithExpand() throws StripeException {
Charge ch = Charge.create(defaultChargeParams);
ch = ch.refund();
List<String> expandList = new LinkedList<String>();
expandList.add("data.balance_transaction");
expandList.add("data.balance_transaction.source");
expandList.add("data.charge");
Map<String, Object> listParams = new HashMap<String, Object>();
listParams.put("charge", ch.getId());
listParams.put("count", 1);
listParams.put("expand", expandList);
Refund refund = Refund.list(listParams).getData().get(0);
Charge expCharge = refund.getChargeObject();
assertNotNull(expCharge);
assertEquals(ch.getId(), expCharge.getId());
BalanceTransaction expBT = refund.getBalanceTransactionObject();
assertNotNull(expBT);
Refund expRefundInBT = (Refund) expBT.getSourceObject();
assertEquals(refund.getId(), expRefundInBT.getId());
}
use of com.stripe.model.Charge in project stripe-java by stripe.
the class RefundTest method testChargePartialRefund.
@Test
public void testChargePartialRefund() 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);
assertFalse(refundedCharge.getRefunded());
assertEquals(refundedCharge.getAmountRefunded(), refundAmount);
}
use of com.stripe.model.Charge in project stripe-java by stripe.
the class RefundTest method testChargeRefundUpdateApiKey.
@Test
public void testChargeRefundUpdateApiKey() throws StripeException {
Charge createdCharge = Charge.create(defaultChargeParams);
ChargeRefundCollection refunds = createdCharge.refund().getRefunds();
Refund refund = refunds.getData().get(0);
Map<String, String> metadata = new HashMap<String, String>();
metadata.put("foo", "bar");
Map<String, Object> updateParams = new HashMap<String, Object>();
updateParams.put("metadata", metadata);
refund = refund.update(updateParams, Stripe.apiKey);
assertEquals("bar", refund.getMetadata().get("foo"));
}
Aggregations