Paypal Checkout SDK - immediate payment

Viewed 327

I need to use Paypal checkout in order to accept immediate payment on my Laravel website, and I switched from old Paypal PHP SDK to the new Paypal checkout SDK to support API V2.

I followed the samples codes that provided in the new SDK, I have to create all workflow on my server, so I created an order with intent=CAPTURE with other required fields.

$request = new OrdersCreateRequest();

$request->headers["prefer"] = "return=representation";

$request->body = $this->buildMinimumRequestBody(...);

$response = $this->client->execute($request);

// redirect the user to approval link.

Order body:

 return array(
            'intent' => 'CAPTURE',
            'application_context' =>
                array(
                    'return_url' => 'https://example.com/return',
                    'cancel_url' => 'https://example.com/cancel',
                    'locale' => 'en-US',
                    'user_action' => 'PAY_NOW',
                    'shipping_preference'=> 'NO_SHIPPING'
                ),
            'purchase_units' =>
                array(
                    0 =>
                        array(
                            'amount' =>
                                array(
                                    'currency_code' => 'USD',
                                    'value' => 12,
                                    'breakdown' =>
                                        array(
                                            'item_total' =>
                                                array(
                                                    'currency_code' => 'USD',
                                                    'value' => 10,
                                                ),
                                            'tax_total' =>
                                                array(
                                                    'currency_code' => 'USD',
                                                    'value' => 2,
                                                ),
                                        ),
                                ),
                          
                        ),
                ),
        );

After the user redirected to approval URL and approving it, I execute the payment like below:

$response = $this->client->execute(new OrdersCaptureRequest($payment_id));

Below is the response after executing the payment.

Order and Payment response

So after directing the user to the approval page, then after approving the payment, then executing the order, I got the above result in the attached screenshot which shows the Order status is completed but the payment status is still "pending" and the reason is "PENDING_REVIEW", so I would like to ask if there is any error or something missed to make the payment immediately without waiting for review with an example.

Thanks.

0 Answers
Related