0

My client has very exacting demands on how the Vendor TX Code supplied to Sage Pay during checkout is formatted.

Is it possible to change this information?

Thanks in advance for any advice.


Thanks to Ian and Adrian I figured this out - my solution follows:

I duplicated the file Merchant_sagepay_direct.php renaming the class to reflect the new gateway.

In the _build_authorize_or_purchase method I added the line

$request['VendorTxCode'] = "ClientSpecificTag_" . substr($request['Description'],strpos($request['Description'], "#") + 1) . "_" . $this->param('transaction_id');

This structures the TXcode as per the clients requirement eg: ClientSpecificTag_OrderNumber_Transaction_ID (order number is stripped from the description).

In order to allow refunds to work I had to add a new method:

I also added a new method

protected function _build_refund()
    {
        $this->require_params('reference');
        $reference = $this->_decode_reference($this->param('reference'));

        $request = parent::_build_refund();

        $request['RelatedVendorTxCode'] = "ClientSpecificTag_" . substr($request['Description'],strpos($request['Description'], "#") + 1) . "_" . $reference->VendorTxCode;

        return $request;
    }

Which ensures refund requests send the correct TX Code.

All tested and working fine.

2
  • For future reference, how exactly do they want it formatted? Why do they have this requirement? Mar 29, 2013 at 8:27
  • Hi Adrian - Its a long story but it all boils down to our clients Technophobia and fear of change. This combined with a stubbon streak makes this seemingly small detail of significant importance. I am going to investigate Ian's proposed solution below, but would appreciate any further pointers you can give me about where changes might need to be made. I am aware that the TX code is also used as part of the refund process. (You have my email still if you don't want to publicise this info). Thanks.
    – Tomtids
    Apr 3, 2013 at 15:13

2 Answers 2

1

Unfortunately this doesn't look to be possible from the Store interface. In the gateway itself it is pulling in the transaction ID and using that as the vendor TX code.

Gateways are designed to be plug and play however so there's no reason why you couldn't duplicate the existing gateway and then set the vendor TX code to be something specific other than transaction ID:

$request['VendorTxCode'] = $this->param('transaction_id');
4
  • Thanks Ian. I'll look into duplicating / altering the Sage Pay gateway.
    – Tomtids
    Mar 28, 2013 at 14:30
  • No probs. It all comes off the sagepay_base so changing that value should filter it's way through the rest of the gateway code. Good luck!
    – Ian Young
    Mar 28, 2013 at 17:36
  • FYI anyone looking to do the same thing.
    – Tomtids
    Apr 4, 2013 at 9:04
  • Nice job. Glad you got it working. Interesting to know about the work around for refunds too.
    – Ian Young
    Apr 5, 2013 at 17:57
2

Ian is exactly right. You can either edit the gateway directly, or you could create your own gateway class which extends the existing one and overwrites the VendorTxCode which is sent to Sage Pay.

This isn't something which I've heard of anyone doing before, normally the VendorTxCode is the same as Store's payment_id which makes them easy to match up should you need to.

You shouldn't need to worry about refunds. Whatever you set the VendorTxCode to, Store will keep a record of that and sent it back to Sage Pay when necessary. Do a test to make sure, but I don't expect you will run into any issues here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.