Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PayPal-Mock-Response in paypal-php-sdk

How can I use negative test using paypal-php-sdk. I try adding the header to the api context but always receive this response:

{
    "name": "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 use a valid URL supported by negative testing."
        }
    ]
}

I sent in header

PayPal-Mock-Response: {"mock_application_codes":"AUTHORIZATION_VOIDED"}

And in my php code

    $i_header["header"] = "PayPal-Mock-Response";
    $i_header["value"] = json_encode(["mock_application_codes" => "INSTRUMENT_DECLINED"]);

    $o_apiContext->addRequestHeader($i_header["header"], $i_header["value"]);

The full list of TESTING INPUT at https://developer.paypal.com/docs/api/payments/#errors

Any suggestions? Thanks

like image 490
Walter Cumpa Avatar asked Aug 30 '17 16:08

Walter Cumpa


1 Answers

This code worked ok for me:

$apiContext->addRequestHeader("PayPal-Mock-Response", "{'mock_application_codes':'INSTRUMENT_DECLINED'}");
like image 88
Adrián E Avatar answered Sep 30 '22 03:09

Adrián E