Skip to main content

Components Documentation

This document provides an in-depth overview of the React components available in the Mileston Payment Client SDK. Note: All components require the MilestonPaymentProvider to provide apikey (checkout api key) and businessid via context.


MilestonPaymentProvider

A React context provider for managing API key and business ID. This provider is required to wrap your component tree to provide the necessary context for other components in the SDK.

Usage

import { MilestonPaymentProvider } from "mileston-payment-client";

function App() {
return (
<MilestonPaymentProvider
apikey="your-api-key"
businessid="your-business-id"
>
{/* Your application components */}
</MilestonPaymentProvider>
);
}

Props

Prop NameTypeDescription
apikeystringYour API key for authentication.
businessidstringYour business ID for identifying your business.
childrenReactNodeThe child components that will consume the context.

Notes

  • Ensure this provider wraps your entire application or the components that require access to the apikey and businessid.
  • This provider is required for components like PayButton, InvoiceCheckout, SubscriptionCheckout, etc.

PayButton

A React component for initiating payments. This component provides a customizable button that opens a popup for processing payments.

Usage

import { MilestonPaymentProvider, PayButton } from "mileston-payment-client";

function App() {
return (
<MilestonPaymentProvider
apikey="your-api-key"
businessid="your-business-id"
>
<PayButton
onPaymentComplete={() => console.log("Payment complete!")}
onPaymentError={(error) => console.error("Payment error:", error)}
paymentUrl="https://checkout.mileston.co/payment"
paymentId="payment-id"
paymentType="invoice"
theme="light"
style={{ backgroundColor: "green", color: "white" }}
className="custom-class"
>
Pay Now
</PayButton>
</MilestonPaymentProvider>
);
}

Props

Prop NameTypeDescription
onPaymentCompletefunctionCallback triggered when the payment is complete.
onPaymentErrorfunctionCallback triggered when payment fails.
paymentUrlstringURL of the payment page.
paymentIdstringID of the payment (e.g., invoice, payment link).
paymentTypestringType of payment (e.g., "invoice", "payment-link", "recurring").
themestringTheme for the payment popup (e.g., "light", "dark").
styleobjectCustom styles for the button.
classNamestringCSS class for the button.
childrenReactNodeThe content to display inside the button (e.g., "Pay Now").

Notes

  • Ensure the MilestonPaymentProvider wraps your component tree to provide the necessary context.
  • Customize the button's appearance using the style and className props.
  • The theme prop allows you to set the visual theme for the payment popup.

SubscriptionCheckout

A React component for subscription-based payments. This component simplifies the process of setting up recurring payments.

Usage

import {
MilestonPaymentProvider,
SubscriptionCheckout,
} from "mileston-payment-client";

<MilestonPaymentProvider apikey="your-api-key" businessid="your-business-id">
<SubscriptionCheckout
businessName="My Business"
businessLogo="https://example.com/logo.png"
plan={{
name: "Premium Plan",
description: "Access all premium features",
amount: 19.99,
currency: "USD",
interval: "monthly",
intervalCount: 1,
}}
walletConnectButtonText="Subscribe with Wallet"
qrCodeButtonText="Generate Subscription QR"
cardButtonText="Subscribe with Card"
buttonClassName="custom-button-class"
dialogTitle="Card Subscription"
dialogDescription="Set up your recurring payment using the secure form"
className="custom-class"
footerText="Thank you for subscribing!"
cancelText="You can cancel your subscription at any time"
paymentLinkId="subscription123"
env="test"
onWalletConnectPaymentComplete={() =>
console.log("Wallet subscription payment complete")
}
onWalletConnectPaymentError={(error) =>
console.error("Wallet subscription payment error:", error)
}
onQrCodePaymentComplete={() =>
console.log("QR Code subscription payment complete")
}
onQrCodePaymentError={(error) =>
console.error("QR Code subscription payment error:", error)
}
onCardPaymentComplete={() =>
console.log("Card subscription payment complete")
}
onCardPaymentError={(error) =>
console.error("Card subscription payment error:", error)
}
amount={19.99}
recipientWalletAddress="0x123456789abcdef"
/>
</MilestonPaymentProvider>;

Props

Prop NameTypeDescription
businessNamestringName of the business.
businessLogostringURL of the business logo.
planobjectSubscription plan details.
plan.namestringPlan name.
plan.descriptionstringPlan description.
plan.amountnumberSubscription amount.
plan.currencystringCurrency code (e.g., USD, EUR).
plan.intervalstringBilling interval (e.g., daily, weekly, monthly, yearly).
plan.intervalCountnumberNumber of intervals between billings (e.g., 1 for monthly, 3 for quarterly).
walletConnectButtonTextstringText for the Wallet Connect button.
qrCodeButtonTextstringText for the QR Code button.
cardButtonTextstringText for the Card button.
buttonClassNamestringCSS class for styling buttons.
dialogTitlestringTitle for the card payment dialog.
dialogDescriptionstringDescription for the card payment dialog.
classNamestringCSS class for the main component.
footerTextstringFooter text for the component.
cancelTextstringText for the cancel subscription message.
paymentLinkIdstringID of the payment link.
envstringEnvironment (e.g., test, production).
onWalletConnectPaymentCompletefunctionCallback for successful Wallet Connect payments.
onWalletConnectPaymentErrorfunctionCallback for Wallet Connect payment errors.
onQrCodePaymentCompletefunctionCallback for successful QR Code payments.
onQrCodePaymentErrorfunctionCallback for QR Code payment errors.
onCardPaymentCompletefunctionCallback for successful Card payments.
onCardPaymentErrorfunctionCallback for Card payment errors.
amountnumberSubscription amount.
recipientWalletAddressstringWallet address of the recipient.

Notes

  • Use this component to streamline subscription management.
  • Customize the subscription plan details using the plan prop.
  • Ensure the recipientWalletAddress is valid to avoid payment failures.
  • The cancelText prop allows you to display a message about subscription cancellation.

InvoiceCheckout

A React component for invoice-based payments. This component is ideal for handling one-time payments.

Usage

import {
MilestonPaymentProvider,
InvoiceCheckout,
} from "mileston-payment-client";

<MilestonPaymentProvider apikey="your-api-key" businessid="your-business-id">
<InvoiceCheckout
businessName="My Business"
businessLogo="https://example.com/logo.png"
currency="USD"
description="Invoice #12345"
walletConnectButtonText="Connect Wallet & Pay"
qrCodeButtonText="Generate Payment QR"
cardButtonText="Pay with Card"
buttonClassName="custom-button-class"
dialogTitle="Pay Invoice"
dialogDescription="Complete your payment securely"
className="custom-class"
footerText="Thank you for your business!"
paymentLinkId="invoice123"
env="test"
onWalletConnectPaymentComplete={() =>
console.log("Wallet payment complete")
}
onWalletConnectPaymentError={(error) =>
console.error("Wallet payment error:", error)
}
onQrCodePaymentComplete={() => console.log("QR Code payment complete")}
onQrCodePaymentError={(error) =>
console.error("QR Code payment error:", error)
}
onCardPaymentComplete={() => console.log("Card payment complete")}
onCardPaymentError={(error) => console.error("Card payment error:", error)}
amount={200}
recipientWalletAddress="0x123456789abcdef"
/>
</MilestonPaymentProvider>;

Props

Prop NameTypeDescription
businessNamestringName of the business.
businessLogostringURL of the business logo.
currencystringCurrency code (e.g., USD).
descriptionstringInvoice description.
walletConnectButtonTextstringText for the Wallet Connect button.
qrCodeButtonTextstringText for the QR Code button.
cardButtonTextstringText for the Card button.
buttonClassNamestringCSS class for styling buttons.
dialogTitlestringTitle for the card payment dialog.
dialogDescriptionstringDescription for the card payment dialog.
classNamestringCSS class for the main component.
footerTextstringFooter text for the component.
paymentLinkIdstringID of the payment link.
envstringEnvironment (e.g., test, production).
onWalletConnectPaymentCompletefunctionCallback for successful Wallet Connect payments.
onWalletConnectPaymentErrorfunctionCallback for Wallet Connect payment errors.
onQrCodePaymentCompletefunctionCallback for successful QR Code payments.
onQrCodePaymentErrorfunctionCallback for QR Code payment errors.
onCardPaymentCompletefunctionCallback for successful Card payments.
onCardPaymentErrorfunctionCallback for Card payment errors.
amountnumberInvoice amount.
recipientWalletAddressstringWallet address of the recipient.

Notes

  • Use this component for one-time payments such as invoices.
  • Ensure the recipientWalletAddress is valid to avoid payment failures.
  • Customize the appearance and behavior using the provided props.

PaymentLinkCheckout

A React component for payment link-based payments. This component is useful for generating payment links for customers.

Usage

import {
MilestonPaymentProvider,
PaymentLinkCheckout,
} from "mileston-payment-client";

<MilestonPaymentProvider apikey="your-api-key" businessid="your-business-id">
<PaymentLinkCheckout
businessName="My Business"
businessLogo="https://example.com/logo.png"
bannerImage="https://example.com/banner.png"
title="Payment Request"
currency="USD"
description="Pay for your order"
walletConnectButtonText="Connect Wallet & Pay"
qrCodeButtonText="Generate Payment QR"
cardButtonText="Pay with Card"
buttonClassName="custom-button-class"
dialogTitle="Pay Securely"
dialogDescription="Complete your payment using the secure form"
className="custom-class"
footerText="Thank you for your payment!"
paymentLinkId="payment123"
env="test"
onWalletConnectPaymentComplete={() =>
console.log("Wallet payment complete")
}
onWalletConnectPaymentError={(error) =>
console.error("Wallet payment error:", error)
}
onQrCodePaymentComplete={() => console.log("QR Code payment complete")}
onQrCodePaymentError={(error) =>
console.error("QR Code payment error:", error)
}
onCardPaymentComplete={() => console.log("Card payment complete")}
onCardPaymentError={(error) => console.error("Card payment error:", error)}
amount={100}
recipientWalletAddress="0x123456789abcdef"
/>
</MilestonPaymentProvider>;

Props

Prop NameTypeDescription
businessNamestringName of the business.
businessLogostringURL of the business logo.
bannerImagestringURL of the banner image for the payment page.
titlestringTitle of the payment request.
currencystringCurrency code (e.g., USD).
descriptionstringDescription of the payment request.
walletConnectButtonTextstringText for the Wallet Connect button.
qrCodeButtonTextstringText for the QR Code button.
cardButtonTextstringText for the Card button.
buttonClassNamestringCSS class for styling buttons.
dialogTitlestringTitle for the card payment dialog.
dialogDescriptionstringDescription for the card payment dialog.
classNamestringCSS class for the main component.
footerTextstringFooter text for the component.
paymentLinkIdstringID of the payment link.
envstringEnvironment (e.g., test, production).
onWalletConnectPaymentCompletefunctionCallback for successful Wallet Connect payments.
onWalletConnectPaymentErrorfunctionCallback for Wallet Connect payment errors.
onQrCodePaymentCompletefunctionCallback for successful QR Code payments.
onQrCodePaymentErrorfunctionCallback for QR Code payment errors.
onCardPaymentCompletefunctionCallback for successful Card payments.
onCardPaymentErrorfunctionCallback for Card payment errors.
amountnumberPayment amount.
recipientWalletAddressstringWallet address of the recipient.

Notes

  • Use this component to generate payment links for customers.
  • Customize the payment page appearance using the bannerImage and title props.
  • Ensure the recipientWalletAddress is valid to avoid payment failures.

PaymentOptions

A React component for displaying available payment options. This component provides tabs for Wallet Connect, QR Code, and Card payment methods.

Usage

import { PaymentOptions } from "mileston-payment-client";

function App() {
return (
<PaymentOptions
walletConnectButtonText="Connect Wallet & Pay"
qrCodeButtonText="Generate Payment QR"
cardButtonText="Pay with Card"
buttonClassName="custom-button-class"
dialogTitle="Pay Securely"
dialogDescription="Complete your payment using the secure form"
defaultTab="wallet"
onTabChange={(tab) => console.log("Selected Tab:", tab)}
onWalletConnectPaymentComplete={(networkId, tokenId) =>
console.log("Wallet payment complete:", networkId, tokenId)
}
onWalletConnectPaymentError={(error) =>
console.error("Wallet payment error:", error)
}
onQrCodePaymentComplete={(networkId, tokenId) =>
console.log("QR Code payment complete:", networkId, tokenId)
}
onQrCodePaymentError={(error) =>
console.error("QR Code payment error:", error)
}
onCardPaymentComplete={() => console.log("Card payment complete")}
onCardPaymentError={(error) =>
console.error("Card payment error:", error)
}
amount={100}
env="test"
recipientWalletAddress="0x123456789abcdef"
paymentType="invoice"
paymentLinkId="payment123"
/>
);
}

Props

Prop NameTypeDescription
walletConnectButtonTextstringText for the Wallet Connect button.
qrCodeButtonTextstringText for the QR Code button.
cardButtonTextstringText for the Card button.
buttonClassNamestringCSS class for styling buttons.
dialogTitlestringTitle for the card payment dialog.
dialogDescriptionstringDescription for the card payment dialog.
defaultTabstringThe default selected tab (e.g., "wallet", "qrcode", "card").
onTabChangefunctionCallback triggered when the selected tab changes.
onWalletConnectPaymentCompletefunctionCallback for successful Wallet Connect payments.
onWalletConnectPaymentErrorfunctionCallback for Wallet Connect payment errors.
onQrCodePaymentCompletefunctionCallback for successful QR Code payments.
onQrCodePaymentErrorfunctionCallback for QR Code payment errors.
onCardPaymentCompletefunctionCallback for successful Card payments.
onCardPaymentErrorfunctionCallback for Card payment errors.
amountnumberPayment amount.
envstringEnvironment (e.g., test, production).
recipientWalletAddressstringWallet address of the recipient.
paymentTypestringType of payment (e.g., "invoice", "payment-link", "recurring").
paymentLinkIdstringID of the payment link.

Notes

  • Use this component to provide multiple payment options to users.
  • Customize the appearance of the buttons using the buttonClassName prop.
  • The defaultTab prop allows you to set the initial selected payment method.
  • Ensure the recipientWalletAddress is valid to avoid payment failures.

SuiWalletProvider

A React context provider for integrating Sui blockchain wallets. This provider sets up the necessary configurations for connecting to Sui networks and managing wallet connections.

Usage

import SuiWalletProvider from "mileston-payment-client";

function App() {
return (
<SuiWalletProvider>{/* Your application components */}</SuiWalletProvider>
);
}

Props

Prop NameTypeDescription
childrenReactNodeThe child components that will consume the wallet context.

Notes

  • The default network is set to testnet, but it also supports mainnet.

Features

  • Network Configuration: Configures Sui networks (testnet and mainnet) using createNetworkConfig.
  • Auto Connection: Automatically connects to the wallet when the provider is initialized.
  • Query Management: Uses QueryClientProvider for managing queries and caching.

WalletConnectPayment

A React component for handling payments via WalletConnect. It supports multiple blockchain networks and tokens.

Usage

import { WalletConnectPayment } from "mileston-payment-client";

function App() {
return (
<WalletConnectPayment
onPaymentComplete={(networkId, tokenId) =>
console.log("Payment complete:", networkId, tokenId)
}
onPaymentError={(error) => console.error("Payment error:", error)}
buttonText="Connect Wallet & Pay"
buttonClassName="custom-class"
recipientWalletAddress={{
eth: "0x123456789abcdef",
sui: "sui-address",
solana: "solana-address",
}}
amount={100}
paymentLinkId="payment123"
env="test"
paymentType="invoice"
userUUID="user-uuid"
/>
);
}

Props

Prop NameTypeDescription
onPaymentCompletefunctionCallback for successful payments.
onPaymentErrorfunctionCallback for payment errors.
buttonTextstringText for the payment button.
buttonClassNamestringCSS class for styling the button.
recipientWalletAddressobjectWallet addresses for different blockchains.
amountnumberPayment amount.
paymentLinkIdstringID of the payment link.
envstringEnvironment (e.g., test, production).
paymentTypestringType of payment (e.g., invoice, recurring).
userUUIDstringUser UUID for tracking payments.

Notes

  • Supports multiple blockchain networks like Ethereum, Sui, and Solana.
  • Automatically handles wallet connections and payment processing.

QrCodePayment

A React component for generating and verifying QR code-based payments.

Usage

import { QrCodePayment } from "mileston-payment-client";

function App() {
return (
<QrCodePayment
onPaymentComplete={(networkId, tokenId) =>
console.log("Payment complete:", networkId, tokenId)
}
onPaymentError={(error) => console.error("Payment error:", error)}
buttonText="Generate Payment QR"
buttonClassName="custom-class"
recipientWalletAddress={{
eth: "0x123456789abcdef",
sui: "sui-address",
solana: "solana-address",
}}
amount={100}
paymentLinkId="payment123"
env="test"
paymentType="invoice"
userUUID="user-uuid"
/>
);
}

Props

Prop NameTypeDescription
onPaymentCompletefunctionCallback for successful payments.
onPaymentErrorfunctionCallback for payment errors.
buttonTextstringText for the QR code generation button.
buttonClassNamestringCSS class for styling the button.
recipientWalletAddressobjectWallet addresses for different blockchains.
amountnumberPayment amount.
paymentLinkIdstringID of the payment link.
envstringEnvironment (e.g., test, production).
paymentTypestringType of payment (e.g., invoice, recurring).
userUUIDstringUser UUID for tracking payments.

Notes

  • Generates a QR code for payment and verifies the transaction via polling.
  • Supports multiple blockchain networks and tokens.

CardPayment

A React component for handling card-based payments. It integrates with onramp services to process payments.

Usage

import { CardPayment } from "mileston-payment-client";

function App() {
return (
<CardPayment
onPaymentComplete={() => console.log("Payment complete")}
onPaymentError={(error) => console.error("Payment error:", error)}
buttonText="Pay with Card"
buttonClassName="custom-class"
recipientWalletAddress={{
eth: "0x123456789abcdef",
sui: "sui-address",
solana: "solana-address",
}}
amount={100}
paymentLinkId="payment123"
env="test"
paymentType="invoice"
userUUID="user-uuid"
/>
);
}

Props

Prop NameTypeDescription
onPaymentCompletefunctionCallback for successful payments.
onPaymentErrorfunctionCallback for payment errors.
buttonTextstringText for the payment button.
buttonClassNamestringCSS class for styling the button.
recipientWalletAddressobjectWallet addresses for different blockchains.
amountnumberPayment amount.
paymentLinkIdstringID of the payment link.
envstringEnvironment (e.g., test, production).
paymentTypestringType of payment (e.g., invoice, recurring).
userUUIDstringUser UUID for tracking payments.

Notes

  • Opens a popup for processing card payments via onramp services.
  • Tracks the payment status and updates the UI accordingly.

SolanaWalletProvider

A React context provider for integrating Solana blockchain wallets. This provider sets up the necessary configurations for connecting to Solana networks and managing wallet connections.

Usage

import SolanaWalletProvider from "mileston-payment-client";

function App() {
return (
<SolanaWalletProvider env="test">
{/* Your application components */}
</SolanaWalletProvider>
);
}

Props

Prop NameTypeDescription
childrenReactNodeThe child components that will consume the wallet context.
envstringThe environment (e.g., "test", "prod").

Notes

  • The env prop determines whether the provider connects to the mainnet or devnet.

Features

  • Network Configuration: Configures Solana networks (mainnet and devnet) using clusterApiUrl.
  • Auto Connection: Automatically connects to the wallet when the provider is initialized.
  • Wallet Modal: Provides a wallet modal for selecting and connecting wallets.