PayPal subscriptions and IPN - paypal

After a PayPal subscription is created for a user, does subscr_signup get sent before or after confirming the payment?
I am using django-paypal, which does not have built-in functionality to handle the subscr_payment IPN message.
This lead me to wonder whether or not I can use subscr_signup as an indicator that the subscription was successful.
Many thanks

Typically subscr_signup is sent after subscr_payment(3 sec apart), but the sequence is not guaranteed. PayPal recommendation is to rely on subscr_signup.
Read more here: http://www.mixedwaves.com/2010/11/paypal-subscriptions-ipn-demystified/

Related

Paypal recurring payment reattempts: IPN callback flow for failed payments, and subscription cancellation?

I have a bog-standrad Paypal subscription -button installation, with an IPN callback flow. One bleeding point of this setup for the past 24 months has been the instant subscription cancellation upon lack of available funds; which, statistically, happens with moderate frequency in the target market I'm currently selling to.
So, current IPN flow is: subscr_signup -> [Nx] subscr_payment -> subscr_cancel/subscr_failed [terminate subscription].
According to a previous SO question: retry to charge the client if a payment fails:
There is a variable sra when set to 1 , PaYPal will try to collect the payment two more times before canceling the subscription. More information on Recurring Payments Reattempts
I suspect using this would drastically reduce "churn-by-payment-issue" problem, and would like to implement this.
My question is, what is the IPN callback flow for these endgame situations? That is, for "payment failed, will retry", VS "payment failed, subscription terminated" , specifically, what order, and txn_type will be called?
Many thanks.

PayPal recurring payment verification

After one has created a monthly billing agreement with a customer; how do I verify that the customer has paid (and not cancelled the agreement) at the next bill statement?
Would I use GetRecurringPaymentsProfileDetails for this information? Basically, I want to automate cancellations/etc.
In your ipn end point a subscr_cancel txn_type is sent when this happens. Then you can update a record in your database to account for this.
Ipn messages when enabled send post requests for all kinds of actions such when a Payment is made or a subscription is cancelled. When you receive a message you need to validate the message, determine what message it is, and then perform an action in your application
Ipn info
https://developer.paypal.com/docs/classic/products/instant-payment-notification/

Paypal IPN prior to renewal

I am setting up a Paypal IPN for a subscription service. After reviewing the documentation and speaking with Paypal, I'm still unsure as to whether the IPN feature will send out notifications before a subscription is renewed. I've got it to where it will notify a user when their account is charged for the renewal, but there is no prior notification that this transaction will take place.
Does anyone have any experience with setting this up and if it's possible?
Thanks!
IPN only notifies you when a payment is made or its status changes. For subscriptions you won't get one prior to renewal.
If you're using the Recurring Payments API, you can get that via GetRecurringPaymentsProfileDetails, which will tell you when the next billing cycle is.

PayPal Subscription Payment Failed

When a subscription payment fails, PayPal will retry for n times.
What transaction type (subscr_cancel or subscr_eot) is sent back via IPN, after all retries fail?
The specifics depend on the PayPal product you're using, although the logic works similar(`ish) across both Website Payments Standard subscription buttons and Express Checkout Recurring Payments (via the CreateRecurringPaymentsProfile API):
This depends on whether you've set MAXFAILEDPAYMENTS or not. If MAXFAILEDPAYMENTS > 0 is set, it will cancel the subscription after n number of attempts and you'll receive a subscr_cancel. If you have it set to MAXFAILEDPAYMENTS=0, you'll get recurring_payment_skipped and the recurring payment will be marked as having an outstanding balance. If you specify AUTOBILLOUTAMT=AutoBillAmt, the outstanding balance will be added to the next billing cycle.
I would suggest taking a look at https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables#id091EB0901HT which lists all IPN variables, including the ones for recurring payments.
Paypal returns subscr_failed for this case, and the possible return values are:
subscr_signup: subscription sign-up.
subscr_cancel: subscription cancellation.
subscr_failed: subscription payment failure.
subscr_payment: subscription payment.
subscr_eot: subscription’s end-of-term.
subscr_modify: subscription modification.
Please click here for further clarification.

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/