I'm trying to send payments to paypal from my laravel app via Omnipay. This works fine, I'm getting a response, getData() shows Success and stuff but...
How do I know, which payment I received?
Let's say I pay 1 Euro for Order No. 100 - How do I assign the Order No. 100 to the payment ?
I have three methods:
postOrder() which has:
$paypal_setitems = [];
foreach(Cart::contents() as $item) {
$paypal_setitems[] = array('name' => $item->name, 'quantity' => $item->quantity, 'price' => ($item->price * (1 + 19.00 / 100.0) ));
}
# Send response to PP
$response = $gateway->purchase($this->getApiInfos($order->id))->setItems($paypal_setitems)->send();
return $response->redirect();
getSuccessPayment() which has:
public function getSuccessPayment() {
$gatewayFactory = new \Omnipay\Common\GatewayFactory;
$gateway = $gatewayFactory->create('PayPal_Express');
#Test API Sandbox
$gateway->setUsername('buy-facilitator_api1.xxxxxx.de');
$gateway->setPassword('xxxxx');
$gateway->setSignature('xxxxx.xxxxx.xxxx.xxxxx');
$gateway->setTestMode(true);
$response = $gateway->completePurchase($this->getApiInfos())->send();
$data = $response->getData(); // this is the raw response object
if($data['ACK'] == 'Success'):
echo '<pre>';
print_r($data);
//return Redirect::to('order/success')->with('order', $this->order);
endif;
}
and getApiInfos() with:
public function getApiInfos($order = NULL) {
return array(
'amount'=> Cart::total(),
'cancelUrl' => \URL::route('paypal_cancel_order'),
'returnUrl' => \URL::route('paypal_return'),
'description' => 'Your Payment at - Order #',
'currency' => 'EUR',
'order' => $order
);
}
I tried to assign 'order' => $order
to the array but this doesn't work.
Any Ideas?
I just need to save a successful payment (and the transactionId and other stuff) to the order but I don't know how.