1

我看到 Parse.com 有用于 Stripe 支付的模块,但我不确定它们是否支持 Stripe.com 托管账户,因为我正在为市场创建移动应用程序,而 Stripe 支持告诉我应该为市场使用托管账户。

Parse.com 条纹模块:https ://parse.com/docs/js/guide#cloud-code-modules-stripe

Stripe.com 管理账户:https ://stripe.com/docs/connect/managed-accounts

有使用 Parse.com Stripe 模块经验的人吗?

4

3 回答 3

3

不幸的是,Parse 很长时间没有更新他们的 Stripe API 库,并表示他们没有更新它的计划。他们的 API 库是针对 Stripe API 的2012-07-09版本构建的,该版本比 Connect 和 Managed Accounts 进入 Stripe API 早几年。因此 Parse API 库不支持托管帐户。

于 2015-07-27T17:53:23.740 回答
1

您需要确保您的 Stripe 帐户已设置为允许连接帐户。通过添加 var Buffer = require('buffer').Buffer; 要在请求范围之外条带化云代码,您可以使用以下代码创建一个帐户:

 var Buffer = require('buffer').Buffer;
 var bankAccountNumber = request.params['bankAccountNumber']
 Parse.Cloud.httpRequest({

            method:"POST",

            url: "https://" +"api.stripe.com/v1" + "/accounts",

             headers: {
                'Authorization': 'Basic ' + new Buffer('YOUR_STRIPE_SECRET_KEY' + ':' + '').toString('base64')
              },
            body:{
                "managed": false,
                "country": "US",
                "email": "example@mailinator.com"

                },
            success: function(httpResponse) {
              response.success(httpResponse.text);
            },
            error: function(httpResponse) {
                response.error('Request failed with response code: ' + httpResponse.status);
            }

如果您创建独立帐户,您将在创建时收到一封电子邮件。Mailinator 是一项服务,允许您使用任何名称创建工作电子邮件地址,但没有隐私。编辑:我正在使用连接的帐户。我注意到,在测试时,如果您成功创建了一个帐户,那么随后尝试使用相同的电子邮件创建一个帐户将会失败。要转移资金,Stripe 需要您可以在平台仪表板的已连接帐户下查看的某些属性。我找到了其中几个的语法(除了银行账户)。Edit2:要完成 Stripe 的必填字段以验证您的帐户,您需要包含一个银行帐户字段。我的项目在 Swift 中运行,传递给我的云代码的参数是在我的应用程序中使用 STPAPIClient.sharedClient() 创建的令牌。https://stripe.com/docs/testing#how-do-i-test-sending-transfers

    body:{
                "managed": true,
                "country": "US",
                "email": "yourUniqueemail@mailinator.com",
                "legal_entity[first_name]": "AnyName",
                "legal_entity[last_name]": "AnyName",
                "legal_entity[dob[day]]": "20",
                "legal_entity[dob[month]]": "11",
                "legal_entity[dob[year]]": "1993",
                "legal_entity[type]": "individual",
                "tos_acceptance[date]": "1438198036",
                "tos_acceptance[ip]": "123.34.56.789",
                "bank_account": bankAccountNumber,
                },

编辑 3:我的代码的工作方式是创建客户并收取费用。收费金额与申请费一起发送到平台。然后从平台支付连接的帐户。(我不完全确定这是使用 Stripe 的正确方法;但是,这种方法似乎在测试模式下工作,并允许我们存储有关客户和我们支付的人的信息.) 好在 Parse 的 api 中存在 charge 方法,所以我们不必发出 POST 请求。这是执行此功能的收费方法。

    Parse.Cloud.define("chargeAccount", function(request, response) {
     var amount2 = request.params['amount']*100;

      Stripe.Charges.create({
        amount: amount2,
        currency: request.params["currency"],
        customer: request.params['customerId'], 
        description: request.params['description'],
        application_fee: amount2/5, 
        destination: request.params['destinationAccountId']
      },{
          success: function(charge) {
           response.success("There was a charge of $" + amount2/100  + " The application fee is: $" +amount2/500 +".");
        },
       error: function(error) {
         response.error("\nThis is the error:\n" +error); 
       }
      })
    });
于 2015-07-29T16:07:10.543 回答
0

我在解析问题部分找到了这个问题。我相信您应该能够更改此代码以满足您的需求。我还没有测试过,但是通过查看stripe api,我想出了这个:

这是 curl 请求的样子:

curl https://api.stripe.com/v1/accounts \
-u sk_test_BQokikJOvBiI2HlWgH4olfQ2: \
-d managed=false \
-d country=US \
-d email="bob@example.com"

所以你的javascript会是这样的,我相信:

Parse.Cloud.httpRequest({

//STRIPE_SECRET_KEY will be your stripe secret key obviously, this is different from the public key that you will use in your iOS/Android side.
// STRIPE_API_BASE_URL = 'api.stripe.com/v1'

method:"POST",
url: "https://" +  STRIPE_API_BASE_URL + "/accounts/",
headers: {
"keys[secret]" : STRIPE_SECRET_KEY
}, 
body:{ 
    "managed="+true,
    "country="+"US",
    "email="+"bob@example.com"
},
success: function(httpResponse) {
    response.success(httpResponse.text);
},
error: function(httpResponse) {
    response.error('Request failed with response code ' + httpResponse.status);
    }
});

这可能不是 100%,因为我无法对其进行测试,但请查看以下问题以获取更多资源:

https://parse.com/questions/cloud-httprequest-unable-to-take-dictionary-object-as-parameter-cant-form-encode-an-object-error

https://www.parse.com/questions/stripe-store-multiple-cards-on-a-customer

于 2015-07-28T17:57:55.383 回答