Exemplo n.º 1
0
 @Test
 public void testCustomerRetrievePerCallAPIKey() throws StripeException {
   Customer createdCustomer = Customer.create(defaultCustomerParams, Stripe.apiKey);
   Customer retrievedCustomer = Customer.retrieve(createdCustomer.getId());
   assertEquals(createdCustomer.getCreated(), retrievedCustomer.getCreated());
   assertEquals(createdCustomer.getId(), retrievedCustomer.getId());
 }
Exemplo n.º 2
0
 @Test
 public void testCustomerDeletePerCallAPIKey() throws StripeException {
   Customer createdCustomer = Customer.create(defaultCustomerParams, Stripe.apiKey);
   DeletedCustomer deletedCustomer = createdCustomer.delete(Stripe.apiKey);
   Customer deletedRetrievedCustomer = Customer.retrieve(createdCustomer.getId(), Stripe.apiKey);
   assertTrue(deletedCustomer.getDeleted());
   assertEquals(deletedCustomer.getId(), createdCustomer.getId());
   assertTrue(deletedRetrievedCustomer.getDeleted());
 }
Exemplo n.º 3
0
 @Test
 public void testInvoiceRetrieveForCustomerPerCallAPIKey() throws StripeException {
   Plan plan = Plan.create(getUniquePlanParams(), Stripe.apiKey);
   Customer customer = createDefaultCustomerWithPlan(plan);
   Map<String, Object> listParams = new HashMap<String, Object>();
   listParams.put("customer", customer.getId());
   listParams.put("count", 1);
   Invoice invoice = Invoice.all(listParams, Stripe.apiKey).getData().get(0);
   assertEquals(invoice.getCustomer(), customer.getId());
 }
Exemplo n.º 4
0
 static InvoiceItem createDefaultInvoiceItem(Customer customer) throws StripeException {
   Map<String, Object> invoiceItemParams = new HashMap<String, Object>();
   invoiceItemParams.put("amount", 100);
   invoiceItemParams.put("currency", "usd");
   invoiceItemParams.put("customer", customer.getId());
   return InvoiceItem.create(invoiceItemParams);
 }
Exemplo n.º 5
0
 @Test
 public void testUpcomingInvoicePerCallAPIKey() throws Exception {
   Customer customer = Customer.create(defaultCustomerParams, Stripe.apiKey);
   createDefaultInvoiceItem(customer);
   Map<String, Object> upcomingParams = new HashMap<String, Object>();
   upcomingParams.put("customer", customer.getId());
   Invoice upcomingInvoice = Invoice.upcoming(upcomingParams, Stripe.apiKey);
   assertFalse(upcomingInvoice.getAttempted());
 }
Exemplo n.º 6
0
 @Test
 public void testUpdateSubscriptionPerCallAPIKey() throws StripeException {
   Plan plan = Plan.create(getUniquePlanParams(), Stripe.apiKey);
   Customer customer = Customer.create(defaultCustomerParams, Stripe.apiKey);
   Map<String, Object> subscriptionParams = new HashMap<String, Object>();
   subscriptionParams.put("plan", plan.getId());
   Subscription sub = customer.updateSubscription(subscriptionParams, Stripe.apiKey);
   assertEquals(sub.getPlan().getId(), plan.getId());
   assertEquals(sub.getCustomer(), customer.getId());
 }
Exemplo n.º 7
0
  @Test
  public void testCustomerCreateWithCouponPerCallAPIKey() throws StripeException {
    Coupon coupon = Coupon.create(getUniqueCouponParams(), Stripe.apiKey);
    Map<String, Object> customerWithCouponParams = new HashMap<String, Object>();
    customerWithCouponParams.put("coupon", coupon.getId());
    Customer customer = Customer.create(customerWithCouponParams, Stripe.apiKey);
    assertEquals(customer.getDiscount().getCoupon().getId(), coupon.getId());

    customer.deleteDiscount();
    assertNull(Customer.retrieve(customer.getId()).getDiscount());
  }