简体   繁体   English

条带:在订阅时设置连接帐户时出现问题

[英]stripe: problems setting connected account on subscription

I'm having some issues for adding an amount fee on a subscription on Stripe.我在为 Stripe 订阅添加金额费用时遇到了一些问题。 Looking at this documentation I should be able to add a connected account when creating the subscription so i can set an application fee on the subscription without having to do any modification on it afterwards.查看此文档,我应该能够在创建订阅时添加关联帐户,这样我就可以在订阅上设置申请费,而无需事后对其进行任何修改。

I'm trying to use a RequestOptions on the subscription creation to add the connected stripe account but it seems that if i use it it's redirecting to the live account and it's not finding the customer i'm using making the request to fail.我正在尝试在创建订阅时使用 RequestOptions 来添加连接的条带帐户,但似乎如果我使用它,它会重定向到真实帐户,并且找不到我正在使用的客户,导致请求失败。

Here is the code of the whole process:下面是整个过程的代码:

        attachPayMethodToCustomer(bookingDetails.getPaymentMethod(), user.getCustomerId());
        Price price = getPriceForItem(item, bookingDetails.isExclusive());

        SubscriptionCreateParams.Item item = SubscriptionCreateParams.Item.builder()
                .setQuantity(1L)
                .setPrice(price.getId())
                .build();

        BigDecimal bd = new BigDecimal(calculateSubscriptionFee(price.getUnitAmount() / 100, bookingDetails.isRecorded()), new MathContext(2, RoundingMode.HALF_UP));

        SubscriptionCreateParams.Builder params = SubscriptionCreateParams.builder()
                .setCustomer(user.getCustomerId())
                .setApplicationFeePercent(bd)
                .addItem(item);

        if (bookingDetails.hasExtras()) {
            Price recordPrice = getExtrasPrice(seller().getCurrency());
            SubscriptionCreateParams.Item extraItem = SubscriptionCreateParams.Item.builder()
                    .setQuantity(1L)
                    .setPrice(extraPrice.getId())
                    .build();

            params.addItem(extraItem);
        }

        RequestOptions ro = new RequestOptions.RequestOptionsBuilder()
                .setStripeAccount(seller.getStripeAccountId())
                .build();

        Subscription subscription = Subscription.create(params.build(), ro);

I'm receiving this exception when it tries to create the subscription:我在尝试创建订阅时收到此异常:

com.stripe.exception.InvalidRequestException: No such customer: 'cus_IaFZjrBAlBsXXX'; com.stripe.exception.InvalidRequestException:没有这样的客户:'cus_IaFZjrBAlBsXXX'; code: resource_missing;代码:resource_missing; request-id: req_C67JN4tgneXXXX but i can see the customer on the dashboard. request-id: req_C67JN4tgneXXXX但我可以在仪表板上看到客户。 I tried also to override the stripe api key to use the test one, but i have the same issue.我还尝试覆盖条带 api 密钥以使用测试密钥,但我遇到了同样的问题。

Thanks a lot, Adrián非常感谢, 阿德里安

After talking with Stripe support it seems i was doing it in the wrong way.在与 Stripe 支持人员交谈后,我似乎以错误的方式进行了操作。

For this they have a different way they call destination charges (here is the link )为此,他们有一种不同的方式来调用目的地费用(这里是链接

Basically instead of using the RequestOptions for there is an option in the subscription called TransferData where you can place the Connected account id.基本上,不是使用 RequestOptions,而是在订阅中有一个名为 TransferData 的选项,您可以在其中放置连接的帐户 ID。 Here is the sample from their web这是来自他们 web 的示例

SubscriptionCreateParams params = SubscriptionCreateParams.builder()
  .setCustomer("cus_XXXXXXX")
  .addItem(SubscriptionCreateParams.Item.builder()
    .setPrice("price_XXXXX")
    .build())
  .setTransferData(
    SubscriptionCreateParams.TransferData.builder()
      .setDestination("{{CONNECTED_STRIPE_ACCOUNT_ID}}")
      .build())
  .addExpand("latest_invoice.payment_intent")
  .build();
Subscription subscription = Subscription.create(params);

Thanks a lot and kudos to Stripe support team!非常感谢 Stripe 支持团队!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM