подпись амазонка проблема интеграции - PullRequest
0 голосов
/ 24 августа 2018

Я хочу интегрировать Amazon Pay в мой веб-сайт. У меня ошибка при расчете подписи:

Рассчитанная нами подпись запроса не соответствует подписи, которую вы предоставлена. Проверьте свой секретный ключ доступа AWS и метод подписи. советоваться Сервисная документация для деталей.

Это мой код:

$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>
...