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

Java StripeException类代码示例

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

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



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

示例1: main

import com.stripe.exception.StripeException; //导入依赖的package包/类
public static void main(String[] args) {
    Stripe.apiKey = "sk_test_RVommOo9ArONhawECkwu3Kz3";
    Map<String, Object> chargeMap = new HashMap<String, Object>();
    chargeMap.put("amount", 100);
    chargeMap.put("currency", "usd");
    Map<String, Object> cardMap = new HashMap<String, Object>();
    cardMap.put("number", "4242424242424242");
    cardMap.put("exp_month", 12);
    cardMap.put("exp_year", 2020);
    chargeMap.put("card", cardMap);
    try {
        Charge charge = Charge.create(chargeMap);
        System.out.println(charge);
    } catch (StripeException e) {
        e.printStackTrace();
    }
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:18,代码来源:SripeExample.java


示例2: testBalanceTransactionRetrieval

import com.stripe.exception.StripeException; //导入依赖的package包/类
@Test
public void testBalanceTransactionRetrieval() throws StripeException {
	Charge.create(defaultChargeParams);
	BalanceTransactionCollection balanceTransactions = BalanceTransaction.all(null);
	assertTrue(balanceTransactions.getCount() > 0);
	assertFalse(balanceTransactions.getData().isEmpty());
	BalanceTransaction first = balanceTransactions.getData().get(0);
	assertNotNull(first.getStatus());

	HashMap<String, Object> fetchParams = new HashMap<String, Object>();
	fetchParams.put("count", 2);
	assertEquals(BalanceTransaction.all(fetchParams).getData().size(), 2);

	BalanceTransaction retrieved = BalanceTransaction.retrieve(first.getId());
	assertEquals(retrieved.getId(), first.getId());
	assertEquals(retrieved.getSource(), first.getSource());
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:18,代码来源:StripeTest.java


示例3: testInvalidAddressZipTest

import com.stripe.exception.StripeException; //导入依赖的package包/类
@Test
public void testInvalidAddressZipTest() throws StripeException {
	Map<String, Object> invalidChargeParams = new HashMap<String, Object>();
	invalidChargeParams.putAll(defaultChargeParams);
	Map<String, Object> invalidCardParams = new HashMap<String, Object>();
	// See https://stripe.com/docs/testing
	invalidCardParams.put("number", "4000000000000036");
	invalidCardParams.put("address_zip", "94024");
	invalidCardParams.put("address_line1", "42 Foo Street");
	invalidCardParams.put("exp_month", 12);
	invalidCardParams.put("exp_year", 2015);
	invalidChargeParams.put("card", invalidCardParams);
	Charge charge = Charge.create(invalidChargeParams);
	assertEquals(charge.getPaid(), true);
	assertEquals(charge.getCard().getAddressZipCheck(), "fail");
	assertEquals(charge.getCard().getAddressLine1Check(), "pass");
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:18,代码来源:StripeTest.java


示例4: testInvalidAddressLine1Test

import com.stripe.exception.StripeException; //导入依赖的package包/类
@Test
public void testInvalidAddressLine1Test() throws StripeException {
	Map<String, Object> invalidChargeParams = new HashMap<String, Object>();
	invalidChargeParams.putAll(defaultChargeParams);
	Map<String, Object> invalidCardParams = new HashMap<String, Object>();
	// See https://stripe.com/docs/testing
	invalidCardParams.put("number", "4000000000000028");
	invalidCardParams.put("address_zip", "94024");
	invalidCardParams.put("address_line1", "42 Foo Street");
	invalidCardParams.put("exp_month", 12);
	invalidCardParams.put("exp_year", 2015);
	invalidChargeParams.put("card", invalidCardParams);
	Charge charge = Charge.create(invalidChargeParams);
	assertEquals(charge.getPaid(), true);
	assertEquals(charge.getCard().getAddressZipCheck(), "pass");
	assertEquals(charge.getCard().getAddressLine1Check(), "fail");
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:18,代码来源:StripeTest.java


示例5: testCustomerCardAddition

import com.stripe.exception.StripeException; //导入依赖的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


示例6: testCustomerCardDelete

import com.stripe.exception.StripeException; //导入依赖的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


示例7: processStripePayment

import com.stripe.exception.StripeException; //导入依赖的package包/类
/**
 * This method processes the pending payment using the configured payment gateway (at the time of writing, only STRIPE)
 * and returns a PaymentResult.
 * In order to preserve the consistency of the payment, when a non-gateway Exception is thrown, it rethrows an IllegalStateException
 *
 * @param reservationId
 * @param gatewayToken
 * @param price
 * @param event
 * @param email
 * @param customerName
 * @param billingAddress
 * @return PaymentResult
 * @throws java.lang.IllegalStateException if there is an error after charging the credit card
 */
PaymentResult processStripePayment(String reservationId,
                                   String gatewayToken,
                                   int price,
                                   Event event,
                                   String email,
                                   CustomerName customerName,
                                   String billingAddress) {
    try {
        final Charge charge = stripeManager.chargeCreditCard(gatewayToken, price,
                event, reservationId, email, customerName.getFullName(), billingAddress);
        log.info("transaction {} paid: {}", reservationId, charge.getPaid());
        Pair<Long, Long> fees = Optional.ofNullable(charge.getBalanceTransactionObject()).map(bt -> {
            List<Fee> feeDetails = bt.getFeeDetails();
            return Pair.of(Optional.ofNullable(StripeManager.getFeeAmount(feeDetails, "application_fee")).map(Long::parseLong).orElse(0L),
                           Optional.ofNullable(StripeManager.getFeeAmount(feeDetails, "stripe_fee")).map(Long::parseLong).orElse(0L));
        }).orElse(null);

        transactionRepository.insert(charge.getId(), null, reservationId,
                ZonedDateTime.now(), price, event.getCurrency(), charge.getDescription(), PaymentProxy.STRIPE.name(),
                fees != null ? fees.getLeft() : 0L, fees != null ? fees.getRight() : 0L);
        return PaymentResult.successful(charge.getId());
    } catch (Exception e) {
        if(e instanceof StripeException) {
            return PaymentResult.unsuccessful(stripeManager.handleException((StripeException)e));
        }
        throw new IllegalStateException(e);
    }

}
 
开发者ID:alfio-event,项目名称:alf.io,代码行数:45,代码来源:PaymentManager.java


示例8: createDefaultInvoiceItem

import com.stripe.exception.StripeException; //导入依赖的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


示例9: createDefaultRecipient

import com.stripe.exception.StripeException; //导入依赖的package包/类
static Recipient createDefaultRecipient()
		throws StripeException {
	Map<String, Object> recipientParams = new HashMap<String, Object>();
	recipientParams.putAll(defaultRecipientParams);
	Recipient recipient = Recipient.create(recipientParams);
	return recipient;
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:8,代码来源:StripeTest.java


示例10: testAccountRetrieve

import com.stripe.exception.StripeException; //导入依赖的package包/类
@Test
public void testAccountRetrieve() throws StripeException {
	Account retrievedAccount = Account.retrieve();
	assertEquals("[email protected]", retrievedAccount.getEmail());
	assertEquals(false, retrievedAccount.getChargeEnabled());
	assertEquals(false, retrievedAccount.getDetailsSubmitted());
	assertEquals(null, retrievedAccount.getStatementDescriptor());
	assertEquals(false, retrievedAccount.getTransferEnabled());

	List<String> currencies = retrievedAccount.getCurrenciesSupported();
	assertEquals(1, currencies.size());
	assertEquals("USD", currencies.get(0));
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:14,代码来源:StripeTest.java


示例11: testBalanceRetrieve

import com.stripe.exception.StripeException; //导入依赖的package包/类
@Test
public void testBalanceRetrieve() throws StripeException {
	Balance retrievedBalance = Balance.retrieve();
	assertEquals(false, retrievedBalance.getLivemode());
	assertEquals(1, retrievedBalance.getPending().size());
	assertEquals(1, retrievedBalance.getAvailable().size());
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:8,代码来源:StripeTest.java


示例12: testChargeRetrieve

import com.stripe.exception.StripeException; //导入依赖的package包/类
@Test
public void testChargeRetrieve() throws StripeException {
	Charge createdCharge = Charge.create(defaultChargeParams);
	Charge retrievedCharge = Charge.retrieve(createdCharge.getId());
	assertEquals(createdCharge.getCreated(), retrievedCharge.getCreated());
	assertEquals(createdCharge.getId(), retrievedCharge.getId());
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:8,代码来源:StripeTest.java


示例13: testChargeCapture

import com.stripe.exception.StripeException; //导入依赖的package包/类
@Test
public void testChargeCapture() throws StripeException {
	HashMap<String, Object> options = (HashMap<String, Object>)defaultChargeParams.clone();
	options.put("capture", false);

	Charge created = Charge.create(options);
	assertFalse(created.getCaptured());

	Charge captured = created.capture();
	assertTrue(captured.getCaptured());
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:12,代码来源:StripeTest.java


示例14: testChargePartialRefund

import com.stripe.exception.StripeException; //导入依赖的package包/类
@Test
public void testChargePartialRefund() throws StripeException {
	Charge createdCharge = Charge.create(defaultChargeParams);
	Map<String, Object> refundParams = new HashMap<String, Object>();
	final Integer REFUND_AMOUNT = 50;
	refundParams.put("amount", REFUND_AMOUNT);
	Charge refundedCharge = createdCharge.refund(refundParams);
	assertFalse(refundedCharge.getRefunded());
	assertEquals(refundedCharge.getAmountRefunded(), REFUND_AMOUNT);
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:11,代码来源:StripeTest.java


示例15: testChargeList

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


示例16: testInvalidCard

import com.stripe.exception.StripeException; //导入依赖的package包/类
@Test(expected = CardException.class)
public void testInvalidCard() throws StripeException {
	Map<String, Object> invalidChargeParams = new HashMap<String, Object>();
	invalidChargeParams.putAll(defaultChargeParams);
	Map<String, Object> invalidCardParams = new HashMap<String, Object>();
	invalidCardParams.put("number", "4242424242424241");
	invalidCardParams.put("exp_month", 12);
	invalidCardParams.put("exp_year", 2015);
	invalidChargeParams.put("card", invalidCardParams);
	Charge.create(invalidChargeParams);
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:12,代码来源:StripeTest.java


示例17: testCustomerRetrieve

import com.stripe.exception.StripeException; //导入依赖的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


示例18: testCustomerList

import com.stripe.exception.StripeException; //导入依赖的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


示例19: testCustomerUpdate

import com.stripe.exception.StripeException; //导入依赖的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


示例20: testCustomerUpdateToBlank

import com.stripe.exception.StripeException; //导入依赖的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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java IR类代码示例发布时间:2022-05-23
下一篇:
Java PubSubProvider类代码示例发布时间: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