0

将独立帐户连接到 Stripe Connect 中的平台时,在用户授权访问后还需要迈出一小步。Stripe 提供了以下代码示例:

 curl https://connect.stripe.com/oauth/token \
    -d client_secret=sk_test_xxxxxxxxxxxxxxxx \
    -d code=AUTHORIZATION_CODE \
    -d grant_type=authorization_code

但是,我的应用程序在 Cloud Code 上运行,我想从我的解析服务器上的云代码函数发出请求。我怎样才能做到这一点?

4

1 回答 1

0

这是解决方案。希望它对某人有所帮助,因为我花了一段时间从云代码功能的角度来获得正确的语法。

 Parse.Cloud.define("postRequest", function(request, response){



 Parse.Cloud.httpRequest({
     method: 'POST',
     url: 'https://connect.stripe.com/oauth/token',
     headers: {
       'Authorization': 'Bearer sk_test_xxxxxxxxxxxxx'
     },
     body: {
    'code': request.params.code, //the authorization code passed back through the redirect_uri after user authorizes platform
    'grant_type': 'authorization_code',
    'client_secret': 'sk_test_xxxxxxxxxxxxx'
     },
   }).then(function(httpResponse) {
     console.log(httpResponse);
     response.success(httpResponse.text);
   }, function(err) {
     console.log(err);
     response.error(err);
   });




});
于 2017-01-19T07:05:25.323 回答