Paypal Recurring api for find next recurring payment occure - paypal

i has been implemented paypal recurring subscription plan in php and paypal recurring also charge via paypal as per recurring periods. but my system didnt find out next recurring was charged or not so how could i know next recurring payment has been charged using paypal api.
i want to help for to upgrade next expire date after next recurring payment changed.

As I understood, you want to see if the user paid or not and change expiration date according to that.
The solution is Webhooks. In your PayPal Application section click on add webhook and choose PAYMENT.SALE.COMPLETED and enter the URL that you want to listen to this event where PayPal will send a post request to this URL when you get a new payment completed.
In the page that corresponds to the URL you entered, you have to do the followings:
Verify that the call is from PayPal, not from another source (in case you are using PHP you can check this: PHP verify Paypal webhook signature)
Parse the data sent from PayPal by reading the body content, not the POST data
Verify that the event is what you need, in this case PAYMENT.SALE.COMPLETED
Verify the amount you received and the currency
Make sure that you have not processed this transaction before and this is too important
If everything is valid, you can save the transaction and do whatever you want, in your case extending the expiry date.

If I understand you correctly, you need to configure Instant Payment Notification (IPN). PayPal's server will POST transaction data to a listener script you have on your server so you can process things accordingly. It happens in real-time.
When working with recurring payments you'll get an IPN when a profile is created, canceled, or suspended, and you'll also get notifications when payments for profiles are completed, failed, etc. You can update your system or send out email notifications accordingly based on the IPN data you get.

Related

Missing PayPal IPN notification

On our website we have option to pay using PayPal. At the time of signup our sytem creates recurring profile in users PayPal account and then till the account continue we receive recurring Payments.
On every successful payment PayPal send us the notifications with transaction details and we updates our system.
Sometimes our system miss the IPN notifications due to outage and as a result our system goes out of sync and does not updates the payments.
I would like to know do we have any PayPal API which we can call to get the transaction details of missing IPN notifications?
How to handle these transactions which are not updated in our system and IPN we ave missed?

Execute tasks after PayPal chained payment is successful

Current Status
I'm quite new to PayPal and I'm currently integrating chained adaptive payments on our website. Already successfully called the PAY API call via the .NET SDK. Money (sandbox enviroment) will be correctly transferred to each participants of this payment (sender, primary and secondary receiver).
Requirement
My goal is to execute vital tasks after the payment is successful (update DB, send mail, ...) or has been cancelled (clean up stuff, ...).
Possible solutions
1)
First approach was to create the payment with actionType set to CREATE, redirect the user to paypal.com (wait for approval), redirect user back to website and execute the payment and then perform the vital tasks. But it seems not to work, the payment will be paid and is COMPLETED before the second redirect.
2)
Another possible solution would be to get the preapproval from the user, redirect back to the website and execute the payment. Haven't tried this solution yet, don't think that this is best practice.
3)
Call PAY with actionType set to "PAY" and wait for IPN. Haven't tried that either, because it is quite difficult to test it locally (even though I've already found this question: Paypal Sandbox Test Tool IPN Simulator in Localhost).
Question(s)
Which solution is best practice? I guess the recommended solution would be to wait for an IPN?
If I'am using IPN how long is the average response time after a payment has been completed? Seconds, minutes, hours? I know it depends on the load of the PayPal webservers and that there are 15 retries over 4 days, but what are some real world numbers?
Can I store additional information (e.g. UserId) about the sender in a payment (besides the memo field) which I then get back in an IPN?
Here is how I do it.
When I'm going to initiate PayPal payment (before I send a request to obtain TOKEN), I create new transaction in my database and set it's status to PENDING. In transaction table I also have userID column, which is foreign key to user table. This way I connect transaction with user.
When transaction is created in my table, I use transactionId value, and save it to PHP $_SESSION variable.
Please note that if you want to support recurring payments, you can provide transactionId to PayPal. This you can do by setting:
"PAYMENTREQUEST_0_INVNUM"=>$transaction->id.
This value will be sent when PayPal sends you IPN request after recurring payment happens.
Go back now to the story
User is redirected to PayPal, and when user fills PayPal username and password, and when user confirms payment details, user will be redirected back to your website and you have to call DoExpressCheckoutPayment to make payment itself.
If the result of DoExpressCheckoutPayment API call is success, that means that transaction was successful and you have money. At this point, you can send email, notifications, or any other important action.
$transactionResponse=$paypal->request("DoExpressCheckoutPayment",$requestParams);//Execute transaction
if(is_array($transactionResponse) && $transactionResponse["ACK"]=="Success")//Payment was successfull
{
//Send email
//Notify user
//Do other important changes in database, for example mark this transaction as successful
Transactions()::model()->updateByPk($_SESSION['transactionId'],array('status'=>'SUCCESS');
}
IMPORTANT NOTE FOR RECURRING PAYMENTS: PayPal can/will send you several IPN requests for the same recurring transaction which means that you have to add logic which will chekc weather specific IPN request is already processed or not. Usually I do it in a way to check weather status of my transaction with transactionId is 'PENDING' or 'SUCCESSFUL'.

How to check Payment failure for Paypal Express Checkout

We are using Paypal recurring billing service (using Express Checkout) at our website for monthly subscription.
Since we have an Australian account so we are not able use the DPRP (Direct Payment Recurring Payment) service offered by Paypal because it seems, DPRP service is limited
to only few countries (US, UK and Canada).
In Express checkout payment details are received at Paypal Website. So we do not have any information, whether the payment failed, user pressed the Back button in browser or He/She intentionally clicked the cancel payment.
After speaking to Paypal support team we get know that there could be multiple possible reason for Payment failure, and seller has to contact Paypal by themself. So we can
not provide any troubleshooting for that at our website.
So we want to know, Is there any possible solution to avoid this or atleast can we diffrentiate between the user for whom payment failed and who intentionally moved to
our website back without doing payment because this way we are not only unable to followup with them but also loosing a part of the customer base, interested in our service.
Any help in this is Appreciated.
Thanks
You should implement the Pay Pal IPN (Instant Payment Notification).
You configure the IPN url address on your PayPal merchant account settings. This page is simple HTML page with server-side programming that is listening for requests coming from PayPal.
There's no need to do something extra in the checkout process for making IPN work. Once you set this up, it will automatically work.
Every time something happens with a transaction in your merchant account, e.g. transaction completed/failed/canceled, PayPal will send an HTTP Post to your IPN listener URL.
Here you can get all the relevant information about the transaction, like the payer ID, the payment status. With this information you can decide what to do with your customer's order.

Does PayPal store recurring payments notify_url?

I have Google for almost 10 hours and it seems a bit unclear.
When I create a "Subscribe" button with my own "notify_url" will PayPal send an IPN to that URL when each recurring payment is made?
Paypal will use the same notify_url that you pass for every recurring payment on that same subscription. An example, may help.
If you pass a notify_url that contains the order id, like:
http://www.mydomain.com/paypal_ipn/{$order_id}
Then when somebody buys a subscription, Order #1, with a recurring payment for $1/day for a month, you will receive IPN data at "http://www.mydomain.com/paypal_ipn/1" for the initial 'txn_type=subscr_signup' and a 'txn_type=subscr_payment' every day until one of the following things occurs:
the user cancels the subscription, at which time you will get a 'txn_type=subscr_canceled'
their credit card expires 'txn_type=subscr_failed'
a month later when the subscription expires 'txn_type=subscr_eot'
On the next order, Order #2, all the IPN calls for that subscription will go to "http://www.mydomain.com/payapl_ipn/2"
Paypal won't store the notify_URL, you need to pass it everytime you send a transaction to paypal for processing. Notify_URL is one of the attributes of the hash; so when paypal receives your transaction hash, it will pick up whatever values you set for each of the attribute and act accordingly. Your understanding is correct!
Just noting that i am also seeing a possibly related problem for echecks where the later clearing ipn is not using the dynamic url that was specified in the originating transaction. First ipn advising pending payment goes to dynamic url
Second ipn advising cleared echeck goes to stored notification url not the dynamic url.
all other instant ipn's are fine and the 2nd ipn is received - but at the wrongurl - can see it in the logs.
any ideas appreciated - pending response from paypal.

Paypal PDT & IPN Question - Can we assume payment is completed when returned to site?

Can we assume that the payment is completed for a transaction when the customer is auto returned to our site?
Paypal advices us to use their IPN system for other types of payment, like an e-check, but also tells us to tell the customer something along the lines of "Thank you for your payment. Your transaction has been completed, and a receipt for your purchase has been emailed to you. You may log into your account at www.paypal.com/ca to view details of this transaction."
What are the downfalls of not using IPN, and just assuming the payment is completed when paypal auto-returns users to our site?
Thanks!
Relying solely on the return url is a pretty bad idea. It would be easy for a bad guy to skip payment and just visit your return url to complete the order.
There is a pretty comprehensive article about this here
No.
However, using the Auto Return option in your Paypal account in conjunction with Payment Data Transfer (Profile/My Selling Tools/Website preferences/Website Payment Preferences) will give you payment confirmation data in the URL you use for Auto Return, for example:
www.yourReturnURL.com?tx=9XV61416UY0043254&st=Completed&amt=9%2e00&cc=USD&cm= 9601&item_number=2
You need to verify this data (anyone could send a fake request) by sending the payment reference ("tx" parameter above) back to Paypal and waiting for a VERIFIED response.
This last step is identical as the one you take for the IPN (Instant Payment Notification) implementation.
With PDT you get the notification instantly. PDT has a a major weakness: it sends order confirmations once and only once. As a result, when PDT sends a confirmation, your site must be running; otherwise, it will never receive the message.
With IPN, in contrast, delivery of order confirmations is virtually guaranteed since IPN resends a confirmation until your site acknowledges receipt. For this reason, PayPal recommends that you implement IPN rather than PDT.
Note: If your site must be notified of payments immediately, you can implement both IPN and PDT.
More info here: https://developer.paypal.com/docs/classic/ipn/integration-guide/IPNPDTAnAlternativetoIPN/