CheckoutWithEth
CheckoutWithEth embeds a component on your page that accepts ETH payments on Ethereum (or Goerli).
This component also handles:
- Connecting the payment wallet
- Prompting the payment wallet to switch chain, if necessary
- Informing the payment wallet they have insufficient funds
Paper requests the precise amount of funds on the correct chain for the easiest buying experience.
Competing alternatives often require the user to send funds to an arbitrary address, resulting in buyers sending insufficient funds or sending on the wrong blockchain.
Example
The user is prompted to connect their payment wallet. This step is skipped if they've already connected their wallet to your app since this connection is established on your domain.

The user is then prompted to review their purchase, accept the Terms of Service, and complete their payment.

This SDK is available in ReactJS and JavaScript.
Integration: ReactJS
- Install the ReactJS SDK with your preferred package manager.
npm install @paperxyz/react-client-sdk
yarn add @paperxyz/react-client-sdk
- Copy your API key from the Developer Dashboard: Developers page.
- When a buyer wants to make a purchase, create a Checkout Elements Client Secret (API reference) to generate an SDK Client Secret. You will provide some buyer information and configure behavior via this API.
- Instantiate a
PaperSDKProvider
provider to store Paper-specific properties. - Within the provider, instantiate the
CheckoutWithEth
component to render this component. Pass the SDK Client Secret to this component.
Example code
import { CheckoutWithEth, PaperSDKProvider } from "@paperxyz/react-client-sdk";
import "@paperxyz/react-client-sdk/dist/index.css";
<PaperSDKProvider appName="My Web3 App" chainName="Polygon">
<CheckoutWithEth
sdkClientSecret="MY_SDK_CLIENT_SECRET"
receivingWalletType="MetaMask"
showConnectWalletOptions
onSuccess={(result) => {
console.log("Payment successful.");
}}
onError={(error) => {
console.error("Payment error:", error);
}}
options={{
colorBackground: '#121212',
colorPrimary: '#19A8D6',
colorText: '#f0f0f0',
borderRadius: 24,
}}
/>
</PaperSDKProvider>
Note: Remember to import the .css
stylesheet!
PaperSDKProvider
props
PaperSDKProvider
propsName | Type | Description |
---|---|---|
appName | string | The application name that will be shown on the wallet, if provided. |
chainName | enum Valid values: - Polygon - Mumbai - Ethereum - Goerli - Solana - SolanaDevnet | The chain matching the registered contract for this checkout. |
CheckoutWithEth
props
CheckoutWithEth
propsName | Type | Description |
---|---|---|
sdkClientSecret * | string | The SDK Client Scret returned from the Create Checkout Elements Client Secret API. |
onSuccess * | (props : { transactionResponse: TransactionResponse; transactionId: string; }) => void | This method is called after the payment has been initiated. This payment is pending and may still fail off-chain. |
options | object | Customize component styling. See Customization. |
receivingWalletType | enum Valid values: - WalletConnect - MetaMask - Coinbase Wallet - Phantom - Preset | Defaults to Preset .The wallet type of the user wallet receiving the NFT to render the appropriate wallet icon in the component. |
suppressErrorToast | boolean | Defaults to false .If false , there will be a toast (within the iFrame) that pops up informing the user of what went wrong.This can include cancelling transaction, pending transactions etc. |
showConnectWalletOptions | boolean | Defaults to true .If true a connect wallet screen will be displayed allowing users to connect their wallet. |
payingWalletSigner | ethers.Signer | If provided, the component will request funds from this signer. |
onWalletConnected | (props: { userAddress: string, chainId: number }) => void | This method is called when a payment wallet is connected. |
onPageChange | (currentPage: CheckoutWithEthPage) => void | This method is called when the buyer transitions between pages. |
onError | (error: PaperSDKError) => void | This method is called when an error is encountered. |
setUpUserPayingWalletSigner | (args: { chainId: number }) => void | This method is called before the payingWalletSigner is asked to pay with the chainId that the payingWalletSigner is supposed to be on. |
Integration: JavaScript
- Install the JavaScript SDK with your preferred package manager.
npm install @paperxyz/js-client-sdk
yarn add @paperxyz/js-client-sdk
- Copy your API key from the Developer Dashboard: Developers page.
- When a buyer wants to make a purchase, create a Checkout Elements Client Secret (API reference) to generate an SDK Client Secret. You will provide some buyer information and configure behavior via this API.
- Call
createCheckoutWithEthElement
to insert the iframe on your page. Pass the SDK Client Secret to this component.- If you don't provide
elementOrId
, this call returns an iframe element for you to insert into your page.
- If you don't provide
Code example
import type { createCheckoutWithEthElement } from "@paperxyz/js-client-sdk";
// Assume a container exists:
//
// <div id="paper-checkout-container" />
//
const iframe = await createCheckoutWithEthElement({
sdkClientSecret: "MY_SDK_CLIENT_SECRET",
elementOrId: "paper-checkout-container",
payingWalletSigner,
setUpUserPayingWalletSigner,
receivingWalletType,
onError(error) {
console.log("Payment error:", error);
},
onSuccess({ transactionId }) {
console.log("Payment successful.");
},
});
// Alternatively, insert the iframe programmatically:
//
// const iframe = createCheckoutWithEthElement(...)
// document.getElementById('paper-checkout-container').appendChild(iframe);
Props
Name | Type | Description |
---|---|---|
sdkClientSecret * | string | The client secret returned from the Checkout SDK intent API. |
payingWalletSigner * | ethers.Signer | The connected wallet who is going to be paying the ETH required for the checkout |
options | object | Customize component styling. See Customization. |
setUpUserPayingWalletSigner | (args: { chainId: number; }) => void | Promise | If provided, the callback will be called before asking buyers to pay with the chainId that they are expected to be on.Developers must make sure that users are on the right chain (Goerli for testnets, Eth for mainnets) or risk buyers sending funds into the void. |
receivingWalletType | enum Valid values: - WalletConnect - MetaMask - Coinbase Wallet - Phantom - Preset | Defaults to Preset .The wallet type of the user wallet receiving the NFT to render the appropriate wallet icon in the component. |
onError | (error: PaperSDKError) => void | This method is called when anything wrong happens during the checkout process |
onSuccess | (props : { transactionResponse: TransactionResponse; transactionId: string; }) => void) | This method is called when the transaction is successfully sent to the blockchain |
suppressErrorToast | boolean | Defaults to true .If false, any error thrown will be displayed in a toast. |
onLoad | () => void | This method is called when the iframe loads |
elementOrId | string | HTMLElement | If provided, the iframe will be appended this element. Note that you can either pass in a reference to the container element or the id associated with the container element |
Customization
The optional options
argument allows you to customize the component's styling. All customization fields are optional.
options
object
options
objectName | Type | Description |
---|---|---|
colorPrimary | string In hex, e.g. #cf3781 | The primary brand color for buttons and links. |
colorBackground | string In hex, e.g. #cf3781 | The background color of the page. |
colorText | string In hex, e.g. #cf3781 | The color for text on the page and UI elements. |
borderRadius | number In px, e.g. 0 for sharp corners, 12 for rounded corners, 24 for pill shape | The roundness of buttons and input elements. |
Updated 14 days ago