Along with creating the HTML for Amazon Simple Pay buttons manually, you can build the HTML form request dynamically using code. This enables you to set the amount to charge the customer dynamically as well, and generate the button request for the user.
This technique enables you to manipulate the transaction between the time the user clicks your button and when the Amazon Payments portion of the transaction begins.
Generating a Button Request For the User
| 1 |
Add an option to your web page, such as a radio button, that enables a buyer to select Amazon Payments as a payment instrument. Use one of the logos from our logo guidelines document to implement the radio button.
|
| 2 | Use the procedure presented in previous sections to generate the complete HTML form for the button (including product parameters and signing information). For more information, see Creating Button Forms Dynamically. Do not render this HTML until the user clicks the button you created in step 1. |
| 3 |
When the buyer selects Amazon Payments as a payment instrument, render the form and submit it immediately. There are a variety of ways to do this. For example, you could submit the form in the body.onload event:
Since the form's ACTION attribute is to Amazon Payments, the buyer completes the purchase as with an Amazon Simple Pay static button. |
For a complete example, see Adding Amazon as an Additional Payment Option.