Imports SysDataNet.Store Imports System.Data.SqlClient Public Class PaymentPage Inherits System.Web.UI.Page Protected CartID As String = "" Protected currency As String = "" Protected Total As Decimal = 0 Protected PortalID As Integer = 0 Protected LangId As Integer = 0 Protected WithEvents lblAmountCur As System.Web.UI.WebControls.Label Protected WithEvents SubmitBtn As System.Web.UI.WebControls.LinkButton Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load '------------------------------------------ ' Get LangID from querystring - BEGIN '------------------------------------------ If Not (Request.Params("LangId") Is Nothing) Then LangId = Request.Params("LangId") End If '------------------------------------------ ' Get LangID from querystring - END '------------------------------------------ '--------------------- ' Get CartID - BEGIN '--------------------- Dim cart As StoreCartDB = New StoreCartDB CartID = cart.GetShoppingCartId() '--------------------- ' Get CartID - END '--------------------- '--------------------------------------------- ' Get the Total to pay and Currency - BEGIN '--------------------------------------------- Dim GetTot As StoreDB = New StoreDB GetTot.GetCustTot(CartID, Total, currency, 0) 'This is the field that show the amount on the page Me.lblAmountCur.Text = Format(Total, "##,##0.00") & " " & currency '--------------------------------------------- ' Get the Total to pay and Currency - END '--------------------------------------------- '---------------------------------------- ' Get the PortalID from CartID - Begin '---------------------------------------- Dim LogDB As StoreDB = New StoreDB Dim drUploadDirectory As SqlDataReader = LogDB.GetPortalIDUploadDirectory(CartID, 0) While drUploadDirectory.Read PortalID = drUploadDirectory("PortalID") End While drUploadDirectory.Close() '---------------------------------------- ' Get the PortalID from CartID - End '---------------------------------------- End Sub Private Sub SubmitBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SubmitBtn.Click Try '---------------------------------- 'Get info about the Client - BEGIN '---------------------------------- Dim CustDetails As StoreDB = New StoreDB Dim drCustDetails As SqlDataReader = CustDetails.GetTempCustDetails(CartID, 0) Dim strFirstName As String Dim strLastName As String Dim strAddr1 As String Dim strAddr2 As String Dim strCity As String Dim strStateCode As String Dim strZIP As String Dim strCompany As String Dim strCountryCode As String Dim strCustomerEmail As String While drCustDetails.Read strCompany = drCustDetails("BCompany") strFirstName = drCustDetails("BName") strLastName = drCustDetails("BSurname") strAddr1 = drCustDetails("BAddr1") strAddr2 = drCustDetails("BAddr2") strCity = drCustDetails("BCity") strStateCode = drCustDetails("BStateCode") strCountryCode = drCustDetails("BCountryCode") strZIP = drCustDetails("BZIP") strCustomerEmail = drCustDetails("email") End While drCustDetails.Close() '---------------------------------- 'Get info about the Client - END '---------------------------------- '---------------------------- ' Get the Store Email - BEGIN '---------------------------- Dim GetStoreEmail As StoreDB = New StoreDB Dim strStoreEmail As String = GetStoreEmail.GetSettingString(PortalID, "store_email", 0) '---------------------------- ' Get the Store Email - END '---------------------------- '------------------------------- ' get the Items in Cart - BEGIN '------------------------------- Dim cart As StoreCartDB = New StoreCartDB Dim drItemCart As SqlDataReader = cart.GetItems(LangId, CartID, 0) Dim strItemName As String While drItemCart.Read strItemName = strItemName & CType(drItemCart("ModelName"), String) & " " & Trim(CType(drItemCart("Attributes"), String)) & " (" & CType(drItemCart("Quantity"), String) & ")" & "; " End While drItemCart.Close() '------------------------------- ' get the Items in Cart - END '------------------------------- Dim strLogin As String = "" Dim strPassword As String = "" Dim TX_ID As String = "" '------------------------------------ ' Get the type of transaction - BEGIN '------------------------------------ Dim strTypeTransaction As String Dim GetPayType As StoreDB = New StoreDB Dim intTypeTrans As Integer = GetPayType.GetSettingInteger(PortalID, "type_transaction", 0) If intTypeTrans = 0 Then intTypeTrans = 1 End If '------------------------------------ ' Get the type of transaction - END '------------------------------------ '------------------------------------------------------ ' if it is APPROVED create the order - BEGIN '------------------------------------------------------ Dim RefOrder As String = "" Dim ordersDatabase As StoreDB = New StoreDB 'TX_ID is the transactionID returned by the payment processor 'to be used to charge the credit card in the second step Dim orderId As Integer = ordersDatabase.PlaceOrder(TX_ID, intTypeTrans, CartID, "Custom Payment Module", LangId, RefOrder, 0) ' Redirect to the INVOICE page - Begin Dim SDN As StoreAdmin = New StoreAdmin Dim TabIDInvoice As Integer = 0 TabIDInvoice = SDN.GetTabIDFromControlSRC(PortalID, "DesktopModules/SysDataNetStore/StoreInvoice.ascx", 0) Dim Setting As StoreDB = New StoreDB Dim strURLHome As String = Setting.GetSettingString(PortalID, "url_home", 0) Response.Redirect(strURLHome & "/Default.aspx?TabID=" & TabIDInvoice & "&langID=" & LangId) ' Redirect to the INVOICE page - End '------------------------------------------------------ ' if it is APPROVED create the order - End '------------------------------------------------------ '-------------------------------------------------------------------- 'Log the error, to be seen in the Payment Log SDN Store Admin menu '-------------------------------------------------------------------- Catch er As Exception Dim LogDB As StoreDB = New StoreDB LogDB.AddLog(PortalID, "Custom Payment Module", er.Message, 0) End Try End Sub End Class