【问题标题】:Parse + Stripe iOS main.js解析 + 条纹 iOS main.js
【发布时间】:2015-12-09 06:50:01
【问题描述】:

我真的很难让 Parse + Stripe 在我的项目中工作。在这一点上,我想要一个最简单的工作版本,可以让我向用户收费。

我找到的最接近答案的内容如下: Simplest Example I've Found

当我使用上面链接中的更正代码时,我得到了以下错误:

  Input: {"token":"tok_16kNOcIPNR1PIJsTyhvwTFJ9"}
  Result: TypeError: Object [object Object] has no method 'isString'
at request (stripe.js:49:25)
at post (stripe.js:117:12)
at Object.module.exports.Charges.create (stripe.js:157:16)
at main.js:19:31

请帮助 =**( 这太令人沮丧了。

---------- 更新-----

其他一些帖子也有类似的错误,看起来应该归咎于 Parse Cloud 代码的最新版本:1.6.0。在控制台视图中使用以下命令行提示符恢复到 1.5.0 版:

parse jssdk 1.5.0

现在,不幸的是我仍然收到以下错误(但我认为这是由于我现在的云代码 main.js 文件。当我最终弄清楚如何完成云代码文件时,我会保持这个线程更新。

Error Domain=Parse Code=141 "success/error was not called" UserInfo=0x1740e5700 {code=141, temporary=0, error=success/error was not called, NSLocalizedDescription=success/error was not called}

【问题讨论】:

    标签: ios parse-platform stripe-payments


    【解决方案1】:

    最后。好的,这里是使用 Parse + Stripe 的最基本代码。

    iOS 代码

    - (IBAction)save:(id)sender {
    STPCard *card = [[STPCard alloc] init];
    card.number = self.paymentTextField.cardNumber;
    card.expMonth = self.paymentTextField.expirationMonth;
    card.expYear = self.paymentTextField.expirationYear;
    card.cvc = self.paymentTextField.cvc;
    
    NSLog(@"%@, %@", self.paymentTextField.cvc, self.paymentTextField.cardNumber);
    [[STPAPIClient sharedClient] createTokenWithCard:card
                                          completion:^(STPToken *token, NSError *error) {
                                              if (error) {
                                                  NSLog(@"up here");
                                                  NSLog(@"error - %@", error);
                                              } else {
                                               //[self createBackendChargeWithToken:token];
                                                  NSLog(@"down here");
                                                    NSString *myVal = token.tokenId;
    
    
                                                  NSLog(@"%@",token);
                                                  [PFCloud callFunctionInBackground:@"hello" withParameters:@{@"token":myVal}
                                                                              block:^(NSString *result, NSError *error) {
                                                                                  if (!error) {
                                                                                      NSLog(@"from Cloud Code Res: %@",result);
                                                                                  }
                                                                                  else
                                                                                  {
                                                                                      NSLog(@"from Cloud Code: %@",error);
                                                                                  }
    
                                                                              }];
                                              }
                                          }];
    }
    

    然后是main.js代码:

    var Stripe = require('stripe');
    Stripe.initialize('sk_test_********'); //replace *** with your key values
    
    
    Parse.Cloud.define(“hello”, function(request, response) {
    
    var stripeToken = request.params.token;
    
     var charge = Stripe.Charges.create({
     amount: 1000, // express dollars in cents 
     currency: 'usd',
     card: stripeToken
     }).then(null, function(error) {
     console.log('Charging with stripe failed. Error: ' + error);
     }).then(function() {
       // And we're done!
       response.success('Success');
    
       });
       });
    

    现在,这仅在您将云代码恢复到版本 1.5.0 时才有效(正如其他人帮助我的那样)。希望这对其他人也有帮助。

    【讨论】:

    • 谢谢,我遇到了同样的问题。他们对这些模块做了什么 n 1.6.X ?引用任何模块时,文档会部分损坏。也许有不同的方式来要求模块?
    • 遇到同样的问题!有什么可以帮助的吗?
    • 只有在您将云代码恢复到版本 1.5.0 时才有效,这有帮助
    • 太棒了。很高兴它有帮助。不幸的是,我不知道为什么它不适用于 1.6.0。我们需要联系 Parse =\
    • cd 进入您的云代码目录并运行 parse jssdk 1.5.0parse deploy
    【解决方案2】:

    只是为了从上面更明确一点:

    cd 进入您的云代码目录并运行 parse jssdk 1.5.0parse deploy

    【讨论】:

      猜你喜欢
      • 2016-07-26
      • 2017-03-14
      • 2016-05-10
      • 1970-01-01
      • 1970-01-01
      • 2014-08-27
      • 2018-06-28
      • 2018-08-22
      • 2019-01-02
      相关资源
      最近更新 更多