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


Java Customer类代码示例

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


Customer类属于com.stripe.model包,在下文中一共展示了Customer类的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: 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


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