paypal定期付款与初始付款

时间:2014-01-24 11:02:02

标签: php recurring-billing paypal

您好我m using paypal express checkout with the merchant sdk. I have implemented recurring payment using the integration manual, but the given example doesn进行初始付款(立即向用户收费)。 我的付款代码是:

初始化付款:

    $cart = $this->cart->getCart();
    $items = $cart['items'];
    $itemTotal = 0;

    foreach ($items as $k => $item) {
        $product = $this->addItem($item);
        $itemTotal += $product->Amount;
        $this->paymentDetails->PaymentDetailsItem[$k] = $product;
    }

    $this->orderTotal->currencyID = 'USD';
    $this->orderTotal->value = $this->cart->getCartAmount();

    $this->paymentDetails->OrderTotal = $this->orderTotal;
    $this->paymentDetails->PaymentAction = 'Sale';
    $this->paymentDetails->InvoiceID = $invoice_id->{'$id'};

    $setECReqDetails = new \PayPal\EBLBaseComponents\SetExpressCheckoutRequestDetailsType();
    $setECReqDetails->PaymentDetails[0] = $this->paymentDetails;
    $setECReqDetails->CancelURL = $this->cancelURL;

    $setECReqDetails->ReturnURL = $this->returnURL;

    $billingAgreementDetails = new \PayPal\EBLBaseComponents\BillingAgreementDetailsType('RecurringPayments');
    $billingAgreementDetails->BillingAgreementDescription = 'recurringbilling';
    $setECReqDetails->BillingAgreementDetails = array($billingAgreementDetails);

    $setECReqType = new \PayPal\PayPalAPI\SetExpressCheckoutRequestType();
    $setECReqType->Version = $this->version;
    $setECReqType->SetExpressCheckoutRequestDetails = $setECReqDetails;

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

    return $this->paypalService->SetExpressCheckout($setECReq);

然后在我提供的返回网址上,我使用以下代码创建定期付款:

$profileDetails = new \PayPal\EBLBaseComponents\RecurringPaymentsProfileDetailsType();
    $profileDetails->BillingStartDate = "2014-01-24T00:00:00:000Z";

    $paymentBillingPeriod = new \PayPal\EBLBaseComponents\BillingPeriodDetailsType();
    $paymentBillingPeriod->BillingFrequency = 10;
    $paymentBillingPeriod->BillingPeriod = "Day";
    $paymentBillingPeriod->Amount = new \PayPal\CoreComponentTypes\BasicAmountType("USD", "1.0");
    $scheduleDetails = new \PayPal\EBLBaseComponents\ScheduleDetailsType();
    $activationDetails = new \PayPal\EBLBaseComponents\ActivationDetailsType();
    $activationDetails->InitialAmount = new \PayPal\CoreComponentTypes\BasicAmountType('USD', 49);
    $activationDetails->FailedInitialAmountAction = 'ContinueOnFailure';
    $scheduleDetails->Description = "recurringbilling";
    $scheduleDetails->ActivationDetails = $activationDetails;
    $scheduleDetails->PaymentPeriod = $paymentBillingPeriod;

    $createRPProfileRequestDetails = new \PayPal\EBLBaseComponents\CreateRecurringPaymentsProfileRequestDetailsType();
    $createRPProfileRequestDetails->Token = $token;

    $createRPProfileRequestDetails->ScheduleDetails = $scheduleDetails;
    $createRPProfileRequestDetails->RecurringPaymentsProfileDetails = $profileDetails;

    $createRPProfileRequest = new \PayPal\PayPalAPI\CreateRecurringPaymentsProfileRequestType();
    $createRPProfileRequest->CreateRecurringPaymentsProfileRequestDetails = $createRPProfileRequestDetails;

    $createRPProfileReq = new \PayPal\PayPalAPI\CreateRecurringPaymentsProfileReq();
    $createRPProfileReq->CreateRecurringPaymentsProfileRequest = $createRPProfileRequest;

    return $this->paypalService->CreateRecurringPaymentsProfile($createRPProfileReq);
}

在我的沙盒帐户中,我可以看到定期付款已创建,但没有初始付款。 我的问题是:如何设置此定期付款,以便进行初始付款?

希望我能解释好我的问题。如果您需要更多信息评论。

EIDT:我的问题是如何使用初始付款创建定期付款。我编辑了我的代码片段。经过一些阅读后,我看到我错过了设置“ActivationDetailsType”的设置。我进行了设置,它可以解决一个问题...付款资料正在等待4-5个小时,然后通过。我在论坛等等读到...这是一个沙盒问题,但不幸的是我无法确定付款是否会被删除。在我的情况下,我需要立即批准付款。我的新问题是,在创建定期付款配置文件时,该帐户的响应是正常的(成功或不成功)且配置文件处于待处理状态,我可以将付款视为成功,并确保我肯定会得到这笔款项

感谢您的时间。 问候, 的Georgi

1 个答案:

答案 0 :(得分:0)

很晚,但我有类似的担忧。

  

我的新问题是,在创建定期付款配置文件时,该帐户的响应是正常的(成功或不成功)且配置文件处于待处理状态,我可以将付款计为成功,并确保我将获得资金确定吗?

我目前正在努力,但在PayPal反映付款之前,我不会计算工资。我会利用IPN来触发付款时应该采取的行动。至于PayPal的4-5小时处理(尽管来自网络的消息来源说生产不应该有相同的延迟),我只是一定要通知买家他/她的付款仍然由PayPal处理。