Rest API payment execute TRANSACTION_REFUSED in sandbox

followbuddha
New Community Member

I am working with php. I have only one item to sell. I set up a Rest API process that is working fine, but the payment execute always returns TRANSACTION_REFUSED as follows:

{"name":"TRANSACTION_REFUSED","details":[],"message":"The request was refused","information_link":"https://developer.paypal.com/docs/api/payments/#errors","debug_id":"cb4b790f444ab"}

status 400.

 

After the buyer has approved the sale in paypal using the approval_url from the create payment,

I'm using the execute link returned from the create payment to finish the sale:

{"href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-LREIWJQ9H778703D3277483D/execute","rel":"ex..."}

 

Here my php script:

            $json_data = '{
                "payer_id": "'.$payerid.'"
            }';
            // $ehref = the link from above.
            $ch = curl_init($ehref);
            curl_setopt($ch, CURLOPT_HEADER, false);    // don't return headers
            curl_setopt($ch, CURLOPT_SSLVERSION , 6);
            curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
            curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $json_data);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_HTTPHEADER, array(
                'Content-Type: application/json',
                'Authorization: Bearer '.$access_token)
            );

            $json_response = curl_exec($ch);

 

My paypal account is in EUR. The sandbox account I'm using for the buyer is in USD. I first tried the whole thing simply using the Paypal button solution, which worked fine. But I need more. So I decided to set up the sale as Rest API. (I did before as express checkout, but that isn't working anymore, so I decided to rebuild completly.)

Login to Me Too
0 REPLIES 0

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.