I get this one when paypal returns me to my local dev env on complete payment:
array:1 [▼ // app/Http/Controllers/ParentPaypalController.php:101 "error" => array:5 [▼"name" => "UNPROCESSABLE_ENTITY" "details" => array:1 [▶] "message" => "The requested action could not be performed, semantically incorrect, or failed business validation." "debug_id" => "f287683883b27" "links" => array:1 [▼ 0 => array:3 [▶] ] ]]
Code in Laravel controller which generate request:
$provider = new PayPalClient; $provider->setApiCredentials(config('paypal')); $provider->getAccessToken(); $response = $provider->createOrder(["intent" => "CAPTURE","application_context" => ["return_url" => route('paypal.thank_you', $parentInvoice->id),"cancel_url" => route('paypal.cancel', $parentInvoice->id), ],"purchase_units" => [ 0 => ["reference_id" => $parentInvoice->id,"amount" => ["currency_code" => "EUR","value" => $membership->amount ] ] ] ]); if (isset($response['id']) & $response['id'] != null) { foreach ($response['links'] as $links) { if ($links['rel'] == 'approve') { return redirect()->away($links['href']); } } return redirect() ->route('paypal.cancel') ->with('error', 'Something went wrong.'); } else { return redirect() ->route('paypal.cancel') ->with('error', $response['message'] ?? 'Something went wrong.'); }
All code is run from localhost env.
The request body looks like this:
[ "intent" => "CAPTURE" "application_context" => [ "return_url" => "http://paypal_demo.test/paypal_pay_card/thank_you/9cb73566-b2e3-499b-adf2-fa3382987033" "cancel_url" => "http://paypal_demo.test/paypal_pay_card/cancel/9cb73566-b2e3-499b-adf2-fa3382987033" ] "purchase_units" => [ 0 => [ "reference_id" => "9cb73566-b2e3-499b-adf2-fa3382987033" "amount" => [ "currency_code" => "EUR" "value" => "20.00" ] ] ] ]
Here is $response that I get before go redirect to Paypal:
"id" => "45R71510DA8720826" "status" => "CREATED" "links" => array:4 [▼ 0 => array:3 [▼"href" => "https://api.sandbox.paypal.com/v2/checkout/orders/45R71510DA8720826" "rel" => "self" "method" => "GET" ] 1 => array:3 [▼"href" => "https://www.sandbox.paypal.com/checkoutnow?token=45R71510DA8720826" "rel" => "approve" "method" => "GET" ] 2 => array:3 [▼"href" => "https://api.sandbox.paypal.com/v2/checkout/orders/45R71510DA8720826" "rel" => "update" "method" => "PATCH" ] 3 => array:3 [▼"href" => "https://api.sandbox.paypal.com/v2/checkout/orders/45R71510DA8720826/capture" "rel" => "capture" "method" => "POST" ] ]