I am trying to integrate amazon payment gateway with my .net core project. I am wondering if there is a way to redirect the user by forming a url with required query params rather than triggering the payment from the amazon button click. But unfortunately I could not find any documentation in the amazon pay sdk for .net or amazon pay developer docs.
public async Task PostRedirectPayment(PaymentTransaction paymentTransaction)
{
var order = await _orderService.GetOrderByGuid(paymentTransaction.OrderGuid);
//create common query parameters for the request
var queryParameters = await CreateQueryParameters(order);
await AddOrderTotalParameters(queryParameters, order);
var Signature=SignParameters(queryParameters, secretKey);
IDictionary<String, String> SortedParameters = new SortedDictionary<String, String>(queryParameters, StringComparer.Ordinal);
SortedParameters.Add("signature", System.Web.HttpUtility.UrlEncode(Signature));
//remove null values from parameters
queryParameters = SortedParameters.Where(parameter => !string.IsNullOrEmpty(parameter.Value))
.ToDictionary(parameter => parameter.Key, parameter => parameter.Value);
//var url = JsonConvert.SerializeObject(SortedParameters);
var url = QueryHelpers.AddQueryString(GetAmazonPayUrl(), queryParameters);
_httpContextAccessor.HttpContext.Response.Redirect(url);
}
private async Task<IDictionary<string, string>> CreateQueryParameters(Order order)
{
//create query parameters
return new Dictionary<string, string>
{
//the character set and character encoding
// ["charset"] = "utf-8",
//set return method to "2" (the customer redirected to the return URL by using the POST method, and all payment variables are included)
//["rm"] = "2",
["accessKey"] = "my access key",
["sellerId"] = "my seller id",
["lwaClientId"] = "my client id",
//PDT, IPN and cancel URL
["return"] = $"{storeLocation}/PDTHandler?custom={order.OrderGuid}",
//["notify_url"] = $"{storeLocation}/IPNHandler",
["cancelReturnURL"] = $"{storeLocation}/CancelOrder",
//order identifier
["sellerOrderId"] = order.OrderNumber.ToString(),
//["custom"] = order.OrderGuid.ToString(),
["sellerNote"]="",
["currencyCode"] = order.CustomerCurrencyCode,
["shippingAddressRequired"]="false",
["paymentAction"]= "AuthorizeAndCapture"
//shipping address, if exists
["no_shipping"] = order.ShippingStatusId == ShippingStatus.ShippingNotRequired ? "1" : "2",
["address_override"] = order.ShippingStatusId == ShippingStatus.ShippingNotRequired ? "0" : "1",
["first_name"] = order.ShippingAddress?.FirstName,
["last_name"] = order.ShippingAddress?.LastName,
["address1"] = order.ShippingAddress?.Address1,
["address2"] = order.ShippingAddress?.Address2,
["city"] = order.ShippingAddress?.City,
["stateOrRegion"] = stateProvince,
["country"] = countryCode,
["postalCode"] = order.ShippingAddress?.ZipPostalCode,
["email"] = order.ShippingAddress?.Email
};
}
I could do paypal integration by similar way( I am using CreateQueryParameters function to form the url query for paypal) . So if anyone know if its possible to do similar integration for amazon pay, how should be the query and what would be the amazon pay end point we need to use?