CodeIgniter custom value with omnipay

2019-07-24 19:03发布

I'm trying to pass a custom value to a payment with PayPal - OmniPay

Here is the code I use :

$response = $gateway->purchase(
    array(
        'cancelUrl'=>base_url().'checkout/cancel',
        'returnUrl'=>base_url().'checkout/confirm',
        'amount' =>  number_format($retn['invoiceDatas']['price'], 2, '.', ''),
        'description' => 'Facture #'.$id,
        'currency' => 'EUR',
        'transactionid'=> $id,
        'custom' => $id,
        'description' => 'Facture'
    )
)->send();
$response->redirect();

And here is the code from checkout page :

$response = $gateway->completePurchase(array('amount' => 75.00, 'currency' => 'EUR'))->send();
$data = $response->getData(); // this is the raw response object
echo '<pre>';
print_r($data);
echo '</pre>';

But in the data printed array I've a lot of informations but no informations about "transactionID" or "custom" variable..

Please help. Thanks

2条回答
祖国的老花朵
2楼-- · 2019-07-24 19:51

I think you should pass 'transactionID'=> $id, with capitals, instead of 'transactionid'=> $id,.

查看更多
萌系小妹纸
3楼-- · 2019-07-24 19:52

There is no such thing as a custom parameter in Omnipay/PayPal.

You should store this data in your database, then look it up based on the transactionId. parameter.

Since PayPal does not pass this back to you, the easiest solution is to create a custom returnUrl. For example:

'returnUrl' => base_url().'checkout/confirm/'.$id,

Then when your customer lands on the returnUrl, you can look up the transaction from your database based on segment 3 (the transaction ID), and mark it as paid.

查看更多
登录 后发表回答