尝试进行PayPal付款时出现HTTP 400错误

我在构build我的小玩具支付网关表单时遇到了这个错误,但是现在我意识到,在克隆存储库之后,我甚至无法正确运行示例代码

我input了我的客户端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) 

我非常渴望find我要去的地方。

您使用的卡(4417119669820331)不是唯一的。 在REST API中testing付款时,特别是对于信用卡号码,请尽量不要使用默认的信用卡号码,例如4417119669820331.尝试使用其他号码,例如4532371704016199。

或者,使用此网站( http://www.fakenamegenerator.com/ )生成假信用卡进行testing。