当前位置: 首页>>代码示例>>Java>>正文


Java Customer.create方法代码示例

本文整理汇总了Java中com.stripe.model.Customer.create方法的典型用法代码示例。如果您正苦于以下问题:Java Customer.create方法的具体用法?Java Customer.create怎么用?Java Customer.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.stripe.model.Customer的用法示例。


在下文中一共展示了Customer.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testCustomerCardAddition

import com.stripe.model.Customer; //导入方法依赖的package包/类
@Test
public void testCustomerCardAddition() throws StripeException {
	Customer createdCustomer = Customer.create(defaultCustomerParams);
	String originalDefaultCard = createdCustomer.getDefaultCard();

	Map<String, Object> creationParams = new HashMap<String, Object>();
	creationParams.put("card", defaultCardParams);
	Card addedCard = createdCustomer.createCard(creationParams);

	Token token = Token.create(defaultTokenParams);
	createdCustomer.createCard(token.getId());

	Customer updatedCustomer = Customer.retrieve(createdCustomer.getId());
	assertEquals((Integer) updatedCustomer.getCards().getData().size(), (Integer) 3);
	assertEquals(updatedCustomer.getDefaultCard(), originalDefaultCard);

	Map<String, Object> updateParams = new HashMap<String, Object>();
	updateParams.put("default_card", addedCard.getId());
	Customer customerAfterDefaultCardUpdate = updatedCustomer.update(updateParams);
	assertEquals((Integer) customerAfterDefaultCardUpdate.getCards().getData().size(), (Integer) 3);
	assertEquals(customerAfterDefaultCardUpdate.getDefaultCard(), addedCard.getId());

	assertEquals(customerAfterDefaultCardUpdate.getCards().retrieve(originalDefaultCard).getId(), originalDefaultCard);
	assertEquals(customerAfterDefaultCardUpdate.getCards().retrieve(addedCard.getId()).getId(), addedCard.getId());
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:26,代码来源:StripeTest.java

示例2: testCustomerCardDelete

import com.stripe.model.Customer; //导入方法依赖的package包/类
@Test
public void testCustomerCardDelete() throws StripeException {
	Customer customer = Customer.create(defaultCustomerParams);
	Map<String, Object> creationParams = new HashMap<String, Object>();
	creationParams.put("card", defaultCardParams);
	customer.createCard(creationParams);

	Card card = customer.getCards().getData().get(0);
	DeletedCard deletedCard = card.delete();
	Customer retrievedCustomer = Customer.retrieve(customer.getId());

	assertTrue(deletedCard.getDeleted());
	assertEquals(deletedCard.getId(), card.getId());
	for(Card retrievedCard : retrievedCustomer.getCards().getData()) {
	    assertFalse("Card was not actually deleted: " + card.getId(), card.getId().equals(retrievedCard.getId()));
	}
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:18,代码来源:StripeTest.java

示例3: createDefaultCustomerWithPlan

import com.stripe.model.Customer; //导入方法依赖的package包/类
static Customer createDefaultCustomerWithPlan(Plan plan)
		throws StripeException {
	Map<String, Object> customerWithPlanParams = new HashMap<String, Object>();
	customerWithPlanParams.putAll(defaultCustomerParams);
	customerWithPlanParams.put("plan", plan.getId());
	Customer customer = Customer.create(customerWithPlanParams);
	return customer;
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:9,代码来源:StripeTest.java

示例4: testCustomerCreate

import com.stripe.model.Customer; //导入方法依赖的package包/类
@Test
public void testCustomerCreate() throws StripeException {
	Customer customer = Customer.create(defaultCustomerParams);
	assertEquals(customer.getDescription(), "J Bindings Customer");
	List<Card> customerCards = customer.getCards().getData();
	assertEquals(1, customerCards.size());
	assertEquals("4242", customerCards.get(0).getLast4());
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:9,代码来源:StripeTest.java

示例5: testCustomerRetrieve

import com.stripe.model.Customer; //导入方法依赖的package包/类
@Test
public void testCustomerRetrieve() throws StripeException {
	Customer createdCustomer = Customer.create(defaultCustomerParams);
	Customer retrievedCustomer = Customer.retrieve(createdCustomer.getId());
	assertEquals(createdCustomer.getCreated(),
			retrievedCustomer.getCreated());
	assertEquals(createdCustomer.getId(), retrievedCustomer.getId());
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:9,代码来源:StripeTest.java

示例6: testCustomerUpdate

import com.stripe.model.Customer; //导入方法依赖的package包/类
@Test
public void testCustomerUpdate() throws StripeException {
	Customer createdCustomer = Customer.create(defaultCustomerParams);
	Map<String, Object> updateParams = new HashMap<String, Object>();
	updateParams.put("description", "Updated Description");
	Customer updatedCustomer = createdCustomer.update(updateParams);
	assertEquals(updatedCustomer.getDescription(), "Updated Description");
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:9,代码来源:StripeTest.java

示例7: testCustomerCreateWithCouponPerCallAPIKey

import com.stripe.model.Customer; //导入方法依赖的package包/类
@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());
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:14,代码来源:StripeTest.java

示例8: testCustomerUpdateToNull

import com.stripe.model.Customer; //导入方法依赖的package包/类
@Test
public void testCustomerUpdateToNull() throws StripeException {
	Customer createdCustomer = Customer.create(defaultCustomerParams);
	Map<String, Object> updateParams = new HashMap<String, Object>();
	updateParams.put("description", null);
	Customer updatedCustomer = createdCustomer.update(updateParams);
	assertEquals(updatedCustomer.getDescription(), null);
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:9,代码来源:StripeTest.java

示例9: testCustomerCardUpdate

import com.stripe.model.Customer; //导入方法依赖的package包/类
@Test
public void testCustomerCardUpdate() throws StripeException {
	Customer customer = Customer.create(defaultCustomerParams);
	Card originalCard = customer.getCards().getData().get(0);
	Map<String, Object> updateParams = new HashMap<String, Object>();
	updateParams.put("name", "J Bindings Cardholder, Jr.");
	Card updatedCard = originalCard.update(updateParams);
	assertEquals(updatedCard.getName(), "J Bindings Cardholder, Jr.");
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:10,代码来源:StripeTest.java

示例10: testInvoiceItemUpdatePerCallAPIKey

import com.stripe.model.Customer; //导入方法依赖的package包/类
@Test
public void testInvoiceItemUpdatePerCallAPIKey() throws StripeException {
	Customer customer = Customer.create(defaultCustomerParams,
			Stripe.apiKey);
	InvoiceItem createdInvoiceItem = createDefaultInvoiceItem(customer);
	Map<String, Object> updateParams = new HashMap<String, Object>();
	updateParams.put("description", "Updated Description");
	updateParams.put("amount", 200);
	InvoiceItem updatedInvoiceItem = createdInvoiceItem.update(
			updateParams, Stripe.apiKey);
	assertTrue(updatedInvoiceItem.getAmount() == 200);
	assertEquals(updatedInvoiceItem.getDescription(), "Updated Description");
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:14,代码来源:StripeTest.java

示例11: testUpdateSubscription

import com.stripe.model.Customer; //导入方法依赖的package包/类
@Test
public void testUpdateSubscription() throws StripeException {
	Plan plan = Plan.create(getUniquePlanParams());
	Customer customer = Customer.create(defaultCustomerParams);
	Map<String, Object> subscriptionParams = new HashMap<String, Object>();
	subscriptionParams.put("plan", plan.getId());
	Subscription sub = customer.updateSubscription(subscriptionParams);
	assertEquals(sub.getPlan().getId(), plan.getId());
	assertEquals(sub.getCustomer(), customer.getId());
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:11,代码来源:StripeTest.java

示例12: testInvoiceItemDeletePerCallAPIKey

import com.stripe.model.Customer; //导入方法依赖的package包/类
@Test
public void testInvoiceItemDeletePerCallAPIKey() throws StripeException {
	Customer customer = Customer.create(defaultCustomerParams,
			Stripe.apiKey);
	InvoiceItem createdInvoiceItem = createDefaultInvoiceItem(customer);
	DeletedInvoiceItem deletedInvoiceItem = createdInvoiceItem
			.delete(Stripe.apiKey);
	assertTrue(deletedInvoiceItem.getDeleted());
	assertEquals(deletedInvoiceItem.getId(), createdInvoiceItem.getId());
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:11,代码来源:StripeTest.java

示例13: testInvoiceItemUpdate

import com.stripe.model.Customer; //导入方法依赖的package包/类
@Test
public void testInvoiceItemUpdate() throws StripeException {
	Customer customer = Customer.create(defaultCustomerParams);
	InvoiceItem createdInvoiceItem = createDefaultInvoiceItem(customer);
	Map<String, Object> updateParams = new HashMap<String, Object>();
	updateParams.put("description", "Updated Description");
	updateParams.put("amount", 200);
	InvoiceItem updatedInvoiceItem = createdInvoiceItem
			.update(updateParams);
	assertTrue(updatedInvoiceItem.getAmount() == 200);
	assertEquals(updatedInvoiceItem.getDescription(), "Updated Description");
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:13,代码来源:StripeTest.java

示例14: testInvoiceItemRetrievePerCallAPIKey

import com.stripe.model.Customer; //导入方法依赖的package包/类
@Test
public void testInvoiceItemRetrievePerCallAPIKey() throws StripeException {
	Customer customer = Customer.create(defaultCustomerParams,
			Stripe.apiKey);
	InvoiceItem createdInvoiceItem = createDefaultInvoiceItem(customer);
	InvoiceItem retrievedInvoiceItem = InvoiceItem.retrieve(
			createdInvoiceItem.getId(), Stripe.apiKey);
	assertEquals(createdInvoiceItem.getId(), retrievedInvoiceItem.getId());
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:10,代码来源:StripeTest.java

示例15: testUpcomingInvoice

import com.stripe.model.Customer; //导入方法依赖的package包/类
@Test
public void testUpcomingInvoice() throws Exception {
	Customer customer = Customer.create(defaultCustomerParams);
	createDefaultInvoiceItem(customer);
	Map<String, Object> upcomingParams = new HashMap<String, Object>();
	upcomingParams.put("customer", customer.getId());
	Invoice upcomingInvoice = Invoice.upcoming(upcomingParams);
	assertFalse(upcomingInvoice.getAttempted());
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:10,代码来源:StripeTest.java


注:本文中的com.stripe.model.Customer.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。