Monday 21 April 2003 3:58:56 am
I've just about 'cracked it'. (read on... if you're interested in making the ez3 shop talk to a payment gateway) All that remains is to know how to populate the html form to the payment gateway with the data from the order header (customer names, total amount including VAT, etc.) I don't know enough about template variables and template functions yet. HELP!! Description of ez3 shop processing Assume shopping site is at www.demo.ez3 The first I did was create in admin, a standard workflow (I called mine 'eWay Connect'). In the triggers section of admin I then edited triggers and selected this workflow for the trigger 'Shop/Checkout/before'. Go into www.demo.ez3/index.php, select the shop and select a few items into your shopping cart.
http://www.demo.ez3/index.php/shop/confirmorder/
is the URI which has the confirm button in it which when pressed will invoke the checkout URI
With existing ez3 templates, and with the rules used within index.php, because the shop is section 5 of demo,
design\demo\override\templates\pagelayout_section_5.tpl
is invoked with the embedded main body
{$module_result.content}
being the output of:
design\standard\templates\shop\confirmorder.tpl In addition, before execution kernel\shop\confirmorder.php is also 'automatically' invoked and processed as part of the tpl output. When the 'Confirm' button is selected by the user
http://www.demo.ez3/index.php/shop/checkout/
is invoked.
Index.php interprets this URI as, load pagelayout_section_5.tpl and embeds/executes the code found at URI /kernel/shop/checkout.php
However, there is a database trigger already existing in demo as follows:
Field name Data description
id 1 Trigger id
name Pre_checkout Name of trigger
module shop Invoke ..\kernel\shop\module when
trigger executed
function checkout ..\kernel\shop\checkout.php function
to invoke when trigger executed
connect_type b before workflow_id 2 eWay connect workflow
As part of this execution (prior to display to the client) ez3 fetches and processes the template associated with the pre_checkout trigger, which is design\standard\templates\workflow\eventtype\result\event_ezcheckout.tpl
Why? Well, I suppose there are internal rules within ez3 that say something like this:
Is an event associated with the URI shop/checkout? Yes there is.
Is it a pre or post event? It's a pre checkout event. Ah ha!
The template associated with this event is searched for, initially in
design\demo\override\templates\workflow\eventtype\result\event_ezcheckout.tpl
If this does not exist, use the template to be found at
design\standard\templates\workflow\eventtype\result\event_ezcheckout.tpl
and displays the results in the main body of pagelayout_section_5.tpl (ie {$module_result.content} ) as per the other internal rules of ez3.
It is now necessary to understand how to access the order total and customer details to allow them to be passed to the payment gateway (in my case eWay)
A form needs to be included in the 'override' ezcheckout.tpl in the appropriate demo/override directory, that uses the HTTP POST method which replaces the little dummy one delivered with ezcheckout.tpl in the standard ez3 directory which displays heading 'Check Out' and an empty text field and button labeled 'next'. The following code fragment is an example of what is required:
<table border="1" width="70%" cellspacing="0" cellpadding="5" bordercolor="#000080">
<tr>
<td width="22%" valign="top"><p class="subtitle"><a href="http://www.eway.com.au" target="_blank"><img alt="eWAY - a total e commerce solution" border="0" height="91" src="http://www.eway.com.au/images/logos/eway.gif" width="200"></a></p></td>
<td width="78%" valign="top" bgcolor="#ffffff"> <form method="post" action="https://www.eway.com.au/gateway/payment.asp">
<input type="hidden" name="ewayCustomerID" value="87654321">
<input type="hidden" name="ewayTotalAmount" value="10">
<input type="hidden" name="ewayCustomerFirstName" value="Roxarne">
<input type="hidden" name="ewayCustomerLastName" value="Paton">
<input type="hidden" name="ewayCustomerEmail" value="sales@eway.com.au">
<input type="hidden" name="ewayCustomerAddress" value="18 Mayne Street Parkes NSW">
<input type="hidden" name="ewayCustomerPostcode" value="2870">
<input type="hidden" name="ewayCustomerInvoiceDescription" value="ASP code e-postcard">
<input type="hidden" name="ewayCustomerInvoiceRef" value="webactive002">
<input type="hidden" name="ewayURL" value="http://www.demo.ez3">
<input type="hidden" name="ewaySiteTitle" value="myez3Site">
<p><input type="submit" value="Process Secure Credit Card Transaction using eWAY" name="submit"></p>
</form>
</td>
</tr>
</table>
As may be seen, this array is POST'ed using https to the eway URI, namely:
https://www.eWAY.com.au/gateway/payment.asp
This all works, believe it or not.
It displays correctly in www.demo.ez3 in the checkout screen.
It connects correctly with eway via an https connection
eway processes it correctly, and returns to www.demo.ez3 however... My final problem is: HOW DO I POPULATE THE EWAY VARIABLES WITH THE ORDER HEADER AND TOTAL VARIABLES SUCH AS {$order.total_inc_vat} which is available and used in design\standard\templates\shop\confirmorder.tpl All help would be greatly appreciated. With many thanks,
Sol Millin
byron bay australia
|