PHP SDK Failed To Capture Order
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've Tried Too Much to Pass This Step and I'm too depressed please anyone help me ending this **bleep** job please.
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use PayPalCheckoutSdk\Core\PayPalHttpClient; use PayPalCheckoutSdk\Core\SandboxEnvironment; use PayPalCheckoutSdk\Orders\OrdersGetRequest; use Sample\CaptureIntentExamples\CaptureOrder; use PayPalCheckoutSdk\Orders\OrdersCaptureRequest; class PaymentController extends Controller { public function captureOrder(Request $request) { $env = new SandboxEnvironment(env('CLIENT_ID'), env('CLIENT_SECRET')); $client = new PayPalHttpClient($env); // \Debugbar::info($env); // \Debugbar::info($client); $orderId = (string) $request->orderId; $orderRequest = new OrdersCaptureRequest($orderId); // // $orderRequest->prefer('return=representation'); try { // Call API with your client and get a response for your call $response = $client->execute($orderRequest); print "Status Code: {$response->statusCode}\n"; print "Status: {$response->result->status}\n"; print "Order ID: {$response->result->id}\n"; print "Links:\n"; foreach($response->result->links as $link) { print "\t{$link->rel}: {$link->href}\tCall Type: {$link->method}\n"; } print "Capture Ids:\n"; foreach($response->result->purchase_units as $purchase_unit) { foreach($purchase_unit->payments->captures as $capture) { print "\t{$capture->id}"; } } // To toggle printing the whole response body comment/uncomment below line echo json_encode($response->result, JSON_PRETTY_PRINT), "\n"; }catch (HttpException $ex) { echo $ex->statusCode; print_r($ex->getMessage()); } } }
This is the response
{"name":"UNPROCESSABLE_ENTITY","details":[{"issue":"COMPLIANCE_VIOLATION","description":"Transaction cannot be processed due to a possible compliance violation. To get more information about the transaction, call Customer Support."}],"message":"The requested action could not be performed, semantically incorrect, or failed business validation.","debug_id":"61c92ba61f03c","links":[{"href":"https://developer.paypal.com/docs/api/orders/v2/#error-COMPLIANCE_VIOLATION","rel":"information_link..."}]} C:\wamp64\www\imgtute\vendor\paypal\paypalhttp\lib\PayPalHttp\HttpClient.php#215

Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
- failed to pay with sandbox account in Sandbox Environment
- CHECKOUT.ORDER.APPROVED webhook event not triggered if payment_source is passed in in REST APIs
- Why does PayPal redirect to different pages (login vs credit card form) depending on browser mode? in Braintree Server-side Integration (PHP, Java, .NET, Ruby, Python, NodeJS SDKs)
- webhook payment capture completed issue in Sandbox Environment
- Suspect orders yet payment accepted without AVS in PayPal Payments Standard