Skip to main content

React

The @apolopay-sdk/react package provides a native React component that wraps the SmartPay payment button.

Installation

npm install @apolopay-sdk/react

Usage

import { PaymentButton } from '@apolopay-sdk/react';

function CheckoutPage() {
const [processId, setProcessId] = useState('');

useEffect(() => {
// Call your backend to create a payment process
fetch('/api/create-payment', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ amount: 25.50 }),
})
.then(res => res.json())
.then(data => setProcessId(data.processId));
}, []);

return (
<div>
<h1>Complete Your Purchase</h1>
<PaymentButton
publicKey="YOUR_PUBLIC_KEY"
processId={processId}
/>
</div>
);
}

export default CheckoutPage;

Props

PropTypeRequiredDescription
publicKeystringYour payment button's public key
processIdstringThe process ID from your backend

Next Steps