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


Java CardException类代码示例

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


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

示例1: createCharge

import com.stripe.exception.CardException; //导入依赖的package包/类
/**
 * The checkout form only makes a token, the final charge happens using this
 * call.
 * 
 * @param email
 *          - Primary Email
 * @param amount
 *          - Amount to be charged.
 * @param token
 *          - Token created off "checkout"
 * @return
 * @throws AuthenticationException
 * @throws InvalidRequestException
 * @throws APIConnectionException
 * @throws APIException
 * @throws CardException
 */
public String createCharge(String email, BigDecimal amount, String token)
    throws AuthenticationException, InvalidRequestException, APIConnectionException, APIException, CardException {

  log.warn("Charging: " + email + " For: " + amount);

  try {

    // See your keys here: https://dashboard.stripe.com/account/apikeys
    Stripe.apiKey = gricConfigProperties.getStripeApiKey();

    // Create a charge: this will charge the user's card
    Map<String, Object> chargeParams = new HashMap<String, Object>();
    // Amount in cents, multiple by 100, and send it as integer for API.
    chargeParams.put("amount", amount.multiply(new BigDecimal("100")).intValueExact());
    chargeParams.put("currency", "usd");
    chargeParams.put("source", token);
    chargeParams.put("description", "Glen Rock Indian Community Event");
    chargeParams.put("receipt_email", email);
    chargeParams.put("statement_descriptor", "GRIC Payment");

    Charge charge = Charge.create(chargeParams);

    String chargeIdAndReceiptNumber = charge.getId() + "," + charge.getReceiptNumber();

    return chargeIdAndReceiptNumber;
  } catch (Exception e) {
    // The card has been declined
    log.error("Charge failed for: " + email + " For: " + amount);
    throw e;
  }
}
 
开发者ID:glen-rock-indian-community,项目名称:gric-event-management,代码行数:49,代码来源:Talk2Stripe.java

示例2: handleAPIError

import com.stripe.exception.CardException; //导入依赖的package包/类
private static void handleAPIError(String rBody, int rCode)
		throws InvalidRequestException, AuthenticationException,
		CardException, APIException {
	APIResource.Error error = gson.fromJson(rBody,
			APIResource.ErrorContainer.class).error;
	switch (rCode) {
	case 400:
		throw new InvalidRequestException(error.message, error.param, null);
	case 404:
		throw new InvalidRequestException(error.message, error.param, null);
	case 401:
		throw new AuthenticationException(error.message);
	case 402:
		throw new CardException(error.message, error.code, error.param,
				null);
	default:
		throw new APIException(error.message, null);
	}
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:20,代码来源:APIResource.java

示例3: convertTheirChargesToOurs

import com.stripe.exception.CardException; //导入依赖的package包/类
private Charges convertTheirChargesToOurs(Map<String, Object> chargeParams)
		throws AuthenticationException, InvalidRequestException,
		APIConnectionException, CardException, APIException {
	ChargeCollection list = Charge.list(chargeParams);
	Charges charges = new Charges();
	for (Charge charge : list.getData()) {
		charges.getCharges().add(
				new com.example.legacyapp.dto.Charge(charge.getCustomer(), charge.getAmount(), charge.getCaptured())
		);
	}
	return charges;
}
 
开发者ID:marcingrzejszczak,项目名称:the-legacy-app,代码行数:13,代码来源:CustomerRentalHistoryManagerImpl.java

示例4: pay

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

示例5: rebill

import com.stripe.exception.CardException; //导入依赖的package包/类
/**
 * Charge him again.
 * @throws IOException If fails
 */
private void rebill() throws IOException {
    final Item item = this.item();
    final Long cents = Long.parseLong(item.get("stripe_cents").getN());
    final String customer = item.get("stripe_customer").getS();
    try {
        Charge.create(
            new StickyMap<String, Object>(
                new MapEntry<>("amount", cents),
                new MapEntry<>("currency", "usd"),
                new MapEntry<>(
                    "description",
                    String.format("ThreeCopies: %s", this.name)
                ),
                new MapEntry<>("customer", customer)
            ),
            new RequestOptions.RequestOptionsBuilder().setApiKey(
                Manifests.read("ThreeCopies-StripeSecret")
            ).build()
        );
    } catch (final APIException | APIConnectionException
        | AuthenticationException | CardException
        | InvalidRequestException ex) {
        throw new IOException(ex);
    }
    this.item().put(
        "paid",
        new AttributeValueUpdate().withValue(
            new AttributeValue().withN(
                Long.toString(cents * TimeUnit.HOURS.toSeconds(1L))
            )
        ).withAction(AttributeAction.ADD)
    );
}
 
开发者ID:yegor256,项目名称:threecopies,代码行数:38,代码来源:DyScript.java

示例6: createCardToken

import com.stripe.exception.CardException; //导入依赖的package包/类
Token createCardToken() throws AuthenticationException, InvalidRequestException, APIConnectionException,
		CardException, APIException {
	Map<String, Object> tokenParams = Maps.newHashMap();
	Map<String, Object> cardParams = Maps.newHashMap();
	cardParams.put("number", "4242424242424242");
	cardParams.put("exp_month", 11);
	cardParams.put("exp_year", 2019);
	cardParams.put("cvc", "314");
	tokenParams.put("card", cardParams);
	Token token = Token.create(tokenParams);
	return token;
}
 
开发者ID:spacedog-io,项目名称:spacedog-server,代码行数:13,代码来源:StripeResourceTest.java

示例7: deleteDiscount

import com.stripe.exception.CardException; //导入依赖的package包/类
public void deleteDiscount(String apiKey) throws AuthenticationException,
		InvalidRequestException, APIConnectionException, CardException,
		APIException {
	request(RequestMethod.DELETE,
			String.format("%s/discount",
					instanceURL(Customer.class, this.id)), null,
			Discount.class, apiKey);
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:9,代码来源:Customer.java

示例8: retrieve

import com.stripe.exception.CardException; //导入依赖的package包/类
public static BalanceTransaction retrieve(String id, String apiKey)
		throws AuthenticationException, InvalidRequestException,
		APIConnectionException, CardException, APIException {
	String url = String.format("%s/%s/%s", Stripe.API_BASE, "v1/balance/history", id);
	return request(RequestMethod.GET, url, null,
			BalanceTransaction.class, apiKey);
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:8,代码来源:BalanceTransaction.java

示例9: all

import com.stripe.exception.CardException; //导入依赖的package包/类
public static BalanceTransactionCollection all(Map<String, Object> params, String apiKey)
		throws AuthenticationException, InvalidRequestException,
		APIConnectionException, CardException, APIException {
	String url = String.format("%s/%s", Stripe.API_BASE, "v1/balance/history");
	return request(RequestMethod.GET, url, params,
			BalanceTransactionCollection.class, apiKey);
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:8,代码来源:BalanceTransaction.java

示例10: all

import com.stripe.exception.CardException; //导入依赖的package包/类
public static RecipientCollection all(Map<String, Object> params,
		String apiKey) throws AuthenticationException,
		InvalidRequestException, APIConnectionException, CardException,
		APIException {
	return request(RequestMethod.GET, classURL(Recipient.class), params,
			RecipientCollection.class, apiKey);
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:8,代码来源:Recipient.java

示例11: delete

import com.stripe.exception.CardException; //导入依赖的package包/类
public DeletedRecipient delete(String apiKey)
		throws AuthenticationException, InvalidRequestException,
		APIConnectionException, CardException, APIException {
	return request(RequestMethod.DELETE,
			instanceURL(Recipient.class, this.id), null,
			DeletedRecipient.class, apiKey);
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:8,代码来源:Recipient.java

示例12: delete

import com.stripe.exception.CardException; //导入依赖的package包/类
public DeletedInvoiceItem delete(String apiKey)
		throws AuthenticationException, InvalidRequestException,
		APIConnectionException, CardException, APIException {
	return request(RequestMethod.DELETE,
			instanceURL(InvoiceItem.class, this.id), null,
			DeletedInvoiceItem.class, apiKey);
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:8,代码来源:InvoiceItem.java

示例13: all

import com.stripe.exception.CardException; //导入依赖的package包/类
public InvoiceLineItemCollection all(Map<String, Object> params,
		String apiKey) throws AuthenticationException,
		InvalidRequestException, APIConnectionException, CardException,
		APIException {
	String url = String.format("%s%s", Stripe.API_BASE, this.getURL());
	return request(RequestMethod.GET, url, params,
			InvoiceLineItemCollection.class, apiKey);
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:9,代码来源:InvoiceLineItemCollection.java

示例14: all

import com.stripe.exception.CardException; //导入依赖的package包/类
public CustomerCardCollection all(Map<String, Object> params,
    String apiKey) throws AuthenticationException,
    InvalidRequestException, APIConnectionException, CardException,
    APIException {
  String url = String.format("%s%s", Stripe.API_BASE, this.getURL());
  return request(RequestMethod.GET, url, params,
      CustomerCardCollection.class, apiKey);
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:9,代码来源:CustomerCardCollection.java

示例15: delete

import com.stripe.exception.CardException; //导入依赖的package包/类
public DeletedCard delete(String apiKey) throws AuthenticationException,
		InvalidRequestException, APIConnectionException, CardException,
		APIException {
	return request(RequestMethod.DELETE,
			this.getInstanceURL(), null, DeletedCard.class,
			apiKey);
}
 
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:8,代码来源:Card.java


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