SDK API Reference for React
Latest Version
v2.7.14 - Complete TypeScript documentation
Framework
React SDK - Hooks-based API for React 18+
React is Required: This API reference covers the React-based TagadaPay Plugin SDK v2
(
@tagadapay/plugin-sdk/v2). All hooks and components require React 18+. For V1 docs, see the legacy
documentation.Quick Navigation
Query Hooks
TanStack Query hooks for data fetching
Mutation Hooks
Hooks for data updates
Utility Hooks
Helper hooks for common tasks
Payment Hooks
Payment processing and 3DS
Location Hooks
Address and geolocation
Components
Reusable React components
Installation & Setup
Provider Setup
Wrap your app withTagadaProvider:
Query Hooks
useCheckout()
Fetch and manage checkout data with automatic caching.data: Checkout object with all checkout dataisLoading: Boolean loading stateerror: Error object if request failedrefetch(): Function to manually refetch dataisFetching: Boolean indicating background refetch
useProducts()
Fetch product catalog with automatic caching.data: Array of product objectsisLoading: Loading stateerror: Error staterefetch(): Manual refetch function
useOffer()
Single-offer hook that initializes a checkout session up front, exposes apayOffer() mutation, and returns offer + line-item state. Kept exported as
useOffer (aliasing useOfferQuery) for backwards compatibility.
usePreviewOffer() instead — same
single-offer shape, lighter footprint, automatic MIT/CIT pickup.
usePreviewOffer()
Lightweight offer preview hook for post-checkout upsell pages. Fetches an offer with a precomputed summary, lets the customer pick variants and quantities, and recomputes totals client-side without round-tripping to the backend on every change. Pay once the customer accepts.
Returns
MIT vs CIT auto-pickup
pay() looks up stepConfig.paymentInitiator from the runtime
window.__TGD_STEP_CONFIG__ injection and applies it automatically:
paymentInitiator: 'merchant'(default) → MIT, sent to Stripe asoff_session: true. No 3DS challenge, higher conversion.paymentInitiator: 'customer'→ CIT, sent assetup_future_usage: 'off_session'. May trigger 3DS — useful when MITs are being declined by the issuer.
{ initiatedBy }:
OffersResource.payOffer() and OffersResource.payWithCheckoutSession() use the
same auto-pickup. All three paths share getAssignedPaymentInitiator() under
the hood.
usePromotions()
Fetch active promotions and campaigns.useDiscounts()
Manage discount codes and validation.useOrder()
Fetch order details.useOrderBump()
Manage upsell offers (order bumps).useStoreConfig()
Access store configuration and settings.useShippingRates()
Fetch available shipping options.usePostPurchases()
Fetch post-purchase offers.useVipOffers()
Fetch VIP exclusive offers.useClubOffers()
Manage subscription/club offers.useCustomerOrders()
Fetch customer order history.useCustomerSubscriptions()
Manage customer subscriptions.Mutation Hooks
useCheckout()
Manage checkout sessions with create, update, and payment capabilities.checkoutToken: String - Existing checkout token, or empty string to create new
checkout: Checkout session objectinit(): Function to create a new checkout session with line itemsupdateLineItems(): Function to update cart itemsupdateCustomerAndSessionInfo(): Function to update customer/shipping infoerror: Error object if any operation fails
usePayment()
Process payments with automatic state management.usePaymentPolling()
Poll payment status for async payments.Utility Hooks
useAuth()
Manage authentication and user sessions.user: Current user objectisAuthenticated: Boolean auth statelogin(): Login functionlogout(): Logout functionisLoading: Auth check in progress
useCustomer()
Access customer profile data.useCustomerInfos()
Manage customer information and validation.useCredits()
Manage store credit and balance.useFunnel()
Navigate and track funnel steps.useCheckoutToken()
Manage checkout session tokens.useCurrency()
Format money and handle currency conversions.useGeoLocation()
Detect user’s geographic location.usePluginConfig()
Access plugin-specific configuration.useTranslation()
Internationalization and localization.useApiClient()
Direct access to API client for custom requests.useApiQuery()
Create custom API queries with TanStack Query.Payment Hooks
useThreeds()
Handle 3D Secure authentication.useThreedsModal()
Manage 3DS modal display.useExpressPaymentMethods()
Integrate Apple Pay and Google Pay.Location Hooks
useGoogleAutocomplete()
Address autocomplete with Google Places API.useISOData()
Access country and region data.Components
ApplePayButton
Pre-styled Apple Pay button component.GooglePayButton
Pre-styled Google Pay button component.DebugDrawer
Development helper for debugging plugin state.Path Remapping Functions
Path Remapping Guide
See the complete path remapping guide for detailed examples, testing, and advanced patterns
matchRoute()
New in v2.7.14 Check if the current URL matches an internal path pattern AND extract URL parameters. Signature:internalPath- Your plugin’s internal path pattern (e.g.,/checkout,/product/:id)
matched-trueif the current URL matches the internal path (considering remapping)params- Object containing extracted URL parameters
shouldMatchRoute()
Check if the current URL matches an internal path pattern (without parameter extraction).Tip: Use
matchRoute() instead if you need URL parameters. shouldMatchRoute() only returns a boolean.internalPath- Your plugin’s internal path pattern
boolean-trueif the current URL matches
- ✅ Simple route matching without parameters
- ✅ Conditional rendering based on route
- ✅ Route guards and redirects
matchRoute() instead:
- ✅ When you need URL parameters
- ✅ When passing params to child components
getPathInfo()
Get detailed information about the current path and remapping status. Signature:PathInfoobject with detailed path information
getInternalPath()
Get the current internal path, ornull if no remapping is active.
Signature:
string- Internal path if remapping is activenull- If no remapping is active
- ✅ Quick remapping status check
- ✅ Logging and debugging
- ✅ Conditional behavior based on remapping
getPathInfo() instead:
- ✅ Need both external and internal paths
- ✅ Need query parameters or hash
- ✅ Building debug UI
Path Remapping Types
RouteMatchResult
PathInfo
Path Remapping Best Practices
✅ Good Practices
❌ Bad Practices
Complete Path Remapping Guide
See the complete guide for configuration, testing, troubleshooting, and advanced patterns
TypeScript Types
The SDK exports comprehensive TypeScript types:Best Practices
1. Always Use V2 for New Projects
2. Handle Loading and Error States
3. Use TanStack Query Features
4. Combine Multiple Hooks
Support
- Examples: See SDK Examples
- Tutorial: Follow the SDK Tutorial
- Best Practices: Read Best Practices
- Support: developer-support@tagadapay.com
