use of com.stripe.model.Card in project stripe-java by stripe.
the class CustomerTest method testCustomerCreate.
@Test
public void testCustomerCreate() 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 testCustomerSourceList.
@Test
public void testCustomerSourceList() throws StripeException {
Customer customer = Customer.create(defaultCustomerParams);
Map<String, Object> creationParams = new HashMap<String, Object>();
creationParams.put("bank_account", defaultBankAccountParams);
customer.createBankAccount(creationParams);
HashMap<String, Object> listParams = new HashMap<String, Object>();
List<ExternalAccount> customerSourceList = customer.getSources().all(listParams).getData();
assertEquals(2, customerSourceList.size());
assert (customerSourceList.get(0) instanceof Card);
assertEquals("4242", ((Card) customerSourceList.get(0)).getLast4());
assert (customerSourceList.get(1) instanceof BankAccount);
assertEquals("6789", ((BankAccount) customerSourceList.get(1)).getLast4());
}
use of com.stripe.model.Card in project stripe-java by stripe.
the class CustomerTest method testCustomerCreateWithSource.
@Test
public void testCustomerCreateWithSource() throws StripeException {
HashMap<String, Object> customerCreationParams = new HashMap<String, Object>();
customerCreationParams.put("source", "tok_visa");
Customer customer = Customer.create(customerCreationParams);
assertNotNull(customer);
assertNotNull(customer.getId());
assertNotNull(customer.getSources());
assert (customer.getSources().getData().get(0) instanceof Card);
assertNotNull(customer.getDefaultSource());
ExternalAccount card = customer.getSources().retrieve(customer.getDefaultSource());
assertEquals(card.getId(), customer.getDefaultSource());
}
use of com.stripe.model.Card 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.Card in project stripe-java by stripe.
the class RecipientTest method testRecipientCardAddition.
@Test
public void testRecipientCardAddition() throws StripeException {
Recipient createdRecipient = Recipient.create(defaultRecipientParams);
final String originalDefaultCard = createdRecipient.getDefaultCard();
Map<String, Object> creationParams = new HashMap<String, Object>();
creationParams.put("card", "tok_visa_debit");
final Card addedCard = createdRecipient.createCard(creationParams);
createdRecipient.createCard("tok_visa_debit");
Recipient updatedRecipient = Recipient.retrieve(createdRecipient.getId());
assertEquals((Integer) 3, (Integer) updatedRecipient.getCards().getData().size());
assertEquals(updatedRecipient.getDefaultCard(), originalDefaultCard);
Map<String, Object> updateParams = new HashMap<String, Object>();
updateParams.put("default_card", addedCard.getId());
Recipient recipientAfterDefaultCardUpdate = updatedRecipient.update(updateParams);
assertEquals((Integer) recipientAfterDefaultCardUpdate.getCards().getData().size(), (Integer) 3);
assertEquals(recipientAfterDefaultCardUpdate.getDefaultCard(), addedCard.getId());
assertEquals(recipientAfterDefaultCardUpdate.getCards().retrieve(originalDefaultCard).getId(), originalDefaultCard);
assertEquals(recipientAfterDefaultCardUpdate.getCards().retrieve(addedCard.getId()).getId(), addedCard.getId());
}
Aggregations