skip to Main Content

Using Paypal for payment it is working fine when I hit html form from a browser then It redirect’s me to Paypal page for payment but on other side when I try to hit it from postman api then it gives error on postman as it is redirecting so my question is that how I would access that redirect or url of that redirect in Postman API?

I used this code

try {
                $response = $this->gateway->purchase(array(
                    'amount' => $order_amount->total_price,
                    'currency' => env('PAYPAL_CURRENCY'),
                    'returnUrl' => url('success'),
                    'cancelUrl' => url('error'),
                ))->send();
                if ($response->isRedirect()) {
                     $response->redirect(); // this will automatically forward the customer
                } else {
                    // not successful
                    return $response->getMessage();
                }
            } catch (Exception $e) {
                

return $e->getMessage();
}

2

Answers


  1. You cannot "access" redirect URLs from Postman, nor from any other automated system. The redirect URL mus be opened in a browser, and a payer account must sign in to give approval. On return from PayPal to the provided return_url, the ID of the order or payment will be in the URL. This should then be used to capture/execute it.


    For best results, do not use any redirects. At all. Redirects returned by the API are for old websites, and should not be used by new integrations.

    Instead, use the following approval flow from the payment page, which keeps your site loaded in the background (no redirect away): https://developer.paypal.com/demo/checkout/#/pattern/server

    A full stack example in node can be found at: https://developer.paypal.com/docs/checkout/standard/integrate/ ; its backend can of course be implemented in PHP/laravel or any other web environment capable of returning the JSON from the API.

    Login or Signup to reply.
  2. Laravel offers a function to get redirect Url

    use this $response->getRedirectUrl()

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search