Getting SecureTrading's XPay running locally on the Mac (Leopard)
So, you've decided to use SecureTrading's XPay gateway as your gateway (as I recently have, having had problems with my previous gateway, Protx, and their awful customer support). Your next step is to want to write some code and connect it up to the XPay server.
Here's the code you need to write to get XPay started (funnily enough, you don't need any of the -Dsecurity.manager things that they mention in the docs):
java -cp ./XPay.jar XPay
That's nice and neat, but when you run the test code, you'll get the following result:
danieltenner@daniel-tenners-macbook-pro:~/Downloads/xpay/xpay/example$ java Test /somepath/xpay-certs/sometest1234certs.pem ** Note: When using live certificates, they should be kept in secure place on your server ** Reading from file: /somepath/xpay-certs/sometest1234certs.pem Reading from file: test.xml Please wait while the transaction is authorised... HTTP/1.1 200 OK <ResponseBlock> <Response Type="Not Given"> <OperationResponse> <Result>0</Result> <Message>(1000) Failed to connect to a payment gatewayjava.io.IOException: Connection to gateway failed</Message> </OperationResponse> <Order>Omitted</Order> <Optional>Omitted</Optional> </Response> </ResponseBlock>
Oops. It turns out that when SecureTrading say they want Java 1.4.2, they really mean it. So how do you get that going? Well, it's easier than it sounds, actually. Just open up "Java preferences" using QuickSilver or Spotlight, and you can just drag the java 1.4.2 to the top spot on the bottom list, like so:
Great. So then you run your test, and you get... another error, perhaps something like:
<ResponseBlock Live="" Version="3.51"> <Response Type="AUTH"> <OperationResponse> <Message>(3100) Invalid SiteReference for certificate</Message> <TransactionReference>0-0-0</TransactionReference> <Result>0</Result> </OperationResponse> </Response> </ResponseBlock>
If you get that, it just means you forgot to update the SiteReference in the xml file. If you received a certificate file that looked like company1234testcerts.pem, that means your site reference is company1234. Replace it in test.xml, and you may (if they haven't fixed that by the time you read this article), get the next error!
<ResponseBlock Live="FALSE" Version="3.51"> <Response Type="AUTH"> <OperationResponse> <Message>(3100) Invalid ExpiryDate</Message> <TransactionReference>17-9-1155953</TransactionReference> <Result>0</Result> </OperationResponse> </Response> </ResponseBlock>
This one's more obvious... when I last downloaded the XPay package (in 2009), the credit card expiry date in the test.xml file was set to 02/08! Change that to a date in the future, and you should finally get the expected result:
<ResponseBlock Live="FALSE" Version="3.51"> <Response Type="AUTH"> <OperationResponse> <TransactionReference>12-3-4567890</TransactionReference> <TransactionCompletedTimestamp>2009-04-14 15:22:20</TransactionCompletedTimestamp> <AuthCode>AUTH CODE:TEST</AuthCode> <TransactionVerifier>Aw6BrpfpS+3o2t7h4/c7daA9NShF42ZYBtRVK3kVRW8F4/LGUzP5my2FawzJDULJaKXTwUE2CjHupzYDKWddlPP0nlndJKBGwQIt0NuK8QFfLS/w+TFxRuesFvcWBf2yd+nYmjVSudb3i4PurVQpkwOjvbE3uVsQnzaSzHF7Z6yY=</TransactionVerifier> <Result>1</Result> <SettleStatus>0</SettleStatus> <SecurityResponseSecurityCode>2</SecurityResponseSecurityCode> <SecurityResponsePostCode>2</SecurityResponsePostCode> <SecurityResponseAddress>2</SecurityResponseAddress> </OperationResponse> <Order> <OrderInformation>This is a test order</OrderInformation> <OrderReference>Order0001</OrderReference> </Order> </Response> </ResponseBlock>
