我想将Amazon pay集成到我的网站中。计算签名时出现错误:
我们计算出的请求签名与您的签名不匹配 提供。检查您的AWS Secret Access密钥和签名方法。请教 服务文档以了解详细信息。
这是我的代码:
$config =array( 'merchant_id' => '*********',
'access_key' => '*********',
'secret_key' => '*********',
'client_id' => '*********',
'currency_code' => 'eur',
'region' => '***',
'sandbox' => true);
// Instantiate the client object with the configuration
$client = new Client($config);
$client->setSandbox(true);
//print_r($_SESSION);
$parameters= array();
$parameters['SignatureVersion'] = 2;
$parameters['SignatureMethod'] = "HmacSHA256";
$parameters['AWSAccessKeyId'] = '*******';
//$parameters['Timestamp'] = gmdate("Y-m-d\TH:i:s.\\0\\0\\0\\Z", time());
$parameters['Action'] = "GetCompetitivePricingForASIN";
$signature= new Signature($config,$parameters);
$stringToSign= $signature->calculateStringToSignV2($parameters);
$sig= $signature->sign($stringToSign,"HmacSHA256");
echo $sig;
?>
<div id="addressBookWidgetDiv" style=" min-width: 300px;width: 100%;max-width: 900px;min-height: 228px;height: 240px;max-height: 400px;"></div>
<div id="walletWidgetDiv" style="min-width: 300px;width: 100%;max-width: 900px;min-height: 228px;height: 240px;max-height: 400px;"></div>
<form name="form" action="https://mws-
eu.amazonservices.com/schema/OffAmazonPayments" method ="post">
<input type ="text" name ="AWSAccessKeyId"
value="AKIAIAQIYNXL6NOOWJDA">
<input type ="text" name="Action" value ="SetOrderAttributes">
<input type="text" name="AmazonOrderReferenceId" id="orderReferenceId">
<input type="text" name="OrderReferenceAttributes.OrderTotal.Amount" value="<? echo $_SESSION['totalPrice']+$_SESSION['shipping'] ;?>">
<input type="text" name ="OrderAttributes.OrderTotal.CurrencyCode" value ="EUR">
<input type "text" name="OrderAttributes.SellerOrderAttributes.SellerOrderId" value ="5678-23">
<input type ="text" name="OrderAttributes.SellerOrderAttributes.StoreName" value="original-laguiole">
<input type="text" name="MWSAuthToken" value="<?= $_GET['access_token'] ?>">
<input type="text" name="SignatureMethod" value="HmacSHA256">
<input type="text" name="SignatureVersion" value="2">
<input type="text" name="Timestamp" value="<? echo gmdate('Y-m-d\TH:i:s.u\Z');?>">
<input type="text" name="Signature" value="<? echo $sig;?>">
<input type="text" name="Version" value="2018-08-02">
<input style="height:36px;margin-left:0%" type="submit" value="Submit
Order">
</form>