
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
@mercadopago/sdk-react
Advanced tools
Mercado Pago's Official React SDK.
This is a wrapper that allows integrate Checkout Bricks, Secure Fields and Core Methods easily inside React projects.
Before starts verify if you have installed Node version 14.18.0 or superior.
First, install SDK MercadoPago React:
npm install @mercadopago/sdk-react
Start the instance of MercadoPago:
import { initMercadoPago } from '@mercadopago/sdk-react';
initMercadoPago('YOUR_PUBLIC_KEY');
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
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;
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;
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;
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;
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
import { CardNumber } from '@mercadopago/sdk-react';
const App = () => {
return <CardNumber placeholder='Card number'/>;
};
export default App;
import { SecurityCode } from '@mercadopago/sdk-react';
const App = () => {
return <SecurityCode placeholder='Security code'/>;
};
export default App;
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;
import { ExpirationMonth } from '@mercadopago/sdk-react';
const App = () => {
return <ExpirationMonth placeholder='Expiration month'/>;
};
export default App;
import { ExpirationYear } from '@mercadopago/sdk-react';
const App = () => {
return <ExpirationYear placeholder='Expiration year'/>;
};
export default App;
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>',
});
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
Return all the document types based on the public_key
import { getIdentificationTypes } from '@mercadopago/sdk-react';
const identificationTypes = await getIdentificationTypes();
Returns a payment methods list
import { getPaymentMethods } from '@mercadopago/sdk-react';
const paymentMethods = await getPaymentMethods({ bin: '<CARD_BIN>' });
Returns a issuers list
import { getIssuers } from '@mercadopago/sdk-react';
const issuers = await getIssuers({
paymentMethodId: '<CARD_PAYMENT_METHOD_ID>',
bin: '<CARD_BIN>',
});
Returns all installments available
import { getInstallments } from '@mercadopago/sdk-react';
const installments = await getInstallments({
amount: <AMOUNT>,
locale: '<LOCALE>',
bin: '<CARD_BIN>',
});
Return a token card
import { createCardToken } from '@mercadopago/sdk-react/coreMethods';
const cardToken = await createCardToken({
cardNumber: '<CREDIT_CARD_NUMBER>',
cardholderName: '<CARDHOLDER_NAME>',
cardExpirationMonth: '<CARD_EXPIRATION_MONTH>',
cardExpirationYear: '<CARD_EXPIRATION_YEAR>',
securityCode: '<CARD_SECURITY_CODE>',
identificationType: '<BUYER_IDENTIFICATION_TYPE>',
identificationNumber: '<BUYER_IDENTIFICATION_NUMBER>',
});
To use Mercado Pago React SDK, follow the steps:
Install project:
npm i
Execute project build:
npm build
Execute npm run start to initialize storybook.
This project is under Apache license, version 2.0. See Apache 2.0 file for more details.
FAQs
Mercado Pago SDK React
We found that @mercadopago/sdk-react demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 15 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.