I want to integrate Omnipay paypal in laravel 4
. I have gone through but I was unable to understand how to do it. I didn\'t find any documentation. I have gone thro
As per your points
1-) Here you will give credentials of one to whome money will be transferred. And buyer will give his credentials on PayPal site he will be redirected.
2-) After having gateway object and setting credentials you will call the purchase()
method of omnipay as follow
$response = $gateway->purchase(
array(
'cancelUrl' => 'www.xyz.com/cancelurl',
'returnUrl' => 'www.xyz.com/returnurl',
'amount' => 25,
'currency' => 'USD'
)
)->send();
$response->redirect();
This will redirect User to paypal site where he will give his credentials and do a transaction. After successful transaction at paypal user will be redirect to the URL that you have specified in returnurl
. And at returnurl you will create same gateway
object as you did above as stated below.
$gateway = Omnipay::create('PayPal_Express');
$gateway->setUsername('XXXXX');
$gateway->setPassword('XXXX');
$gateway->setSignature('XXXXX');
$response = $gateway->completePurchase(
array(
'cancelUrl' => 'www.xyz.com/cancelurl',
'cancelUrl' => 'www.xyz.com/cancelurl',
'returnUrl' => 'www.xyz.com/returnurl',
'amount' => 25,
'currency' => 'USD'
)
)->send();
$data = $response->getData(); // this is the raw response object
echo '<pre>';
print_r($data);
The completePurchase
method will complete the transaction and you will get response in array.
NOTE when user is redirected on return url, the URL also contains transaction_id and payer_id. :-) I hope it is quite simple.