0

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

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以及需要哪些字段才能使其成功?

4

1 回答 1

1

贝宝 SDK 非常简单。首先,如果我是你,我会安装他们的示例代码并确保它在你的服务器上工作,根据我以前的经验,很少有 SDK 无法工作并且有 php 版本问题的情况。

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

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

如果操作正确,您将获得一个令牌,

步骤 2.) GetExpressCheckout - 使用之前获得的令牌,您将通过令牌执行 GetExpressCheckout,如果正确,您将获得:Ack、令牌、PayerID、价值、货币ID,基本上是一个包含所有购买详细信息的对象。

步骤 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;
        }
    }
}

我希望这会有所帮助。

于 2013-06-10T12:43:01.910 回答