Parse response from payment server - How?

  HighTower 15:46 19 Jul 06
Locked

I'm building an e-commerce site which has to integrate with a payment provider not on the supported list of the scripts I am using. As such I must manually integrate rather than have the luck of using a Dreamweaver wizard.

So far I've build the cart and all is fine, and I know where I need to send the http post to so that the payment gateway can do its magic. However, on completion of the transaction the payment gateway sends my back a response which a script (that I have to write) will parse. The details in this response include all details from the payment, whether it has been successful etc. I combine this with session variables (which includes details of the purchase) and insert into a database and send a mail informing customers and merchants that a transaction has taken place.

Easy!

Except - how do I parse this string that is sent back? Never done this before - don't know where to start! Am using Dreamweaver if that makes things any easier.

Thanks

  harristweed 17:45 19 Jul 06

php can read most things. Do you have a example of the returned responce, so we can advise?

I'm not sure what help Dreamweaver can offer in this situation. I guess very little!

  HighTower 09:36 20 Jul 06

This is the example they provide in the documentation:

VPResponseCode=00&VPCrossReference=04100514165800502449&VPMessage=AUTHCODE:00502&VPTransactionUnique=VP ORDER-123456789&VPOrderDesc=VPORDER-123456789&VPBillingCountry=826&VPCardName=Test CardName&VPBillingPostCode=HA67HJ&VPBillingEmail=[email protected]&VPBillingPhoneNumber=0208 9770657&VPAmountReceived=1299&VPAVSCV2ResponseCode=222100&VPCV2ResultMessage=CV2 Matched&VPAVSResultMessage=PostcodeMatched&VPAVSAddressMessage=Address Numeric Matched&VPCardType=VD&VPBillingAddress=Unit 5 Pickwick Walk 120 Uxbridge Road Hatch End Middlesex

Thanks for your help

  harristweed 08:42 21 Jul 06

That looks like a normal 'name – value pair' string, that is sent via the get or post methods (I guess the finance house would use POST). So you could extract the data using:


$value=$_POST[VPResponseCode];
$another_value=$_POST[VPCrossReference];
etc.


However I’d use a function:

<?php
function register_globals($form_array)
{
foreach($form_array as $name => $value)
{
$GLOBALS[$name] = $value;
}
}
//call the function with
register_globals($_POST);
?>


This will result in the variables:

$VPResponseCode
$VPCrossReference
$VPMessage
etc.

(in this case, having the values:
$VPResponseCode="00";
$VPCrossReference="04100514165800502449";
$VPMessage="AUTHCODE:00502";)

This is a very useful function, I use it for form handling all the time. It works just as well for GET.

Just change
register_globals($_POST);
to
register_globals($_GET);

Hope this helps....

  HighTower 16:27 21 Jul 06

Just picked up your response. Will have a look through it and try it over the weekend with a couple of beers (well, always works for me!).

I appreciate the time you've spend on this, so thanks a lot - I'll let you know how it goes.

This thread is now locked and can not be replied to.

Intel Coffee Lake 8th-gen Core processors release date rumours

1995-2015: How technology has changed the world in 20 years

Framestore’s haunting post-WWII title sequence for new BBC series SS-GB

How to install MacOS Sierra on an older Mac: Get Sierra running on Macs & MacBooks from before 2009