快速结账无法正常工作。它给出了ACK失败

时间:2013-06-10 12:17:40

标签: php codeigniter

我正在使用PAYPAL创建Expresscheckout API。设置expresscheckout并使expresscheckout正常工作。我从这两个步骤得到了一个tocken和payerid。但是当我转到DoExpresscheckout时,它会让我失败。

DoExpressCheckoutPaymentResponseType Object
(
    [DoExpressCheckoutPaymentResponseDetails] => 
    [FMFDetails] => 
    [Timestamp] => 2013-06-10T12:15:02Z
    [Ack] => Failure
    [CorrelationID] => a88b9b744676a
    [Errors] => Array
        (
            [0] => ErrorType Object
                (
                    [ShortMessage] => This Express Checkout session has expired.
                    [LongMessage] => This Express Checkout session has expired.  Token value is no longer valid.
                    [ErrorCode] => 10411
                    [SeverityCode] => Error
                    [ErrorParameters] => 
                )

        )

    [Version] => 98.0
    [Build] => 6341744
)

是否有任何人拥有DoExpresscheckout的正确代码以及需要哪些字段才能使其成功?

1 个答案:

答案 0 :(得分:1)

好的paypal SDK非常简单。首先,如果我是你,我会安装他们的示例代码,并确保它在您的服务器上工作,从我以前的经验,很少见的情况下SDK不会工作,并有PHP版本问题。

其次,在您确定它在您的服务器上运行后,图表流程为:

步骤1.)SetExpressCheckout - 包含所有必填字段:帐单地址,产品购物车总数等...

如果这样做是正确的,你将获得一个令牌,

步骤2.)GetExpressCheckout - 使用先前获得的令牌,您将执行GetExpressCheckout传递令牌,如果完成正确,您将获得:Ack,Token,PayerID,value,currencyID以及基本上已完成所有购买的对象细节。

步骤3.)DoExpressCheckout - 使用从2获取的字段来执行DoExpressCheckout,如下所示:

$path = $pluginfolder.'paypal/lib';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
require_once('services/PayPalAPIInterfaceService/PayPalAPIInterfaceServiceService.php');
require_once('PPLoggingManager.php');

$logger = new PPLoggingManager('DoExpressCheckout');

$token = urlencode( $getToken );
$payerId = urlencode(  $getPayerID);
$paymentAction = urlencode(  $paymentType);

$orderTotal = new BasicAmountType();
$orderTotal->currencyID = $getCurrencyID;
$orderTotal->value = $getOrderTotal;

$paymentDetails= new PaymentDetailsType();
$paymentDetails->OrderTotal = $orderTotal;
if(isset($notifyURL))
{
    $paymentDetails->NotifyURL = $notifyURL;
}

$DoECRequestDetails = new DoExpressCheckoutPaymentRequestDetailsType();
$DoECRequestDetails->PayerID = $payerId;
$DoECRequestDetails->Token = $token;
$DoECRequestDetails->PaymentAction = $paymentAction;
$DoECRequestDetails->PaymentDetails[0] = $paymentDetails;

$DoECRequest = new DoExpressCheckoutPaymentRequestType();
$DoECRequest->DoExpressCheckoutPaymentRequestDetails = $DoECRequestDetails;


$DoECReq = new DoExpressCheckoutPaymentReq();
$DoECReq->DoExpressCheckoutPaymentRequest = $DoECRequest;

/*
* Trying to go a head with the payment and catching errors that might occure.
*/
try {
    /* wrap API method calls on the service object with a try catch */
    $DoECResponse = $paypalService->DoExpressCheckoutPayment($DoECReq);
} catch (Exception $ex) {
    if(isset($ex)) {
        $ex_message = $ex->getMessage();
        $ex_type = get_class($ex);

        if($ex instanceof PPConnectionException) {
            $error[] = "Error connecting to " . $ex->getUrl();
            $errorCheck =  true;
        } else if($ex instanceof PPMissingCredentialException || $ex instanceof PPInvalidCredentialException) {
            $error[] = $ex->errorMessage();
            $errorCheck =  true;
        } else if($ex instanceof PPConfigurationException) {
            $error[] = "Invalid configuration. Please check your configuration file";
            $errorCheck =  true;
        }
    }
}

我希望有所帮助。