在构建我的小玩具支付网关表单时遇到此错误,但现在我意识到在克隆存储库here后我甚至无法正确运行示例代码。
我已将我的客户端ID和密码输入configure.js。我是沙箱模式。
我正在运行的文件:
var create_payment_json = {
"intent": "sale",
"payer": {
"payment_method": "credit_card",
"funding_instruments": [{
"credit_card": {
"type": "visa",
"number": "4417119669820331",
"expire_month": "11",
"expire_year": "2018",
"cvv2": "874",
"first_name": "Joe",
"last_name": "Shopper",
"billing_address": {
"line1": "52 N Main ST",
"city": "Johnstown",
"state": "OH",
"postal_code": "43210",
"country_code": "US"
}
}
}]
},
"transactions": [{
"amount": {
"total": "7.00",
"currency": "USD",
"details": {
"subtotal": "5.00",
"tax": "1.00",
"shipping": "1.00"
}
},
"description": "This is the payment transaction description."
}]
};
paypal.payment.create(create_payment_json, function (error, payment) {
if (error) {
console.log(error);
throw error;
} else {
console.log("Create Payment Response");
console.log(payment);
}
});
跑步时,我得到了
> node create_with_credit_card.js
{ [Error: Response Status : 400]
response:
{ name: 'UNKNOWN_ERROR',
message: 'An unknown error has occurred',
information_link: 'https://developer.paypal.com/webapps/developer/docs/api/#UNKNOWN_ERROR',
debug_id: '599dd3222e6fb',
httpStatusCode: 400 },
httpStatusCode: 400 }
C:\cygwin64\home\Ryan\PayPal-node-SDK\samples\payment\create_with_credit_card.js:47
throw error;
^
Error: Response Status : 400
at IncomingMessage.<anonymous> (C:\cygwin64\home\Ryan\PayPal-node-SDK\lib\client.js:136:23)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:442:13)
我不顾一切地想知道我在哪里出错了。
答案 0 :(得分:1)
您使用的卡(4417119669820331)并非唯一。在REST API中测试付款时,尤其是信用卡号码,请尽量不要使用默认的信用卡号码4417119669820331。尝试使用其他数字,如示例4532371704016199.
或者,使用此网站(http://www.fakenamegenerator.com/)生成虚假信用卡以进行测试。