phplaravelpaypalpaypal-sandboxomnipay

PayPal Sandbox "Sorry, we can’t complete your purchase at this time "


I have set up PayPal Sandbox to test my PayPal Express integration, but whenever I log in to the sandbox from the payment page, I get greeted by the following error message; "Sorry, we can’t complete your purchase at this time"

I am using laravel-omnipay and omnipay-paypal with the PayPal_Express gateway.

I think this is likely to be a configuration issue (or a bug..? Although I'm hoping it's not.) in PayPal, but this is the piece of code I am using to initiate the payment:

public function checkout ()
{
    $cart = Cart::forSession ();

    $response = Omnipay::purchase
    (
        [
            'amount' => $cart->getPrice (),
            'currency' => preferred_currency ()->name,
            'description' => (string) $cart,
            'returnUrl' => URL::action ('OrderController@checkoutReturn'),
            'cancelUrl' => URL::action ('OrderController@checkoutCancel')
        ]
    )->send ();

    if ($response->isSuccessful ())
        dd ('successful', $response);
    else if ($response->isRedirect ())
        return $response->getRedirectResponse ();
    else
        return Redirect::to ('/cart')->with ('alerts', [new Alert ('An error occurred while attempting to process your order: ' . $response->getMessage (), Alert::TYPE_ALERT)]);
}

And the omnipay.php configuration file:

return array(
    'gateway' => 'PayPal_Express',
    'defaults' => array(
        'testMode' => true,
    ),
    'gateways' => array(
        'PayPal_Express' => array(
            'username' => '<>',
            'password' => '<>',
            'signature' => '<>',
            'landingPage' => array('billing', 'login'), 
        ),
    ),
);

The username, password and signature I am using are the ones I created in the PayPal Sandbox for my account.

The sandbox account I am using to test this is a "personal"/buyer account, with funding sources and "Payment Review" disabled. The Sandbox Accounts overview on the PayPal Developer website indicates the sandbox account's status as "complete".

I'm hoping I didn't miss something obvious. I checked out some of the other answers on Stack Overflow but none of those seemed to offer a solution for this exact problem.


Solution

  • Contact PayPal support, as there is something wrong on their end.