条纹 javascript API Stripe.Recipients 未定义
Stripe javascript API Stripe.Recipients undefined
所以我正在使用 Parse 来处理支持 Stripe 的应用程序。我们希望我们的用户能够兑现他们的应用程序积分,我们正计划使用 Stripe 来处理这个问题。我已经能够在 Stripe 中成功创建客户,并且 link 为这些创建了一个银行账户。现在,我正在尝试向这些银行账户之一发起转账,之后
https://stripe.com/docs/tutorials/sending-transfers
但我 运行 遇到了 Stripe.recipients
未定义的问题。
相关代码:
条带初始化:
var Stripe = require('stripe');
Stripe.initialize('sk_test_ukk7e8B46I39nxoUd6XILpPZ');
用于传输的解析云函数:
Parse.Cloud.define("startTransfer", function(request, response) {
var userObjectId = request.params.userObjectId;
var credits = request.params.credits;
var StripeCustomer = Parse.Object.extend("StripeCustomer");
var stripeCustomerQuery = new Parse.Query(StripeCustomer);
stripeCustomerQuery.equalTo("userObj", userObjectId);
stripeCustomerQuery.find({
success: function(results) {
if(results.length == 0) {
} else if(results.length == 1) {
var customer = results[0];
// handle returning customer adding a new card
Stripe.Recipients.create({
name: customer.description,
type: "individual",
bank_account: customer.source,
email: customer.email
}, function(err, recipient) {
// recipient;
console.log("have a recipient");
if(err == nil) {
Stripe.transfers.create({
amount: credits,
currency: "usd",
recipient: recipient,
bank_account: customer.source,
statement_descriptor: "Cash Out"
}, function(err1, transfer) {
// asynchronously called
if(err == nil) {
response.success("Successfully transferred funds");
} else {
response.error(err1);
}
});
} else {
response.error(err);
}
});
}
}, error: function(error) {
reponse.error(error);
}
});
});
我是从 iOS 调用的,使用 PFCloud.callFunction API 调用。它似乎正确地命中了这段代码,但是 Recipients 在错误消息中被认为是未定义的,但是 Stripe 文档需要它。我该如何解决这个问题?
事实证明,Stripe 云代码模块确实使用了旧版本的 Stripe。因此,根据此错误报告,解决方案是下载更新的 SDK 并手动将其添加到云代码模块中。
来源:
https://developers.facebook.com/bugs/523104684492016/
错误报告中的实际 post(来自 Facebook 员工):
Parse modules are using an old version of the API and there is no plan to update it in the near future.
As a workaround please download the newer SDKs directly off the third party site, place it in "cloud/" folder and import it using require();
We're going to close this by design.
所以我正在使用 Parse 来处理支持 Stripe 的应用程序。我们希望我们的用户能够兑现他们的应用程序积分,我们正计划使用 Stripe 来处理这个问题。我已经能够在 Stripe 中成功创建客户,并且 link 为这些创建了一个银行账户。现在,我正在尝试向这些银行账户之一发起转账,之后
https://stripe.com/docs/tutorials/sending-transfers
但我 运行 遇到了 Stripe.recipients
未定义的问题。
相关代码:
条带初始化:
var Stripe = require('stripe');
Stripe.initialize('sk_test_ukk7e8B46I39nxoUd6XILpPZ');
用于传输的解析云函数:
Parse.Cloud.define("startTransfer", function(request, response) {
var userObjectId = request.params.userObjectId;
var credits = request.params.credits;
var StripeCustomer = Parse.Object.extend("StripeCustomer");
var stripeCustomerQuery = new Parse.Query(StripeCustomer);
stripeCustomerQuery.equalTo("userObj", userObjectId);
stripeCustomerQuery.find({
success: function(results) {
if(results.length == 0) {
} else if(results.length == 1) {
var customer = results[0];
// handle returning customer adding a new card
Stripe.Recipients.create({
name: customer.description,
type: "individual",
bank_account: customer.source,
email: customer.email
}, function(err, recipient) {
// recipient;
console.log("have a recipient");
if(err == nil) {
Stripe.transfers.create({
amount: credits,
currency: "usd",
recipient: recipient,
bank_account: customer.source,
statement_descriptor: "Cash Out"
}, function(err1, transfer) {
// asynchronously called
if(err == nil) {
response.success("Successfully transferred funds");
} else {
response.error(err1);
}
});
} else {
response.error(err);
}
});
}
}, error: function(error) {
reponse.error(error);
}
});
});
我是从 iOS 调用的,使用 PFCloud.callFunction API 调用。它似乎正确地命中了这段代码,但是 Recipients 在错误消息中被认为是未定义的,但是 Stripe 文档需要它。我该如何解决这个问题?
事实证明,Stripe 云代码模块确实使用了旧版本的 Stripe。因此,根据此错误报告,解决方案是下载更新的 SDK 并手动将其添加到云代码模块中。
来源:
https://developers.facebook.com/bugs/523104684492016/
错误报告中的实际 post(来自 Facebook 员工):
Parse modules are using an old version of the API and there is no plan to update it in the near future.
As a workaround please download the newer SDKs directly off the third party site, place it in "cloud/" folder and import it using require();
We're going to close this by design.