-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Payhip - new sources #18741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Payhip - new sources #18741
Conversation
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
WalkthroughAdds 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 Changes
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"
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ 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)
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. Comment |
There was a problem hiding this 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 accessesevent.id
andevent.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. Missingsubscription_id
ordate_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
⛔ 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 incomponents/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.
Resolves #8152
Summary by CodeRabbit
New Features
Chores