Introduction
Microsoft WebMatrix provides an easy way to get started with web development, and together with new Razor syntax for ASP.NET Web Pages it includes everything you need to get your web site up, running and integrated with many other sites and networks, in a short period of time. The WebMatrix helpers are designed to make your life easier when creating web sites. They provide you a simple and consistent way of performing common web development tasks that otherwise would require a great deal of custom coding. With a few lines of code you should be able to secure your web site using membership, store information in Windows Azure Storage, integrate your site with Amazon, among others things.
The Amazon Checkout Helper for WebMatrix makes it simple to integrate features such a Checkout by Amazon Shopping carts, 1-Click, and Flexible Payment Services in your site. For example, you can use a shopping cart widgets with all the features that it already has the Amazon.com Website, and relay on its security and confidentiality offered by Amazon and Microsoft in a few lines of code.
Getting Started in 60 Seconds
These steps will guide you on how to display the Amazon Checkout button.
- Add the following line to the _AppStart.cshtml page of your WebMatrix
Site (if the file does not already exist, create it in the root of the website).
Note: the Merchand Id, awsAccessKeyId and secretKeyId must be provided. For instructions on how to provision a Seller Central account and obtain these parameters, you can read the Integration Guide for Checkout by Amazon@{ AmazonCheckout.Initialize("{merchand-key}", awsAccessKeyId:"XXX", secretKeyId:"XXX"); }
- In any WebMatrix page, add the following code to display the Checkout button:
@AmazonCheckout.GetAmazonButton("productName", "description", 10, //Price: must be a decimal value. "imageUrl", 5, //Weight: must be a double value. "categoryName", "promotionId", "amazonCondition", "amazonTaxTableId", )
These steps will guide you on how to add Shopping cart functionallity
- Add the following line to the _AppStart.cshtml page of your WebMatrix
Site (if the file does not already exist, create it in the root of the website).
Note: the Merchand Id, awsAccessKeyId and secretKeyId must be provided. For instructions on how to provision a Seller Central account and obtain these parameters, you can read the Integration Guide for Checkout by Amazon@{ AmazonCheckout.Initialize("{merchand-key}"); }
- It makes sense to put an access button to the shopping cart in the head section. To do this, in the _SiteLayout.cshtml, on the Head section add the following code:
@AmazonCheckout.GetShoppingCart()
- Below every product item, add the following code to show the "Add to shopping cart" button:
@AmazonCheckout.GetAmazonButton("productName", "description", 10, //Price: must be a decimal value. "imageUrl", 5, //Weight: must be a double value. "categoryName", "promotionId", "amazonCondition", "amazonTableId" )
Running the Amazon Checkout Helper Sample
Optionally, you can download a sample WebMatrix web site where you can see the helper in action. This sample also demonstrates how to handle a Checkout By Amazon and the Shopping Cart functionallity. To download and run it with Microsoft WebMatrix, follow these steps:
- Download the sample site from the helper's Codeplex site, Downloads section. Extract the contents and open the folder in WebMatrix.
- Update the _AppStart.cshtml file to replace the following placeholders:
- Replace the {yourMerchantId} placeholder with the Merchant Id you can find in the Seller Central site.
- Replace the {yourAwsAccessKey} placeholder with the AWS Access Key you can find in the Seller Central site.
- Replace the {yourAwsSecretKey} placeholder with the AWS Secret Key you can find in the Seller Central site.
- Replace the {yourAssociateTag} placeholder with the Associate Tag Key you can find in the Seller Central site.
- Configure the site URL to match the ReturnUrl configured in Seller Central. To do this, perform the following steps:
- From the Seller Central site, configure the return URL to <yourSiteUrl>\Thankyou.cshtml, replacing the <yourSiteUrl> with the URL of your site. For more information on how to configure the return URL in Seller Central you can read the Integration Guide for Checkout by Amazon NOTE: For development purposes, you can use 127.0.0.1:8088 as your site URL.
- In the Web Matrix, in the right menu, click the Site option.
- In the right menu, click the Settings option.
- In the Settings main content page, set the site URL to <yourSiteUrl>
You can find more information about the Amazon API in https://payments.amazon.com/sdui/sdui/helpTab .
Learn more on WebMatrix, ASP.NET Web Pages and the Razor Syntax with the WebMatrix tutorials.