本文介绍了如何在Stripe中的已连接帐户上创建订阅计划?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在带区连接托管帐户上创建订阅计划.我尝试了以下代码:

I am trying to create a subscription plan on a stripe connect managed account. I tried the following code:

Parse.Cloud.define("createSubscription", function (request, response) {
 Parse.Cloud.httpRequest({
    method:"POST",
    url: "https://" + "sk_test_****************" + ':@' + "api.stripe.com/v1" + "/accounts/" + 'acct_**********' + "/plans/",  
    headers: {
    'Authorization': 'Basic ********************'
  },
  body: {
    'amount': 2000,
    'interval': 'month',
    'name': 'JPGB Plan',
    'currency': 'usd',
    'id':'first Plan',
  },
        success: function(httpResponse) {
        response.success(httpResponse.text);
        },
        error: function(httpResponse) {
        response.error('Request failed with response code' + httpResponse.status);
        }
    });                 
});

但这失败并显示404(请求的资源不存在)错误.

But this failed with a 404 (the requested resource doesn't exist) error.

这就是我的方法.

  Parse.Cloud.define("createAccountPlan", function (request, response) {
 Parse.Cloud.httpRequest({
    method:"POST",
    url: "https://" + "sk_test_****************" + ':@' + "api.stripe.com/v1/plans",  
    headers: {
    'Stripe-Account': request.params.accountId
    },
    body: {
        'amount': request.params.amount,
        'interval': 'day',
        'interval_count':request.params.intervalCount,
        'name': request.params.planName,
        'currency': 'usd',
        'id':request.params.planId,
    },
    success: function(httpResponse) {
    response.success(httpResponse.text);
    },
    error: function(httpResponse) {
    response.error('Request failed with response code' + httpResponse.status);
    }
});                 
});

推荐答案

来自 Stripe连接文档:

(展示客户的演示)

这里的条带化文档有些微妙,但这意味着您可以使用相同的技术为关联帐户上的客户进行订购.您也可以使用它来为该关联帐户制作产品和计划.以及您想代表关联客户执行的其他任何操作:

Stripe docs are a little subtle here, but this means you can use the same technique to make a subscription for a customer on a connected account. You can also use it to make the products and plans for that connected account too. and anything else you want to do on behalf of the connected customer:

(async function(){
  let subscription = await stripe.subscriptions.create({
    customer: "someCustomerID",
    plan: "planID"
  },{
    stripe_account: "connectedStripeAccountID"
  });
})();

这篇关于如何在Stripe中的已连接帐户上创建订阅计划?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 02:07