Search in sources :

Example 11 with Card

use of com.stripe.model.Card in project stripe-java by stripe.

the class RecipientTest method testRecipientCardDelete.

@Test
public void testRecipientCardDelete() throws StripeException {
    Recipient recipient = Recipient.create(defaultRecipientParams);
    Map<String, Object> creationParams = new HashMap<String, Object>();
    creationParams.put("card", "tok_visa_debit");
    recipient.createCard(creationParams);
    Card card = recipient.getCards().getData().get(0);
    DeletedCard deletedCard = card.delete();
    Recipient retrievedRecipient = Recipient.retrieve(recipient.getId());
    assertTrue(deletedCard.getDeleted());
    assertEquals(deletedCard.getId(), card.getId());
    for (Card retrievedCard : retrievedRecipient.getCards().getData()) {
        assertFalse("Card was not actually deleted: " + card.getId(), card.getId().equals(retrievedCard.getId()));
    }
}
Also used : HashMap(java.util.HashMap) DeletedCard(com.stripe.model.DeletedCard) DeletedRecipient(com.stripe.model.DeletedRecipient) Recipient(com.stripe.model.Recipient) DeletedCard(com.stripe.model.DeletedCard) Card(com.stripe.model.Card) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 12 with Card

use of com.stripe.model.Card in project stripe-java by stripe.

the class ChargeTest method testInvalidAddressLine1Test.

@Test
public void testInvalidAddressLine1Test() throws StripeException {
    Map<String, Object> invalidChargeParams = new HashMap<String, Object>();
    invalidChargeParams.putAll(defaultChargeParams);
    invalidChargeParams.put("source", "tok_avsLine1Fail");
    Charge charge = Charge.create(invalidChargeParams, supportedRequestOptions);
    assertEquals(charge.getPaid(), true);
    assertThat(charge.getSource(), instanceOf(Card.class));
    Card card = (Card) charge.getSource();
    assertEquals(card.getAddressLine1Check(), "fail");
}
Also used : HashMap(java.util.HashMap) Charge(com.stripe.model.Charge) Card(com.stripe.model.Card) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 13 with Card

use of com.stripe.model.Card 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");
}
Also used : HashMap(java.util.HashMap) Charge(com.stripe.model.Charge) Card(com.stripe.model.Card) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Example 14 with Card

use of com.stripe.model.Card 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());
}
Also used : Charge(com.stripe.model.Charge) Card(com.stripe.model.Card) BaseStripeFunctionalTest(com.stripe.BaseStripeFunctionalTest) Test(org.junit.Test)

Aggregations

BaseStripeFunctionalTest (com.stripe.BaseStripeFunctionalTest)14 Card (com.stripe.model.Card)14 Test (org.junit.Test)14 HashMap (java.util.HashMap)10 Customer (com.stripe.model.Customer)6 DeletedCustomer (com.stripe.model.DeletedCustomer)6 DeletedExternalAccount (com.stripe.model.DeletedExternalAccount)6 ExternalAccount (com.stripe.model.ExternalAccount)6 Charge (com.stripe.model.Charge)5 DeletedCard (com.stripe.model.DeletedCard)3 DeletedRecipient (com.stripe.model.DeletedRecipient)3 Recipient (com.stripe.model.Recipient)3 BankAccount (com.stripe.model.BankAccount)1 DeletedBankAccount (com.stripe.model.DeletedBankAccount)1 Dispute (com.stripe.model.Dispute)1 EvidenceSubObject (com.stripe.model.EvidenceSubObject)1 ExternalAccountCollection (com.stripe.model.ExternalAccountCollection)1 LinkedList (java.util.LinkedList)1