[英]integrating Stripe.com and Parse.com with iOS - can't add a subscription to a customer
Thanks in advance! 提前致谢!
I've been smashing my head against my desk all day trying to figure out why I can't add a Stripe subscription to a customer via Parse. 我整天都在把头砸在桌子上,试图弄清楚为什么我不能通过Parse向客户添加Stripe订阅。
Here is what my dictionary looks like in objective-C: 这是我的字典在Objective-C中的样子:
NSDictionary *productInfo = @{ @"tokenId": token.tokenId,
@"plan": @"Test Plan",
@"email": currentUser.email };
I'm calling this PFCloud function in the background: 我在后台调用此PFCloud函数:
Parse.Cloud.define("createSubscription", function(request, response) {
var Stripe = require('stripe');
// Test
Stripe.initialize('abcdefghijklmnopqrstuvwxyz');
Stripe.Customers.create({
card: request.params.tokenId,
email: request.params.email,
plan: request.params.plan
}, {
success: function(httpResponse) {
response.success("Success - subscription created");
},
error: function(httpResponse) {
response.error("Error - subscription canceled");
}
})
});
I've interchanged "card" with "source" as mentioned in Stripe's documentation: https://stripe.com/docs/tutorials/subscriptions . 我已经将Stripe文档中提到的“卡片”与“源”互换了: https : //stripe.com/docs/tutorials/subscriptions 。
I've also tried using the plan Id rather than name. 我还尝试过使用计划ID而不是名称。 Does anyone know what I'm doing wrong?
有人知道我在做什么错吗?
Edit: I forgot to mention that I am getting this error message, half of which I wrote - [Error]: Error - subscription canceled (Code: 141, Version: 1.6.3). 编辑:我忘了提到我收到此错误消息,我写了其中一半-[错误]:错误-订阅已取消(代码:141,版本:1.6.3)。
For anyone that is interested in integrating Parse and Stripe, here is the solution. 对于有兴趣集成Parse和Stripe的任何人,这里都是解决方案。 I talked to the good people at Stripe customer support and they told me two important things.
我与Stripe客户支持部门的好人进行了交谈,他们告诉了我两件事。
First, if you are using the newest Stripe API version (2015-02-18) then you're going to want to use the key "source" but if you are using an older version then you're going to want to use the key "card". 首先,如果您使用的是最新的Stripe API版本(2015-02-18),则将要使用键“源”,但如果使用的是旧版本,则将要使用钥匙卡”。
Second, make sure to use the ID of your plan rather than it's name for the key "plan". 其次,请确保使用计划的ID而不是密钥“计划”的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.