[ic] WorldPay integration

Lyn St George interchange-users@interchange.redhat.com
Sun Jan 13 13:29:01 2002


On Mon, 31 Dec 2001 12:56:52 +0000, Craig Burton wrote:

>I've seen this topic pop up a couple of times in the archives, but no 
>resolution.
>
>Anyone any further with worldpay integration than initial thoughts willing 
>to share some knowledge to get this working? Or is there some out there 
>already I should be looking at?
>
>thanks v much, Craig
>craig@rokitdesign.com

Happy New Year to you

We have done this are quite happy with the result, especially their 
recurring payment system. Herewith a full explanation:

WorldPay insist on passing your shopper to their own server, and taking
the credit card info directly there, but they do accept other variables
passed from your server to theirs.

WP can then send your own variables back to you on their 'receipt'
page. In theory these could be parsed and used to log the order and
send emails to the merchant and shopper, but in practice there was some
trouble with the session id changing. My memory is a bit hazy now, but
I seem to remember that getting the original session id to replace the
new one proved difficult to do reliably, and reliability is key here.

Therefore, we decided to do everything before we left our own server,
and just accept the likelihood of some order numbers being void. What
we did is this: on the penultimate page on our server, we collect all
the shoppers data (a la "checkout.html") and raise an order number with
'[seti myordernumber][fcounter etc/order.number][/seti]'. The shopper
then goes to the final page where he is asked to "verify his details"
(just an excuse to have this page) and where all the hidden action
happens.

Firstly, all the IC form variables are mapped to WP variables ready to
pass to the next page (on the WP server). Eg, a few of the variables to
pass (lines may wrap):

<form action="https://select.worldpay.com/wcc/purchase" method="post">
<input type=hidden name="futurePayType" value="regular">
blah (your id's etc)
<input type=hidden name="normalAmount" value="[total-cost noformat=1]">
<INPUT TYPE=hidden NAME="cartId" VALUE="[scratch myordernumber]">
<input type=hidden name="currency" value="USD">
[item-list]
<input type=hidden name="desc" value="[item-description]">
[/item-list]
<input type=hidden name="name" value="[value fname] [value lname]">
<input type=hidden name="address" value="[value address1]&#10;
[value address2]&#10; [value city]&#10;[value zip]&#10;[value state]">

<!-- next are values to pass to WP using their syntax for merchant's
variables -->
[item-list]
<input type=hidden name="MC_salestax"value="[salestax]">
[/item-list]
<input type=hidden name="MC_company" value="[value company]">
blah

Note that anything directly from the basket must be wrapped with
[item-list][/item-list]. The order number is sent to WP as the
'cartId', and referred to in the WP receipt banner as the 'Merchant's
ref'.

The next thing is to log all this info to an individually numbered
order file in orders/.

[tag op=log file="orders/[scratch myordernumber]" interpolate=1 hide=1]
Order number: [scratch myordernumber]
Date: [tag time tz=GMT0BST]%A, %d %B, %Y. %H:%M GMT[/tag]
[item-list]
Code: [item-code]
Description: [item-description]
Database: [item-modifier db]
Style: [item-modifier style]
VAT: [salestax] blah .. blah [/tag]

and also log it in another place for back-up and safety:

[tag op=log file=logs/orders.txt interpolate=1 hide=1]
Order number: [scratch myordernumber]
Date: [tag time tz=GMT0BST]%A, %d %B, %Y. %H:%M GMT[/tag]
[item-list]
Code: [item-code]
Description: [item-description]
Database: [item-modifier db]
Style: [item-modifier style]
VAT: [salestax]
Total cost: [total-cost][/item-list]
blah .. =============
[/tag]
(the ====== serves to separate orders, as they are all written
to a single file here)

and then send an email to yourself as the merchant:

[set name=email interpolate=1]
[email 		to="sales@zolotek.net"
		subject="Order no: [scratch myordernumber]"
		from="admin@zolotek.net"
		reply="admin@zolotek.net"]
Order number: [scratch myordernumber]
Date: [tag time tz=GMT0BST]%A, %d %B, %Y. %H:%M GMT[/tag]
[item-list]
Code:[item-code]
Description: [item-description]
Database: [item-modifier db]
Style: [item-modifier style]
VAT: [salestax]
Total cost: [total-cost][/item-list]
First name: [value fname]
Surname: [value lname]
Blah
[/email]
[/set]

WorldPay will send emails to both the merchant and the shopper upon
successful completion of the payment process. Because you have sent the
ordernumber as the 'merchant ref', you can easily match the WP email to
your own email. If you have your own emailed order but there is no WP
email to match, then that order must be considered void, and we move it
into a separate sub-folder in the email client for auditing purposes.

WP allow you to set up a 'callback URL' - what this does is to pluck a
page from your server and display it on the WP server as though it's
their own page. Therefore, you configure this page to look like your
own (including links back to your server) and also to display a full
receipt with all the variables which you previously mapped from the IC
names to the WP names.

An example, using our 'callback' page:
<center>Order: <WPDISPLAY ITEM=cartId><p>
<b>Please print this as a tax receipt for your records</b></center> <p>
Dear <WPDISPLAY ITEM="name">,
<p>
Thank you for your order of <WPDISPLAY ITEM="desc"> hosting package
with your choices of <WPDISPLAY ITEM="MC_shop_db"> database and
<WPDISPLAY ITEM="MC_shop_style"> shop style. The total price is
<WPDISPLAY ITEM="MC_total_cost"> including VAT of
<WPDISPLAY ITEM="MC_salestax"> per month. Payments start in one
month from today, after your free month of eCommerce hosting.
<p>
Further details are: <p>
Company = <WPDISPLAY ITEM="MC_company"><br>
First name = <WPDISPLAY ITEM="MC_fname"><br>
blah
Post code = <WPDISPLAY ITEM="postcode"><br>
Notes and comments:<br> <wpdisplay item="MC_notes"><br>
<p>
<WPDISPLAY ITEM=banner>

The last item, the banner, is WorldPay's receipt which includes your
order number as the 'merchant's ref'. It has very limited information,
and specifically does not include any salestax info. Therefore, we
include everything the customer previously entered onto this page and
ask him to print it.

This system does not send an email from us to the customer (though we
can do that manually, and he gets the WP email anyway) but otherwise it
works well.

HTH, if not contact me.

Cheers
Lyn St George
+---------------------------------------------------------------------------------
+ http://www.zolotek.net .. eCommerce hosting, consulting
+ http://www.os2docs.org .. some 'How To' stuff ....
+---------------------------------------------------------------------------------