isbuynow Element
Inject code to render express checkout buttons that lets a shopper buy a specific product.
To render express checkout buttons for a shopper to pay for their current basket, see <ispayment>.
<isbuynow>
is only used with B2C Commerce Payments. An associated payments
account must be successfully enabled and configured for use on the storefront site where
this element appears.
Syntax
<isbuynow
payment-request = SalesforcePaymentRequest expression \\required
></isbuynow>
- payment-request = SalesforcePaymentRequest expression
-
Specify a
dw.extensions.payments.SalesforcePaymentRequest
as part of an expression for the tag. See SalesforcePaymentRequest.
Purpose
The <isbuynow>
tag injects <script>
code in the page to render express checkout buttons that lets a shopper buy a specific
product. See dw.extensions.payments to configure the express checkout
buttons and understand how they're rendered.
Rules of Use
This tag can appear multiple times on the same page, with no limit. The tag must be placed where <script> tags are valid, after the closing </head> tag in the HTML page.
This tag can't be used in a cached template because it's used for the shopper to pay for their current basket. The options in the SalesforcePaymentRequest include line items with amounts that depend on variables such as, currency, prices, promotions, and applicable shipping methods. Consider these when using this tag in a cached template.
Express checkout buttons are only rendered when applicable for the shopper. If the shopper isn't using a supported device or operating system, or hasn't configured them to use the available express checkout buttons, then no button is presented.
Example
In this example, <script> code is injected by <ispayment> to render an Apple Pay button configured with Commerce Cloud Payments on the site. The ID of the component is βapplepayβ and the CSS class name where the component is to be rendered is βapple-pay-button-containerβ.
A helper function, COHelpers.calculateBuyNowData, creates the basket data and payment request options. See dw.extensions.payments for details on how the data prepares a basket when a shopper taps an express checkout button and how the options create line items for the payment request, and then display the browser payment app, such as Apple Pay.
SalesforcePaymentRequest
object
can be placed in a controller. <isscript> is used here as an example.<isscript>
var SalesforcePaymentRequest = require('dw/extensions/payments/SalesforcePaymentRequest');
var COHelpers = require('*/cartridge/scripts/checkout/checkoutHelpers');
var buyNowData = COHelpers.calculateBuyNowData(pdict.product, pdict.quantity, pdict.price);
var paymentRequest = new SalesforcePaymentRequest('applepay', '.apple-pay-button-container');
paymentRequest.addInclude(SalesforcePaymentRequest.ELEMENT_TYPE_APPLEPAY);
paymentRequest.setBasketData(buyNowData.basketData);
paymentRequest.setOptions(buyNowData.options);
</isscript>
<ispayment payment-request="${paymentRequest}"></ispayment>