繁体   English   中英

使用Stripe和Parse存储信用卡。 没有方法每个错误

[英]Store credit card with Stripe and Parse. has no method each error

你好stackoverflow社区

我拼命试图通过iOS应用程序在Stripe中创建新的客户和信用卡。 我很幸运得到令牌。

但是,当运行以下代码与客户创建信用卡时,我在解析云代码中收到错误“没有方法'_each'”:

E2015-09-24T21:19:45.502Z]v10 Ran cloud function saveCardInformation with: 
Input: {"cardToken":"tok_16oh81JJfrimOSDHs6YSw4v5","objectId":"asdfdf"}
Result: TypeError: Object [object Object] has no method '_each'
   at request (stripe.js:58:11)
   at post (stripe.js:117:12)
   at Object.module.exports.Customers.create (stripe.js:239:16)
   at main.js:62:22

我执行以下Parse云代码:

//Parse Cloud code for creating new Stripe Customer and new Credit Card
var Stripe = require('stripe');
Stripe.initialize('mykey');

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

Stripe.Customers.create({
     source: request.params.cardToken,
   },{
     success: function(httpResponse) {
     response.success("Customer successfully created!");
    },
     error: function(httpResponse) {
     response.error(httpResponse.message);
  }
});

在相应的iOS应用中,我有以下代码:

STPCard *stpcard = [[STPCard alloc] init];
stpcard.number = @"4568785465487897";
stpcard.expMonth = 5;
stpcard.expYear = 2017;
stpcard.cvc = @"255";

NSLog(@"card created");

[[STPAPIClient sharedClient] createTokenWithCard:stpcard
                   completion:^(STPToken *token, NSError  *error) {
                         if (error) {
                                 NSLog(@"error, no token created");
                            } else {
                                 NSLog(@"Token from callback recieved");
                                 [self createBackendChargeWithToken:token];
                                   }
}];

到这里为止。

以下方法引起麻烦

- (void)createBackendChargeWithToken:(STPToken *)token
{
NSDictionary *productInfo = @{@"cardToken": token.tokenId,
                              @"objectId": @"asdfdf"};

[PFCloud callFunctionInBackground:@"saveCardInformation"
                   withParameters:productInfo
                            block:^(id object, NSError *error) {
                                if (error) {
                                   NSLog(@"error,");
                                    return ;
                                }

                              [[[UIAlertView alloc] 
                              initWithTitle:NSLocalizedString(@"Success", 
                                                              @"Success")
                                                              message:nil
                                                              delegate:nil
                              cancelButtonTitle:NSLocalizedString(@"OK","OK"
                              otherButtonTitles:nil] show];
                              }];
}

非常感谢您的回答和指导!

将您的云代码版本恢复为1.5.0或更早版本。

在这里解释: Parse + Stripe iOS main.js

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM