Paypal Express checkout(PHP):交易ID无效(DoAuthorization)

时间:2015-08-10 07:54:53

标签: php curl paypal

我使用Paypal Express Checkout方法购买我的购物车。 paypal支付工作正常。 我在事务处理后使用了沙盒帐户中的正确TRANSACTIONID,但给定的代码始终返回错误Transaction id is invalid

  $request_params = array
        (
        'METHOD' => 'DoAuthorization',
        'USER' => $api_username,
        'PWD' => $api_password,
        'VERSION' => $api_version,
        'TRANSACTIONID'=>$payment['transaction_id'],
        'AMT' => $order['sub_total'],
        'CURRENCYCODE' => 'USD',
        );

   $nvp_string = '';

   foreach ($request_params as $var => $val)
   {
     $nvp_string .= '&' . $var . '=' . urlencode($val);
   }

   $certFile = 'C:\xampp\htdocs\my_project\certificate\cert_key_pem.txt';

   $curl = curl_init();
   curl_setopt($curl, CURLOPT_VERBOSE, 1);
   curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
   curl_setopt($curl, CURLOPT_TIMEOUT, 10);
   curl_setopt($curl, CURLOPT_URL, $api_endpoint);
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($curl, CURLOPT_SSLCERT, $certFile);
   curl_setopt($curl, CURLOPT_POSTFIELDS, $nvp_string

   $result = curl_exec($curl);
   curl_close($curl);

   $result_array = $this->NVPToArray($result);
   echo "<pre>"; print_r($result_array); die();

数组给出的值如下

   Array
   (
    [TIMESTAMP] => 2015-08-10T07:45:36Z
    [CORRELATIONID] => deb2f549572b0
    [ACK] => Failure
    [VERSION] => 85.0
    [BUILD] => 000000
    [L_ERRORCODE0] => 10609
    [L_SHORTMESSAGE0] => Invalid transactionID.
    [L_LONGMESSAGE0] => Transaction id is invalid.
    [L_SEVERITYCODE0] => Error
   )

如果您对Paypal Express Checkout DoAuthorization上的此类错误有任何疑问,请帮助我。感谢

0 个答案:

没有答案