Links

Offering local pricing

Learn how to set up local pricing for use with Prebuilt Checkout
By pairing the DynamicPricing.js library with Prebuilt Checkout, you can engage the local pricing service and access its benefits.
On this page, you can learn how to:

Configuring your front-end

When coding your site's front-end, make sure you:

Adding the local pricing script

On each html page on your site that contains price elements, add the following script. You can configure the script's attributes but the rest of the code must remain unaltered.
<script id="DR-Dynamic-Pricing">
(function () {
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.setAttribute('data-dr-apiKey', 'YOUR_PUBLIC_API_KEY')
// optional - defaults to 'DR-currencySelector'
s.setAttribute('data-dr-currency-selector', 'currency-selector');
// optional - defaults to browser language
s.setAttribute('data-dr-default-country', 'FR');
s.src = 'https://js.digitalriver.com/v1/DynamicPricing.js';
document.getElementsByTagName('head')[0].appendChild(s);
})();
</script>

Setting up the local pricing selector

To configure the local pricing selector, you'll need to designate a DOM element and apply a stylesheet.

Adding price elements

For each DOM element on your site that displays pricing information, add a data-dr-original-price attribute.
<div data-dr-original-price="199.99"></div>

Handling checkout

When customers initiate checkout, handle that event by defining a POST /drop-in/checkout-sessions request. As part of this operation, make sure you:
After you send the request, we look at your secret API key and determine whether you're using the local pricing service. If you are, we use the checkout-session's shoppingCountry, currency, and items[].price to perform another conversion and then apply the same rounding and currency formatting rules. This means that the currency denominated product prices customers see on your storefront and in your cart are identical to those in the Prebuilt Checkout modal.
Storefront
Cart
Prebuilt Checkout

Access price formatting rules

Once customers provide payment and complete their purchase, and Digital River converts the checkout-session to an order, we return pricingFormat in checkout_session.order.created and onCheckoutComplete.
checkout_session.order.created
{
"id": "dacc88d7-3f88-469b-9764-35a15681e6c9",
...
"pricingFormat": {
"currencyNumberFormat": "#,###.##",
"symbol": "₩",
"decimalPlaces": 0,
"currencySymbolBeforePrice": true,
"useCurrencySymbolSpace": false
},
"liveMode": false
}
},
...
}
You can use these rules to maintain consistent price formatting. More specifically, you can use them ensure that the prices in your customer notifications and on your site's order management pages have the same format as those on your storefront and in the checkout modal.