解析条纹iOS main.js

我真的很难让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}

解决方法

最后.好的,这里是使用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(正如其他人帮助我的话),这只会起作用.希望这也有助于其他人.

相关文章

当我们远离最新的 iOS 16 更新版本时,我们听到了困扰 Apple...
欧版/美版 特别说一下,美版选错了 可能会永久丧失4G,不过只...
一般在接外包的时候, 通常第三方需要安装你的app进行测...
前言为了让更多的人永远记住12月13日,各大厂都在这一天将应...