Helper Methods
Note: Current version does not support the full Checkout by Amazon API.
The helper mainly consists of a AmazonCheckout.cshtml file that should be placed in the App_Code folder of your WebMatrix site.
static void |
Initialize(string merchantId, string awsAccessKeyId = null, string secretKeyId = null, X509Certificate2 x509Certificate = null, string associateTag = null, bool useSandbox = true, string currencyCode = "USD", string lengthUnitOfMeasure = "IN", string volumeUnitOfMeasure = "cubic-cm", string weightUnitOfMeasure = "LB", string jewelryWeightUnitOfMeasure = "LB", string degreeUnitOfMeasure = "degrees", string memorySizeUnitOfMeasure = "GB", string frequencyUnitOfMeasure = "MHz", string amperageUnitOfMeasure = "amps", string timeUnitOfMeasure = "sec", string dateUnitOfMeasure = "days", string assemblyTimeUnitOfMeasure = "minutes", string ageRecommendedUnitOfMeasure = "months", string batteryPowerUnitOfMeasure = "mAh", string voltageUnitOfMeasure = "volts", string wattageUnitOfMeasure = "watts", string temperatureRatingUnitOfMeasure = "degrees-celsius", string clothingSizeUnitOfMeasure = "IN") |
Initializes the Amazon Checkout helper. ExamplesInitialize Helper with AWS Signatures
@{
AmazonCheckout.Initialize( merchantId: "{merchantId}", awsAccessKeyId: "{awsAccessKeyId}", secretKeyId: "{secretKeyId}") } Initialize Helper with X.509 Signatures
@using System.Security.Cryptography.X509Certificates;
Note: to use X.509 certificates you must include the System.Security.dll assembly in the bin folder of the application
@{ AmazonCheckout.Initialize( merchantId: "{merchantId}", x509Certificate: new X509Certificate2(@"pfx-location", "YouPassword"), } |
|
static HelperResult |
GetAmazonButton( string name, string description, Decimal price, string imageUrl, double weight, string categoryName, string promotionId, string condition, string taxTableId, string imageButtonUrl = "https://payments.amazon.com/gp/cba/button?ie=UTF8&color=orange&background=white&size=medium", string alternativeButtonText = "Checkout with Amazon Payments", int quantity = 1, string sku = "", bool expressCheckout = true, string[] upsellingItems = null, string[] inclusionCategories = null, string[] exclusionCategories = null) |
Shows the Checkout By Amazon or the Add to Cart button depending on your configuration |
|
static HelperResult |
GetAmazonButton( AmazonCheckout.AmazonCart shoppingCart, string imageButtonUrl = "https://payments.amazon.com/gp/cba/button?ie=UTF8&color=orange&background=white&size=medium", string alternativeButtonText = "Checkout with Amazon Payments", bool expressCheckout = true) |
Initializes the Amazon CBA helper. |
|
static AmazonCart | CreateAmazonCart() |
Creates an empty Shopping Cart. |
|
static AmazonCart |
AddItem(string name, string description, Decimal price, string imageUrl, int quantity, string sku, double? weight = null, string categoryName = null, string promotionId = null, string condition = null, string taxTableId = null, IEnumerable |
Adds Items to the cart. |
|
AmazonCart |
AddUpsellingItems(IEnumerable |
Add items for upsell in the checkout's process |
|
AmazonCart |
AddInclusionCategories(IEnumerable |
Add an inclusion category in the checkout's process |
|
AmazonCart |
AddExclusionCategories(IEnumerable |
Add an exclusion category in the checkout's process |
|
AmazonCart | WithFixedAmountDiscount(string promotionId, string description, decimal amount) |
Define a Fixed Amount Discount for the Shopping Cart |
|
AmazonCart | WithDiscountRate(string promotionId, string description, decimal value) |
Define a promotion discount for the Shopping Cart |
|
@AmazonCheckout |
GetShoppingCart(Func |
Shows the cart |
|
TaxTable | AddRuleForUSZipRegion(string zipCode, decimal rate, bool isShippingTaxed = false) |
Adds a rule for a ZIP region of type Example
@{
singleItemCart.DefaultTaxTable .AddRuleForPredefinedRegion(AmazonCheckout.AmazonPredefinedRegion.USContinental48States, 0.06m) .AddRuleForUSState("WA", 0.15m, true) .AddRuleForUSZipRegion("98004", 0.03m); } |
|
TaxTable | AddRuleForPredefinedRegion(AmazonPredefinedRegion region, decimal rate, bool isShippingTaxed = false) |
Adds a rule for a predefined regionPossible predefined regionsAmazonCheckout.AmazonPredefinedRegion.USContinental48StatesAmazonCheckout.AmazonPredefinedRegion.USFull50States AmazonCheckout.AmazonPredefinedRegion.USAll AmazonCheckout.AmazonPredefinedRegion.WorldAll |
|
TaxTable | AddRuleForUSState(string stateCode, decimal rate, bool isShippingTaxed = false) |
Adds a rule for a state regionPossible values for stateCodeShow/hide listing |
|
TaxTable | AddRuleForPostalRegion(string postalRegion, decimal rate, bool isShippingTaxed = false) |
Adds a rule for a postal region |
|
TaxTable | AddRuleForCountry(string countryCode, decimal rate, bool isShippingTaxed = false) |
Adds a rule for a country region |
|
ShippingMethod | IncludeUSZipRegion(string zipCode) |
Includes a zip region of a given zip code in the shipping
Example
@{
shoppingCart.ShippingMethods.Add("shipping-1", "Standard shipping") .WithServiceLevel(AmazonCheckout.ServiceLevel.OneDay) .WithItemQuantityBasedShippingRate(5) .WithShipmentBasedShippingRate(10) .WithWeightBasedShippingRate(12) .IncludeCountryRegion("US") .IncludePredefinedRegion(AmazonCheckout.AmazonPredefinedRegion.USFull50States) .IncludeUSZipRegion("98004") .IncludeUSStateRegion("CA") .ExcludeCountryRegion("GB") .ExcludeUSZipRegion("01984") .ExcludeUSStateRegion("AZ"); } |
|
ShippingMethod | IncludePredefinedRegion(AmazonPredefinedRegion region) |
Includes a predefined region in the shipping method
Possible predefined regionsAmazonCheckout.AmazonPredefinedRegion.USContinental48StatesAmazonCheckout.AmazonPredefinedRegion.USFull50States AmazonCheckout.AmazonPredefinedRegion.USAll AmazonCheckout.AmazonPredefinedRegion.WorldAll Example
@{
shoppingCart.ShippingMethods.Add("shipping-1", "Standard shipping") .WithServiceLevel(AmazonCheckout.ServiceLevel.OneDay) .WithItemQuantityBasedShippingRate(5) .WithShipmentBasedShippingRate(10) .WithWeightBasedShippingRate(12) .IncludeCountryRegion("US") .IncludePredefinedRegion(AmazonCheckout.AmazonPredefinedRegion.USFull50States) .IncludeUSZipRegion("98004") .IncludeUSStateRegion("CA") .ExcludeCountryRegion("GB") .ExcludeUSZipRegion("01984") .ExcludeUSStateRegion("AZ"); } |
|
ShippingMethod | IncludeUSStateRegion(string stateCode) |
Includes a US State region in the shipping (See AddRuleForUsState method for a list of possible US State region codes)
|
|
ShippingMethod | IncludePostalRegion(string postalRegion) |
Includes a Postal region in the shipping
|
|
ShippingMethod | IncludeCountryRegion(string countryCode) |
Includes a Country region in the shipping (See AddRuleForCountry method for a list of possible Country region codes)
|
|
ShippingMethod | ExcludeUSZipRegion(string zipCode) |
Excludes a zip region of a given zip code of the shipping
|
|
ShippingMethod | ExcludePredefinedRegion(AmazonPredefinedRegion region) |
Excludes a predefined region in the shipping method
Possible predefined regionsAmazonCheckout.AmazonPredefinedRegion.USContinental48StatesAmazonCheckout.AmazonPredefinedRegion.USFull50States AmazonCheckout.AmazonPredefinedRegion.USAll AmazonCheckout.AmazonPredefinedRegion.WorldAll |
|
ShippingMethod | ExcludeUSStateRegion(string stateCode) |
Excludes a US State region of the shipping (See AddRuleForUsState method for a list of possible US State region codes)
|
|
ShippingMethod | ExcludePostalRegion(string postalRegion) |
Excludes a Postal region in the shipping
|
|
ShippingMethod | ExcludeCountryRegion(string countryCode) |
Excludes a Country region in the shipping (See AddRuleForCountry method for a list of possible Country region codes)
|
|
ShippingMethod | WithServiceLevel(ServiceLevel serviceLevel) |
Possible service levelsAmazonCheckout.ServiceLevel.StandardAmazonCheckout.ServiceLevel.Expedited AmazonCheckout.ServiceLevel.OneDay AmazonCheckout.ServiceLevel.TwoDay Example
@{
shoppingCart.ShippingMethods.Add("shipping-1", "Standard shipping") .WithServiceLevel(AmazonCheckout.ServiceLevel.OneDay) .WithItemQuantityBasedShippingRate(5) .WithShipmentBasedShippingRate(10) .WithWeightBasedShippingRate(12) .IncludeCountryRegion("US") .IncludePredefinedRegion(AmazonCheckout.AmazonPredefinedRegion.USFull50States) .IncludeUSZipRegion("98004") .IncludeUSStateRegion("CA") .ExcludeCountryRegion("GB") .ExcludeUSZipRegion("01984") .ExcludeUSStateRegion("AZ"); } |
|
ShippingMethod | WithShipmentBasedShippingRate(decimal rate) |
|
|
ShippingMethod | WithWeightBasedShippingRate(decimal rate) |
|
|
ShippingMethod | WithItemQuantityBasedShippingRate(decimal rate) |
|