我尝试使用基于here的nodejs的paypal rest sdk来模拟负面测试
Hier是我的代码实现:
config.headers = {
"PayPal-Mock-Response": {"mock_application_codes":"INSTRUMENT_DECLINED"}
}
paypal.payment.execute(paymentId, data, config, function (error, payment) {
if (error) {
console.log(error.response);
} else {
// success code
}
}});
但是我遇到了以下错误:
{ name: 'SIMULATION_FRAMEWORK_INVALID_NEGATIVE_TESTING_INPUT',message:'Invalid input found. See the following supported cases.',links: [ { href: 'https://developer.paypal.com/docs/api/nt-rest/',rel: 'information_link' } ],details: [ { issue: 'You must have valid input.' } ],httpStatusCode: 400 }
任何人都可以帮我解决我的代码中的错误吗?
非常感谢
答案 0 :(得分:1)
您必须对对象进行字符串化
headers: {
'PayPal-Mock-Response': JSON.stringify({
"mock_application_codes":"CANNOT_PAY_SELF"
})
},