授权令牌是无效的FuturePay API

时间:2017-05-30 08:15:00

标签: php authorization token

我正在使用FuturePay APi

在沙盒环境中我调用API但它给出了以下错误。

  

授权令牌无效

响应代码

  

FPE00003

这是我的代码。

    $toekn= $_REQUEST['token'];
    define('FP_API_KEY', 'api key');
    define('FP_SECRET', 'secret');
    header('Content-Type: application/json');

    $postData = http_build_query(array('api_version' => '2','order_action' => 'capture',
              'authorization_token' => $toekn,'reference' => '93840292',
              'amount' => '650.00','order_tag' => 'organic search',
              'order_description' => 'Product 123, 587',
              'soft_descriptor' => 'Merchant Name','merchant_id' => 'QR040893',
              'billing_zip' => '90210','billing_address ' => '1234 Some St',
              'billing_country' => 'US','billing_region' => 'CA',
              'physical_goods' => '0','subscription'=>'0','billing_address'=>'test address'
    ));
    $hash = base64_encode(hash_hmac('sha256', time() . FP_API_KEY . FP_SECRET,
    FP_API_KEY, true));
    $cr = curl_init("https://sandbox.futurepay.com/api/order");
    curl_setopt($cr, CURLOPT_POST, true);
    curl_setopt($cr, CURLOPT_POSTFIELDS, $postData);
    curl_setopt($cr, CURLOPT_HTTPHEADER, array(
     'api_key: ' . FP_SECRET,
     "signature: $hash"
    ));
    curl_setopt($cr, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($cr);
    //echo $response; 
    $json = json_decode($response, true);
    echo $json['message']; //here response is showing The Authorization Token was Invalid

如何摆脱这个错误?任何人使用此FuturePay API

0 个答案:

没有答案