Plug & Play SDK
Embed a complete checkout form in your site with minimal configuration. Glin handles the UI, validation, and payment processing.
Overview
The Plug & Play SDK renders a full checkout experience inside your page with just a few lines of code. It uses Glin's default styling and includes everything your customer needs to complete a payment -- card form with brand detection, PIX QR code, address auto-fill, inline validation, and 3DS authentication.
Prerequisites
- remittanceId -- Create a remittance via
POST /merchant-api/remittances/from your server. See the Redirect Checkout guide. - publicKey -- Your checkout public key, available in the Integrations section of your merchant dashboard.
Preview
The checkout renders two side-by-side widgets: the Checkout Form on the left and the Remittance Summary on the right. Below is a live paginated example with just a few lines of code.
GlinCheckout.mount('#checkout', {
publicKey: 'YOUR_PUBLIC_KEY',
remittanceId: 'REMITTANCE_ID',
paginated: true,
onPaymentReady: async ({ remittanceId, paymentData }) => {
const res = await fetch('/api/confirm-payment', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ remittanceId, paymentData }),
});
return res.json();
},
});Checkout Widgets
The SDK renders two complementary panels that together form the complete checkout experience.
Layout Options
Control how the checkout form sections are arranged using the layout option, and where the remittance summary appears using summaryPosition.
Form Layout
| Name | Type | Required | Description |
|---|---|---|---|
vertical | default | — | All form sections stacked in a single scrollable column. Best for narrow containers and mobile. |
For a multi-step wizard experience, use the paginated option instead. This shows one section at a time with next/back navigation and a step indicator.
Summary Position
| Name | Type | Required | Description |
|---|---|---|---|
right | default | — | Summary panel on the right side of the form (as shown in the preview). Best for desktop layouts. |
left | string | — | Summary panel on the left side of the form. |
top | string | — | Summary panel above the form. Best for narrow containers and mobile-first layouts. |
bottom | string | — | Summary panel below the form. |
hidden | string | — | Hides the summary panel entirely. Use when you display order details in your own UI. |
On mobile viewports, the summary panel automatically stacks above the form regardless of the summaryPosition setting.
Example: Paginated (Accordion Steps)
GlinCheckout.mount('#checkout', {
publicKey: 'YOUR_PUBLIC_KEY',
remittanceId: 'REMITTANCE_ID',
// Accordion-style form: one section at a time, others collapsed
paginated: true,
// Summary stays visible beside the active step
summaryPosition: 'right',
// Card form language. Defaults to 'pt-BR' (SDK 1.1.0+)
locale: 'en',
onPaymentReady: async ({ remittanceId, paymentData }) => {
const res = await fetch('/api/confirm-payment', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ remittanceId, paymentData }),
});
return res.json();
},
onSuccess: (data) => console.log('Paid!', data),
});For full control over theme colors, field visibility, pre-filled data, and CSS overrides, see the Customizable SDK page.
Script Tag Integration
The fastest way to get started. Include the SDK script from the Glin CDN, add a container element, and call GlinCheckout.mount().
<script src="https://sdk.glin.com.br/v1/glin-checkout.js"></script>
<div id="checkout"></div>
<script>
GlinCheckout.mount('#checkout', {
publicKey: 'YOUR_PUBLIC_KEY',
remittanceId: 'REMITTANCE_ID',
// Required: forward payment data to your backend for server-side confirmation
onPaymentReady: async ({ remittanceId, paymentData }) => {
const res = await fetch('/api/confirm-payment', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ remittanceId, paymentData }),
});
return res.json();
},
onSuccess: (data) => {
console.log('Payment confirmed:', data.orderId);
window.location.href = '/thank-you';
},
onError: (error) => {
console.error('Payment failed:', error.message);
}
});
</script>GlinCheckout as a global variable. No build step required. npm Integration
If you use a bundler (Vite, Webpack, etc.), install the SDK as a dependency and import it directly.
npm install @glin/checkout-sdkimport { GlinCheckout } from '@glin/checkout-sdk';
const checkout = GlinCheckout.create({
publicKey: 'YOUR_PUBLIC_KEY',
remittanceId: remittanceId,
onPaymentReady: async ({ remittanceId, paymentData }) => {
const res = await fetch('/api/confirm-payment', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ remittanceId, paymentData }),
});
return res.json();
},
onSuccess: (data) => {
router.push('/thank-you');
},
});
checkout.mount('#checkout');What's Included
The Plug & Play SDK ships with a complete set of features out of the box:
- Floating labels -- Clean, modern input styling with animated labels
- Card brand detection -- Automatically identifies Visa, Mastercard, Amex, and more from the card number
- CEP auto-fill -- Brazilian postal codes auto-fill city, state, and neighborhood fields
- Inline validation -- Real-time field validation with clear error messages
- 3DS authentication -- Handles 3D Secure challenges transparently when required by the issuer
- PIX QR code -- Generates and displays a PIX QR code for instant bank transfers
- Remittance summary -- Displays amount breakdown, exchange rates, taxes, and installment options
Estados de Pagamento
O SDK gerencia automaticamente os diferentes estados do fluxo de pagamento, oferecendo feedback visual ao cliente em cada etapa.
Callbacks
Use callbacks to react to checkout events in your application.
| Name | Type | Required | Description |
|---|---|---|---|
onPaymentReady | (data: PaymentReadyData) => Promise<PaymentConfirmResponse> | — | Required. Called when payment data is ready (card tokenized, customer registered). Forward paymentData to your backend, which calls POST /merchant-api/remittances/{id}/pay with your API key. Return the response so the SDK can handle PIX, 3DS, or polling. |
onSuccess | (data: SuccessData) => void | — | Called when the payment is confirmed. Receives remittanceId, orderId, paymentMethod, and optionally customerId. |
onError | (error: ErrorData) => void | — | Called when a payment attempt fails. Receives a code and a human-readable message. |
onReady | () => void | — | Called when the checkout form is fully rendered and ready for interaction. |