首页 > 解决方案 > 贝宝无效的负面测试输入

问题描述

我尝试使用基于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 }

谁能帮助我的代码有什么问题?

非常感谢

标签: node.jspaypalpaypal-sandboxpaypal-ipnpaypal-rest-sdk

解决方案


您必须对对象进行字符串化:

headers: {
            'PayPal-Mock-Response': JSON.stringify({
                "mock_application_codes":"CANNOT_PAY_SELF"
            })
        },

推荐阅读