Merci de votre visite. Cette page est disponible en anglais uniquement.

HAQM Pay script


HAQM Pay script

Add the HAQM Pay script to your HTML file to enable front-end functionality on your website.

<script src="http://static-na.payments-haqm.com/checkout.js"></script>
<script src="http://static-eu.payments-haqm.com/checkout.js"></script>
<script src="http://static-fe.payments-haqm.com/checkout.js"></script>

Render the HAQM Pay button

Use amazon.Pay.renderButton() to render the HAQM Pay button to a HTML container element.

The HAQM Pay script will make an AJAX request using the configuration provided for the createCheckoutSession button parameter. The response must be in JSON format.

Code sample

<body>
    <div id="HAQMPayButton"></div>
    <script src="http://static-na.payments-haqm.com/checkout.js"></script>
    <script type="text/javascript" charset="utf-8">
        amazon.Pay.renderButton('#HAQMPayButton', {
            merchantId: 'merchant_id',
            createCheckoutSession: {
                url: 'http://mystore/amazonpay/createcheckoutsession'
            },
            sandbox: true, // dev environment
            ledgerCurrency: 'USD', // HAQM Pay account ledger currency
            checkoutLanguage: 'en_US', // render language
            productType: 'PayAndShip', // checkout type
            placement: 'Cart', // button placement
            buttonColor: 'Gold'
        });
    </script>
</body>
<body>
    <div id="HAQMPayButton"></div>
    <script src="http://static-eu.payments-haqm.com/checkout.js"></script>
    <script type="text/javascript" charset="utf-8">
        amazon.Pay.renderButton('#HAQMPayButton', {
            merchantId: 'merchant_id',
            createCheckoutSession: {
                url: 'http://mystore/amazonpay/createcheckoutsession'
            },
            sandbox: true, // dev environment
            ledgerCurrency: 'EUR', // HAQM Pay account ledger currency
            checkoutLanguage: 'en_GB', // render language
            productType: 'PayAndShip', // checkout type
            placement: 'Cart', // button placement
            buttonColor: 'Gold'
        });
    </script>
</body>
<body>
    <div id="HAQMPayButton"></div>
    <script src="http://static-eu.payments-haqm.com/checkout.js"></script>
    <script type="text/javascript" charset="utf-8">
        amazon.Pay.renderButton('#HAQMPayButton', {
            merchantId: 'merchant_id',
            createCheckoutSession: {
                url: 'http://mystore/amazonpay/createcheckoutsession'
            },
            sandbox: true, // dev environment
            ledgerCurrency: 'GBP', // HAQM Pay account ledger currency
            checkoutLanguage: 'en_GB', // render language
            productType: 'PayAndShip', // checkout type
            placement: 'Cart', // button placement
            buttonColor: 'Gold'
        });
    </script>
</body>
<body>
    <div id="HAQMPayButton"></div>
    <script src="http://static-fe.payments-haqm.com/checkout.js"></script>
    <script type="text/javascript" charset="utf-8">
        amazon.Pay.renderButton('#HAQMPayButton', {
            merchantId: 'merchant_id',
            createCheckoutSession: {
                url: 'http://mystore/amazonpay/createcheckoutsession'
            },
            sandbox: true, // dev environment
            ledgerCurrency: 'JPY', // HAQM Pay account ledger currency
            checkoutLanguage: 'ja_JP', // render language
            productType: 'PayAndShip', // checkout type
            placement: 'Cart', // button placement
            buttonColor: 'Gold'
        });
    </script>
</body>

Parameters

Parameter
Description
merchantId
(required)

Type: string
HAQM Pay merchant account identifier
createCheckoutSession
(required)

Type: createCheckoutSession
Configuration for calling your endpoint to Create Checkout Session. The response must be in JSON format
placement
(required)

Type: string
Placement of the HAQM Pay button on your website

Supported values: ‘Home’, ‘Product’, ‘Cart’, ‘Checkout’, and 'Other'
ledgerCurrency
(required)

Type: string
Ledger currency provided during registration for the given merchant identifier

Supported values:
  • US merchants - 'USD'
  • EU merchants - 'EUR'
  • UK merchants - 'GBP'
  • JP merchants - 'JPY'
productType

Type: string
Product type selected for checkout

Supported values:
  • 'PayAndShip' - Offer checkout using buyer's HAQM wallet and address book. Select this product type if you need the buyer's shipping details
  • 'PayOnly' - Offer checkout using only the buyer's HAQM wallet. Select this product type if you do not need the buyer's shipping details
Default value: 'PayAndShip'
buttonColor

Type: string
Color of the HAQM Pay button

Supported values: 'Gold', 'LightGray', 'DarkGray'
Default value: 'Gold'
checkoutLanguage

Type: string
Language used to render the button and text on HAQM Pay hosted pages. Please note that supported language(s) is dependent on the region that your HAQM Pay account was registered for

Supported values: 
  • US merchants - 'en_US'
  • EU/UK merchants - 'en_GB', 'de_DE', 'fr_FR', 'it_IT', 'es_ES'
  • JP merchants - 'ja_JP'
sandbox

Type: boolean
Sets button to Sandbox environment

Default value: false

Type: createCheckoutSession

Parameter
Description
url
(required)

Type: string
Your endpoint URL to Create Checkout Session
method

Type: string
HTTP request method

Supported values: 'GET', 'POST'
Default value: 'POST'
extractHAQMCheckoutSessionId

Type: string
Checkout Session ID parameter in the response

Default value: 'checkoutSessionId'

Enable checkout info updates

Use amazon.Pay.bindChangeAction() to enable updates in case the buyer wants to select a different shipping address or payment method.

Code sample

<script type="text/javascript" charset="utf-8">
    amazon.Pay.bindChangeAction('#changeButton1', {
      amazonCheckoutSessionId: 'xxxx',
      changeAction: 'changeAddress'
    });
</script>

Parameters

Parameter
Description
amazonCheckoutSessionId
(required)

Type: string
HAQM Pay Checkout Session identifier
changeAction
(required)

Type: string
Update requested by the buyer

Supported values: 'changeAddress', 'changePayment'

Sign out from HAQM

Use amazon.Pay.signout() to give buyers the option of signing out from their HAQM account.

Best practice: Give buyers the option of signing out after they complete checkout. Bind the function to a “Sign out from HAQM” link on your order confirmation page.

Code sample

<script type="text/javascript">
  document.getElementById('Signout').onclick = function() {
    amazon.Pay.signout();
  };
</script>