Reputation: 1641
I have searched all over and have ran in circles on OmniPays github trying to find documentation on how to implement PayPal Express in OmniPay.
$response = Omnipay::purchase([
'amount' => $total,
'encodedTestIDs' => serialize($payForTestID),
'returnUrl' => 'http://php.bhiceu.com/payment/return',
'cancelUrl' => 'http://php.bhiceu.com/payment/cancel'
])->send();
//dd($response);
//die;
if ($response->isRedirect()) {
// redirect to offsite payment gateway
$response->redirect();
} else {
// payment failed: display message to customer
echo $response->getMessage();
}
The above code successfully sends me to PayPal with the proper amount and when I cancel or check I am returned to the appropriate URLS, however all that I get back is the paypal token which I cannot find any documentation on what to do with.
Upvotes: 3
Views: 2230
Reputation: 5283
The answer ended up being quite simple, but I had to go digging through the source code for it as the documentation for the library is non-existent.
$response = Omnipay::completePurchase([
'amount' => $price,
'currency' => $currency
])->send();
You simply call Omnipay::completePurchase
with the same amount
and currency
as the initial Omnipay::purchase
call.
After this, you would use Omnipay::fetchCheckout()->send()
to obtain information like the shipping address etc.
Upvotes: 2
Reputation: 846
You need to complete the purchase by using completePurchase() method.
look at omnipay/example code at https://github.com/thephpleague/omnipay-example/blob/master/index.php#L203-L218
Upvotes: 2