我一直在尝试使用 amazon sdk for .net 将 amazon pay 与我的 mvc 应用程序集成。我按照此处提到的步骤进行操作。我可以使用在卖家账户中创建的私钥和公钥创建客户端。
using Amazon.Pay.API.Types;
using Amazon.Pay.API.WebStore;
public class Sample
{
public WebStoreClient InitiateClient()
{
// set up config
var payConfiguration = new ApiConfiguration
(
region: Region.Europe,
publicKeyId: "MY_PUBLIC_KEY_ID", // LIVE-XXXXX or SANDBOX-XXXXX
privateKey: "PATH_OR_CONTENT_OF_MY_PRIVATE_KEY"
);
// init API client
var client = new WebStoreClient(payConfiguration);
return client;
}
}
当我尝试创建签名时使用客户端我收到异常为不支持的私钥格式
using Amazon.Pay.API.WebStore.CheckoutSession;
using Amazon.Pay.API.WebStore;
public class Sample : PageModel
{
// ..
public string Signature { get; private set; }
public string Payload { get; private set; }
public void OnGet()
{
// prepare the request
var request = new CreateCheckoutSessionRequest
(
checkoutReviewReturnUrl: "https://example.com/review.html",
storeId: "amzn1.application-oa2-client.000000000000000000000000000000000"
);
// generate the button signature
var signature = client.GenerateButtonSignature(request);
// generate the signature and payload string that is passed back to the frontend
Signature = client.GenerateButtonSignature(request);
Payload = request.ToJson();
}
}
异常的堆栈跟踪
at Amazon.Pay.API.SignatureHelper.GenerateSignature(String stringToSign)
at Amazon.Pay.API.WebStore.WebStoreClient.GenerateButtonSignature(String jsonString)
at Amazon.Pay.API.WebStore.WebStoreClient.GenerateButtonSignature(CreateCheckoutSessionRequest request)