【问题标题】:Unable to create Stripe subscription with non-USD price无法以非美元价格创建 Stripe 订阅
【发布时间】:2021-04-10 21:31:23
【问题描述】:

我正在尝试使用美元、欧元和英镑通过 Stripe 设置订阅付款。我有一种产品,有 3 种价格,每种货币一种。如果我选择美元价格,它可以工作,但其他人的订阅创建失败,但有以下例外:

com.stripe.exception.InvalidRequestException:指定价格使用eur,与usd 的预期货币不匹配。请改用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);

有什么想法吗?发送。

【问题讨论】:

    标签: java stripe-payments


    【解决方案1】:

    我在 freenode 上的#stripe 上收到了答复:

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

    在 30 秒内恢复。令人印象深刻的支持。

    【讨论】:

      猜你喜欢
      • 2020-09-18
      • 1970-01-01
      • 1970-01-01
      • 2022-08-06
      • 1970-01-01
      • 2017-08-28
      • 1970-01-01
      • 2012-09-14
      • 2016-09-06
      相关资源
      最近更新 更多