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 for: Customer Charged, Payment Refunded, New Subscription Created, and Subscription Canceled.
    • Introduced a shared HTTP-facing base to validate incoming 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.

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 13, 2025 6:44pm
pipedream-docs-redirect-do-not-edit Ignored Ignored Oct 13, 2025 6:44pm

Copy link
Contributor

coderabbitai bot commented Oct 13, 2025

Walkthrough

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

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 customResponse-enabled, db), stub isRelevant(), a 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; relevance check event.type === "paid"; generateMeta constructs { 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; relevance check 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; relevance check 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; relevance check 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 (Charged / Sub Created / Refunded / Canceled)
  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 fresh trails arrive on time—
Paid, created, refunds told,
Canceled threads in payload gold.
Base burrow routes each beat just right,
I thump, emit, then take to flight. 🐇✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Out of Scope Changes Check ⚠️ Warning In addition to the requested successful transaction source, the pull request adds extra webhook sources for new subscriptions, refunds, and subscription cancellations, which fall outside the scope defined by issue #8152. Consider limiting the pull request to only the successful transaction source or update the linked issue scope to encompass these additional event sources.
Description Check ⚠️ Warning The pull request description only contains a reference to closing issue #8152 and does not include the required ## WHY section or any rationale as specified by the repository’s description template. Please update the description to follow the template by filling in the ## WHY section with the background and motivation for adding these new Payhip sources.
✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title “Payhip - new sources” succinctly and accurately reflects the primary change of adding multiple new Payhip sources, making it clear to reviewers what this pull request delivers.
Linked Issues Check ✅ Passed The changes introduce a “Customer Charged” source that correctly handles Payhip “paid” webhook events and generates the required metadata, satisfying the primary objective of implementing a successful transaction trigger from issue #8152.
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 bebb4f8 and 030176d.

📒 Files selected for processing (1)
  • components/payhip/sources/new-subscription-created/new-subscription-created.mjs (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/payhip/sources/new-subscription-created/new-subscription-created.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). (3)
  • GitHub Check: Lint Code Base
  • 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.

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

1 participant