-1

How do I add some sort of reference for my own system when redirecting a user to a purchase page via Omnipay (I am using the PxPay gateway)?

Basically I want to store the order ID against the payment, so when the user (or notification) comes back I can process the order.

Petah
  • 45,477
  • 28
  • 157
  • 213
  • Yea I understand the `TxnDataX` fields in PxPay, but I'm looking for a multi gateway approach. – Petah Jul 14 '14 at 03:38
  • well each gate way is different. –  Jul 14 '14 at 03:39
  • If you're looking for a multi-gateway approach, you'll need to build a higher level payment gateway processing wrapper to work over the top and communicate internally with your appropriate gateway API code each time. – scrowler Jul 14 '14 at 03:40
  • oddly i'm building one at the moment "poli functions', 'pxpay functions', 'paypal functions' .... you will never not have to write different code for each –  Jul 14 '14 at 03:42
  • @Dagon I built one recently too. Even if you don't need the wrapper immediately, it's a good idea to build it in now anyway for future-proofing. What happens with PaymentExpress start charging through the roof and you want to change to eGate or something else? Best to write for that now eh, not too much extra development required...! – scrowler Jul 14 '14 at 03:44
  • at least the cash and cheque gateways are easy –  Jul 14 '14 at 03:46
  • @Dagon until they tell you they want that to API into Vend... `` – scrowler Jul 14 '14 at 03:48

1 Answers1

1

PxPay supports multiple parameters to be passed in, and back out again. You should have a good look through the integration guide, it gives a clear definition of what fields are required/optional, what data types or limits apply and what they should be used for.

You can use the fields TxnData1, TxnData2, TxnData3 for any custom attributes, as well as MerchantReference which should be used for the order ID as in your example. Essentially, whatever information you pass in those fields will be passed back to you once the transaction is complete.

Here's an example request to PxPay 2.0:

<GenerateRequest>
    <PxPayUserId>your_user_id</PxPayUserId>
    <PxPayKey>foobar1234</PxPayKey>
    <TxnType>Purchase</TxnType>
    <AmountInput>1.23</AmountInput>
    <CurrencyInput>NZD</CurrencyInput>
    <MerchantReference>YOUR_ORDER_ID_HERE</MerchantReference>
    <TxnData1>Custom data field 1</TxnData1>
    <TxnData2>Custom data field 2</TxnData2>
    <TxnData3>Custom data field 3</TxnData3>
    <UrlSuccess>http://stackoverflow.com</UrlSuccess>
    <UrlFail>http://facepalm.com</UrlFail>
</GenerateRequest>

I've had a quick look through the code for the Omnipay Payment Express code on GitHub, and you'll find this line in the class that generates a request to PxPay:

public function getData()
{
    $this->validate('amount', 'returnUrl');

    $data = new SimpleXMLElement('<GenerateRequest/>');
    $data->PxPayUserId = $this->getUsername();
    $data->PxPayKey = $this->getPassword();
    $data->TxnType = $this->action;
    $data->AmountInput = $this->getAmount();
    $data->CurrencyInput = $this->getCurrency();
    $data->MerchantReference = $this->getDescription(); // here's your field
    $data->UrlSuccess = $this->getReturnUrl();
    $data->UrlFail = $this->getReturnUrl();

    return $data;
}

So looks that current code only supports the MerchantReference field, although I'm sure you could add your own support for the other fields. Fork it on GitHub - sure someone else will appreciate it down the line too.

scrowler
  • 24,273
  • 9
  • 60
  • 92
  • `MerchantReference` is shown to the user as a "description" isn't it? The order ID doesn't really fit this case (as a human readable description would be better. – Petah Jul 14 '14 at 03:45
  • @Petah seriously, read the documentation (page 11): `The Merchant Reference reference is returned in the transaction response, which can be used interpreted by the merchant website. Common uses for the merchant reference field are invoice and order numbers. This is an optional field.` You could also use `TxnId` for your order ID. – scrowler Jul 14 '14 at 03:47
  • TxnId is the one you want –  Jul 14 '14 at 03:49
  • And is there anyway to set the `TxnId` with Omnipay? – Petah Jul 14 '14 at 03:51
  • @Petah - updated answer, looks like you might have to add your own support for `TxnId` but `MerchantReference` is there already – scrowler Jul 14 '14 at 04:01
  • i think your wrong suggesting MerchantReference over TxnId –  Jul 14 '14 at 04:01
  • I guess it depends whether your invoice/order numbers are unique and only used once. In the Omnipay case, it seems the API extension for PaymentExpress doesn't support the `TxnId` field, but should be easy enough to add it in. – scrowler Jul 14 '14 at 04:03