I have a chat site and I am going to make it possible for the users to reserve a nickname for a subscription fee per month. I have been reading up on PayPal documentation and understand how to do such using PHP with the various callbacks from PayPal to check that the initial payment has been confirmed but what I don't understand how to do is how to each month check that the subscription has still been paid/not cancelled, otherwise do something (in this case remove their subscriber account)?
You can use PayPal IPN feature https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNIntro/?mark=IPN.
Refer to https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNandPDTVariables/, there is a "profile_status" variable , PayPal can notify you if profile status is changed.
Related
I am creating recurring payment using paypal and want the status of the payment after few days.I mean i want to check user is still subscribe us or cancel the subscription. if he/she cancel the subscription or i want to update his status into my website.
Can you anyone help me out please.
Thank you.
If you are using Standard subscriptions or NVP/SOAP recurring payments APIs when you will get an IPN when the profile is canceled, so you can automate the processing of that. In the case of recurring payments APIs you could also use GetRecurringPaymentsProfileDetails any time you want to check the status.
If you are using REST API billing agreements / billing plans then you can use Webhooks, which are similar to IPN. You could also use GET to pull plan details.
I have a website that accepts PayPal payments and I need to check old payments (like a week ago) that
appear pending on my server.
Since payments are "pending" on my server I don't have the PayPal transaction id to identify then on PayPal servers so I need another way to search for them, for example, using the "item number" that corresponds to the payment id on my site.
The final idea is to have a cron job that runs every day and checks for pending payments and retrieve their status on PayPal and try to confirm them automatically.
Is there a way to check a payment status using PayPal's api by the item number or other field?
Thanks in advance.
There is a much easier system to check on payments that are made through them and that is the Paypal IPN API.
Paypal IPN API Documentation should get you started and up and running.
Inside of the provided code from the IPN API, they have multiple methods to check for payments and if they are paid, pending, denied, etc.
Hope this helps!
I have a subscription plan ie $30 for every month and first month is free. but I am not getting any response from Paypal when somebody subscribes however I get response after one month for the first payment. Paypal does not send any response back if the first month is free ? How can I find out somebody subscribed successfully ?
Are you using standard subscription buttons or Express Checkout with Recurring Payments?
Either way, you'll get IPN's when a new subscription profile is created as well as when each payment comes through. If you're not seeing that I would check your IPN history in your PayPal account to see if you're finding errors there, and also check your web logs to see if you're finding errors there.
I'm guessing that your IPN script is failing for some reason when it gets hit for the new profile IPN's.
The txn_type value would be either subscr_signup or recurring_payment_profile_created depending on which method you're using.
Am having a lot of trouble getting my head around this paypal payment stuff...
How can i confirm that the user has successfully signed up for my subscription?
I know 0 about IPN but for example : If a user signs up to my website with example#e.com but uses the paypal account sample#s.com to pay then how to i match up the user.
I read that PDT do not send out a transaction ID (tx) for recurring (subscription) payments is that true ?
Just need help with it all... honest and easy :)
Thanks.
Yeah sometimes is hard to understand Paypal and all their documentation but for any kind of subscription i would recommend Paypal IPN. You set IPN URL in your paypal account for example: http://www.domain.com/ipn.php. Then you create a subscription button in paypal account where you can set the price, recurring price etc.
More about Paypal IPN you can read here:
https://www.paypal.com/ipn
When creating Paypal button you can also add some custom fields which can help you determine which customer really pays. So for example you have a database of users and there is user with userid=100, username=Nickname and registered_email=xxx#gmail.com. Now you can decide to add userid=100 as a custom field and add this to paypal button. For example CUSTOM=100.
ipn.php in this case is a script which handles all the logic. When user pay, Paypal send any status to http://www.domain.com/ipn.php (you set this in your paypal account as IPN URL). So ipn.php in this case needs to check if payment is complete and status is ok. Then retrieve a CUSTOM field ($_POST['custom']) which is in this case 100 (userid). And then update your database with users and somehow mark that this user payed of course if status is Completed.
Hope this helps a little. But in this case it's not really important from which paypal account user pays and which is registered in your database. All you need is that you somehow link it together. In this case with userid or something like that.
If you want to implement Paypal IPN and your customers don't use same email from my experience you can use a form to authenticate the user
user login on your website with xxx#example.org
user clicks on your item and pays with yyy#example.org
after he pays you can redirect him to a form where they can merge Paypal account with website account
every time that user pays then your IPN will be covered by the information he provided
you should save his payment information for later use.
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.
PayPal Instant Payment Notification (IPN)
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