Table of Contents

Class CheckoutHandler

Namespace
Dynamicweb.Ecommerce.Cart
Assembly
Dynamicweb.Ecommerce.dll

A CheckoutHandler does all the business logic required to complete an order. Inherit from this base class to extend the checkout logic in Dynamicweb Ecommerce Cart.

public abstract class CheckoutHandler : ConfigurableAddIn
Inheritance
CheckoutHandler
Derived
Inherited Members

Remarks

Make use of the Dynamicweb Configurable AddIn API to add editable properties to the checkout handler.

Fields

OrderIdRequestName

Returns the name of the request value that CartV2 should look for in order to forward the call to the CheckoutHandler's Redirect method.

protected static readonly string OrderIdRequestName

Field Value

string

Properties

CheckoutHandlerOrderId

Gets the OrderId based on the CheckoutHandler redirect parameter.

public static string CheckoutHandlerOrderId { get; }

Property Value

string

The checkout handler order identifier.

DefaultCheckoutHandler

Returns an instance of DefaultCheckoutHandler.

public static CheckoutHandler DefaultCheckoutHandler { get; }

Property Value

CheckoutHandler

The default checkout handler.

HasServerCallback

Gets or sets a value indicating whether the payment gateway makes a callback request to the server with payment transaction details or not. Use order.SaveGatewayResult to save transaction details in callback processing. Default value is false.

protected bool HasServerCallback { get; set; }

Property Value

bool

true if this instance has server callback; otherwise, false.

ShouldRedirectToCheckoutHandler

Gets a value indicating whether CartV2 should redirect to CheckoutHandler.

public static bool ShouldRedirectToCheckoutHandler { get; }

Property Value

bool

true if CartV2 should redirect to CheckoutHandler; otherwise, false.

Methods

BeginCheckout(Order)

This method is called when the checkout procedure is started and the order is handled to the checkout handler.

public OutputResult BeginCheckout(Order order)

Parameters

order Order

The order that need to be checked out.

Returns

OutputResult

The module output.

Remarks

Return a OutputResult to control the flow of checkout, be that content or redirection.

BeginCheckout(Order, CheckoutParameters)

This method is called when the checkout procedure is started in a headless context with custom urls and the order is handled to the checkout handler.

public virtual OutputResult BeginCheckout(Order order, CheckoutParameters parameters)

Parameters

order Order

The order that need to be checked out.

parameters CheckoutParameters

Parameters to configure how the checkout process should go.

Returns

OutputResult

The module output.

Remarks

Return a OutputResult to control the flow of checkout, be that content or redirection.

CheckoutDone(Order)

This method should be called when the handler is done with the checkout even if the checkout fails.

protected void CheckoutDone(Order order)

Parameters

order Order

The order

GetBaseUrl(Order)

protected virtual string GetBaseUrl(Order order)

Parameters

order Order

Returns

string

GetBaseUrl(Order, bool)

Gets the base URL.

protected virtual string GetBaseUrl(Order order, bool headless = false)

Parameters

order Order

The order.

headless bool

Returns

string

System.String.

GetCheckoutHandlerFromPayment(Payment)

Returns the CheckoutHandler from the given payment, or null if it doesn't exist

public static CheckoutHandler GetCheckoutHandlerFromPayment(Payment payment)

Parameters

payment Payment

The payment

Returns

CheckoutHandler

CheckoutHandler.

GetCheckoutHandlerFromPaymentID(string)

Returns the checkout handler from the given payment id, or null if it doesn't exist

public static CheckoutHandler GetCheckoutHandlerFromPaymentID(string paymentID)

Parameters

paymentID string

Id of the payment

Returns

CheckoutHandler

The CheckoutHandler linked with the payment.

GetOrderFromCallback<T>(CallbackData)

Gets the order from checkout handler callback

public static Order GetOrderFromCallback<T>(CallbackData data) where T : ICheckoutHandlerCallback

Parameters

data CallbackData

Callback data.

Returns

Order

Type Parameters

T

Checkout handler which implements the ICheckoutHandlerCallback interface.

GetPostedInfo(Order)

Returns all posted info as xml string

protected virtual string GetPostedInfo(Order order)

Parameters

order Order

The order

Returns

string

System.String.

GetSubmitFormResult(string, IDictionary<string, string>)

Gets a OutputResult that can submit a form to e.g. a gateway.

protected static OutputResult GetSubmitFormResult(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.

Returns

OutputResult

Remarks

The generated form is posted with javascript. If you need to be able to post without javascript, just render a template with a form and a submit button.

GetSubmitFormResult(string, IDictionary<string, string>, bool)

Gets a OutputResult that can submit a form to e.g. a gateway.

protected static OutputResult GetSubmitFormResult(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, values are url encoded before post.

Returns

OutputResult

Remarks

The generated form is posted with javascript. If you need to be able to post without javascript, just render a template with a form and a submit button.

HandleRequest(Order)

Function that is called from CartV2 when OrderIdRequestName is in the Request.

Implement this method to receive redirects from CartV2

public virtual OutputResult HandleRequest(Order order)

Parameters

order Order

The order with order ID equal to the request OrderIdRequestName

Returns

OutputResult

Returns the output to the module.

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 OutputResult to control the flow of checkout, be that content or redirection.

HideCardNumber(string)

Hide part of card number, e.g. for card number 4711100000009999 it returns XXXXXXXXXXXX9999

protected static string HideCardNumber(string cardNumber)

Parameters

cardNumber string

The card number

Returns

string

System.String.

LogError(Order, Exception, string, params object[])

Logs an error. This is written in the error log and in the event log

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

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.

LogError(Order, string, params object[])

Logs an error. This is written in the error log and in the event log

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

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.

LogEvent(Order, string, DebuggingInfoType, params object[])

Logs an event. This is written in the event log.

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

LogEvent(Order, string, params object[])

Logs an event. This is written in the event log.

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

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.

PassCallbackToCheckoutHandler(Order, CallbackData)

Passes the callback data to checkout handler.

public static OutputResult PassCallbackToCheckoutHandler(Order order, CallbackData data)

Parameters

order Order

The order being checked out.

data CallbackData

Callback data.

Returns

OutputResult

Return a OutputResult to control the flow of checkout, be that content or redirection.

PassToCart(Order)

This method should be called when ready to pass responsibility back to the cart. Called when the checkout handler is done processing the order for the request and letting the cart finish the request.

protected static OutputResult PassToCart(Order order)

Parameters

order Order

The order that is currently being checked out.

Returns

OutputResult

PassToCheckoutHandler()

Passes responsibility for handling the request to the CheckoutHandler. This handler is found through the order created by the id in OrderIdRequestName

public static OutputResult PassToCheckoutHandler()

Returns

OutputResult

Return a OutputResult to control the flow of checkout, be that content or redirection.

PassToCheckoutHandler(Order)

Passes responsibility for handling the request to the CheckoutHandler. This handler is found through the order created by the id in OrderIdRequestName

public static OutputResult PassToCheckoutHandler(Order order)

Parameters

order Order

The order being checked out.

Returns

OutputResult

Return a OutputResult to control the flow of checkout, be that content or redirection.

Render(Order, Template)

Renders the specified order.

protected virtual string Render(Order order, Template renderingTemplate)

Parameters

order Order

The order.

renderingTemplate Template

The template.

Returns

string

System.String.

RenderInlineForm(Order)

Render inline payment form.

public virtual string RenderInlineForm(Order order)

Parameters

order Order

The order that need to be checked out.

Returns

string

SetOrderComplete(Order)

Performs the logic for setting the order complete

protected void SetOrderComplete(Order order)

Parameters

order Order

The order to set complete

Remarks

If you have a transaction number from e.g. a gateway, use SetOrderComplete(Order order, string transactionNumber).

SetOrderComplete(Order, string)

Sets the transaction number and performs the logic for setting the order complete

protected void SetOrderComplete(Order order, string transactionNumber)

Parameters

order Order

The order to set complete

transactionNumber string

The transaction number

See Also

To top