从DoExpressCheckoutPayment回复中获取transactionId

时间:2012-10-09 21:45:04

标签: php paypal express-checkout

我无法获得交易ID以及来自doexpresscheckoutpayment的回复中的其他信息,我花了几个晚上阅读但我要么不理解发生什么事情或者我得错了什么

这里有一些代码

    function ConfirmPayment( $FinalPaymentAmt )
{

    //Format the other parameters that were stored in the session from the previous calls   
    $token              = urlencode($_SESSION['TOKEN']);
    $paymentType        = urlencode($_SESSION['PaymentType']);
    $currencyCodeType   = urlencode($_SESSION['currencyCodeType']);
    $payerID            = urlencode($_SESSION['payer_id']);

    $serverName         = urlencode($_SERVER['SERVER_NAME']);

    $nvpstr  = '&TOKEN=' . $token . '&PAYERID=' . $payerID . '&PAYMENTREQUEST_0_PAYMENTACTION=' . $paymentType . '&PAYMENTREQUEST_0_AMT=' . $FinalPaymentAmt;
    $nvpstr .= '&PAYMENTREQUEST_0_CURRENCYCODE=' . $currencyCodeType . '&IPADDRESS=' . $serverName; 

     /* Make the call to PayPal to finalize payment
        If an error occured, show the resulting errors
        */
    $resArray=hash_call("DoExpressCheckoutPayment",$nvpstr);

    /* Display the API response back to the browser.
       If the response from PayPal was a success, display the response parameters'
       If the response was an error, display the errors received using APIError.php.
       */
    $ack = strtoupper($resArray["ACK"]);

    return $resArray;
}

然后

$resArray = ConfirmPayment($finalPaymentAmount);
$ack = strtoupper($resArray["ACK"]);
if ($ack == "SUCCESS" || $ack == "SUCCESSWITHWARNING") {

    $transactionId = $resArray["TRANSACTIONID"]; // ' Unique transaction ID of the payment. Note:  If the PaymentAction of the request was Authorization or Order, this value is your AuthorizationID for use with the Authorization & Capture APIs.
    $transactionType = $resArray["TRANSACTIONTYPE"]; //' The type of transaction Possible values: l  cart l  express-checkout
    $paymentType = $resArray["PAYMENTTYPE"]; //' Indicates whether the payment is instant or delayed. Possible values: l  none l  echeck l  instant
    $orderTime = $resArray["ORDERTIME"]; //' Time/date stamp of payment

等等

doexprescheoutpayment工作,因为它确实完成了paypal支付,它只是$ transactionID和其他人总是空的,我想记录这些

可以指出我正确的方向

感谢 克雷格

1 个答案:

答案 0 :(得分:2)

根据PayPal's DoExpressCheckoutPayment API操作文档:

  

自版本63.0起,不推荐使用TRANSACTIONID。使用   改为PAYMENTINFO_n_TRANSACTIONID。

同样,不推荐使用PAYMENTTYPETRANSACTIONTYPEORDERTIME。在响应消息中检查提供的链接以获取更新的变量名称。