Skip to content

Conversation

@michelle0927
Copy link
Collaborator

@michelle0927 michelle0927 commented Oct 13, 2025

Resolves #8152

Summary by CodeRabbit

  • New Features

    • Added Payhip instant sources: Customer Charged, Payment Refunded, New Subscription Created, Subscription Canceled.
    • Added a shared HTTP-facing base to validate webhooks and emit structured metadata (ID, summary, timestamp).
    • Included sample test events for each source to simplify testing.
  • Chores

    • Bumped component version to 0.1.1.
    • Updated platform dependency for improved compatibility.

@vercel
Copy link

vercel bot commented Oct 13, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
pipedream-docs Ignored Ignored Oct 16, 2025 4:34am
pipedream-docs-redirect-do-not-edit Ignored Ignored Oct 16, 2025 4:34am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 13, 2025

Walkthrough

Adds a Payhip HTTP base source, four instant webhook triggers with sample test payloads (customer charged, new subscription created, payment refunded, subscription canceled), and bumps package version while upgrading @pipedream/platform.

Changes

Cohort / File(s) Summary of changes
Package metadata
components/payhip/package.json
Bump package version to 0.1.1 and upgrade dependency @pipedream/platform to ^3.1.0.
Payhip base HTTP source
components/payhip/sources/common/base.mjs
New common source module providing an HTTP handler with props (payhip, http with customResponse, db), stub isRelevant(), generateMeta() that throws ConfigurationError, and run(event) that responds 200 and emits events when relevant.
Customer Charged trigger
components/payhip/sources/customer-charged/customer-charged.mjs
New source extending base; isRelevant(event) checks event.type === "paid"; generateMeta builds { id, summary, ts }; includes sampleEmit from test-event.mjs.
Customer Charged test fixture
components/payhip/sources/customer-charged/test-event.mjs
New static sample payload representing a Payhip paid event.
New Subscription Created trigger
components/payhip/sources/new-subscription-created/new-subscription-created.mjs
New source extending base; isRelevant(event) checks event.type === "subscription.created"; generateMeta uses subscription_id and date_subscription_started; includes sampleEmit.
New Subscription test fixture
components/payhip/sources/new-subscription-created/test-event.mjs
New static sample payload representing a subscription.created event.
Payment Refunded trigger
components/payhip/sources/payment-refunded/payment-refunded.mjs
New source extending base; isRelevant(event) checks event.type === "refunded"; generateMeta uses id and date_created; includes sampleEmit.
Payment Refunded test fixture
components/payhip/sources/payment-refunded/test-event.mjs
New static sample payload representing a refunded payment event.
Subscription Canceled trigger
components/payhip/sources/subscription-canceled/subscription-canceled.mjs
New source extending base; isRelevant(event) checks event.type === "subscription.deleted"; generateMeta uses subscription_id and date_subscription_deleted; includes sampleEmit.
Subscription Canceled test fixture
components/payhip/sources/subscription-canceled/test-event.mjs
New static sample payload representing a subscription.deleted event.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Payhip as Payhip Webhook
  participant HTTP as Payhip Base HTTP Source
  participant Src as Specific Source
  participant PD as Event Emitter

  Payhip->>HTTP: POST webhook (JSON body)
  HTTP->>HTTP: run(event) -> respond 200
  HTTP->>Src: isRelevant(event.body)?
  alt Relevant
    Src->>Src: generateMeta(event.body)
    Src->>PD: $emit(event.body, meta)
  else Not relevant
    HTTP-->>Payhip: 200 OK (no emit)
  end

  note over Src,PD: Relevance checks by event.type:<br/>"paid" | "subscription.created" | "refunded" | "subscription.deleted"
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

I twitch my ears at webhooks’ chime,
Four new tales arrive on time—
Paid and started, refunded, gone,
Base burrow routes each little song.
I thump, emit, and hop along. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Description Check ⚠️ Warning The PR description provided is minimal, containing only "Resolves #8152" without following the template structure that specifies a "WHY" section should be completed. While the reference to the issue establishes a link to the requirements, the description does not explain why these sources are being added, what problems they solve, or provide any meaningful context about the changes beyond the issue number. The template's "WHY" section remains unfilled, making the description largely incomplete.
Out of Scope Changes Check ❓ Inconclusive Beyond the explicitly stated requirement for "Successful transaction" handling (implemented via the Customer Charged source), the PR also introduces three additional sources: New Subscription Created, Payment Refunded, and Subscription Canceled. While these are coherent additions to a Payhip integration and leverage the same base architecture, they were not mentioned in issue #8152's stated objectives. The issue specifically lists only "Successful transaction" as the trigger to implement, making the additional sources potentially beyond the original scope. Clarify whether the additional sources (New Subscription Created, Payment Refunded, and Subscription Canceled) were intentionally included as part of this PR's scope or if they should be separated into a follow-up PR. If they are intentional expansions of the Payhip integration, update issue #8152 or add comments in the PR to document this scope expansion decision.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "Payhip - new sources" directly and concisely summarizes the main change in the pull request, which is the addition of multiple new source modules for the Payhip integration. The title is specific enough for a developer scanning commit history to quickly understand that this PR introduces new webhook event sources for Payhip without being overly broad or generic.
Linked Issues Check ✅ Passed The linked issue #8152 specifies that a "Successful transaction" trigger should be implemented for the Payhip app. The PR successfully implements this requirement through the Customer Charged source, which emits events when a webhook of type "paid" is received—directly corresponding to successful payment transactions. This core requirement is clearly met by the changes in this pull request.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue-8152

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 030176d and dd0b85d.

📒 Files selected for processing (1)
  • components/payhip/sources/customer-charged/customer-charged.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/payhip/sources/customer-charged/customer-charged.mjs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Lint Code Base
  • GitHub Check: pnpm publish
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Publish TypeScript components

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (6)
components/payhip/sources/common/base.mjs (1)

14-16: Document that isRelevant() must be overridden by child classes.

The stub implementation returns true for all events, which could lead to incorrect event processing if a child forgets to override it.

Consider throwing an error like generateMeta() to enforce implementation:

 isRelevant() {
-  return true;
+  throw new ConfigurationError("isRelevant is not implemented");
 },
components/payhip/sources/customer-charged/customer-charged.mjs (2)

17-23: Add defensive property checks in generateMeta.

The method assumes all event properties exist. If Payhip's webhook payload changes or is malformed, this could throw an error.

Add property validation:

 generateMeta(event) {
+  if (!event.id || !event.customer_email || event.price === undefined || !event.date) {
+    throw new Error("Missing required fields in webhook payload");
+  }
   return {
     id: event.id,
     summary: `${event.customer_email} charged $${event.price}`,
     ts: event.date,
   };
 },

20-20: Consider formatting the price with currency.

The summary uses $${event.price} which assumes USD and displays cents as dollars (e.g., "900" displays as "$900" instead of "$9.00").

Format according to the currency field:

-summary: `${event.customer_email} charged $${event.price}`,
+summary: `${event.customer_email} charged ${event.currency} ${(event.price / 100).toFixed(2)}`,

This assumes Payhip sends price in cents (verify with their documentation).

components/payhip/sources/subscription-canceled/subscription-canceled.mjs (1)

17-23: Add defensive property checks in generateMeta.

The method assumes all event properties exist. If the webhook payload is malformed, this could throw an error.

Add property validation:

 generateMeta(event) {
+  if (!event.subscription_id || !event.date_subscription_deleted) {
+    throw new Error("Missing required fields in webhook payload");
+  }
   return {
     id: event.subscription_id,
     summary: `Subscription Canceled: ${event.subscription_id}`,
     ts: event.date_subscription_deleted,
   };
 },
components/payhip/sources/payment-refunded/payment-refunded.mjs (1)

17-23: Consider defensive field access.

The generateMeta method directly accesses event.id and event.date_created without validation. If these fields are missing from the webhook payload, the emitted event metadata will contain undefined values.

Consider adding validation or fallback values:

 generateMeta(event) {
   return {
-    id: event.id,
-    summary: `Payment Refunded: ${event.id}`,
-    ts: event.date_created,
+    id: event.id || event.transaction_id,
+    summary: `Payment Refunded: ${event.id || "Unknown"}`,
+    ts: event.date_created || Date.now(),
   };
 },
components/payhip/sources/new-subscription-created/new-subscription-created.mjs (1)

17-23: Consider defensive field access.

Similar to the payment-refunded source, generateMeta directly accesses fields without validation. Missing subscription_id or date_subscription_started would result in undefined metadata values.

Consider adding validation:

 generateMeta(event) {
   return {
-    id: event.subscription_id,
-    summary: `New Subscription: ${event.subscription_id}`,
-    ts: event.date_subscription_started,
+    id: event.subscription_id || event.id,
+    summary: `New Subscription: ${event.subscription_id || "Unknown"}`,
+    ts: event.date_subscription_started || Date.now(),
   };
 },
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7f84b6d and bebb4f8.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • components/payhip/package.json (2 hunks)
  • components/payhip/sources/common/base.mjs (1 hunks)
  • components/payhip/sources/customer-charged/customer-charged.mjs (1 hunks)
  • components/payhip/sources/customer-charged/test-event.mjs (1 hunks)
  • components/payhip/sources/new-subscription-created/new-subscription-created.mjs (1 hunks)
  • components/payhip/sources/new-subscription-created/test-event.mjs (1 hunks)
  • components/payhip/sources/payment-refunded/payment-refunded.mjs (1 hunks)
  • components/payhip/sources/payment-refunded/test-event.mjs (1 hunks)
  • components/payhip/sources/subscription-canceled/subscription-canceled.mjs (1 hunks)
  • components/payhip/sources/subscription-canceled/test-event.mjs (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
components/payhip/sources/subscription-canceled/subscription-canceled.mjs (1)
components/payhip/sources/common/base.mjs (1)
  • event (26-26)
components/payhip/sources/new-subscription-created/new-subscription-created.mjs (1)
components/payhip/sources/common/base.mjs (1)
  • event (26-26)
components/payhip/sources/payment-refunded/payment-refunded.mjs (1)
components/payhip/sources/common/base.mjs (1)
  • event (26-26)
components/payhip/sources/customer-charged/customer-charged.mjs (1)
components/payhip/sources/common/base.mjs (1)
  • event (26-26)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: pnpm publish
  • GitHub Check: Publish TypeScript components
  • GitHub Check: Verify TypeScript components
  • GitHub Check: Lint Code Base
🔇 Additional comments (9)
components/payhip/package.json (1)

16-16: Verify compatibility with @pipedream/platform v3.1.0.

The dependency upgrade from ^1.5.1 to ^3.1.0 is a major version jump. Based on learnings, the SDK was redesigned with breaking changes between 1.x and 3.x.

Please verify that the ConfigurationError import used in components/payhip/sources/common/base.mjs is available and that there are no breaking API changes affecting this integration.

Based on learnings.

components/payhip/sources/new-subscription-created/test-event.mjs (1)

1-15: LGTM!

The test payload is well-structured and includes all necessary fields for a subscription.created event.

components/payhip/sources/customer-charged/test-event.mjs (1)

1-32: LGTM!

The test payload is comprehensive and includes all necessary fields for a customer charged event.

components/payhip/sources/payment-refunded/test-event.mjs (1)

1-34: LGTM!

The test payload correctly represents a refund event with appropriate fields including refund timestamps and amounts.

components/payhip/sources/subscription-canceled/test-event.mjs (1)

1-16: LGTM!

The test payload correctly represents a subscription cancellation event with all necessary fields.

components/payhip/sources/customer-charged/customer-charged.mjs (1)

14-16: LGTM!

The event type check correctly filters for "paid" events as documented in the Payhip webhook types.

components/payhip/sources/subscription-canceled/subscription-canceled.mjs (1)

14-16: LGTM!

The event type check correctly filters for "subscription.deleted" events as documented in the Payhip webhook types.

components/payhip/sources/payment-refunded/payment-refunded.mjs (1)

1-26: LGTM!

The source implementation follows Pipedream conventions correctly. The structure cleanly extends the common base, properly filters webhook events by type, and generates appropriate metadata for event emission.

components/payhip/sources/new-subscription-created/new-subscription-created.mjs (1)

1-26: Overall structure looks good.

The implementation correctly extends the common base and follows Pipedream source patterns. The webhook filtering logic and metadata generation are appropriate for the subscription.created event type.

jcortes
jcortes previously approved these changes Oct 14, 2025
Copy link
Collaborator

@jcortes jcortes left a comment

Choose a reason for hiding this comment

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

Hi @michelle0927 lgtm! Ready for QA!

@michelle0927
Copy link
Collaborator Author

/approve

@michelle0927 michelle0927 merged commit 744efc3 into master Oct 16, 2025
10 checks passed
@michelle0927 michelle0927 deleted the issue-8152 branch October 16, 2025 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Payhip

3 participants