Skip to content

React SDK Reference

This page documents the main @mintmoney/react API surface used in applications.

Package

bash
npm install @mintmoney/react

The package expects:

  • react >=18 <20
  • react-dom >=18 <20

createConfig(publicKey, options)

Creates the SDK config object used by MintMoneyProvider.

tsx
import { createConfig } from '@mintmoney/react/config';

const config = createConfig('pk_live_or_test_xxx', {
  checkoutId: 'checkout_uuid',
  apiUrl: 'https://api.getmint.money',
});

Parameters

NameTypeRequiredNotes
publicKeystringYesMint public key for browser requests
options.checkoutIdstringYesMint checkout ID
options.apiUrlstringNoDefaults to https://api.getmint.money
options.themePartial<ThemeConfig>NoPartial theme overrides
options.cryptoCheckoutConfigCryptoCheckoutConfigNoCrypto checkout behavior overrides

CryptoCheckoutConfig

FieldTypeDefault
numBlockConfirmationsnumber1
paymentConfirmationStatusPaymentStatusconfirming_payment

MintMoneyProvider

Provides the SDK config and theme context.

tsx
import { MintMoneyProvider } from '@mintmoney/react/context';

<MintMoneyProvider config={config}>
  <App />
</MintMoneyProvider>;

You should place this high enough in your tree that all checkout triggers can access it.

Checkout

Renders a Mint checkout trigger and opens the checkout modal when invoked.

tsx
import { Checkout } from '@mintmoney/react';

<Checkout createPayment={createPayment} />;

Props

PropTypeRequiredDescription
createPayment() => Promise<Payment>YesCreates a Mint payment, usually via your backend
onSuccess(paymentId: string) => Promise<void>NoCalled after a successful payment
onError(error: Error) => Promise<void>NoCalled if payment creation or checkout fails
asChildbooleanNoUses your child element as the trigger
childrenReactNodeNoCustom trigger element when asChild is true

getPaymentById(paymentId)

Fetches a Mint payment by ID using the configured public key and API URL.

tsx
import { getPaymentById } from '@mintmoney/react';

const payment = await getPaymentById(paymentId);

This is useful when:

  • you want to poll payment status
  • you are building a hosted-payment wrapper
  • you need to refresh payment state after checkout

PaymentStatus

The SDK uses the same main statuses as the Mint API:

  • pending
  • confirming_payment
  • paid
  • failed

Styling

Import the default stylesheet once:

ts
import '@mintmoney/react/css/styles.css';

For customisation guidance, see Customisation.