Imports System.Text Imports BVSoftware.BVC.Core Public Class checkout_receipt Inherits BaseStorePage Protected WithEvents lnkMyAccount As System.Web.UI.WebControls.HyperLink Protected WithEvents PayPalLink As System.Web.UI.WebControls.HyperLink Protected WithEvents pnlPayPal As System.Web.UI.WebControls.Panel Protected WithEvents MetaDescriptionControl As BVSoftware.WebControls.MetaTag Protected WithEvents MetaKeywordsControl As BVSoftware.WebControls.MetaTag Protected WithEvents lblInstructions As System.Web.UI.WebControls.Label Protected WithEvents CSSTag1 As BVSoftware.WebControls.CSSTag Protected WithEvents pnlOKAY As System.Web.UI.WebControls.Panel Protected WithEvents msg As BVSoftware.WebControls.WebPageMessage Protected WithEvents lblPayPal1 As System.Web.UI.WebControls.Label Protected WithEvents OrderViewer1 As OrderViewer #Region " Web Form Designer Generated Code " 'This call is required by the Web Form Designer. 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() 'SP2- Assures that SSL is used for this page if set up Me.RequiresSSL = True '-SP2 End Sub #End Region Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) Handles MyBase.Load If Not Page.IsPostBack Then MetaKeywordsControl.Content = WebAppSettings.MetaKeywords MetaDescriptionControl.Content = WebAppSettings.MetaDescription CSSTag1.StyleSheetURL = PersonalizationServices.GetPersonalizedStyleSheet PageTitle = "Receipt" Try ' Add link back to my account lnkMyAccount.NavigateUrl = WebAppSettings.SiteStandardRoot & "MyAccount_Orders.aspx" lnkMyAccount.Text = Content.SiteTerms.GetTerm("MyAccount") ' Get Current cart to place order Dim Cart As Orders.Order Cart = BVC2004Store.GetCurrentShoppingCart() ' Create Response Holder Dim pipeResponse As Pipelines.OrderPipelineResponse ' Run save order pipeline If Cart Is Nothing Then Throw New ArgumentException("Your shopping cart couldn't be loaded. Please try again.") Else pipeResponse = Pipelines.CheckoutPipeline.Run(Cart) If pipeResponse.ReadyForCheckout = True Then '2004.7 Dim limitMessage As String = "" If OrderServices.CheckOrderMinimumsAndMaximums(Cart, limitMessage) = True Then pipeResponse = Pipelines.ReceiveOrderPipeline.Run(Cart) Else pipeResponse.Result = False pipeResponse.AddError("MINMAX", limitMessage, True) End If Else pipeResponse.Result = False End If End If ' Read Response If pipeResponse.Result = True Then ' Pipeline passed to display receipt Me.pnlOKAY.Visible = True Me.OrderViewer1.Visible = True Try BVC2004Store.ClearCurrentCartID() LoadOrder(Cart.ID) Catch ex As Exception msg.ShowException(ex) End Try Else ' Pipeline Failed so display errors Dim sbError As New StringBuilder If pipeResponse.Errors.Count > 0 Then sbError.Append("") SaveError(sbError.ToString()) End If End If Cart = Nothing Catch Ex As Exception SaveError(ex.Message) End Try Else Response.Redirect("checkout_confirm.aspx") End If End Sub Sub SaveError(ByVal ErrorMessage As String) Dim sb As New StringBuilder sb.Append("There was an error while attempting to save your order!") sb.Append("
 
") sb.Append(ErrorMessage) sb.Append("Click Here to check your order and try again") msg.ShowWarning(sb.ToString) sb = Nothing OrderViewer1.Visible = False End Sub Sub LoadOrder(ByVal OrderID As String) Try Dim o As Orders.Order = OrderServices.GetExistingOrder(OrderID) If Not o Is Nothing Then ViewState("OrderID") = o.ID ' Set Paypal and Instructions before viewer loads pnlPayPal.Visible = False Dim thisMethod As BVSoftware.BVC.Interfaces.PaymentMethod For i As Integer = 0 To o.Payments.Length - 1 If o.Payments(i).PaymentType = BVSoftware.BVC.Interfaces.PaymentRecordType.Information And o.Payments(i).PaymentMethod <> BVSoftware.BVC.Interfaces.PaymentMethod.GiftCertificate Then thisMethod = o.Payments(i).PaymentMethod End If Next Select Case thisMethod Case BVSoftware.BVC.Interfaces.PaymentMethod.Check lblInstructions.Text = WebAppSettings.PaymentInstructionsCheck Case BVSoftware.BVC.Interfaces.PaymentMethod.CreditCard lblInstructions.Text = WebAppSettings.PaymentInstructionsCreditCard Case BVSoftware.BVC.Interfaces.PaymentMethod.Email lblInstructions.Text = WebAppSettings.PaymentInstructionsEmail Case BVSoftware.BVC.Interfaces.PaymentMethod.Fax lblInstructions.Text = WebAppSettings.PaymentInstructionsFax Case BVSoftware.BVC.Interfaces.PaymentMethod.PayPal lblInstructions.Text = WebAppSettings.PaymentInstructionsPayPal Dim sPayPalLink As String = "https://www.paypal.com/xclick/business=" & Server.UrlEncode(WebAppSettings.PayPalUsername) sPayPalLink += "&item_name=" & Server.UrlEncode("Order" & o.CompletedOrderID) & "&amount=" sPayPalLink += Server.UrlEncode(String.Format("{0:0.00}", o.GetRequestedRemainingTotal)) sPayPalLink += "&no_note=1¤cy_code=" sPayPalLink += WebAppSettings.PayPalCurrencyCode sPayPalLink += "&invoice=" & o.CompletedOrderID PayPalLink.NavigateUrl += sPayPalLink pnlPayPal.Visible = True Dim sbPayPal As New StringBuilder sbPayPal.Append("") sbPayPal.Append("") RegisterStartupScript("onLoad", sbPayPal.ToString()) sbPayPal = Nothing Case BVSoftware.BVC.Interfaces.PaymentMethod.PurchaseOrder lblInstructions.Text = WebAppSettings.PaymentInstructionsPurchaseOrder Case BVSoftware.BVC.Interfaces.PaymentMethod.Telephone lblInstructions.Text = WebAppSettings.PaymentInstructionsTelephone End Select OrderViewer1.LoadOrder(o) Else msg.ShowError("Couldn't Load Order ID " & OrderID) End If Catch Ex As Exception msg.ShowException(Ex) End Try End Sub End Class