1

I was searching a while and also read the paypal docs but I am unable to find an answer to my question. I created a recurring payment with Paypal Express Checkout. Everything is working fine, but now I need to know a little bit more about webhooks.

Assume a user registered and created a recurring subscription. The set-up fee is 0,00€ and the first payment will be in one week. After the first payment, the billing cycle will be every week. Now about my webhook question: I guess I need to use the PAYMENT.SALE.COMPLETED webhook am I right? As soon as I get paid every week, the PAYMENT.SALE.COMPLETED webhook will fire for every successfull payment and therefore add a new entry inside my database. Am I right? Or do I need to use another webhook for recurring payments?

Is there someone who uses this webhook in combination of a recurring subscription? Would be great if someone can help me out understanding if PAYMENT.SALE.COMPLETED is the correct webhook for recurring subscriptions.

Christoph C.
  • 840
  • 2
  • 22
  • 38

2 Answers2

1

Yes, PAYMENT.SALE.COMPLETED is sent after every successful billing event for a subscription.

Here is an example timeline of a subscription sale on my website:

2021-07-30 13:17:13.143: PAYMENT.SALE.COMPLETED - first payment

2021-07-30 13:17:10.679: BILLING.SUBSCRIPTION.ACTIVATED

2021-07-30 13:16:15.032: BILLING.SUBSCRIPTION.CREATED - this came after the one above, so make sure you can handle that

2021-08-30 11:13:05.321: PAYMENT.SALE.COMPLETED with "state"=>"completed" - second recurring payment

2021-09-08 14:34:44.816: PAYMENT.SALE.COMPLETED with "state"=>"completed","payment_hold_status"=>"RELEASED" - this is the release of the second recurring payment

If the recurring payment fails, you will receive BILLING.SUBSCRIPTION.PAYMENT.FAILED. Paypal retries the payment 3 times. See the attribute next_payment_retry_time which is set to null after the 3rd and final failed payment attempt.

You can configure your billing plan to automatically suspend a subscription after x number of failed payments (note: set this to be 1+ because 0 keeps is always active) and/or automatically add the outstanding payments to the next billing cycling.

Screenshot below:

Automatically pause a subscription on a failed payment

Dagmar
  • 2,968
  • 23
  • 27
  • Thanks for this. How do you distinguish between a first payment and recurring payment with PAYMENT.SALE.COMPLETED ? Thank you. – user1889992 Jun 28 '23 at 18:51
  • There's no way to do this (at least as far as I can see) from the PAYMENT.SALE.COMPLETED payload. I look at the order in my own database and can see by the order status whether it is the first payment or a recurring payment. – Dagmar Jun 30 '23 at 07:03
  • Thanks so much, I did same before asking question. Feels like a hack but I could not think of any other way. Knowing you did same validates what I did too. – user1889992 Jul 01 '23 at 10:07
  • It isn't a hack at all - Paypal sends you the details of the subscriptions and payments separately and you are expected to maintain your own view in order to perform the necessary actions – Dagmar Jul 03 '23 at 05:52
0

I don't believe you have any choice for which webhook PayPal will send you. I am fighting with this right now because PAYMENT.SALE.COMPLETED is the one they send me, but it doesn't contain enough data for me to match it up with a customer or a shopping cart. I want them to return CHECKOUT.ORDER.COMPLETED instead, but there doesn't seem to be a way to make that happen.

CaymanCarver
  • 389
  • 3
  • 14
  • 1
    You can set `custom_id` and this is then sent with every webhook notification - at least in 2021, perhaps it was different in 2018 – Dagmar Sep 28 '21 at 11:50