npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@mercadopago/sdk-react

v1.0.6

Published

Mercado Pago SDK React

Readme

React SDK MercadoPago

Mercado Pago's Official React SDK.

NPM Version Downloads

Table of Contents

About

This is a wrapper that allows integrate Checkout Bricks, Secure Fields and Core Methods, and Fast Payment authentication easily inside React projects.

Prerequisites

Before starts verify if you have installed Node version v16.20.2 or superior.

Installation

First, install SDK MercadoPago React: npm install @mercadopago/sdk-react

Initialization

Start the instance of MercadoPago:

import { initMercadoPago } from '@mercadopago/sdk-react';

initMercadoPago('YOUR_PUBLIC_KEY');

Checkout Bricks

Checkout Bricks are modular checkout components. Below are examples of Brick implementations, for more information check the Examples folder.

Note It's mandatory to have previously done the Initialization step

Card Payment Brick

Use CardPayment component inside your functional React:

import { CardPayment } from '@mercadopago/sdk-react';

const App = () => {
  return (
    <CardPayment
      initialization={{ amount: AMOUNT }}
      onSubmit={async (param) => {
        console.log(param);
      }}
    />
  );
};
export default App;

Payment Brick

Use Payment component inside your functional React:

import { Payment } from '@mercadopago/sdk-react';

const App = () => {
  return (
    <Payment
      initialization={{
        amount: AMOUNT,
        preferenceId: '<YOUR_PREFERENCE_ID>',
      }}
      onSubmit={async (param) => {
        console.log(param);
      }}
    />
  );
};
export default App;

Status Screen Brick

Use StatusScreen component inside your functional React:

import { StatusScreen } from '@mercadopago/sdk-react';

const App = () => {
  return <StatusScreen initialization={{ paymentId: 'YOUR_PAYMENT_ID' }} />;
};
export default App;

Wallet Brick

Use Wallet component inside your functional React:

import { Wallet } from '@mercadopago/sdk-react';

const App = () => {
  return <Wallet initialization={{ preferenceId: 'YOUR_PREFERENCE_ID' }} />;
};
export default App;

Brand Brick

Use Brand component inside your functional React:

import { Brand } from '@mercadopago/sdk-react';

const App = () => {
  return <Brand />;
};
export default App;

Secure Fields

Secure Fields are input components that allow you to collect credit and debit card information safely, and allow you to get the PCI SAQ A certification. The Secure Fields module also provides a method to get the card token safely without the need to store the card data.

Note It's mandatory to have previously done the Initialization step

Fast Payment

This feature is disabled by default, to enable, please contact the offical Mercado Pago support via developer's website: www.mercadopago.com/developers

Fast Payment allows users to authenticate using their MercadoPago/MercadoLibre account and quickly access their saved payment methods for streamlined checkout experiences.

Note It's mandatory to have previously done the Initialization step

createAuthenticator

Creates an authenticator instance for Fast Payments authentication flow.

import { createAuthenticator } from '@mercadopago/sdk-react';

// Show authentication UI and get FastPaymentToken
try {
  const authenticator = await createAuthenticator('100.00', '[email protected]');
  const fastPaymentToken = await authenticator.show({
    confirmationLocation: 'web',
  });
  console.log('FastPaymentToken:', fastPaymentToken);
} catch (error) {
  console.error(error.message, 'Error code:', error?.errorCode);
}

For a complete working example, see the examples/fastPaymentFlow/ directory.

Components

Card Number

import { CardNumber } from '@mercadopago/sdk-react';

const App = () => {
  return <CardNumber placeholder="Card number" />;
};
export default App;

Security Code

import { SecurityCode } from '@mercadopago/sdk-react';

const App = () => {
  return <SecurityCode placeholder="Security code" />;
};
export default App;

Expiration Date

Note: Expiration Date cannot coexist with Expiration Month or Expiration Year

import { ExpirationDate } from '@mercadopago/sdk-react';

const App = () => {
  return <ExpirationDate placeholder="Expiration date" />;
};
export default App;

Expiration Month

import { ExpirationMonth } from '@mercadopago/sdk-react';

const App = () => {
  return <ExpirationMonth placeholder="Expiration month" />;
};
export default App;

Expiration Year

import { ExpirationYear } from '@mercadopago/sdk-react';

const App = () => {
  return <ExpirationYear placeholder="Expiration year" />;
};
export default App;

Methods

createCardToken

Return a token card

import { createCardToken } from '@mercadopago/sdk-react';
const cardToken = await createCardToken({
  cardholderName: '<CARDHOLDER_NAME>',
  identificationType: '<BUYER_IDENTIFICATION_TYPE>',
  identificationNumber: '<BUYER_IDENTIFICATION_NUMBER>',
});

updateCardToken

Update a token card

import { updateCardToken } from '@mercadopago/sdk-react';
const cardToken = await updateCardToken('<OLD_CARD_TOKEN>');

Core Methods

For a full explanation of each function parameters and return, check the SDK-JS documentation of the Core Methods

Note It's mandatory to have previously done the Initialization step

getIdentificationTypes

Return all the document types based on the public_key

import { getIdentificationTypes } from '@mercadopago/sdk-react';
const identificationTypes = await getIdentificationTypes();

getPaymentMethods

Returns a payment methods list

import { getPaymentMethods } from '@mercadopago/sdk-react';
const paymentMethods = await getPaymentMethods({ bin: '<CARD_BIN>' });

getAccountPaymentMethods

Returns account payment methods for authenticated users using FastPaymentToken

import { getAccountPaymentMethods } from '@mercadopago/sdk-react';
const accountPaymentMethods = await getAccountPaymentMethods('<FAST_PAYMENT_TOKEN>');

getCardId

Retrieves card ID from a pseudotoken using FastPaymentToken authentication

import { getCardId } from '@mercadopago/sdk-react';
const cardIdResponse = await getCardId('<FAST_PAYMENT_TOKEN>', '<PSEUDOTOKEN>');
console.log(cardIdResponse.card_id);

updatePseudotoken

Updates a pseudotoken with card token information

import { updatePseudotoken } from '@mercadopago/sdk-react';
await updatePseudotoken('<FAST_PAYMENT_TOKEN>', '<PSEUDOTOKEN>', '<CARD_TOKEN>');

getIssuers

Returns a issuers list

import { getIssuers } from '@mercadopago/sdk-react';
const issuers = await getIssuers({
  paymentMethodId: '<CARD_PAYMENT_METHOD_ID>',
  bin: '<CARD_BIN>',
});

getInstallments

Returns all installments available

import { getInstallments } from '@mercadopago/sdk-react';
const installments = await getInstallments({
  amount: <AMOUNT>,
  locale: '<LOCALE>',
  bin: '<CARD_BIN>',
});

By default, your bundler should select the appropriate module format. However, if you need to explicitly use ECMAScript Modules (ESM) or CommonJS (CJS), you can specify. For example, use import createCardToken from '@mercadopago/sdk-react/esm/secureFields/createCardToken/index'; for ECMAScript modules, or const createCardToken = require('@mercadopago/sdk-react/cjs/secureFields/createCardToken/index'); for CommonJS modules.

Run SDK project

Replace the <YOUR_PUBLIC_KEY> on examples/contants with your public key.

To run Mercado Pago React SDK, follow the steps:

Install project dependencies:

npm install

Execute project build (optional):

npm run build

Execute storybook:

npm run start

License

This project is under Apache license, version 2.0. See Apache 2.0 file for more details.