Recurring payments paypal IPN - php

I am working on client's project for paid memberships.
clients want to do recurring payments and i am stumped upon IPN settings for recurring payments.
As Paypal say, if notify_url is specified in html form it will override Paypal's default notify_url if specified. That's fine for one time payment.
But what for recuring payments ? which Settings paypal use for sending IPN notifications to clients server. Is that the notify url which user specified for first time in HTML form or Paypal's default ipn settings ?
what if user hasnot specified paypal default ipn setting ? but had specified it in html form when user was subscribing for the first time.
Any help will be appreciable.
Thanks.

What I have is that notify_url only works for the initial transaction but for the recurring payment, IPN url is being used.
I am also trying to get some answers to verify if this is how it works as there are people with different opinion and offical doc doesn't seem to have this info in detail.

Related

Paypal Rest Api - recurring payment issue

I'm trying to setup recurring payments in Paypal for my website using REST API, and I have 2 questions/problems:
Can't see transaction details in the paypal checkout page:
For one time payment, I know how to display transaction details by providing values for item_list (as in https://developer.paypal.com/docs/api/).
However I don't know what values we should provide so that recurring payment profile will be shown on checkout page as well.
In the below picture(left side) you can see that no information is presented to the client regarding the payment amount and setup fees.
If I switch to production environment when the user tries to make a recurring payment, the user is redirected to the paypal website and he sees this error:
Sorry, we weren’t able to set up preapproved payments at this time.
Please return to the merchant and choose another way to pay.
So what's the issue with the recurring payment:
Why the user does not see any information regarding the payment amount in checkout paypal checkout page.
Why in production env the user gets that error message?
I'm using this documentation:
http://paypal.github.io/PayPal-PHP-SDK/sample/doc/billing/CreatePlan.html
http://paypal.github.io/PayPal-PHP-SDK/sample/doc/billing/CreateBillingAgreementWithPayPal.html
http://paypal.github.io/PayPal-PHP-SDK/sample/doc/billing/ExecuteAgreement.html
How will I be notified when a paypal client cancel the recurring payment?
It is important for my web application to know when somebody cancel the recurring payment.
I read something about webhooks, is this the way?
Can you give me some documentation?
My location is Romania, if this matters.
Thanks,
Catalin

scripts to update my database after a payment is made using paypal

Im haing a problem iv been researching for weeks now on the paypal API but i just can't figer how to do this.
I need there to be a button on my website which then it goes to paypal.
Once you have paid the chosen amount it goes to a php page which updates the database though php.
You have to turn on paypal ipn in your paypal preferences. Once paypal has the money it sends you a transaction back to your server. In the script that accepts the transaction you can have it update your tables.
Documentation : https://www.x.com/sites/default/files/ipnguide.pdf
generally you pass a notify_url parameter with the request, and set up a page which handles and validates IPN notifications, and PayPal will send requests to that page to notify you when payments/refunds/etc. go through. That IPN handler page would then be the correct place to update the database to mark orders as having been paid.
i found a tutorial here: http://net.tutsplus.com/tutorials/php/using-paypals-instant-payment-notification-with-php/
I found more suitable the PayPal NVP API instead of tradional IPN (Instant Payment Method)
You can find several code examples for PHP (including very similar to your problem and more advanced) in the library code for NVP samples

PayPal adaptive payment success function

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.

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.
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

Using a different PayPal IPN URL per transaction

I have seen and know how to use IPN for paypal payments but I am having a small issue. With IPN you need to enter an IPN address to your PayPal File so it knows you got sent the payment (Instant Activation of Product). If I have multiple sites, I can't do this as It only allows one.
I have seen the WHMCS system manage to do this using Website Payments Standard (Does not require any IPN Settings) where the user's invoice is marked as paid after the payment is sent. The user does not need to be redirected to another page and as a seller, the only info you need to put in is your paypal email for things to start working.
Does anyone know how this works and where to learn this?
Thank you for your help
You can specify a per-transaction IPN URL by passing in notify_url along with the other data in the form.
E.g. <input type="hidden" name="notify_url" value="http://....">
This will override whatever you have set up within your PayPal Profile.

Categories