无法创建非美元价格的Stripe订阅



我正在尝试使用美元、欧元和英镑设置Stripe的订阅付款。我有一种产品,有三种价格,每种货币一种。如果我选择美元价格,它是有效的,但其他人的订阅创建失败,除了这个例外:

com.stripe.exception.InvalidRequestException:指定的价格使用的是与预期货币usd不匹配的eur。使用usd代替

我不明白美元是从哪里来的。我创建订阅的代码:

// link PaymentMethod to Customer .. might throw CardException
PaymentMethod pm = null;
try {
pm = PaymentMethod.retrieve(paymentMethodId);
pm.attach(PaymentMethodAttachParams.builder().setCustomer(customer.getId()).build());
} catch (CardException e) {
throw new ReportableException(e.getMessage());
}
// make default PaymentMethod for customer
CustomerUpdateParams cup = CustomerUpdateParams.builder()
.setInvoiceSettings(CustomerUpdateParams.InvoiceSettings.builder().setDefaultPaymentMethod(paymentMethodId).build())
.build();
customer.update(cup);
SubscriptionCreateParams.Item item = SubscriptionCreateParams.Item.builder().setPrice(price).build();
// create subscription
SubscriptionCreateParams subCreateParams = SubscriptionCreateParams.builder()
.addItem(item)
.setCustomer(customer.getId())
.addAllExpand(Arrays.asList("latest_invoice.payment_intent"))
.build();
Subscription subscription = Subscription.create(subCreateParams);

有什么想法吗?Tx.

我在freenode上的#stripe上收到了一个答案:

@timebox
A Customer can only have one currency.
You've already created a Subscription on that Customer with USD.

不到30秒就回来了。令人印象深刻的支持。

最新更新