简体   繁体   中英

Paypal recurring payment for custom billing cycle

I am working on a website in PHP that needs custom cycle for paypal recurring payment. Ex: a customer wants to receive a product in every 15 days. So paypal should process billing in every 15 days for the customer. Others can ask for the same in 30 days, and so on.

I also need the payment status to be updated. I guess paypal will send some data when a recurring payment is done. Not getting clear instructions on implementing the recurring. What I am getting is to create the recurring payment button from paypal account.

Can anyone help me on this?

Assuming the number of days is chosen at checkout time and never changes for that particular customer's custom billing cycle...

Quick solution:

You can generate a "Subscribe" button via http://www.paypal.com/buttons for a certain number of days, say 15 days. In "Step 2", uncheck the option to save the button at PayPal. Once you have generated the code, click the option to remove the code protection.

This will give you plain HTML, and "15" will be one of the variables there. Possible variables are documented at https://developer.paypal.com/docs/classic/paypal-payments-standard/integration-guide/Appx_websitestandard_htmlvariables/

So, you can change that hidden input to be of type "text" -- or alternatively to still be hidden but set by your javascript or server-side code, and have a dynamic button for X number of days. The image can also be changed to one of your own, of course.

More involved solution: integrate one of PayPal's recurring subscription APIs, which will accomplish much the same thing as that HTML button. This seems to be the newest API: https://developer.paypal.com/docs/subscriptions/

(The API and the HTML button are separate products , and not interchangeable in terms of how you manage existing recurring profiles later on, so if you need a full-fledged API, best integrate it from day 1 rather than using the HTML button)


If the first assumption does not hold, and you need customers to be able to adjust the billing cycle at a later date after checkout, then things get more complicated.


As far as getting payment status updates, you can integrate PayPal's webhook service: https://developer.paypal.com/docs/integration/direct/webhooks/

There is also an older IPN service that is similar in function

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM