node.js - 贝宝无效的负面测试输入
问题描述
我尝试使用基于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 }
谁能帮助我的代码有什么问题?
非常感谢
解决方案
您必须对对象进行字符串化:
headers: {
'PayPal-Mock-Response': JSON.stringify({
"mock_application_codes":"CANNOT_PAY_SELF"
})
},
推荐阅读
- laravel - 在 laravel 和 vue 上未定义的道具
- arrays - 如何迭代地将新列添加到预先存在的 numpy 数组
- kubernetes - 如何在 Kubernetes 中暴露 NodePort 并连接
- javascript - 除非页面刷新,否则 AJAX 不会在聊天框系统中显示最后一条消息
- pandas - 尝试从 CSV 中删除值时出现键错误 0
- python - 如何在不复制的情况下更改列表列表?
- azure - 服务帐户能否将更改推送到 Azure Repos?
- unit-testing - Googletest/gtets:致命错误:gtest.h:没有这样的文件或目录
- puppeteer - Puppeteer 设置第 n 个输入的值
- react-native - 警告:componentWillReceiveProps 已重命名,不推荐使用