Skip to content
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

Update new-payment.mjs #15266

Merged
merged 3 commits into from
Jan 13, 2025
Merged

Update new-payment.mjs #15266

merged 3 commits into from
Jan 13, 2025

Conversation

samss084
Copy link
Contributor

@samss084 samss084 commented Jan 11, 2025

WHY

Summary by CodeRabbit

  • New Features
    • Enhanced payment event handling with a new method to process and emit payment details.
    • Added support for capturing payment event information including amount and timestamp.
  • Updates
    • Updated version of the payment component to 0.1.2.
    • Updated package version for @pipedream/stripe to 0.6.2.

Copy link

vercel bot commented Jan 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
pipedream-docs-redirect-do-not-edit ⬜️ Ignored (Inspect) Jan 12, 2025 4:20pm

Copy link

vercel bot commented Jan 11, 2025

@samss084 is attempting to deploy a commit to the Pipedreamers Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Jan 11, 2025

Walkthrough

The pull request updates the version property in the components/stripe/sources/new-payment/new-payment.mjs file from "0.1.1" to "0.1.2" and introduces a new method emitEvent. This method processes an event parameter to extract the payment amount and emits an event with relevant details. Additionally, the version of the package @pipedream/stripe is updated from 0.6.1 to 0.6.2, with no other changes to functionality or metadata.

Changes

File Change Summary
components/stripe/sources/new-payment/new-payment.mjs Updated version from "0.1.1" to "0.1.2"; added emitEvent(event) method to emit payment event details.
components/stripe/package.json Updated package version from "0.6.1" to "0.6.2"; no other changes.

Suggested Reviewers

  • jcortes
  • GTFalcao

Poem

🐰 In the code where payments flow,
A new method now starts to glow.
With events emitted, amounts in sight,
Hopping through transactions, oh what a delight!
A version updated, fresh and bright! 🌟


📜 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 fcfe5d3 and 0ab767f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (2)
  • components/stripe/package.json (1 hunks)
  • components/stripe/sources/new-payment/new-payment.mjs (2 hunks)
✅ Files skipped from review due to trivial changes (1)
  • components/stripe/package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • components/stripe/sources/new-payment/new-payment.mjs

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@dylburger dylburger added the User submitted Submitted by a user label Jan 11, 2025
@pipedream-component-development
Copy link
Collaborator

Thank you so much for submitting this! We've added it to our backlog to review, and our team has been notified.

@pipedream-component-development
Copy link
Collaborator

Thanks for submitting this PR! When we review PRs, we follow the Pipedream component guidelines. If you're not familiar, here's a quick checklist:

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: 1

🔭 Outside diff range comments (1)
components/stripe/sources/new-payment/new-payment.mjs (1)

Line range hint 1-44: Remove duplicate code block

The file contains duplicate declarations of imports and the default export. This is a syntax error that needs to be fixed immediately.

Remove one of the duplicate blocks. Keep only one copy of the code:

import common from "../common/webhook-base.mjs";

export default {
  ...common,
  key: "stripe-new-payment",
  name: "New Payment",
  type: "source",
  version: "0.1.1",
  description: "Emit new event for each new payment",
  methods: {
    ...common.methods,
    getEvents() {
      return [
        "payment_intent.created",
      ];
    },
    async onEvent(event) {
      const amount = 5500.00;
      this.$emit(event, {
        summary: `New payment of $${amount} received`,
        id: event.id,
        ts: event.created,
      });
    },
  },
};
-import common from "../common/webhook-base.mjs";
-
-export default {
-  ...common,
-  key: "stripe-new-payment",
-  name: "New Payment",
-  type: "source",
-  version: "0.1.1",
-  description: "Emit new event for each new payment",
-  methods: {
-    ...common.methods,
-    getEvents() {
-      return [
-        "payment_intent.created",
-      ];
-    },
-    async onEvent(event) {
-      const amount = 5500.00;
-      this.$emit(event, {
-        summary: `New payment of $${amount} received`,
-        id: event.id,
-        ts: event.created,
-      });
-    },
-  },
-};
🧰 Tools
🪛 Biome (1.9.4)

[error] 21-44: Illegal duplicate default export declarations

multiple default exports are erroneous

the module's default export is first defined here

(parse)


[error] 19-19: Shouldn't redeclare 'common'. Consider to delete it or rename it.

'common' is defined here:

(lint/suspicious/noRedeclare)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0dfb5b2 and fcfe5d3.

📒 Files selected for processing (1)
  • components/stripe/sources/new-payment/new-payment.mjs (1 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
components/stripe/sources/new-payment/new-payment.mjs

[error] 21-44: Illegal duplicate default export declarations

multiple default exports are erroneous

the module's default export is first defined here

(parse)


[error] 19-19: Shouldn't redeclare 'common'. Consider to delete it or rename it.

'common' is defined here:

(lint/suspicious/noRedeclare)

🔇 Additional comments (2)
components/stripe/sources/new-payment/new-payment.mjs (2)

21-44: Please provide PR description

The PR lacks a description explaining the rationale behind these changes. Given the significance of the changes (adding event handling and payment processing), please update the PR description to include:

  1. The purpose of these changes
  2. Any related issues or tickets
  3. Testing performed to validate the changes
🧰 Tools
🪛 Biome (1.9.4)

[error] 21-44: Illegal duplicate default export declarations

multiple default exports are erroneous

the module's default export is first defined here

(parse)


36-36: ⚠️ Potential issue

Replace hardcoded amount with actual payment amount

The amount is hardcoded to 5500.00, which will incorrectly report the same amount for all payments instead of using the actual payment amount from the event.

The amount should be extracted from the payment event. Based on Stripe's API, the amount should be accessed from the event object:

-const amount = 5500.00;
+const amount = (event.data?.object?.amount ?? 0) / 100; // Stripe amounts are in cents

Let's verify the Stripe payment intent event structure:

✅ Verification successful

Review comment is accurate and critical

The review comment correctly identifies a critical issue. The file components/stripe/sources/common/webhook-base.mjs confirms that event.data.object is the correct pattern for accessing Stripe webhook event data, and hardcoding the amount defeats the purpose of a payment webhook integration.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other Stripe payment handlers to confirm the event structure
rg -l 'payment_intent.*amount' --type js

Length of output: 42


Script:

#!/bin/bash
# Search for Stripe payment handling with broader patterns
echo "=== Searching for Stripe payment handling ==="
rg -l "stripe.*payment" --type js

echo -e "\n=== Searching for amount handling in payment context ==="
rg "amount.*event" --type js -A 2 -B 2

echo -e "\n=== Looking for Stripe event object usage ==="
rg "event\.data\.object" --type js -A 2 -B 2

Length of output: 460


Script:

#!/bin/bash
# Examine the specific file and its context
echo "=== Checking the specific file content ==="
cat components/stripe/sources/new-payment/new-payment.mjs

echo -e "\n=== Looking for other .mjs files with Stripe handling ==="
fd -e mjs | xargs rg "stripe" -l

echo -e "\n=== Looking for event.data.object pattern in .mjs files ==="
fd -e mjs | xargs rg "event\.data\.object" -A 2 -B 2

Length of output: 6643

@vunguyenhung
Copy link
Collaborator

Hi everyone, all test cases are passed! Ready for release!

Test report
https://vunguyenhung.notion.site/Update-new-payment-mjs-179bf548bb5e810783ebf40a0f53bb88

@vunguyenhung vunguyenhung merged commit 7464146 into PipedreamHQ:master Jan 13, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
User submitted Submitted by a user
Development

Successfully merging this pull request may close these issues.

5 participants