我正在尝试将亚马逊支付网关与我的 .net 核心项目集成。我想知道是否有一种方法可以通过形成具有所需查询参数的 url 来重定向用户,而不是通过点击亚马逊按钮触发付款。但不幸的是,我在 amazon pay sdk for .net 或 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
};
}
我可以通过类似的方式进行贝宝集成(我正在使用 CreateQueryParameters 函数来形成贝宝的 url 查询)。因此,如果有人知道是否可以为亚马逊支付进行类似的集成,那么查询应该如何以及我们需要使用的亚马逊支付端点是什么?