在PHP中编码Amazon Flexible Payments秘密字符串的问题

前端之家收集整理的这篇文章主要介绍了在PHP中编码Amazon Flexible Payments秘密字符串的问题前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用亚马逊支付服务,他们要求我做这样的事情:

这是完整的签名,所以你可以看到我添加了签名方法

$string_to_sign = "GET\n
authorize.payments-sandBox.amazon.com\n
cobranded-ui/actions/start?
SignatureMethod=HmacSHA256&SignatureVersion=2&callerKey=my_key&callerReference=YourCallerReference&paymentReason=donation&pipelineName=SingleUse&returnUrl=http%3A%2F%2Fyourwebsite.com%2Freturn.html&transactionAmount=4.0";

然后我加密它如下.

$encoded_string_to_sign = URLEncode(Base64_Encode(hash_hmac("sha256",$string_to_sign,'my_secret_key')));

我这样做,但后来我从他们那里得到一个错误说:

Caller Input Exception: The following input(s) are either invalid or absent:[signatureMethod]

知道这里可能出了什么问题吗?

以下是整个代码:(变量分配上面的值)

<?PHP
$string_to_sign = 'GET
authorize.payments-sandBox.amazon.com/cobranded-ui/actions/startSignatureMethod=HmacSHA256&SignatureVersion=2&callerKey=AKIAJENBYSJCJX2IDWDQ&callerReference=YourCallerReference&paymentReason=donation&pipelineName=SingleUse&returnUrl=http%3A%2F%2Fproblemio.com&transactionAmount=4.0';

    $encoded_string_to_sign = URLEncode(Base64_Encode(hash_hmac("sha256",'my_secret_key')));

$amazon_request_sandBox = 'https://authorize.payments-sandBox.amazon.com/cobranded-ui/actions/start?SignatureVersion=2&returnUrl='.$return_url.'&paymentReason='.$payment_reason.'&callerReference=YourCallerReference&callerKey='.$my_access_key_id.'&transactionAmount=4.0&pipelineName=SingleUse&SignatureMethod=HmacSHA256&Signature='.$encoded_string_to_sign;

//echo $amazon_request_sandBox; - use this if you want to see the resulting request and paste it into the browser

header('Location: '.$amazon_request_sandBox);
?>

谢谢!!

检查您是否在请求中包含& SignatureMethod = HmacSHA256

这种错误有三个基本性质:

>缺少键/值
>键/值上的错别字
>键/值上的编码或空格不正确

希望有所帮助!

问候

原文链接:https://www.f2er.com/php/135311.html

猜你在找的PHP相关文章