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
Related
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.
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!
We have a little problem in our system, we allow customers to pay using PayPal which is great!
But in the following situation we have this issue:
A customer pays us using PayPal.
We send the product to our customer when the transaction has completed.
A few days later, PayPal refuses to pay us because the customer have his PayPal account connected with his bank account. And the funds on that bank account is too low.
So, is there a way to let PayPal know us when this happens through API/URL call to our server ?
As Dagon mentioned, IPN is the best way to handle this.
You'll setup a listener script on your server, and every time a transaction happens on your PayPal account, the PayPal server will POST data about that account to your listener script. You'll get different parameters depending on the type of transaction that occurs. You can see a list of the types and parameters here.
You can build your email notifications, database updates, etc. into your IPN script to fully automate post-payment processing tasks.
So, in the example you've provided, what would happen is when the transaction first takes place the IPN would be triggered with a payment_status of Pending, and then you'd also see a parameter called pending_reason with a value of echeck. This tells you the payment was made, but it's an echeck which takes time to clear, so the status again is Pending instead of Completed.
A few days later when that payment does clear (or fails) you'd get another IPN with an updated payment_status. Only upon receiving an actual COMPLETED payment_status would you then would you deliver the order.
Again, this can all be automated within your IPN script.
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.
I am new to sandbox and paypal payment gateway. I am using paypal adaptive payment to pay amount to two people at a time. My current code works perfectly. I am using the paypal generated code. I just want to know that is it possible that when the payment is made successfully can I make that entry to my database. I have my php code, but where do I need to write this?
Thanks in advance(plzz no down votes)
You should wait for the IPN message that contain details about the payment status
https://www.paypal.com/ipn
You need to define the url of the php script that listen for those messages in your paypal account. There are some php examples on how to implement it.