Ok, so i have my code that encrypts the order details and then sends the post data to EPDQ. The code for this is as follows...
Code: Select all
Code Behind
VB
Public Class Example
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'The Following Creates the WebClient Object
Dim web As New System.Net.WebClient()
'The Header Content Type is then set
web.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
'PostData is then declared as data type Byte and populated with the post data
Dim PostData As Byte() = System.Text.Encoding.ASCII.GetBytes("clientid=[clientid]&password=[password]&oid=[orderid]&chargetype=PreAuth¤cycode=826&total=[total]")
'The Web object is then used to upload the postdata to the Encryption URL and the response is stored in the Response variable
Dim Response As Byte() = web.UploadData("https://secure2.epdq.co.uk/cgi-bin/CcxBarclaysEpdqEncTool.e", "POST", PostData)
'The response from the post is then converted from Type Byte to String and stored in the session variable
Session("Response") = (System.Text.Encoding.ASCII.GetString(Response))
End Sub
End Class
ASPX
VB
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Example.aspx.vb" Inherits="WebProject1.Example"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Example</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie3-2nav3-0">
</HEAD>
<body MS_POSITIONING="FlowLayout">
'The Session Variable is then output to the FORM and on form submit is posted to the CPI
<FORM action="https://secure2.epdq.co.uk/cgi-bin/CcxBarclaysEpdq.e" method="post">
<%= session("Response") %>
<INPUT type="hidden" name="returnurl" value="http://www.store.co.uk/">
<INPUT type="hidden" name="merchantdisplayname" value="My Store">
<INPUT TYPE="submit" VALUE="purchase">
</FORM>
</body>
</HTML>
These are obviously the example values and will need updating to include the details that i need to send, and therefore i need to know what the variable names would be.
I am assuming that this either needs to be added to the final page of the checkout where the customer would be clicking on "Submit Payment" or some sort of reference would need to be added to that final page to launch this if it was in its own seperate page. The thing with my current shopping cart is that when i select "Custom Payment Method" in the Admin side, it then knows to call/trigger the contents of an _INCPayOut_.asp page, which includes the above code, so the trigger is already done for me. This is where i am struggling, as i don't know which page i need to amend to include this code or include a call to load the page. Also do I need to add something in to the Admin so that it then knows to call my custom routine, similar to my existing ASP cart?
From the point where this code is triggered, and the ubmit button is pressed, the control is then handed over to ePDQ site where any customer data included in the code is passed over and the remaining card and customer details are collected. After the payment has been processed, the response is posted to my "response handling page". The sample script for the response handling script is as follows...
Code: Select all
Code Behind
Public Class Response
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim fs, fname, path, timestamp
If Request.ServerVariables("request_method") = "POST" Then
fs = Server.CreateObject("Scripting.FileSystemObject")
path = "c:\" 'set your logfile directory path here
timestamp = Day(Date.Now) & "-" & Month(Date.Now) & "-" & Year(Date.Now)
timestamp = timestamp & "--" & Hour(Now) & "-" & Minute(Now) & "-" & Second(Now)
fname = fs.CreateTextFile(path & timestamp & "-" & Request.Form("oid") & ".log", True)
fname.WriteLine("OrderID - " & Request.Form("oid"))
fname.WriteLine("Transaction Status - " & Request.Form("transactionstatus"))
fname.WriteLine("Total - " & Request.Form("total"))
fname.WriteLine("ClientID - " & Request.Form("clientid"))
fname.WriteLine("Transaction Time Stamp - " & Request.Form("datetime"))
fname.Close()
fname = Nothing
fs = Nothing
End If
End Sub
End Class
As you can see, this appears to be recording the data in a text file, however i need to amend this section so that it updates the order in the db with the result of the transaction, but this is also where i am stuck as i don't know how able commerce is expecting the result and how to tell it the result. Can this be handled by this script or does it need to be done as a trigger within the Admin? If so, how?
At the same time as the payment is processed and the response it returned, ePDQ sends the customer back to whichever page i specify in the first encryption code as the "returnurl". This would presumably be some sort of Thank You page. Again, i would need to know what that page is in AbleCommerce, if it actually exists. If not i guess i will have to create my own Thank You page. I suppose i would also need something on this to retrieve back the order details based on the "oid" that was returned by ePDQ when it returned the customer.
So, i am still unsure on how to:
1) Call the Encryption Script (either by calling it as a seperate page or including the code in one of AbleCommerce's checkout pages)
2) Which existing page should i use to do this
3) How do i update the order when the transaction status is posted back (instead of writing to the text file as in the example above)
4) Is there a Thank You page? Which page is it?
This is as much as i can decipher from the integration guide in terms of my understanding of the process, but it is the connections between AbleCommerce and these 2 scripts that i am stuck with. I just don't know how to add to the Admin side as a Payment Gateway/Processor etc, or what the pages are that i need to call the script from, or the variables that would be available to me that i would need to submit to ePDQ.
I hope that someone can help me with this.
Thanks
Andrew