How to test Subscription payments

heiwil
Contributor
Contributor

Hi, 

 

I have a MERN stack application which provides subscriptions for pro versions.

A user can click a paypal button and approve a subscription. This subscription is stored in my database by calling my backend with the subscriptionId. My backend calls paypal to get the subscriptions's data and stores the subscription in my database with the start_date, status and next_billing_date.

 

So now to my Problem.

How can I simulate, when an automatically payment for a subscription was made?

 

I implemented webhooks, reacting on following events:

  • BILLING.SUBSCRIPTION.ACTIVATED - store subscription in our database if not existing (should already exist with status=ACTIVE by onApprove function of paypal button)
  • PAYMENT.SALE.COMPLETED - how can I simulate this? I guess I receive a payment with date, amount and currency and have to get subscription again to find out my new next_billing_date
  • PAYMENT.SALE.REVERSED - I manually cancel the subscription in paypal and my database
  • BILLING.SUBSCRIPTION.PAYMENT.SUSPEND: I manually cancel the subscription in paypal and my database
  • BILLING.SUBSCRIPTION.CANCELLED - I manually cancel the subscription in my database
How can I simulate those webhooks in sandbox mode (especially the auto payment) ? I know the webhook simulator, but this simulator has no real data. E.g. I can not see, if the subscription's next billing_date is the new one, since no real data were processed. So I have no clue how to update my subscriptions next_billing_date.
 
Is there maybe even a better practice to sync the paypal subscriptions and my database? I need to have the start_date, the next_billing_date and the status in my database to show them my users.
 
Thanks for any hints 😊
 
 
Login to Me Too
1 REPLY 1

vaishnavib
Moderator
Moderator

Good day @heiwil

 

Thank you for posting to the PayPal community.

 

I would like to inform you that by utilizing webhooks, you will receive notifications when a user subscribes. These notifications will enable you to make the necessary changes in your database. To gain a better understanding of webhooks and how they work, I kindly suggest referring to the following link: https://developer.paypal.com/api/rest/webhooks/event-names/.

 

However, I regret to inform you that at this time, we do not have a PayPal code available that allows for the direct updating of subscription statuses in the database. To make the required changes, I recommend reaching out to your website developer who can assist you further with this matter.

 

If you still facing the issue, please create a MTS ticket via -   https://www.paypal-support.com/s/?language=en_US with detailed error information. 

 

Sincerely,

Vaishnavi

PayPal MTS

 

If this post or any other was helpful, please enrich the community by giving kudos or accepting it as a solution.

Login to Me Too

Haven't Found your Answer?

It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.