Skip to content

Conversation

@rodrigopavezi
Copy link
Member

@rodrigopavezi rodrigopavezi commented Jun 9, 2025

Changes

  • add platform fee support to payment routes and sections

Screenshot 2025-06-09 at 11 39 03

Summary by CodeRabbit

  • New Features
    • Platform fee information is now displayed for payment routes when applicable, including the fee percentage and recipient address.
  • Enhancements
    • Payment routes now support and show platform fee details in both the selected route preview and the list of available routes.
  • Chores
    • Added new environment variables to configure platform fee percentage and address for payments.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 9, 2025

Walkthrough

The changes introduce the handling and display of a platform fee in the payment flow. Platform fee information is retrieved from the backend, passed through server and client layers, and rendered in the UI within payment route components. Server-side payment endpoints are updated to include platform fee parameters in their requests.

Changes

File(s) Change Summary
src/components/payment-route.tsx Extended props and UI to accept and display an optional platform fee with percentage and address.
src/components/payment-section.tsx Refactored payment route data handling to extract and pass platform fee prop to PaymentRoute components.
src/lib/types/index.ts Added optional platformFee property to the PaymentRoute interface.
src/server/routers/invoice.ts Appended platform fee parameters to payment URLs and returned platform fee data in getPaymentRoutes.
src/server/routers/payment.ts Included platform fee percentage and address in payloads for pay and batchPay mutations.
.env.example Added new environment variables for platform fee percentage and address.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI (PaymentSection)
    participant UI (PaymentRoute)
    participant Server (invoice/payment routers)
    participant Payment API

    User->>UI (PaymentSection): Initiate payment flow
    UI (PaymentSection)->>Server (invoice router): getPaymentRoutes()
    Server (invoice router)->>Payment API: GET /paymentRoutes?feePercentage&feeAddress
    Payment API-->>Server (invoice router): { routes, platformFee }
    Server (invoice router)-->>UI (PaymentSection): { routes, platformFee }
    UI (PaymentSection)->>UI (PaymentRoute): Render route with platformFee prop
    UI (PaymentRoute)-->>User: Display route info incl. platform fee

    User->>UI (PaymentSection): Select and submit payment
    UI (PaymentSection)->>Server (payment router): pay() or batchPay() with feePercentage & feeAddress
    Server (payment router)->>Payment API: POST pay request with fee params
    Payment API-->>Server (payment router): Payment result
    Server (payment router)-->>UI (PaymentSection): Payment result
Loading

Suggested reviewers

  • bassgeta
  • MantisClone

📜 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 db16d3f and 2ef85da.

📒 Files selected for processing (1)
  • .env.example (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .env.example
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Lint

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

@rodrigopavezi rodrigopavezi enabled auto-merge (squash) June 9, 2025 10:21
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: 4

🧹 Nitpick comments (2)
src/components/payment-route.tsx (2)

17-20: Consider the usage of the address property.

The platformFee.address property is defined in the interface but not used in the component's display logic. If this property is intended for future use, consider adding a comment explaining its purpose. Otherwise, consider removing it to keep the interface lean.


128-134: Simplify the conditional check and approve the display logic.

The platform fee display implementation looks good overall. Consider simplifying the conditional check for better readability:

-          {platformFee?.percentage && platformFee?.percentage > 0 && (
+          {(platformFee?.percentage ?? 0) > 0 && (

The styling with purple color is consistent with the existing design patterns, and the placement below the speed information maintains good UI hierarchy.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 57c433f and 8a786a8.

📒 Files selected for processing (5)
  • src/components/payment-route.tsx (3 hunks)
  • src/components/payment-section.tsx (4 hunks)
  • src/lib/types/index.ts (1 hunks)
  • src/server/routers/invoice.ts (3 hunks)
  • src/server/routers/payment.ts (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Build
  • GitHub Check: Lint
🔇 Additional comments (7)
src/lib/types/index.ts (1)

9-9: LGTM! Clean type definition for platform fee support.

The optional platformFee property is well-defined and maintains backward compatibility.

src/components/payment-section.tsx (3)

124-124: Good variable naming improvement.

Renaming to paymentRoutesData better reflects that this contains the full API response, not just the routes array.


137-138: Clean data extraction pattern.

Properly destructures the API response to separate routes and platform fee data for downstream usage.


593-593: Consistent prop passing for platform fee display.

The platformFee prop is consistently passed to both the selected route preview and the route options list.

Also applies to: 610-610

src/server/routers/invoice.ts (2)

301-301: Good cleanup of redundant variable declaration.

Removing the redundant const declaration properly reuses the previously declared variable.


394-397: Well-structured return format for platform fee support.

The updated return structure properly separates routes and platform fee data, maintaining backward compatibility while adding the new functionality.

src/components/payment-route.tsx (1)

29-29: LGTM!

The prop destructuring is correctly implemented and consistent with the interface changes.

@MantisClone
Copy link
Member

As discussed at the Tech Daily, make sure that the displayed fee includes Platform fee. It should be returned by the API, ideally.

@rodrigopavezi
Copy link
Member Author

@MantisClone I am trying to implement the platform fee for easyinvoice in the api side but the Fee in the API is on ETH and platformFee can be on USDC for instance. I don’t think we should sum them up as it would require some external exchange rate.

@MantisClone
Copy link
Member

Please display the Crosschain and Platform fees separately.

  • This makes it clear that we support Platform Fees in the sent currency.
  • This is easier than using external exchange rates to combine the fees in the frontend.

@rodrigopavezi
Copy link
Member Author

Please display the Crosschain and Platform fees separately.

  • This makes it clear that we support Platform Fees in the sent currency.
  • This is easier than using external exchange rates to combine the fees in the frontend.

It is already doing it. @MantisClone could you re-review it?

Copy link
Contributor

@bassgeta bassgeta left a comment

Choose a reason for hiding this comment

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

Seems absolutely legit, thanks for this change and the API side changes too!
image
The fee shows up as it should 😎

@rodrigopavezi rodrigopavezi merged commit 7496d66 into main Jun 11, 2025
5 checks passed
@rodrigopavezi rodrigopavezi deleted the feat/platform-fee branch June 11, 2025 08:20
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.

4 participants