簡體   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