Skip to content

feat: adds support for custom actions#8100

Open
georgeweiler wants to merge 2 commits intomainfrom
ramp-custom-actions
Open

feat: adds support for custom actions#8100
georgeweiler wants to merge 2 commits intomainfrom
ramp-custom-actions

Conversation

@georgeweiler
Copy link
Contributor

@georgeweiler georgeweiler commented Mar 3, 2026

Explanation

Summary of Changes

Controller

  • getBuyWidgetData(quote) returns BuyWidget | null (url, browser?, orderId?) instead of string | null
  • addPrecreatedOrder(params) added — accepts { orderId, providerCode, walletAddress, chainId? }, parses order ID, creates stub order with status: Precreated, adds to controller for polling

Mobile

  • BuildQuote: uses getBuyWidgetData, calls addPrecreatedOrder before opening external browser (PayPal), passes orderId to Checkout for WebView flows; debug instrumentation removed
  • Checkout: uses addPrecreatedOrder instead of Redux addFiatCustomIdData; supports orderId and customOrderId; removed removeFiatCustomIdData from callback handling

Hooks

  • useRampsOrders: added addPrecreatedOrder, AddPrecreatedOrderParams
  • useRampsQuotes: getBuyWidgetData returns Promise<BuyWidget | null>
  • useRampsController: exposes getBuyWidgetData and addPrecreatedOrder

Renames

  • getWidgetUrl → getBuyWidgetData
  • addOrderForPolling → addPrecreatedOrder
  • AddOrderForPollingParams → AddPrecreatedOrderParams

Files Modified

  • Controller: RampsController.ts, RampsController.test.ts
  • Mobile: BuildQuote.tsx, Checkout.tsx, useRampsQuotes.ts, useRampsController.ts, useRampsOrders.ts, plus tests and mocks
  • Extension: amount-input.tsx, useRampsQuotes.ts, actions.ts, ramps-controller-init.ts
  • Debug dashboard: dashboard.html, RampsDebugBridge.ts

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Medium Risk
Introduces a breaking API change (getWidgetUrlgetBuyWidgetData) and adds new order-state mutation via addPrecreatedOrder, which could affect downstream consumers and order polling behavior.

Overview
Updates the redirect-provider widget fetch API by replacing getWidgetUrl() with getBuyWidgetData(), returning the full BuyWidget payload (including browser/orderId) and treating missing/nullable url as null.

Adds support for polling pre-created orders via addPrecreatedOrder(), which inserts a minimal stub RampsOrder in Precreated status (parsing orderId and normalizing providerCode) so existing polling can later hydrate it. Tests were updated/added to cover the new return type, null handling, and stub-order creation.

Written by Cursor Bugbot for commit 292cc29. This will update automatically on new commits. Configure here.

@georgeweiler georgeweiler requested a review from a team as a code owner March 3, 2026 20:25
}
return buyWidget;
} catch {
return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

The catch here swallows everything silently. From the caller's perspective it just returns null and there's no way to know if it was a missing buyURL or a failed network request. Worth at least logging the error before returning null.

? orderId.split('/orders/')[1]
: orderId;
const normalizedProviderCode = providerCode.replace('/providers/', '');

Copy link
Contributor

Choose a reason for hiding this comment

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

This providerCode normalization (stripping /providers/) is also done in BuildQuote.tsx before calling addPrecreatedOrder. Two copies of the same logic means they can drift apart. Worth extracting into a shared util.

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.

2 participants