Giter Site home page Giter Site logo

aledavidgueva / sdk-nodejs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mercadopago/sdk-nodejs

0.0 0.0 0.0 1.67 MB

Mercado Pago's Official Node.js SDK

Home Page: https://developers.mercadopago.com/

License: MIT License

Shell 0.05% JavaScript 0.21% TypeScript 99.74%

sdk-nodejs's Introduction

SDK Node Mercado Pago

Mercado Pago SDK for NodeJS

NPM Version Downloads License

This library provides developers with a simple set of bindings to help you integrate Mercado Pago API to a website and start receiving payments.

πŸ’‘ Requirements

The SDK Supports NodeJS version 12 or higher.

πŸ“² Installation

First time using Mercado Pago? Create your Mercado Pago account, if you don’t have one already.

  1. Install NodeJS SDK for MercadoPago running in command line:
$ npm install --save mercadopago
  1. Copy the access_token in the credentials section of the page and replace YOUR_ACCESS_TOKEN with it.

That's it! Mercado Pago SDK has been successfully installed.

🌟 Getting Started

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: Make the request
payment.create({ body }).then(console.log).catch(console.log);

Step 1: Import the parts of the module you want to use

Import MercadoPagoConfig and API objects from the MercadoPago module.

import { MercadoPagoConfig, Payment } from 'mercadopago';

Step 2: Initialize the client object

Initialize the client object, passing the following:

  • accessToken: Application's private key.
  • options: These are optional fields,
    • timeout: Are the timeout of requests
    • idempotencyKey: Idempotency Is for retrying requests without accidentally performing the same operation twice

For example:

const client = new MercadoPagoConfig({ accessToken: 'access_token', options: { timeout: 5000, idempotencyKey: 'abc' } });

Step 3: Initialize the API object

Initialize the API object you want to use, passing the client object from the previous step.

const payment = new Payment(client);

Step 4: Create the request object

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>'
	},
};

Step 5: Make the request

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);

πŸ“š Documentation

Visit our Dev Site for further information regarding:

Check our official code reference to explore all available functionalities.

🀝 Contributing

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.

Patches to version 1.x.x

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.

❀️ Support

If you require technical support, please contact our support team at our developers site: English / Portuguese / Spanish

🏻 License

MIT license. Copyright (c) 2023 - Mercado Pago / Mercado Libre 
For more information, see the LICENSE file.

sdk-nodejs's People

Contributors

arielfr avatar lucmkz avatar brunacamposxx avatar taliyada avatar romerosilva avatar gdeandradero avatar lucmantovani avatar edmarsoaress avatar rhames07 avatar delias-silva avatar victorgodinho-meli avatar eltinmeli avatar dependabot[bot] avatar leonardosal avatar mortaro avatar danieldspx avatar diegorbaquero avatar gafigueroa avatar hdlopez avatar jlucaso1 avatar laissonsilveira avatar lfeitosa avatar matiasgualino avatar chamini2 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.