条纹捕获电荷量节点和Swift
Stripe Capture Charge Amount Node and Swift
我正在尝试获取不同金额的费用,但我收到一条错误消息,指出存在 "no such charge",有时金额应低于费用,事实确实如此。然而,最常见的错误是 "no such charge" 错误,尽管收费并非为零。
这是node.js中的Cloud Code函数:
Parse.Cloud.define("cancellationFee", function(request, response){
stripe.charges.capture({
charge: request.params.charge,
amount: 500,
destination: 500
}, function(err, charge) {
if(err){
console.log(err);
response.error(err);
}else{
console.log("Successfully captured cancellation fee");
response.success("captured cancellation fee");
}
});
});
Swift代码
charge变量不为nil
PFCloud.callFunctionInBackground("cancellationFee", withParameters: ["charge": chargeID]) { (success: AnyObject?, error: NSError?) -> Void in
if error == nil{
// code
}else{
// code
}
}
您确定您的错误不是由于将目的地设置为数字造成的吗?目的地应该是一个帐户 ID。并且还应该在 创建 充电时设置,而不是捕获充电。除了要捕获的费用外,您不应将任何其他参数传递给收费方法。
您也不应在此处设置收费金额。
对于一些仍然遇到这个问题的人来说,正确的解决方案是首先将 charge_id 作为 String 传递,然后作为第二个参数,对象中的 数量 如下所示:
stripe.charges.capture( 'chargeIdExample3242', {amount: 23} );
我正在尝试获取不同金额的费用,但我收到一条错误消息,指出存在 "no such charge",有时金额应低于费用,事实确实如此。然而,最常见的错误是 "no such charge" 错误,尽管收费并非为零。
这是node.js中的Cloud Code函数:
Parse.Cloud.define("cancellationFee", function(request, response){
stripe.charges.capture({
charge: request.params.charge,
amount: 500,
destination: 500
}, function(err, charge) {
if(err){
console.log(err);
response.error(err);
}else{
console.log("Successfully captured cancellation fee");
response.success("captured cancellation fee");
}
});
});
Swift代码 charge变量不为nil
PFCloud.callFunctionInBackground("cancellationFee", withParameters: ["charge": chargeID]) { (success: AnyObject?, error: NSError?) -> Void in
if error == nil{
// code
}else{
// code
}
}
您确定您的错误不是由于将目的地设置为数字造成的吗?目的地应该是一个帐户 ID。并且还应该在 创建 充电时设置,而不是捕获充电。除了要捕获的费用外,您不应将任何其他参数传递给收费方法。
您也不应在此处设置收费金额。
对于一些仍然遇到这个问题的人来说,正确的解决方案是首先将 charge_id 作为 String 传递,然后作为第二个参数,对象中的 数量 如下所示:
stripe.charges.capture( 'chargeIdExample3242', {amount: 23} );