Skip to content

Conversation

@aimensahnoun
Copy link
Member

@aimensahnoun aimensahnoun commented Sep 24, 2024

resolves #127

  • Allows seller to pass in feeAddress and feeAmountInUSD.
  • Convert feeAmountInUSD to selected payment currency.
  • If feeAddress and feeAmountInUSD are valid, we show them to the buyer in the confirmation step and calculate the total.
  • Add fee details to the payment note if feeAddress and feeAmountInUSD are valid.

Payment without fee

CleanShot 2024-09-26 at 14 57 29
CleanShot 2024-09-26 at 15 16 52

Payment with fee

CleanShot 2024-09-26 at 14 42 29
CleanShot 2024-09-26 at 15 17 22

Summary by CodeRabbit

  • New Features

    • Introduced support for transaction fees in the payment confirmation process.
    • Added new properties to display fee details, including fee address and amount in USD.
    • Updated UI to conditionally show fee information during payment.
  • Documentation

    • Enhanced documentation for the PaymentWidget component to include examples of new fee-related properties.
  • Bug Fixes

    • Improved logic for handling fees in payment requests, ensuring accurate fee calculations and displays.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 24, 2024

Walkthrough

The changes introduce new properties to the payment widget components to support transaction fees, allowing the platform to take fees during payment processing. New properties feeAddress and feeAmountInUSD are added to relevant components, and the logic for handling payment requests is updated to include fee details. The UI is modified to display fee information, enhancing the overall functionality of the payment widget.

Changes

Files Change Summary
packages/payment-widget/src/lib/components/payment-confirmation.svelte
packages/payment-widget/src/lib/payment-widget.svelte
Introduced new properties feeAddress and feeAmountInUSD. Updated UI to display fee information and adjusted button implementation.
packages/payment-widget/src/lib/react/PaymentWidget.d.ts Added optional properties feeAddress and feeAmountInUSD to the PaymentWidgetProps interface and updated documentation for example usage.
packages/payment-widget/src/lib/utils/request.ts Updated prepareRequestParameters function to include new parameters for handling fees and modified logic to construct transaction notes and invoice items reflecting fee details.

Assessment against linked issues

Objective Addressed Explanation
Expose feeAddress and feeAmount for platform fee (Issue #127)

Possibly related PRs


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 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.

@aimensahnoun aimensahnoun marked this pull request as ready for review September 26, 2024 12:16
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: 13

🧹 Outside diff range comments (1)
packages/payment-widget/src/lib/payment-widget.svelte (1)

Line range hint 4-4: Remove unused Button import and LGTM on button implementation

The standard HTML button implementation looks good and provides more direct control over styling. However, the Button component import on line 4 is no longer used and should be removed.

Please remove the following unused import:

- import { Button } from "@requestnetwork/shared-components/button";

The button implementation and its click handler logic are correct, properly handling both connected and disconnected states.

Also applies to: 199-212

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between c26d150 and 78c981e.

📒 Files selected for processing (4)
  • packages/payment-widget/src/lib/components/payment-confirmation.svelte (7 hunks)
  • packages/payment-widget/src/lib/payment-widget.svelte (6 hunks)
  • packages/payment-widget/src/lib/react/PaymentWidget.d.ts (2 hunks)
  • packages/payment-widget/src/lib/utils/request.ts (6 hunks)
🔇 Additional comments (3)
packages/payment-widget/src/lib/payment-widget.svelte (3)

25-25: LGTM: New fee-related properties added

The addition of feeAddress and feeAmountInUSD properties aligns with the PR objectives. The default values are appropriately set, with ethers.constants.AddressZero used for feeAddress.

Also applies to: 41-42


236-237: LGTM: Fee properties passed to PaymentConfirmation

The feeAddress and feeAmountInUSD props are correctly passed to the PaymentConfirmation component, ensuring that the fee information is available for processing and display during payment confirmation.


Line range hint 1-486: Summary: Implementation of custom fee functionality looks good

The changes in this file successfully implement the custom fee functionality as per the PR objectives. The new properties feeAddress and feeAmountInUSD are properly integrated into the component and passed to the relevant child components.

Key points:

  1. New fee-related properties are added and properly used.
  2. The button implementation has been updated for better control and styling.
  3. CSS styles are well-implemented with a minor suggestion for improvement.

Next steps:

  1. Address the minor suggestions in the review comments.
  2. Ensure that the PaymentConfirmation component (not shown in this file) properly handles the new fee properties.
  3. Update tests to cover the new fee functionality.
  4. Consider adding documentation for the new fee-related properties in the component's JSDoc or README.

Overall, the changes look good and align well with the PR objectives.

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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Files that changed from the base of the PR and between 78c981e and 74f9728.

📒 Files selected for processing (1)
  • packages/payment-widget/src/lib/payment-widget.svelte (6 hunks)
🔇 Additional comments (3)
packages/payment-widget/src/lib/payment-widget.svelte (3)

8-8: LGTM: Import of ethers library

The addition of the ethers import is appropriate for using ethers.constants.AddressZero in the new feeAddress property.


235-236: LGTM: Fee properties passed to PaymentConfirmation

The feeAddress and feeAmountInUSD properties are correctly passed to the PaymentConfirmation component. This change is consistent with the new properties added to the parent component and allows for proper handling of fee information in the confirmation step.


374-407: 🧹 Nitpick (assertive)

LGTM on button styles with a minor suggestion

The new button styles are well-implemented, providing a consistent look and feel with proper hover and disabled states. The use of SCSS nesting and CSS variables is good for maintainability and theming.

For consistency with other color definitions in the file, consider using an SCSS variable for the button's background color:

+ $button-bg-color: #0bb489;
- background-color: #0bb489;
+ background-color: $button-bg-color;

- background-color: rgba($color: #0bb489, $alpha: 0.8);
+ background-color: rgba($color: $button-bg-color, $alpha: 0.8);

This change would make it easier to update the color scheme in the future if needed.

Copy link
Member

@rodrigopavezi rodrigopavezi left a comment

Choose a reason for hiding this comment

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

looks good 👍

@aimensahnoun aimensahnoun merged commit 5eb3818 into main Sep 26, 2024
@aimensahnoun aimensahnoun deleted the 127-payment-widget-expose-feeaddress-and-feeamount-so-platform-can-take-a-fee branch September 26, 2024 12:36
<section class="rn-payment-widget-body">
<h2>Pay with crypto</h2>
<Button
<button
Copy link
Member

Choose a reason for hiding this comment

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

@aimensahnoun for future reference, odd changes like this warrant a comment in the code to explain why we're breaking from convention.

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.

[payment widget] expose feeAddress and feeAmount so platform can take a fee

4 participants