Class CheckoutHandler
- Namespace
- Dynamicweb.Ecommerce.Cart
- Assembly
- Dynamicweb.Ecommerce.dll
public abstract class CheckoutHandler : ConfigurableAddIn
- Inheritance
-
CheckoutHandler
- Inherited Members
Remarks
Fields
OrderIdRequestName
protected static readonly string OrderIdRequestName
Field Value
- See Also
Properties
CheckoutHandlerOrderId
public static string CheckoutHandlerOrderId { get; }
Property Value
- string
- The checkout handler order identifier.
- See Also
DefaultCheckoutHandler
public static CheckoutHandler DefaultCheckoutHandler { get; }
Property Value
- CheckoutHandler
- The default checkout handler.
- See Also
HasServerCallback
false
.protected bool HasServerCallback { get; set; }
Property Value
- bool
true
if this instance has server callback; otherwise,false
.
- See Also
ShouldRedirectToCheckoutHandler
public static bool ShouldRedirectToCheckoutHandler { get; }
Property Value
- bool
true
if CartV2 should redirect to CheckoutHandler; otherwise,false
.
- See Also
Methods
CheckoutDone(Order)
protected void CheckoutDone(Order order)
Parameters
order
Order- The order
Examples
Public Overrides Function StartCheckout(ByVal order As eCommerce.Orders.Order) As String
LogEvent(order, "StartCheckout")
Try
SetOrderComplete(order)
LogEvent(order, "SetOrderComplete succeeded")
Catch ex As Exception
LogError(order, "SetOrderComplete failed with the message: {0}", ex.Message)
End Try
CheckoutDone(order)
RedirectToCart(order)
Return Nothing
End Function
- See Also
GetBaseUrl(Order)
protected virtual string GetBaseUrl(Order order)
Parameters
order
Order- The order.
Returns
- string
- System.String.
- See Also
GetCheckoutHandlerFromPayment(Payment)
public static CheckoutHandler GetCheckoutHandlerFromPayment(Payment payment)
Parameters
payment
Payment- The payment
Returns
- CheckoutHandler
- CheckoutHandler.
Examples
Payment myPayment;
...
CheckoutHandler myCheckoutHandler = CheckoutHandler.GetCheckoutHandlerFromPayment(myPayment);
- See Also
GetCheckoutHandlerFromPaymentID(string)
public static CheckoutHandler GetCheckoutHandlerFromPaymentID(string paymentID)
Parameters
paymentID
string- Id of the payment
Returns
- CheckoutHandler
- The CheckoutHandler linked with the payment.
Examples
string myPaymentId;
...
CheckoutHandler myCheckoutHandler = CheckoutHandler.GetCheckoutHandlerByPaymentId(myPaymentId);
- See Also
GetCheckoutHandlerFromPaymentID(string, string)
public static CheckoutHandler GetCheckoutHandlerFromPaymentID(string paymentID, string langID)
Parameters
Returns
- CheckoutHandler
- The CheckoutHandler linked with the payment.
Examples
string myPaymentId;
...
CheckoutHandler myCheckoutHandler = CheckoutHandler.GetCheckoutHandlerByPaymentId(myPaymentId);
- See Also
GetPostedInfo(Order)
protected virtual string GetPostedInfo(Order order)
Parameters
order
Order- The order
Returns
- string
- System.String.
Examples
Order myOrder;
Get transaction number from gateway
string transNum;
...
Set the order complete
SetOrderComplete(myOrder, transNum);
- See Also
HideCardNumber(string)
protected static string HideCardNumber(string cardNumber)
Parameters
cardNumber
string- The card number
Returns
- string
- System.String.
- See Also
LogError(Order, Exception, string, params object[])
protected void LogError(Order order, Exception ex, string message, params object[] args)
Parameters
order
Order- The current order or null
ex
Exception- Optional Exception that caused the error
message
string- The message to log
args
object[]- String.Format args to the message
Examples
Order myOrder;
...
LogError(myOrder, "Something happened in the flow");
Order myOrder;
string eventMessage;
...
LogEvent(myOrder, "Something happened in the flow: {0}", eventMessage);
Remarks
It is highly recommended to make use of the logging methods of the CheckoutHandler base class.
The LogError methods creates a text file of all known system information including session variables, server variables and more. All objects logged are parsed and sub-objects stored in properties are also logged down to a certain level.
This log file can easily consume several Mb of disk space, wo use only LogError on true errors. Otherwise use LogEvent.
- See Also
LogError(Order, string, params object[])
protected void LogError(Order order, string message, params object[] args)
Parameters
order
Order- The current order or null
message
string- The message to log
args
object[]- String.Format args to the message
Examples
Order myOrder;
...
LogError(myOrder, "Something happened in the flow");
Order myOrder;
string eventMessage;
...
LogEvent(myOrder, "Something happened in the flow: {0}", eventMessage);
Remarks
It is highly recommended to make use of the logging methods of the CheckoutHandler base class.
The LogError methods creates a text file of all known system information including session variables, server variables and more. All objects logged are parsed and sub-objects stored in properties are also logged down to a certain level.
This log file can easily consume several Mb of disk space, wo use only LogError on true errors. Otherwise use LogEvent.
- See Also
LogEvent(Order, string, DebuggingInfoType, params object[])
protected void LogEvent(Order order, string message, DebuggingInfoType infoType, params object[] args)
Parameters
order
Order- The current order or null. This is used to link the log entry to the order.
message
string- The message to log
infoType
DebuggingInfoType- Type of message to log
args
object[]- String.Format args to the message
- See Also
LogEvent(Order, string, params object[])
protected void LogEvent(Order order, string message, params object[] args)
Parameters
order
Order- The current order or null. This is used to link the log entry to the order.
message
string- The message to log
args
object[]- String.Format args to the message
Examples
Order myOrder;
...
LogEvent(myOrder, "Something happened in the flow");
Order myOrder;
string eventMessage;
...
LogEvent(myOrder, "Something happened in the flow: {0}", eventMessage);
Remarks
It is highly recommended to make use of the logging methods of the CheckoutHandler base class.
The LogEvent method creates a single line entry to the event log file, with the time of the event, the order id and the message. If the order given is not null, the entry is also linked to the order, making it visible in the order details view of the admin area.
- See Also
Redirect(Order)
Function that is called from CartV2 when OrderIdRequestName is in the Request.
Implement this method to receive redirects from CartV2
public abstract string Redirect(Order order)
Parameters
order
Order- The order with order ID equal to the request OrderIdRequestName
Returns
- string
- Returns the output to the module.
Examples
//Write the port if it is not default
var portString = HttpContext.Current.Request.Url.IsDefaultPort ? "" : string.Format(":{0}", HttpContext.Current.Request.Url.Port);
var pageId = Dynamicweb.Context.Current.Request("ID") == null ? string.Empty : string.Format("ID={0}&", Dynamicweb.Context.Current.Request("ID"));
Url
var myUrl = string.Format("{0}://{1}{2}/Default.aspx?{3}{4}={5}",
HttpContext.Current.Request.Url.Scheme,
HttpContext.Current.Request.Url.Host,
portString,
pageId,
OrderIdRequestName,
order.Id);
Remarks
The most common use of this method is to receive callbacks and redirect urls from a gateway.
To enable the Redirect method to be called on a callback parse an url with the current page id and the order id in the query string to the gateway as the callback url. The order id must be stored in a query string variable named with the return value of the property OrderIdRequestName of the CheckoutHandler base class.
Return a string to control the module output. If a redirect is made within the method, it is not needed to return a string.
- See Also
RedirectToCart(Order)
protected void RedirectToCart(Order order)
Parameters
order
Order- The order.
Examples
Public Overrides Function StartCheckout(ByVal order As eCommerce.Orders.Order) As String
LogEvent(order, "StartCheckout")
Try
SetOrderComplete(order)
LogEvent(order, "SetOrderComplete succeeded")
Catch ex As Exception
LogError(order, "SetOrderComplete failed with the message: {0}", ex.Message)
End Try
CheckoutDone(order)
RedirectToCart(order)
Return Nothing
End Function
- See Also
RedirectToCheckoutHandler()
public static string RedirectToCheckoutHandler()
Returns
- string
- System.String.
- See Also
Render(Order, Template)
protected virtual string Render(Order order, Template template)
Parameters
Returns
- string
- System.String.
- See Also
RenderInlineForm(Order)
public virtual string RenderInlineForm(Order order)
Parameters
order
Order- The order that need to be checked out.
Returns
- See Also
SetOrderComplete(Order)
protected void SetOrderComplete(Order order)
Parameters
order
Order- The order to set complete
Examples
Public Overrides Function StartCheckout(ByVal order As eCommerce.Orders.Order) As String
LogEvent(order, "StartCheckout")
Try
SetOrderComplete(order)
LogEvent(order, "SetOrderComplete succeeded")
Catch ex As Exception
LogError(order, "SetOrderComplete failed with the message: {0}", ex.Message)
End Try
CheckoutDone(order)
RedirectToCart(order)
Return Nothing
End Function
Remarks
- See Also
SetOrderComplete(Order, string)
protected void SetOrderComplete(Order order, string transactionNumber)
Parameters
Examples
Order myOrder;
Get transaction number from gateway
string transNum;
...
Set the order complete
SetOrderComplete(myOrder, transNum);
- See Also
StartCheckout(Order)
public abstract string StartCheckout(Order order)
Parameters
order
Order- The order that need to be checked out.
Returns
- string
- The module output.
Examples
Public Overrides Function StartCheckout(ByVal order As eCommerce.Orders.Order) As String
LogEvent(order, "StartCheckout")
Try
SetOrderComplete(order)
LogEvent(order, "SetOrderComplete succeeded")
Catch ex As Exception
LogError(order, "SetOrderComplete failed with the message: {0}", ex.Message)
End Try
CheckoutDone(order)
RedirectToCart(order)
Return Nothing
End Function
Remarks
- See Also
SubmitForm(string, IDictionary<string, string>)
protected void SubmitForm(string formAction, IDictionary<string, string> hiddenInputs)
Parameters
formAction
string- The url of the action
hiddenInputs
IDictionary<string, string>- Dictionary of input name and input value
Examples
string myMerchant;
string myPriceFormatted;
string myCurrency;
...
var formValues = new Dictionary<string, string>
{
{"merchant", myMerchantId},
{"amount", myPriceFormatted},
{"currency", myCurrency}
}
SubmitForm("https://secure.somegateway.com/authorize", formValues);
Remarks
- See Also
SubmitForm(string, IDictionary<string, string>, bool)
protected void SubmitForm(string formAction, IDictionary<string, string> hiddenInputs, bool urlEncodeAtPost)
Parameters
formAction
string- The url of the action
hiddenInputs
IDictionary<string, string>- Dictionary of input name and input value
urlEncodeAtPost
bool- if set to
true
[URL encode at post].
Examples
string myMerchant;
string myPriceFormatted;
string myCurrency;
...
var formValues = new Dictionary<string, string>
{
{"merchant", myMerchantId},
{"amount", myPriceFormatted},
{"currency", myCurrency}
}
SubmitForm("https://secure.somegateway.com/authorize", formValues);
Remarks
- See Also