Gracias por tu visita. Esta página solo está disponible en inglés.
 Step 2. Build and create an Amazon Pay button | Amazon Pay

Step 2. Build and create an Amazon Pay button

If the payment amount used for your button is variable, like when customers use a shopping cart to make purchases, then you need to use JavaScript to add the Amazon Pay button to your website. This topic includes an example of what your code might look like.

When the amount changes on the checkout page and cannot be preloaded, the signature must be recalculated for each request. You should calculate the signature immediately before passing the payment parameters to hostedParametersProvider. The following example shows how you might do this by using a JQuery.getJSON call to your backend and then hooking up a successful response with the hostedParametersProvider done function. The done function ends the Amazon button creation steps.

Example: Making a getJSON call to the backend and hooking in the hostedParametersProvider done function for the Amazon Pay button:

<div id="AmazonPayButton"/>
<script type="text/javascript">
   OffAmazonPayments.Button("AmazonPayButton", "SELLERID_HERE", {
     type: "hostedPayment",

     hostedParametersProvider: function(done){
        args = {
           amount: $("paymentAmount").val(),
           currencyCode: $("amountCurrencyCode").val(),
           sellerNote: $("noteToBuyer").val()
        // Call the back end to combine button args with
        // other seller config param values and sign it.
           function(data) {
              done (data)
        onError: function(errorCode) {
            // your error handling code

The parameters in the sample above are described in Step 3: Specify the parameter values.

Security warning: Do not expose your MWS secret key in your webpage's JavaScript or HTML code. Because your MWS secret key is used for authentication, keep it private in your backend.