简体   繁体   中英

PHP and Paypal IPN Subscription and recurring payments

I need to setup paypal auto renewal for my customers in website. actually customer will get 30 days website access on every month payment.

if the monthly auto payment is ok we can increase "website access" days by 30. if no it will not add any more days to customers account.

that means i need to RUN a SCRIPT from my own website to check and increase or stop customers "website access" days after each auto payment.

can we set up paypal auto renewal like this? is there any method to run a script ( mywebsite.com/renewalscript.php?customerid=123&payment=ok ) after every auto renewal ? or do you have any other idea to overcome this ?

A simple way could be to have a valid_until date column or something. When a user tries to view content, just check that field and see if they should be able to or not. Then in the IPN listener, you could push that date forward 30 days when a good payment comes in.

If you need help with creating the IPN listener, you might find my tutorial helpful.

You can do this by listening to the IPN for when the txn_type is subscr_eot . When the subscription fails or is cancelled, you can disallow access.

This question explains a bit more about subscr_eot : Subscriptions with Paypal IPN

I use this class: PHP Paypal IPN Integration Class and check:

if($p->ipn_data['txn_type'] == 'subscr_eot')

then set their status to 0 to disallow access.

AFAIK, on every sucessfully debted subscription fee, you get an information via IPN. The "script you need to run" is the IPN script. If PayPal notifies you via IPN, your IPN script needs to handle the request/response and if valid, sets your parameters in your database. This is all done in your IPN handler script on your website.

(Remember to first answer the paypal request in this script before doing any local updates to your tables etc. if you send the request too late, paypal doesn't accept it and sends a new one later).

See https://cms.paypal.com/cgi-bin/marketingweb?cmd=_render-content&content_ID=developer/library_code_ipn_code_samples for sample code

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