Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
mercadopago
Advanced tools
This library provides developers with a simple set of bindings to help you integrate Mercado Pago API to a website and start receiving payments.
The SDK Supports NodeJS version 16 or higher.
First time using Mercado Pago? Create your Mercado Pago account, if you don’t have one already.
$ npm install --save mercadopago
That's it! Mercado Pago SDK has been successfully installed.
Simple usage looks like:
// Step 1: Import the parts of the module you want to use
import { MercadoPagoConfig, Payment } from 'mercadopago';
// Step 2: Initialize the client object
const client = new MercadoPagoConfig({ accessToken: 'access_token', options: { timeout: 5000, idempotencyKey: 'abc' } });
// Step 3: Initialize the API object
const payment = new Payment(client);
// Step 4: Create the request object
const body = {
transaction_amount: 12.34,
description: '<DESCRIPTION>',
payment_method_id: '<PAYMENT_METHOD_ID>',
payer: {
email: '<EMAIL>'
},
};
// Step 5: Create request options object - Optional
const requestOptions = {
idempotencyKey: '<IDEMPOTENCY_KEY>',
};
// Step 6: Make the request
payment.create({ body, requestOptions }).then(console.log).catch(console.log);
Import MercadoPagoConfig
and API objects from the MercadoPago module.
import { MercadoPagoConfig, Payment } from 'mercadopago';
Initialize the client object, passing the following:
accessToken
: Application's private key.options
: These are optional fields,
timeout
: Are the timeout of requestsidempotencyKey
: Idempotency Is for retrying requests without accidentally performing the same operation twiceFor example:
const client = new MercadoPagoConfig({ accessToken: 'access_token', options: { timeout: 5000, idempotencyKey: 'abc' } });
Initialize the API object you want to use, passing the client
object from the previous step.
const payment = new Payment(client);
Create a the request object. For example, for a request to the /v1/payments
endpoint:
const body = {
transaction_amount: 12.34,
description: '<DESCRIPTION>',
payment_method_id: '<PAYMENT_METHOD_ID>',
payer: {
email: '<EMAIL>'
},
};
Use the API object's method to make the request. For example, to make a request to the /v1/payments
endpoint using the payment
object:
payment.create({ body }).then(console.log).catch(console.log);
Visit our Dev Site for further information regarding:
All contributions are welcome, ranging from people wanting to triage issues, others wanting to write documentation, to people wanting to contribute with code.
Please read and follow our contribution guidelines. Contributions not following these guidelines will be disregarded. The guidelines are in place to make all of our lives easier and make contribution a consistent process for everyone.
Since the release of version 2.0.0, version 1 is deprecated and will not be receiving new features, only bug fixes. If you need to submit PRs for that version, please do so by using develop-v1 as your base branch.
If you require technical support, please contact our support team at our developers site: English / Portuguese / Spanish
MIT license. Copyright (c) 2024 - Mercado Pago / Mercado Libre
For more information, see the LICENSE file.
FAQs
Mercadopago SDK for Node.js
We found that mercadopago demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.