Class PaymentRequestHooks
PaymentRequestHooks interface containing extension points for customizing Payment Requests.
These hooks are executed in a transaction.
The extension points (hook names), and the functions that are called by each extension point. A function must be defined inside a JavaScript source and must be exported. The script with the exported hook function must be located inside a site cartridge. Inside the site cartridge a 'package.json' file with a 'hooks' entry must exist.
The hooks entry links to a json file, relative to the 'package.json' file. This file lists all registered hooks inside the hooks property:
A hook entry has a 'name' and a 'script' property.
- The 'name' contains the extension point, the hook name.
- The 'script' contains the script relative to the hooks file, with the exported hook function.
Deprecated:
Salesforce Payments includes support for Google Pay
| Constant | Description |
|---|---|
| extensionPointAbort: String = "dw.extensions.paymentrequest.abort" | The extension point name dw.extensions.paymentrequest.abort. |
| extensionPointGetPaymentRequest: String = "dw.extensions.paymentrequest.getPaymentRequest" | The extension point name dw.extensions.paymentrequest.getPaymentRequest. |
| extensionPointPaymentAcceptedAuthorizeOrderPayment: String = "dw.extensions.paymentrequest.paymentAccepted.authorizeOrderPayment" | The extension point name dw.extensions.paymentrequest.paymentAccepted.authorizeOrderPayment. |
| extensionPointPaymentAcceptedPlaceOrder: String = "dw.extensions.paymentrequest.paymentAccepted.placeOrder" | The extension point name dw.extensions.paymentrequest.paymentAccepted.placeOrder. |
| extensionPointShippingAddressChange: String = "dw.extensions.paymentrequest.shippingAddressChange" | The extension point name dw.extensions.paymentrequest.shippingAddressChange. |
| extensionPointShippingOptionChange: String = "dw.extensions.paymentrequest.shippingOptionChange" | The extension point name dw.extensions.paymentrequest.shippingOptionChange. |
This class does not have a constructor, so you cannot create it directly.
| Method | Description |
|---|---|
| abort(Basket) | Called after the Payment Request user interface was canceled. |
| authorizeOrderPayment(Order, Object) | Called after the shopper accepts the Payment Request payment for the given order. |
| getPaymentRequest(Basket, Object) | Called to get the |
| placeOrder(Order) | Called after payment has been authorized and the given Payment Request order is ready to be placed. |
| shippingAddressChange(Basket, Object) | Called after handling the Payment Request |
| shippingOptionChange(Basket, ShippingMethod, Object) | Called after handling the Payment Request |
assign, create, create, defineProperties, defineProperty, entries, freeze, fromEntries, getOwnPropertyDescriptor, getOwnPropertyNames, getOwnPropertySymbols, getPrototypeOf, hasOwnProperty, is, isExtensible, isFrozen, isPrototypeOf, isSealed, keys, preventExtensions, propertyIsEnumerable, seal, setPrototypeOf, toLocaleString, toString, valueOf, values
- extensionPointAbort: String = "dw.extensions.paymentrequest.abort"
The extension point name dw.extensions.paymentrequest.abort.
- extensionPointGetPaymentRequest: String = "dw.extensions.paymentrequest.getPaymentRequest"
The extension point name dw.extensions.paymentrequest.getPaymentRequest.
- extensionPointPaymentAcceptedAuthorizeOrderPayment: String = "dw.extensions.paymentrequest.paymentAccepted.authorizeOrderPayment"
The extension point name dw.extensions.paymentrequest.paymentAccepted.authorizeOrderPayment.
- extensionPointPaymentAcceptedPlaceOrder: String = "dw.extensions.paymentrequest.paymentAccepted.placeOrder"
The extension point name dw.extensions.paymentrequest.paymentAccepted.placeOrder.
- extensionPointShippingAddressChange: String = "dw.extensions.paymentrequest.shippingAddressChange"
The extension point name dw.extensions.paymentrequest.shippingAddressChange.
- extensionPointShippingOptionChange: String = "dw.extensions.paymentrequest.shippingOptionChange"
The extension point name dw.extensions.paymentrequest.shippingOptionChange.
- abort(basket: Basket): PaymentRequestHookResult
Called after the Payment Request user interface was canceled. The given basket is the one that was passed to other hooks earlier in the Payment Request checkout process.
It is not guaranteed that this hook will be executed for all Payment Request user interfaces canceled by shoppers or otherwise ended without a successful order. Calls to this hook are provided on a best-effort basis.
If the returned result includes a redirect URL, the shopper browser will be navigated to that URL if possible. It is not guaranteed that the response with the hook result will be handled in the shopper browser in all cases.
Parameters:
- basket - the basket that was being checked out using Payment Request
Returns:
- a non-null result ends the hook execution
- authorizeOrderPayment(order: Order, response: Object): Status
Called after the shopper accepts the Payment Request payment for the given order. Basket customer information, billing address, and/or shipping address for the default shipment will have already been updated to reflect the available contact information provided by Payment Request. Any preexisting payment instruments on the basket will have been removed, and a single
DW_ANDROID_PAYpayment instrument added for the total amount. The given order will have been created from this updated basket.The purpose of this hook is to authorize the Payment Request payment for the order. If a non-error status is returned that means that you have successfully authorized the payment with your payment service provider. Your hook implementation must set the necessary payment status and transaction identifier data on the order as returned by the provider.
Return an error status to indicate a problem, including unsuccessful authorization.
See the Payment Request API for more information.
Parameters:
- order - the order paid using Payment Request
- response - response to the accepted
PaymentRequest
Returns:
- a non-null status ends the hook execution
- getPaymentRequest(basket: Basket, parameters: Object): PaymentRequestHookResult
Called to get the
PaymentRequestconstructor parameters for the given basket. You can set properties in the givenparametersobject to extend or override default properties set automatically based on the Google Pay configuration for your site.The
parametersobject will contain the following properties by default:-
methodData- array containing payment methods the web site accepts -
details- information about the transaction that the user is being asked to complete -
options- information about what options the web page wishes to use from the payment request system
Return a result with an error status to indicate a problem.
If the returned result includes a redirect URL, the shopper browser will be navigated to that URL if the Payment Request user interaction is canceled.
See the Payment Request API for more information.
Parameters:
- basket - the basket for the Payment Request request
- parameters - object containing
PaymentRequestconstructor parameters
Returns:
- a non-null result ends the hook execution
-
- placeOrder(order: Order): PaymentRequestHookResult
Called after payment has been authorized and the given Payment Request order is ready to be placed. The purpose of this hook is to place the order, or return a redirect URL that results in the order being placed when the shopper browser is navigated to it.
The default implementation of this hook returns a redirect to
COPlaceOrder-Submitwith URL parametersorder_idset to Order.getOrderNo() andorder_tokenset to Order.getOrderToken() which corresponds to SiteGenesis-based implementations. Your hook implementation should return a result with a different redirect URL as necessary to place the order and show an order confirmation.Alternatively, your hook implementation itself can place the order and return a result with a redirect URL to an order confirmation page that does not place the order. This is inconsistent with SiteGenesis-based implementations so is not the default.
Return an error status to indicate a problem. If the returned result includes a redirect URL, the shopper browser will be navigated to that URL if the Payment Request user interface is canceled.
Parameters:
- order - the order paid using PaymentRequest
Returns:
- a non-null result ends the hook execution
- shippingAddressChange(basket: Basket, details: Object): PaymentRequestHookResult
Called after handling the Payment Request
shippingaddresschangeevent for the given basket. Basket customer information and/or shipping address for the default shipment will have already been updated to reflect the available shipping address information provided by Payment Request. The basket will have already been calculated before this hook is called.Return a result with an error status to indicate a problem.
If the returned result includes a redirect URL, the shopper browser will be navigated to that URL if the Payment Request user interface is canceled.
See the Payment Request API for more information.
Parameters:
- basket - the basket being checked out using Payment Request
- details - updated
PaymentRequestobject details
Returns:
- a non-null result ends the hook execution
- shippingOptionChange(basket: Basket, shippingMethod: ShippingMethod, details: Object): PaymentRequestHookResult
Called after handling the Payment Request
shippingoptionchangeevent for the given basket. The given shipping method will have already been set on the basket. The basket will have already been calculated before this hook is called.Return a result with an error status to indicate a problem.
If the returned result includes a redirect URL, the shopper browser will be navigated to that URL if the Payment Request user interface is canceled.
See the Payment Request API for more information.
Parameters:
- basket - the basket being checked out using Payment Request
- shippingMethod - the shipping method that was selected
- details - updated
PaymentRequestobject details
Returns:
- a non-null result ends the hook execution