Payment Gateway Integration using Amazon Simple Pay Standard

Finding out a way to integrate Amazon Payment Gateway into the application needed lot of exploration. There is too much documentation available on AMAZON on this, but nowhere has it provided concrete guidelines to do this. I thought I would share my experience in achieving this for the community.

Creating an Amazon business Account.

To create an Amazon business account, the website should have a business name, contact information, credit card with US billing address.

Click Create account on the top-right corner and continue with the procedure

You will have to use a Sandbox account while development so that you won’t use your real money

Creating an Amazon Developer Account.

Go to and click the Developer tab.

Click on Sign up for this Service

Then, on the next page showed up, click Sign Up

Creating the Configuration Keys

Sign in to

Configure your Amazon Simple Pay Standard Button



Click on the Generate HTML Button

<form action=”” method=”post”>

  <input value=”1″ >

  <input value=”USD 10″ >

  <input value=”0″ >

  <input value=”qQrYG0ZOONZoEfMdGIYDiyyfuT7sRlKIbOvKduwni0Y=” >

  <input value=”0″ >

  <input value=”2″ >

  <input value=”HmacSHA256″ >

  <input value=”Items Purchased” >

  <input value=”FGDADFJKOCLR2Z75XNKN2K6N85KUNZ183JU9SM” >

  <input value=”11SEM03K88SD016FS1G2″ >

  <input value=”logo” >

  <input value=”1″ >

  <input src=”” border=”0″>



Please Note the “accessKey”, “signature”, “description”, “amazonPaymentsAccountId” and the action of the form and configure these as parameters in your configuration file.

Adding keys to the Configuration File

    <add key=”AccessKeyID” value=”11SEM03K88SD016FS1G2″/>

    <add key=”signature” value=”5cYOI8O6e01WyGgXq7nHT4JJam9hia51nD+H38B4H+Q=”/>

    <add key=”amazonPaymentsAccountId” value=”FGDADFJKOCLR2Z75XNKN2K6N85KUNZ183JU9SM”/>

    <add key=”description” value=”Candles Purchased”/>

    <add key=”AmazonPaymentUrl” value=””/>

Wiring up the Shopping Cart

1)      Creating a class by name PaymentGatewayPost

public class PaymentGatewayPost


        public System.Collections.Specialized.NameValueCollection ListParams = new System.Collections.Specialized.NameValueCollection();

        public string Url = “”;

        public string Method = “post”;

        public string FormName = “form1”;


        public void Add(string name, string value)


            ListParams.Add(name, value);



        public void Post()




            System.Web.HttpContext.Current.Response.Write(string.Format(“</head><body onload=”document.{0}.submit()”>”,FormName));

            System.Web.HttpContext.Current.Response.Write(string.Format(“<form name=”{0}” method=”{1}” action=”{2}” >”,FormName, Method, Url));

            int i = 0;


            while (i < ListParams.Keys.Count)


                System.Web.HttpContext.Current.Response.Write(string.Format(“<input name=”{0}” type=”hidden” value=”{1}”>”,ListParams.Keys[i], ListParams[ListParams.Keys[i]]));

                i += 1;









2)      Create a method and attach this method to your check out functionality.

Check out for the documentation of parameters.

     public void DoPayment(ShoppingCart order)


           string amt = order.Amount ToString();

           Uri gatewayUrl = new Uri(GetConfigValue(“AmazonPaymentUrl”));

           PaymentGatewayPost post = new PaymentGatewayPost();

           post.FormName = “SimplePay”;

           post.Url = gatewayUrl.ToString();

           post.Method = “Post”;

           post.Add(“description”, GetConfigValue(“description”));

           post.Add(“immediateReturn”, “1”);

           post.Add(“signatureVersion”, “2”);

           post.Add(“signatureMethod”, “HmacSHA256”);

           post.Add(“accessKey”, GetConfigValue(“AccessKeyID”));

           post.Add(“referenceId”, order.ReceiptId);//

           post.Add(“signature”, GetConfigValue(“signature”));

           post.Add(“amazonPaymentsAccountId”, GetConfigValue(“amazonPaymentsAccountId”));

           post.Add(“amount”, order.CurrencyCode + ” ” + amt);//

          post.Add(“returnUrl”, GetConfigValue(“ThankYouUrl”) + “?PayType=Amazon”); //where to return after finishing with transaction

           post.Add(“processImmediate”, “1”); //0 will reserve the payment, 1 will process it immediatelly

           post.Add(“abandonUrl”, GetConfigValue(“CancelUrl”) + “?PayType=Amazon”); //same as return url

           post.Post(); //make the post


3)       Reading the Response of the post on the return URL Page.

Check out for for the documentation of response parameters 

     if (Request.QueryString[“status”].Trim().Equals(“PS”) && !string.IsNullOrEmpty(Request.QueryString[“transactionId”].Trim()))


                        transactionId = Request.QueryString[“transactionId”];


Co-Branding the Amazon site.

Co-branding is the way you can provide your custom logo at the AMAZON site. This is the only way you can provide a user experience so that user feels that he is navigating in your website when integrating using this method.

Happy Coding!!!!

Posted in:

Leave a Reply