3

我使用了 paypal php sdk:

https://github.com/paypal/merchant-sdk-php/blob/master/samples/RecurringPayments/CreateRecurringPaymentsProfile.php

快速结帐运作良好,但使用定期付款有问题:令牌无效。sdk中的第152行,据说

一个带时间戳的令牌,其值在对 SetExpressCheckout 的第一次调用的响应中返回。为 SetExpressCheckout 请求中包含的每个计费协议调用一次 CreateRecurringPaymentsProfile,并为每个调用使用相同的令牌。每个 CreateRecurringPaymentsProfile 请求都会创建一个定期付款资料。

但我不明白如何“在 SetExpressCheckout 中调用 CreateRecurringPaymentsProfile 一次”,有我的代码:

public function createPayToken($returnUrl, $cancelUrl, $payModeData) {
    $itemName = $payModeData['name'];
    $order    = $payModeData['fee'];

    // $category = 'Digital';
    $category = 'Physical';

    $currencyCode = "USD";

    $paymentDetails = new PaymentDetailsType();

    $itemAmount = new BasicAmountType($currencyCode, $order);

    $itemDetails = new PaymentDetailsItemType();
    $itemDetails->Name = $itemName;
    $itemDetails->Amount = $itemAmount;
    $itemDetails->Quantity = 1;
    $itemDetails->ItemCategory = $category;

    $paymentDetails->OrderTotal = new BasicAmountType($currencyCode, $order);
    $paymentDetails->PaymentAction = 'Sale';
    $paymentDetails->PaymentDetailsItem[] = $itemDetails;

    $setECReqDetails = new SetExpressCheckoutRequestDetailsType();
    $setECReqDetails->PaymentDetails[] = $paymentDetails;
    $setECReqDetails->ReqConfirmShipping = 0;
    $setECReqDetails->NoShipping = 1;
    $setECReqDetails->AddressOverride = 0;
    $setECReqDetails->CancelURL = $cancelUrl;
    $setECReqDetails->ReturnURL = $returnUrl;

    $setECReqType = new SetExpressCheckoutRequestType();
    $setECReqType->SetExpressCheckoutRequestDetails = $setECReqDetails;

    $setECReq = new SetExpressCheckoutReq();
    $setECReq->SetExpressCheckoutRequest = $setECReqType;

    $paypalService = new PayPalAPIInterfaceServiceService();


    try {
        $setECResponse = $paypalService->SetExpressCheckout($setECReq);
        exit;
    } catch (Exception $ex) {
        echo $ex;
        exit;
    }



    if(isset($setECResponse)) {
        if($setECResponse->Ack =='Success') {
            $token = $setECResponse->Token;
            return $token;
        }
        var_dump($setECResponse);
        exit;
    }

    return false;
}

谢谢你。

4

1 回答 1

4

您只需确保在您的 SetExpressCheckout 请求中包含帐单协议信息。查看此API 调用集示例,以使用 Express Checkout 完成定期付款配置文件

您会注意到 SEC 请求包含 L_BILLINGTYPE0 和 L_BILLINGAGREEMENTDESCRIPTION0 的参数。您需要确保包含这些,否则您返回的令牌对 CreateRecurringPaymentsProfile 无效。

于 2013-06-18T09:36:48.663 回答