Skip to content

✨ server: forward exchange rate to webhooks#917

Draft
nfmelendez wants to merge 1 commit intobasefrom
exchange-rate
Draft

✨ server: forward exchange rate to webhooks#917
nfmelendez wants to merge 1 commit intobasefrom
exchange-rate

Conversation

@nfmelendez
Copy link
Copy Markdown
Contributor

@nfmelendez nfmelendez commented Mar 26, 2026

Summary by CodeRabbit

Release Notes

  • New Features

    • Exchange rates are now forwarded to webhook payloads for transaction created and completed events when the transaction currency differs from the local currency.
  • Documentation

    • Updated webhook event reference tables to document the new exchange rate field in transaction events.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 26, 2026

🦋 Changeset detected

Latest commit: cdd6a70

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@exactly/server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 26, 2026

Walkthrough

This pull request adds support for forwarding exchange rates to webhooks. It extends the webhook payload schema to include an optional exchangeRate field in transaction events when the transaction currency differs from the local currency, along with corresponding documentation and test coverage.

Changes

Cohort / File(s) Summary
Release metadata
.changeset/shy-foxes-trade.md
Added changeset declaring a patch-level version update for @exactly/server package with release note about forwarding exchange rate to webhooks.
Documentation
docs/src/content/docs/webhooks.md
Documented the new optional body.spend.exchangeRate? field (type: number) in Transaction created and Transaction completed webhook event tables.
Server implementation
server/hooks/panda.ts
Extended Valibot schemas to support optional exchangeRate: number in transaction spend payloads; updated webhook dispatch logic to conditionally include spend.exchangeRate when currency differs from localCurrency and event is not "updated".
Server tests
server/test/hooks/panda.test.ts
Updated webhook test suite to validate exchangeRate forwarding: verifies inclusion when currencies differ, omission when currencies match, and absence in updated events; added JSON payload parsing and signature verification assertions.

Sequence Diagram(s)

sequenceDiagram
    participant TxnEvent as Transaction Event
    participant ServerLogic as Server Logic
    participant WebhookBuilder as Webhook Payload Builder
    participant WebhookTarget as External Webhook

    TxnEvent->>ServerLogic: Transaction created/completed<br/>(currency, localCurrency)
    activate ServerLogic
    alt currency ≠ localCurrency
        ServerLogic->>WebhookBuilder: Include exchangeRate
    else currency = localCurrency
        ServerLogic->>WebhookBuilder: Omit exchangeRate
    end
    deactivate ServerLogic
    
    WebhookBuilder->>WebhookBuilder: Construct payload with<br/>conditional exchangeRate
    WebhookBuilder->>WebhookTarget: POST webhook payload
    activate WebhookTarget
    WebhookTarget->>WebhookTarget: Verify signature<br/>& process payload
    deactivate WebhookTarget
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested reviewers

  • cruzdanilo
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: forwarding exchange rate information to webhooks in the server package, which is the primary purpose of all changes across the PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch exchange-rate

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
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces the inclusion of exchange rates in webhook payloads when the transaction currency differs from the local currency. The implementation involves updating the transaction and webhook schemas, modifying the publishing logic to conditionally attach the exchange rate, and updating the documentation. Comprehensive tests have been added and updated to verify the new behavior. I have no feedback to provide.

@sentry
Copy link
Copy Markdown

sentry bot commented Mar 26, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1 1 0 0
View the top 1 failed test(s) by shortest run time
web::web
Stack Traces | 32s run time
Assertion is false: "Sign in" is not visible

To view more test analytics, go to the Prevent Tests Dashboard

Copy link
Copy Markdown

@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 info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 84402000-271a-4d76-8f8b-bd546d875628

📥 Commits

Reviewing files that changed from the base of the PR and between deddc7c and cdd6a70.

📒 Files selected for processing (4)
  • .changeset/shy-foxes-trade.md
  • docs/src/content/docs/webhooks.md
  • server/hooks/panda.ts
  • server/test/hooks/panda.test.ts

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.

1 participant