Skip to main content

AmazonPayments

This page provides an overview of the payments methods provided by the AmazonPayments adapter in the IXOPAY platform. It also includes a full list of all configuration options available to you when integrating AmazonPayments within your payments landscape, as well as an overview of the parameters required when submitting a transaction via IXOPAY's API.

Payment Methods

Payment MethodTransaction FlowsTransaction Types
AmazonPaymentspayment.jsAll

Integration guide

AmazonPayments require you to display the Amazon Widget on your Checkout page. This is handled by the payment.js integration.

​1. Embed the payment.min.js in your page

<script data-main="payment-js" src="https://gateway.ixopay.com/js/integrated/payment.1.3.min.js"></script>
note

It is important to set the data-main="payment-js" attribute on the script tag.

​2. Provide DIV elements on your page for the various Amazon widgets

<div id='loginButton'></div>
<div id='addressWidgetDiv'></div>
<div id='walletWidgetDiv'></div>
<div id='consentWidgetDiv'></div>

​3. Initialize the payment.js with the following parameters:

  • publicIntegrationKey of the AmazonPayments connector
  • IDs of the DIV elements
  • Javascript function to handle AmazonPayments events
  • Additional parameters (see below in example, refer to AmazonPayments Documentation for possible options)
  • Javascript function to handle initialization completion
<script>
var payment = new PaymentJs('1.2');

amazonEventHandler = function (eventName, data) {
//handle events here
}

completeHandler = function (paymentJsInstance) {
//you can do additional stuff in here, e.g. make the DIVs visible if they were hidden
}

var additionalParameters = {
buttonType: 'PwA', // Type of AmazonPayments Button
buttonColor: 'Gold', // Color of AmazonPayments Button
buttonSize: 'small', // Size of AmazonPayments Button
loginPopup: true, // Use Pop-Up for logging customers in into their Amazon account
autoShow: true, // automatically show AmazonPayments Login button once ready
loginRedirectUrl: // if loginPopup is false, provide the URL to get back redirected after customer logged in to Amazon
};

payment.initAmazon(
'public-integration-key',
'loginButton', // mandatory
'addressWidgetDiv', //optional
'walletWidgetDiv', // mandatory
'consentWidgetDiv', // optional, necessary for recurring transactions
amazonEventHandler,
additionalParameters,
completeHandler
);
</script>

​4. You can react on the various AmazonPayments events in your amazonEventHandler.

If you set autoShow to true, the various widget will be automatically shown to fulfill the payment flow.

If set to false, you have to take care about that on your own.

The following events will be fired:

  • login.ready: ready to show login button
  • login.shown: login button was shown
  • login.error: failed to show login button, data will include code and message with Amazon error information
  • login.complete: customer successfully logged in
  • addressBook.error: failed to show addressBook widget, data will include code and message with Amazon error information
  • addressBook.shown: addressBook widget was shown
  • addressBook.selected: customer has chosen/changed the delivery address
  • wallet.error: failed to show wallet widget, data will include code and message with Amazon error information
  • wallet.selected: customer has chosen a wallet
  • wallet.shown: wallet widget was shown
  • consent.complete: consent was granted by customer
  • consent.incomplete: consent is not yet granted by customer
  • consent.error: failed to show consent widget, data will include code and message with Amazon error information

The individual widgets can be shown and hidden with payment.js methods.

<script>
// show/hide login button
payment.amazon().login.show();
payment.amazon().login.hide();

// show/hide addressBook widget
payment.amazon().addressBook.show();
payment.amazon().addressBook.hide();

// show/hide wallet widget
payment.amazon().wallet.show();
payment.amazon().wallet.hide();

// show/hide consent widget
payment.amazon().consent.show();
payment.amazon().consent.hide();

</script>

​5. Once wallet.selected (or consent.complete to enable recurring transactions) was fired, and the customer confirms the order on your checkout page, you must call the tokenize method to obtain a payment token. This token is then to be used in the transactionToken element of the Debit call to the Transaction API.

<script>
payment.tokenize(
{}, //optional additional data
function (token) {
//Submit token to your server and perform transaction through Transaction API

//Example:
$('#transaction_token').val(token); //store the transaction token
$('#payment_form').get(0).submit(); //submit the form
},
function (errors) {
//show/handle errors
}
);
</script>