Skip to content

Log PayPal and Stripe subscription renewals - #15663

Open
phillipthelen wants to merge 12 commits into
developfrom
phillip/sub_events2
Open

Log PayPal and Stripe subscription renewals#15663
phillipthelen wants to merge 12 commits into
developfrom
phillip/sub_events2

Conversation

@phillipthelen

Copy link
Copy Markdown
Member

No description provided.

@SabreCat
SabreCat force-pushed the phillip/sub_events2 branch from 4bebde2 to bdb6364 Compare July 14, 2026 22:51

@SabreCat SabreCat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A unit test is failing, unable to find this.constants when looking up PAYMENT_METHOD. The refactoring must have changed the this context.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Habitica’s server-side payment/analytics pipeline to record subscription renewal events for Stripe and PayPal, and enriches subscription analytics with a “group vs. individual” flag.

Changes:

  • Adds a new analytics event type (renewed) and records renewal events from Stripe webhooks and PayPal IPN.
  • Extends subscription analytics payload/storage with isGroupSubscription.
  • Switches the in-app-purchase dependency to a GitHub-sourced package.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
website/server/models/analytics/subscriptionEvent.js Adds renewed event type and stores isGroupSubscription in the analytics schema.
website/server/libs/payments/subscriptions.js Tracks isGroupSubscription on subscribe/cancel and introduces handleSubscriptionRenewal.
website/server/libs/payments/stripe/webhooks.js Hooks renewal tracking into Stripe invoice.payment_succeeded events.
website/server/libs/payments/paypal.js Adds PayPal IPN renewal handling, refactors cancellation helper, and adds optional IPN verification bypass.
website/server/libs/localAnalytics.js Persists isGroupSubscription when saving subscription analytics events.
package.json Switches in-app-purchase to a GitHub dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread package.json
"heapdump": "^0.3.15",
"helmet": "^4.6.0",
"in-app-purchase": "^1.11.3",
"in-app-purchase": "github:HabitRPG/in-app-purchase",
if (plan) {
await trackSubscriptionEvent({
eventType: 'renewed',
user: ownerId,
Comment thread website/server/libs/payments/stripe/webhooks.js Outdated
const { txn_type, recurring_payment_id } = options;

if (repayTypes.indexOf(txn_type) !== -1) {
payments.handleSubscriptionRenewal(recurring_payment_id);
Comment on lines +374 to +378
if (!PAYPAL_DISABLE_IPN_VERIFICATION) {
await this.ipnVerifyAsync(options, {
allow_sandbox: PAYPAL_MODE === 'sandbox',
});
}

@SabreCat SabreCat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did some debugging to get the events to file without errors, but some data still isn't coming through. Give it a look?

  {
    _id: 'e3f874ed-6c8b-436f-a049-e03e7da0c129',
    userId: '90931b7b-14f0-49ca-a8ef-503e3f533d94',
    eventType: 'renewed',
    paymentMethod: null,
    customerId: null,
    planId: null,
    isGroupSubscription: false,
    createdAt: ISODate('2026-07-30T14:28:40.374Z'),
    updatedAt: ISODate('2026-07-30T14:28:40.374Z'),
    __v: 0
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants