use of com.stripe.model.Card in project stripe-java by stripe.
the class ChargeTest method testChargeRetrieve.
@Test
public void testChargeRetrieve() throws StripeException {
Charge createdCharge = Charge.create(defaultChargeParams);
Charge retrievedCharge = Charge.retrieve(createdCharge.getId());
assertEquals(createdCharge.getCreated(), retrievedCharge.getCreated());
assertEquals(createdCharge.getId(), retrievedCharge.getId());
assertNotNull(retrievedCharge.getSource());
assertEquals("card", retrievedCharge.getSource().getObject());
Card card = (Card) retrievedCharge.getSource();
assertEquals("4242", card.getLast4());
// BT Checks:
assertNotNull(retrievedCharge.getBalanceTransaction());
assertNull(retrievedCharge.getBalanceTransactionObject());
}
use of com.stripe.model.Card in project stripe-java by stripe.
the class CustomerTest method testCustomerCreatePerCallAPIKey.
@Test
public void testCustomerCreatePerCallAPIKey() throws StripeException {
Customer customer = Customer.create(defaultCustomerParams, supportedRequestOptions);
assertEquals(customer.getDescription(), "J Bindings Customer");
List<ExternalAccount> customerSources = customer.getSources().getData();
assertEquals(1, customerSources.size());
assertThat(customerSources.get(0), instanceOf(Card.class));
assertEquals("4242", ((Card) customerSources.get(0)).getLast4());
}
use of com.stripe.model.Card in project stripe-java by stripe.
the class CustomerTest method testCustomerCardUpdate.
@Test
public void testCustomerCardUpdate() throws StripeException {
Customer customer = Customer.create(defaultCustomerParams, supportedRequestOptions);
ExternalAccount originalCard = customer.getSources().getData().get(0);
Map<String, Object> updateParams = new HashMap<String, Object>();
updateParams.put("name", "J Bindings Cardholder, Jr.");
ExternalAccount updatedCard = originalCard.update(updateParams);
assertThat(updatedCard, instanceOf(Card.class));
assertEquals(((Card) updatedCard).getName(), "J Bindings Cardholder, Jr.");
}
use of com.stripe.model.Card in project stripe-java by stripe.
the class RecipientTest method testRecipientCardUpdate.
@Test
public void testRecipientCardUpdate() throws StripeException {
Recipient recipient = Recipient.create(defaultRecipientParams);
Card originalCard = recipient.getCards().getData().get(0);
Map<String, Object> updateParams = new HashMap<String, Object>();
updateParams.put("name", "J Bindings Debitholder, Jr.");
Card updatedCard = originalCard.update(updateParams);
assertEquals(updatedCard.getName(), "J Bindings Debitholder, Jr.");
}
use of com.stripe.model.Card in project stripe-java by stripe.
the class CustomerTest method testCustomerSourceUpdate.
@Test
public void testCustomerSourceUpdate() throws StripeException {
Customer customer = Customer.create(defaultCustomerParams);
ExternalAccountCollection customerSources = customer.getSources();
ExternalAccount paymentSource = customerSources.getData().get(0);
assert (paymentSource instanceof Card);
Card card = (Card) paymentSource;
HashMap<String, Object> updateParams = new HashMap<String, Object>();
updateParams.put("address_line1", "some address details");
Card updatedCard = card.update(updateParams);
assertEquals("some address details", updatedCard.getAddressLine1());
}
Aggregations