本文整理汇总了Java中com.stripe.exception.APIException类的典型用法代码示例。如果您正苦于以下问题:Java APIException类的具体用法?Java APIException怎么用?Java APIException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
APIException类属于com.stripe.exception包,在下文中一共展示了APIException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createCharge
import com.stripe.exception.APIException; //导入依赖的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.APIException; //导入依赖的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.APIException; //导入依赖的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.APIException; //导入依赖的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.APIException; //导入依赖的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.APIException; //导入依赖的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: create
import com.stripe.exception.APIException; //导入依赖的package包/类
public CustomerCardCollection create(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.POST, url, params,
CustomerCardCollection.class, apiKey);
}
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:9,代码来源:CustomerCardCollection.java
示例8: retrieve
import com.stripe.exception.APIException; //导入依赖的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.APIException; //导入依赖的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.APIException; //导入依赖的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: update
import com.stripe.exception.APIException; //导入依赖的package包/类
public Recipient update(Map<String, Object> params, String apiKey)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return request(RequestMethod.POST,
instanceURL(Recipient.class, this.id), params, Recipient.class,
apiKey);
}
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:8,代码来源:Recipient.java
示例12: update
import com.stripe.exception.APIException; //导入依赖的package包/类
public Customer update(Map<String, Object> params, String apiKey)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return request(RequestMethod.POST,
instanceURL(Customer.class, this.id), params, Customer.class,
apiKey);
}
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:8,代码来源:Customer.java
示例13: createCard
import com.stripe.exception.APIException; //导入依赖的package包/类
public Card createCard(String token, String apiKey) throws AuthenticationException,
InvalidRequestException, APIConnectionException, CardException,
APIException {
Map<String, Object> postParams = new HashMap<String, Object>();
postParams.put("card", token);
return createCard(postParams, apiKey);
}
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:9,代码来源:Customer.java
示例14: all
import com.stripe.exception.APIException; //导入依赖的package包/类
public static InvoiceItemCollection all(Map<String, Object> params,
String apiKey) throws AuthenticationException,
InvalidRequestException, APIConnectionException, CardException,
APIException {
return request(RequestMethod.GET, classURL(InvoiceItem.class), params,
InvoiceItemCollection.class, apiKey);
}
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:8,代码来源:InvoiceItem.java
示例15: update
import com.stripe.exception.APIException; //导入依赖的package包/类
public InvoiceItem update(Map<String, Object> params, String apiKey)
throws AuthenticationException, InvalidRequestException,
APIConnectionException, CardException, APIException {
return request(RequestMethod.POST,
instanceURL(InvoiceItem.class, this.id), params,
InvoiceItem.class, apiKey);
}
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:8,代码来源:InvoiceItem.java
示例16: retrieve
import com.stripe.exception.APIException; //导入依赖的package包/类
public Card retrieve(String id, String apiKey) throws AuthenticationException,
InvalidRequestException, APIConnectionException, CardException,
APIException {
// TODO: URL-encode!
String url = String.format("%s%s/%s", Stripe.API_BASE, this.getURL(), id);
return request(RequestMethod.GET, url, null,
Card.class, apiKey);
}
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:9,代码来源:CustomerCardCollection.java
示例17: all
import com.stripe.exception.APIException; //导入依赖的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
示例18: request
import com.stripe.exception.APIException; //导入依赖的package包/类
protected static <T> T request(APIResource.RequestMethod method,
String url, Map<String, Object> params, Class<T> clazz,
String apiKey) throws AuthenticationException,
InvalidRequestException, APIConnectionException, CardException,
APIException {
String originalDNSCacheTTL = null;
Boolean allowedToSetTTL = true;
try {
originalDNSCacheTTL = java.security.Security
.getProperty(DNS_CACHE_TTL_PROPERTY_NAME);
// disable DNS cache
java.security.Security
.setProperty(DNS_CACHE_TTL_PROPERTY_NAME, "0");
} catch (SecurityException se) {
allowedToSetTTL = false;
}
try {
return _request(method, url, params, clazz, apiKey);
} finally {
if (allowedToSetTTL) {
if (originalDNSCacheTTL == null) {
// value unspecified by implementation
java.security.Security.setProperty(
DNS_CACHE_TTL_PROPERTY_NAME, "-1"); // cache forever
} else {
java.security.Security.setProperty(
DNS_CACHE_TTL_PROPERTY_NAME, originalDNSCacheTTL);
}
}
}
}
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:33,代码来源:APIResource.java
示例19: delete
import com.stripe.exception.APIException; //导入依赖的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
示例20: cancelSubscription
import com.stripe.exception.APIException; //导入依赖的package包/类
public Subscription cancelSubscription(Map<String, Object> params,
String apiKey) throws AuthenticationException,
InvalidRequestException, APIConnectionException, CardException,
APIException {
return request(
RequestMethod.DELETE,
String.format("%s/subscription",
instanceURL(Customer.class, this.id)), params,
Subscription.class, apiKey);
}
开发者ID:JoeyMercs,项目名称:UO.me,代码行数:11,代码来源:Customer.java
注:本文中的com.stripe.exception.APIException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论