Integrating without the AddressBook widget
In some cases, such as when you are selling digital products or want to collect a buyer's address on your own, you might not want to collect the buyer's address from the AddressBook widget.
Note: If you do not use the Amazon AddressBook widget to collect an address from the buyer, the transaction will not be covered under the Amazon Pay Payment Protection Policy. For more information about the Amazon Pay Payment Protection Policy, see the Amazon Pay User Agreement.
When an AddressBook widget is shown, an Order Reference object is created. When you integrate without an AddressBook widget, you need to create an Order Reference object by specifying an onOrderReferenceCreate callback function as one of the parameters in the Wallet widget call.
The onOrderReferenceCreate function is called with an Order Reference object when the widget renders. You can get the orderReferenceId by calling the getAmazonOrderReferenceId() function on the Order Reference object. You must store the Order Reference ID as you will need it throughout transaction processing.
The following example shows how to render the Wallet widget when you do not use the AddressBook widget:
<div id="walletWidgetDiv">
</div>
<script>
var orderReferenceId = null;
new OffAmazonPayments.Widgets.Wallet({
sellerId: 'YOUR_SELLER_ID_HERE',
// Add the onOrderReferenceCreate function to
// generate an Order Reference ID.
onOrderReferenceCreate: function(orderReference) {
// Use the following cod to get the generated Order Reference ID.
orderReferenceId = orderReference.getAmazonOrderReferenceId();
},
design: {
designMode: 'responsive'
},
onPaymentSelect: function(orderReference) {
// Replace this code with the action that you want to perform
// after the payment method is selected.
// Ideally this would enable the next action for the buyer
// such as a "Continue" or "Place Order" button.
},
onError: function(error) {
// Your error handling code.
// During development you can use the following
// code to view error messages:
// console.log(error.getErrorCode() + ': ' + error.getErrorMessage());
// See "Handling Errors" for more information.
}
}).bind("walletWidgetDiv");
</script>
You must specify width and height parameters. Otherwise, the widgets don't render. For more information, see the "CSS code for payment widgets" section of Payment widgets.