ios - Stripe 模块的解析返回错误

标签 ios parse-platform stripe-payments

我想在我的应用程序中使用 Stripe 云模块对信用卡收费,但是云函数总是返回错误代码 141。

Error: Uh oh, something went wrong (Code: 141, Version: 1.5.0)
Error Domain=Parse Code=141 "The operation couldn’t be completed. (Parse error 141.)" UserInfo=0x170a640c0 {error=Uh oh, something went wrong, code=141}

这是我的云代码:

var Stripe = require('stripe');
Stripe.initialize('pk_test_xxxxxxxxxxxxxxxx');

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

 Stripe.Charges.create({
   amount: request.params.amount * 100, 
   currency: "usd",
   card: request.params.token
 },{
   success: function(httpResponse) {
     response.success("Purchase made!");
   },
   error: function(httpResponse) {
     response.error("Uh oh, something went wrong");
   }
 });

});

这就是我从我的应用程序中调用此函数的方式:

NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
[params setObject:[NSNumber numberWithInt:100] forKey:@"amount"];
[params setObject:token.tokenId forKey:@"token"];

[PFCloud callFunctionInBackground:@"chargeCreditCard" withParameters:params block:^(id object, NSError *error) {
    if (error) {
        NSLog(@"%@", error);
    }
}];

我已经调试过了,tokenId 是正确的。我还将 global.json 文件中的 Parse 版本号更改为 1.5.0。非常感谢任何帮助!

最佳答案

我可以自己解决问题。第一个提示是记录有用的错误消息,而不是 Parse 文档中提供的错误消息。

error: function(httpResponse) {
 response.error(httpResponse.message);
 // alternatively
 console.log(httpResponse.message);
}

这帮助我找到了导致问题的原因。在我的例子中,我在我的 JavaScript 云代码中使用了可发布的 key ,但 Stripe 模块需要 secret key

关于ios - Stripe 模块的解析返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28304313/

相关文章:

stripe-payments - 如何对前端的 Stripe PaymentIntent 成功 webhook 使用react

ios - App Store 发布时必须增加哪个 iOS 应用程序版本/内部版本号?

ios - 代码 8 : how to change targeted device family

ios - Swift:如何每秒随机更改背景颜色?

javascript - 解析云代码替代方案

android - 将搜索功能添加到我的应用程序的最佳解决方案

ios - Parse.com 无法访问指向 PFObject 的指针

ios - Objective-C Present View Controller 及其导航 Controller

stripe-payments - strip redirect_uri将不起作用

next.js - Stripe Js 发出意外警告和错误