我正在尝试使用亚马逊支付服务,他们要求我做这样的事情:
原文链接:https://www.f2er.com/php/135311.html$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); ?>
谢谢!!