[英]paypal recurring payment with initial payment
您好,我正在m using paypal express checkout with the merchant sdk. I have implemented recurring payment using the integration manual, but the given example doesn
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);
然后在提供的返回URL上,使用以下代碼創建定期付款:
$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個小時,然后才能通過。 我在論壇等上閱讀過……這是一個沙盒問題,但不幸的是,我不能確定付款是否會被取消。 就我而言,我需要立即批准付款。 我的新問題是,在創建定期付款配置文件時,該帳戶的響應是正常的(成功或未完成),並且該配置文件正在處理中,我是否可以將付款算作成功,並確保我可以肯定得到錢
謝謝您的時間。 問候,喬治
很晚了,但我也有類似的擔憂。
我的新問題是,在創建定期付款配置文件時,該帳戶的響應是正確的(成功或不是),並且該配置文件正在處理中,我是否可以將付款算作成功,並確保可以肯定得到付款?
我目前正在處理它,但是直到PayPal反映了付款情況之后,我才開始計算工資。 我會利用IPN觸發付款后應執行的操作。 至於貝寶(PayPal)的4-5小時處理(盡管網上消息說生產不應有相同的延遲),我只想通知買家,貝寶仍在處理他/她的付款。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.