• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Customer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Customer类属于com.stripe.model包,在下文中一共展示了Customer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: pay

import com.stripe.model.Customer; //导入依赖的package包/类
@Override
public void pay(final long cents, final String token, final String email)
    throws IOException {
    final String customer;
    try {
        customer = Customer.create(
            new StickyMap<String, Object>(
                new MapEntry<>("email", email),
                new MapEntry<>("source", token)
            ),
            new RequestOptions.RequestOptionsBuilder().setApiKey(
                Manifests.read("ThreeCopies-StripeSecret")
            ).build()
        ).getId();
    } catch (final APIException | APIConnectionException
        | AuthenticationException | CardException
        | InvalidRequestException ex) {
        throw new IOException(ex);
    }
    this.item().put(
        new AttributeUpdates()
            .with(
                "stripe_cents",
                new AttributeValueUpdate().withValue(
                    new AttributeValue().withN(Long.toString(cents))
                ).withAction(AttributeAction.PUT)
            )
            .with(
                "stripe_customer",
                new AttributeValueUpdate().withValue(
                    new AttributeValue().withS(customer)
                ).withAction(AttributeAction.PUT)
            )
    );
    this.rebill();
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:37,代码来源:DyScript.java


示例4: createDefaultInvoiceItem

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


示例5: 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


示例6: 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


示例7: 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


示例8: testCustomerList

import com.stripe.model.Customer; //导入依赖的package包/类
@Test
public void testCustomerList() throws StripeException {
	Map<String, Object> listParams = new HashMap<String, Object>();
	listParams.put("count", 1);
	List<Customer> Customers = Customer.all(listParams).getData();
	assertEquals(Customers.size(), 1);
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:8,代码来源:StripeTest.java


示例9: 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


示例10: testCustomerUpdateToBlank

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


示例11: 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


示例12: 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


示例13: testCustomerDelete

import com.stripe.model.Customer; //导入依赖的package包/类
@Test
public void testCustomerDelete() throws StripeException {
	Customer createdCustomer = Customer.create(defaultCustomerParams);
	DeletedCustomer deletedCustomer = createdCustomer.delete();
	Customer deletedRetrievedCustomer = Customer.retrieve(createdCustomer
			.getId());
	assertTrue(deletedCustomer.getDeleted());
	assertEquals(deletedCustomer.getId(), createdCustomer.getId());
	assertTrue(deletedRetrievedCustomer.getDeleted());
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:11,代码来源:StripeTest.java


示例14: 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


示例15: testCancelSubscription

import com.stripe.model.Customer; //导入依赖的package包/类
@Test
public void testCancelSubscription() throws StripeException {
	Plan plan = Plan.create(getUniquePlanParams());
	Customer customer = createDefaultCustomerWithPlan(plan);
	assertEquals(customer.getSubscription().getStatus(), "active");
	Subscription canceledSubscription = customer.cancelSubscription();
	assertEquals(canceledSubscription.getStatus(), "canceled");
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:9,代码来源:StripeTest.java


示例16: testCancelSubscriptionAtPeriodEnd

import com.stripe.model.Customer; //导入依赖的package包/类
@Test
public void testCancelSubscriptionAtPeriodEnd() throws StripeException {
	Plan plan = Plan.create(getUniquePlanParams());
	Customer customer = createDefaultCustomerWithPlan(plan);
	assertEquals(customer.getSubscription().getStatus(), "active");
	Map<String, Object> cancelParams = new HashMap<String, Object>();
	cancelParams.put("at_period_end", true);
	Subscription canceledSubscription = customer
			.cancelSubscription(cancelParams);
	assertEquals(canceledSubscription.getStatus(), "active");
	assertEquals(canceledSubscription.getCancelAtPeriodEnd(), true);
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:13,代码来源:StripeTest.java


示例17: testInvoiceItemRetrieve

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


示例18: 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


示例19: testInvoiceItemDelete

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


示例20: testInvoiceRetrieveForCustomer

import com.stripe.model.Customer; //导入依赖的package包/类
@Test
public void testInvoiceRetrieveForCustomer() throws StripeException {
	Plan plan = Plan.create(getUniquePlanParams());
	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).getData().get(0);
	assertEquals(invoice.getCustomer(), customer.getId());
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:11,代码来源:StripeTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java JmxCacheBuster类代码示例发布时间:2022-05-23
下一篇:
Java NonPositiveDefiniteMatrixException类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap