use of com.stripe.model.Charge in project stripe-java by stripe.
the class DisputeTest method testRetrieveDisputeWithExpand.
@Test
public void testRetrieveDisputeWithExpand() throws StripeException, InterruptedException {
int chargeValueCents = 100;
Charge disputedCharge = createDisputedCharge(chargeValueCents, null);
Dispute dispute = disputedCharge.getDisputeObject();
List<String> expandList = new LinkedList<String>();
expandList.add("charge");
Map<String, Object> retrieveParams = new HashMap<String, Object>();
retrieveParams.put("expand", expandList);
Dispute retrievedDispute = Dispute.retrieve(dispute.getId(), retrieveParams, null);
assertEquals(dispute.getId(), retrievedDispute.getId());
Charge expandedCharge = retrievedDispute.getChargeObject();
assertNotNull(expandedCharge);
assertEquals(disputedCharge.getId(), expandedCharge.getId());
Card card = (Card) expandedCharge.getSource();
assertEquals("0259", card.getLast4());
}
use of com.stripe.model.Charge in project stripe-java by stripe.
the class IdempotentTest method testClearingIdempotentcyActuallyWorks.
@Test
public void testClearingIdempotentcyActuallyWorks() throws CardException, APIException, AuthenticationException, InvalidRequestException, APIConnectionException {
RequestOptions options = RequestOptions.builder().setIdempotencyKey(UUID.randomUUID().toString()).clearIdempotencyKey().build();
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 IdempotentTest method testIdempotentRequestSent.
@Test
public void testIdempotentRequestSent() throws CardException, APIException, AuthenticationException, InvalidRequestException, APIConnectionException {
RequestOptions options = RequestOptions.builder().setIdempotencyKey(UUID.randomUUID().toString()).build();
Charge firstCharge = Charge.create(defaultChargeParams, options);
Charge secondCharge = Charge.create(defaultChargeParams, options);
assertEquals(firstCharge.getId(), secondCharge.getId());
}
use of com.stripe.model.Charge in project stripe-java by stripe.
the class RefundTest method testRefundMetadata.
@Test
public void testRefundMetadata() throws StripeException {
Charge createdCharge = Charge.create(defaultChargeParams);
Charge refundedCharge = createdCharge.refund();
testMetadata(refundedCharge.getRefunds().getData().get(0));
}
use of com.stripe.model.Charge in project stripe-java by stripe.
the class RefundTest method testChargeRefundListAndRetrievePerCallAPIKey.
@Test
public void testChargeRefundListAndRetrievePerCallAPIKey() 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, Stripe.apiKey).getData().get(0);
Refund retrieved = ch.getRefunds().retrieve(created.getId(), Stripe.apiKey);
assertEquals(created.getId(), retrieved.getId());
}
Aggregations