0

I have an ecommerce website that redirects to a Paypal express checkout using Omnipay. It will correctly redirect the user to Paypal and return with a successful message with payerID and everything. However, it does not actually take any payment and it does not show up on our paypal account as any payment taken. I am not sure if this is a paypal issue or a configuration problem with Omnipay. I would imagine that Paypal handles this part of it but since it's not working (on our old site it works fine but we do not use Omnipay.)

    $gateway = Omnipay::gateway('paypal');

    //production
    $gateway->setUsername('11111111');
    $gateway->setPassword('1111111111');
    $gateway->setSignature('111111111');

    $cardInput = array(
        'firstName' => $info['first_name_bill'],
        'lastName' => $info['last_name_bill'],
        'billingAddress1' => $info['street_address_1_bill'],
        'billingAddress2' => $info['street_address_2_bill'],
        'billingPhone' => $info['phone_bill'],
        'billingCity' => $info['city_bill'],
        'billingState' => $info['state_bill'],
        'billingPostCode' => $info['zip_bill'],
        'shippingAddress1' => $info['street_address_1_ship'],
        'shippingAddress2' => $info['street_address_2_ship'],
        'shippingPhone' => $info['phone_ship'],
        'shippingCity' => $info['city_ship'],
        'shippingState' => $info['state_ship'],
        'shippingPostCode' => $info['zip_ship'],
    );

    $card = Omnipay::creditCard($cardInput);

    //live
    $response = Omnipay::purchase(
        array(
            'cancelUrl' => 'http://store.site.com/cart/cancel-payment',
            'returnUrl' => 'http://store.site.com/cart/successful-payment',
            'amount' => Input::get('total'),
            'currency' => 'USD',
            'card' => $card,
            'description' => 'Stuff'
        )
    )->send();

    if ($response->isSuccessful()) {
        return Redirect('cart/successful-payment');
    } elseif ($response->isRedirect()) {
        $response->redirect(); // this will automatically forward the customer
    } else {
        return Redirect::back()->with('error', 'There was a problem. Please try again.');
    }
} else {
    return Redirect::to('cart/successful-payment');
}

So basically what this will do is redirect them to Paypal to make a payment then redirect back to our store. That all works fine. They can input their card number and then come back to our store after submitting it. The issue is after it gets return nothing happens through paypal. No orders or payment are exchanged.

adius
  • 13,685
  • 7
  • 45
  • 46
Lynx
  • 1,462
  • 5
  • 32
  • 59

1 Answers1

1

In your return function, the function that gets called when this URL is executed: http://store.site.com/cart/successful-payment you need to call completePurchase. Something like this:

        $gateway = Omnipay::gateway('paypal');

        //production
        $gateway->setUsername('11111111');
        $gateway->setPassword('1111111111');
        $gateway->setSignature('111111111');
        $purchaseId = $_GET['PayerID'];
        $response = $gateway->completePurchase([
            'transactionReference' => $purchaseId
        ])->send();
        // .. check $response here.
delatbabel
  • 3,601
  • 24
  • 29