app/template/aneros2023/lp/amazon_pay_lp_js.twig line 1

Open in your IDE?
  1. <script src="{{ AmazonPayV2Api.checkout_script_url }}"></script>
  2. <script>
  3. document.addEventListener('DOMContentLoaded', function () {
  4.   const mounts = ['mid','end']; // <- render twice
  5.   {% for CartIndex, Cart in Carts %}
  6.     {% set cartKey = Cart.cart_key %}
  7.     const cfg_{{ cartKey }} = {
  8.       merchantId: '{{ AmazonPayV2Config.seller_id }}',
  9.       ledgerCurrency: 'JPY',
  10.       checkoutLanguage: 'ja_JP',
  11.       productType: 'PayAndShip',
  12.       placement: 'Cart',
  13.       buttonColor: 'Gold',
  14.       createCheckoutSessionConfig: {
  15.         payloadJSON: '{{ cart[cartKey].payload|raw }}',
  16.         signature: '{{ cart[cartKey].signature }}',
  17.         publicKeyId: '{{ AmazonPayV2Config.public_key_id }}'
  18.       }
  19.     };
  20.     mounts.forEach(function(suffix){
  21.       const sel = '#AmazonPayButtons{{ cartKey }}_' + suffix;
  22.       if (document.querySelector(sel)) {
  23.         amazon.Pay.renderButton(sel, cfg_{{ cartKey }});
  24.       }
  25.     });
  26.   {% endfor %}
  27. });
  28. </script>