Fragments (all-in-one)
This guide will provide you with everything you need to integrate our powerful, all-in-one payment solution into your application for a seamless native checkout experience.
Getting Started
1
Installation
npm install @pandablue/sdk<script
type="module"
src="https://pandabluesdk.s3.amazonaws.com/releases/pandablue-1.0.21.es.js"
></script>Ensure to install the latest version on this link!
2
Initialization
import SDK from '@pandablue/sdk';
// Instantiate the SDK
const pandablue = new SDK('YOUR_PUBLIC_KEY', { environment: 'stg', locale: 'en' });
// Instantiate the SDK from the global window object
const pandablue = new window.pandablue.SDK('YOUR_PUBLIC_KEY', { environment: 'stg', locale: 'en' });
3
Implementing the Credit Card Form
Basic Example
// Make sure you have instantiated the SDK before this step
<CreditCardForm
authToken="YOUR_CHECKOUT_TOKEN"
country="BR"
onSuccess={handlePaymentSuccess}
onError={handlePaymentError}
onBack={handleGoBack}
onTokenGenerationError={handleTokenError}
messages={handleMessages}
/>4
Handling Callbacks
function handlePaymentSuccess() {
console.log('Payment was successful!');
// e.g., Redirect to a success page or show a success message
}
function handlePaymentError(error) {
console.error('Payment failed:', error);
// e.g., Display an error message to the user
}
function handleGoBack() {
console.log('User clicked go back.');
// e.g., Navigate to the previous step in your checkout flow
}
function handleTokenError(error) {
console.error('Could not generate token:', error);
// This is often a configuration or setup issue.
}
5
Build the solution
Last updated
Was this helpful?



