Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
62c9ef9
add integration test to preference client
brunacamposxx Sep 20, 2023
7fdcd0f
add integration test to payment create and get
brunacamposxx Sep 21, 2023
51a5b05
add integration test to cancel and search payment
brunacamposxx Sep 22, 2023
fa12a5a
fix spelling error
brunacamposxx Sep 22, 2023
dc1bda3
Merge branch 'master-v2' into feature/preference-integration-test
brunacamposxx Sep 25, 2023
2ad5661
add example.e2e.config.js
brunacamposxx Sep 25, 2023
01e7b6a
move integration test files
brunacamposxx Sep 25, 2023
ce145af
add example.e2e.config.js
brunacamposxx Sep 25, 2023
233e7d6
add config.access_token to client
brunacamposxx Sep 26, 2023
0b1c6f7
Merge branch 'master-v2' into feature/payments-integration-test
brunacamposxx Sep 26, 2023
f8e9650
add config.access_token
brunacamposxx Sep 26, 2023
1a19009
add integration test to customer
brunacamposxx Sep 27, 2023
e8fd2b8
remove comment
brunacamposxx Sep 27, 2023
c27e1a5
fix jest imports on e2e
lucmkz Sep 27, 2023
3920132
Merge branch 'master-v2' into feature/payments-integration-test
lucmkz Sep 27, 2023
bd3679a
add integration tests to customers
brunacamposxx Sep 27, 2023
339b271
modify config.example.js to ts
brunacamposxx Sep 27, 2023
fb812a3
organize imports
brunacamposxx Sep 27, 2023
30a12d7
Merge branch 'feature/payments-integration-test' into feature/prefere…
brunacamposxx Sep 27, 2023
b7461b0
modify gitignore to ignore e2e.config.ts
lucmkz Sep 27, 2023
2511cab
modify integration tests to pass through public layer
brunacamposxx Sep 28, 2023
2d485a7
modify integration tests to pass through public layer
brunacamposxx Sep 28, 2023
fa31a60
Merge branch 'master-v2' into feature/customers-integration-test
brunacamposxx Sep 28, 2023
fd34061
merge jest configs
lucmkz Sep 27, 2023
d6397eb
add e2e.config.ts
brunacamposxx Sep 28, 2023
03ada12
modify integration tests to pass through public layer
brunacamposxx Oct 2, 2023
acb9a09
Update e2e/preferences/search.integration.spec.ts
brunacamposxx Oct 2, 2023
257c60d
Merge pull request #265 from mercadopago/master-v2
lucmkz Oct 2, 2023
1533f20
typo issues
lucmkz Oct 2, 2023
83054dd
rename payments to payment
lucmkz Oct 2, 2023
5aef0dc
typo issues
lucmkz Oct 2, 2023
c64a2eb
typo issues
lucmkz Oct 2, 2023
3ecba0e
downgrade version
lucmkz Oct 2, 2023
cb7eb36
Merge pull request #267 from mercadopago/hotfix/typo-issues
lucmkz Oct 2, 2023
fe7a8eb
Merge branch 'master-v2' into feature/preference-integration-test
lucmkz Oct 3, 2023
3936427
correcting types
brunacamposxx Oct 3, 2023
f3ad569
Merge branch 'master' into feature/preference-integration-test
brunacamposxx Oct 3, 2023
9861395
correcting types
brunacamposxx Oct 3, 2023
ecd1f38
rename files
brunacamposxx Oct 3, 2023
d88e4e9
Merge branch 'master' into feature/payments-integration-test
brunacamposxx Oct 3, 2023
0130feb
modify types and rename folder
brunacamposxx Oct 3, 2023
cda6928
improve tests checking response types
brunacamposxx Oct 3, 2023
c7b56da
remove comment
brunacamposxx Oct 3, 2023
94b4d41
Merge branch 'master' into feature/customers-integration-test
brunacamposxx Oct 3, 2023
de4d43e
rename folder
brunacamposxx Oct 3, 2023
abc89ef
improve tests
brunacamposxx Oct 4, 2023
49551c1
added names export for mercadopago module
lucmkz Oct 5, 2023
a726a8d
fix template PR
lucmkz Oct 5, 2023
95cebfe
fix template PR
lucmkz Oct 5, 2023
54d5540
rename MercadoPagoConfig to MercadoPago
lucmkz Oct 5, 2023
c4d02ff
rename MercadoPagoConfig to MercadoPago
lucmkz Oct 5, 2023
842c756
typo
lucmkz Oct 5, 2023
679d073
git flow files refactor
lucmkz Oct 5, 2023
7e47788
readme update
lucmkz Oct 5, 2023
b29945a
refactor gitflow
lucmkz Oct 5, 2023
3459a8c
Merge pull request #275 from mercadopago/fix/gitflow-issue
lucmkz Oct 5, 2023
956f910
Merge branch 'master' into feature/add-namedimport-mpconfig
lucmkz Oct 5, 2023
989e7b4
Merge pull request #274 from mercadopago/feature/add-namedimport-mpco…
lucmkz Oct 5, 2023
1b77c3d
typo worflows to workflows
lucmkz Oct 5, 2023
6afa826
packagelock update
lucmkz Oct 5, 2023
e43dee2
Merge branch 'master' into fix/workflows-issue-typo
lucmkz Oct 5, 2023
07f1ea8
remove 12.x work flow
lucmkz Oct 5, 2023
80b87fa
remove unused exemple
lucmkz Oct 5, 2023
b892a0d
Merge pull request #277 from mercadopago/fix/workflows-issue-typo
lucmkz Oct 5, 2023
54c0b07
rename module MercadoPago to MercadoPagoConfig
lucmkz Oct 5, 2023
544b3e6
Merge pull request #280 from mercadopago/fix/raneme-mp-module
lucmkz Oct 5, 2023
3248865
Merge branch 'master' into feature/preference-integration-test
brunacamposxx Oct 10, 2023
48edc37
fix tests
brunacamposxx Oct 10, 2023
ad7e5b4
rename tests
brunacamposxx Oct 10, 2023
0bcc268
Merge branch 'master' into feature/payments-integration-test
brunacamposxx Oct 10, 2023
cbf6a36
fix imports and add more tests
brunacamposxx Oct 11, 2023
0c1fc58
Merge pull request #269 from lucmkz/feature/preference-integration-test
lucmkz Oct 11, 2023
916bbc3
fix imports, add more matches
brunacamposxx Oct 11, 2023
500e64e
Merge branch 'master' into feature/payments-integration-test
brunacamposxx Oct 11, 2023
b6d90c1
fix types
brunacamposxx Oct 11, 2023
4ddd328
Merge branch 'master' into feature/customers-integration-test
brunacamposxx Oct 11, 2023
4fba05f
modify test matches
brunacamposxx Oct 11, 2023
8d81a29
remove options and fix paymentbody
brunacamposxx Oct 11, 2023
a25cca9
Merge pull request #270 from lucmkz/feature/payments-integration-test
lucmkz Oct 11, 2023
c6a9ef1
Merge branch 'master' into feature/customers-integration-test
brunacamposxx Oct 11, 2023
d69d9df
remove options
brunacamposxx Oct 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .github/worflows/ci.yml β†’ .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: Node.js CI
name: CI

on:
push:
branches: [ "master", "master-v2" ]
branches: [ "master" ]
pull_request:
branches: [ "*" ]
branches: [ "master" ]

jobs:
build:

test:
name: Test on Node v${{ matrix.node-version }}
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x]
node-version: [14.x, 16.x, 18.x, 19.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -22,5 +22,5 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm ci --legacy-peer-deps
- run: npm test
18 changes: 4 additions & 14 deletions .github/worflows/publish.yml β†’ .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,20 @@
name: Node.js Publish Package
name: Publish to NPM

on:
release:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
- run: npm ci
- run: npm test

publish-npm:
needs: build
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm ci --legacy-peer-deps
- run: npm run build
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# ============= Config e2e =============
/e2e/e2e.config.ts

# ============= Lint =============
# Cache eslint
.eslintcache
Expand Down
26 changes: 25 additions & 1 deletion CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Releases

## VERSION 2.0.1
- Added named export to MercadoPago configuration module
- Modified integration example in readme
- Adjusted PR template
- Adjusted gitflow files

## VERSION 2.0.0

* Search Method implementation
Release SDK Node Mercado Pago V2

- TypeScript Support ⭐️
- Type of all requests and all responses
- Maintained compatibility with Vanilla Javascript

Tests
- More than 90% coverage of unit tests
- Documentation
- Implementation examples from ALL clients
- Technical Documentation
- Melhorias no Readme
- Contribution template

Technical debits
- Code registration
- Removal of vulnerable libraries and without recent updates
- Registration with other Mercado Pago SDKs
- Individual Request configuration for client
16 changes: 10 additions & 6 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@
### βœ… Checklist:

- [ ] I followed the instructions indicated in [Contribution Guidelines](CONTRIBUTING.md)
- [ ] I added the changes to CHANGELOG
- [ ] Added the necessary tests for the code or functionality that I'm working on
- [ ] I ran the tests and made sure they work
- [ ] My branch coverage is at least 80%
- [ ] I verified the style of my code matches the one in the project

## 🧰 How to reproduce

- Step by step of how to test, specially for bugs.
- Links of external docs.
- [ ] Not Apply.
- [ ] Step by step of how to test, specially for bugs.
- [ ] Links of external docs.

## πŸ“Έ Screenshots

- Before and after, if it's a fix for a bug.
- [ ] Not Apply.
- [ ] Before and after, if it's a fix for a bug.

## πŸ“„ References

- Links do external documentation
- Diagrams
- Useful links
- [ ] Not Apply.
- [ ] Links do external documentation.
- [ ] Diagrams.
- [ ] Useful links.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
![SDK Node MErcado Pago](https://github.com/lucmkz/sdk-nodejs/assets/31546923/84211022-6fc5-4db1-8772-117eca84f2d9)
![SDK Node Mercado Pago](https://github.com/lucmkz/sdk-nodejs/assets/31546923/84211022-6fc5-4db1-8772-117eca84f2d9)


# Mercado Pago SDK for NodeJS
Expand Down Expand Up @@ -32,10 +32,10 @@ That's it! Mercado Pago SDK has been successfully installed.

```javascript
// Step 1: Import the parts of the module you want to use
import MercadoPago, { Payment } from 'mercadopago';
import { MercadoPagoConfig, Payment } from 'mercadopago';

// Step 2: Initialize the client object
const client = new MercadoPago({ accessToken: 'access_token', options: { timeout: 5000, idempotencyKey: 'abc' } });
const client = new MercadoPagoConfig({ accessToken: 'access_token', options: { timeout: 5000, idempotencyKey: 'abc' } });

// Step 3: Initialize the API object
const payment = new Payment(client);
Expand All @@ -56,10 +56,10 @@ payment.create({ body }).then(console.log).catch(console.log);

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

Import `MercadoPago` and API objects from the MercadoPago module.
Import `MercadoPagoConfig` and API objects from the MercadoPago module.

``` javascript
import MercadoPago, { Payment } from 'mercadopago';
import { MercadoPagoConfig, Payment } from 'mercadopago';
```

### Step 2: Initialize the client object
Expand All @@ -73,7 +73,7 @@ Initialize the client object, passing the following:
For example:

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

### Step 3: Initialize the API object
Expand Down Expand Up @@ -103,7 +103,7 @@ const body = {

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:

```
```javascript
payment.create({ body }).then(console.log).catch(console.log);
```

Expand Down
86 changes: 86 additions & 0 deletions e2e/customer/create.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import MercadoPago, { Customer } from '@src/index';
import { config } from '../e2e.config';

describe('IT customer, create', () => {
test('should create a client and match response object', async () => {
const client = new MercadoPago({ accessToken: config.access_token });
const customer = new Customer(client);

const email = createEmailTestUser();

const body = {
email: email,
first_name: 'Jhon',
last_name: 'Doe',
phone: {
area_code: '55',
number: '991234567'
},
identification: {
type: 'CPF',
number: '12345678900'
},
default_address: 'Home',
address: {
id: '123123',
zip_code: '25065172',
street_name: 'Rua Exemplo',
street_number: 123,
city: {}
},
date_registered: '2023-10-20T11:37:30.000-04:00',
description: 'Description del user',
default_card: 'None'
};

const createCustomer = await customer.create({ body });
expect(createCustomer).toHaveProperty('status', 'active');
expect(createCustomer).toEqual(expect.objectContaining({
email: email,
first_name: 'Jhon',
last_name: 'Doe',
date_registered: '2023-10-20T11:37:30.000-04:00',
description: 'Description del user',
}));
expect(createCustomer).toHaveProperty('phone', expect.objectContaining({
area_code: '55',
number: '991234567'
}));
expect(createCustomer).toHaveProperty('identification', expect.objectContaining({
type: 'CPF',
number: '12345678900'
}));
expect(createCustomer).toHaveProperty('address', expect.objectContaining({
zip_code: '25065172',
street_name: 'Rua Exemplo',
street_number: 123,
}));
expect(createCustomer).toEqual(expect.objectContaining({
id: expect.any(String),
email: expect.any(String),
first_name: expect.any(String),
last_name: expect.any(String),
phone: expect.any(Object),
identification: expect.any(Object),
default_address: expect.any(String),
address: expect.any(Object),
date_registered: expect.any(String),
date_created: expect.any(String),
date_last_updated: expect.any(String),
description: expect.any(String),
user_id: expect.any(Number),
merchant_id: expect.any(Number),
client_id: expect.any(Number),
status: expect.any(String),
}));

const removeCustomer = await customer.remove({ customerId: createCustomer.id });
expect(removeCustomer).toHaveProperty('id', removeCustomer.id);
});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}
});
32 changes: 32 additions & 0 deletions e2e/customer/get.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import MercadoPago, { Customer } from '@src/index';
import { config } from '../e2e.config';

describe('IT customer, get', () => {
test('should get a client and match response object', async () => {
const client = new MercadoPago({ accessToken: config.access_token });
const customer = new Customer(client);

const email = createEmailTestUser();

const body = {
email: email,
};

const createCustomer = await customer.create({ body });
expect(createCustomer).toHaveProperty('id');

const customerGet = await customer.get({ customerId: createCustomer.id });

expect(customerGet).toHaveProperty('id', createCustomer.id);
expect(customerGet).toHaveProperty('email', body.email);

const removeCustomer = await customer.remove({ customerId: customerGet.id });
expect(removeCustomer).toHaveProperty('id', removeCustomer.id);
});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}
});
41 changes: 41 additions & 0 deletions e2e/customer/remove.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import MercadoPago, { Customer } from '@src/index';
import { config } from '../e2e.config';

describe('IT customer, remove', () => {
test('should delete a customer and match response object', async () => {
const client = new MercadoPago({ accessToken: config.access_token });
const customer = new Customer(client);

const email = createEmailTestUser();

const body = {
email: email,
};

const createCustomer = await customer.create({ body });
expect(createCustomer).toHaveProperty('id');

const customerRemove = await customer.remove({ customerId: createCustomer.id });
expect(customerRemove).toHaveProperty('id', createCustomer.id);
expect(customerRemove).toHaveProperty('status', 'deactive');
expect(customerRemove).toEqual(expect.objectContaining({
id: expect.any(String),
email: expect.any(String),
user_id: expect.any(Number),
merchant_id: expect.any(Number),
client_id: expect.any(Number),
status: expect.any(String),
phone: expect.any(Object),
identification: expect.any(Object),
address: expect.any(Object),
date_last_updated: expect.any(String),
}));

});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}
});
21 changes: 21 additions & 0 deletions e2e/customer/search.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import MercadoPago, { Customer } from '@src/index';
import { config } from '../e2e.config';

describe('IT customer, search', () => {
test('should search a client and match response object', async () => {
const client = new MercadoPago({ accessToken: config.access_token });
const customer = new Customer(client);

const customerSearch = await customer.search({ options: { email: '[email protected]' } });
expect(customerSearch).toHaveProperty('results');
expect(customerSearch.results[0]).toHaveProperty('email', '[email protected]');
expect(customerSearch.results[0]).toEqual(expect.objectContaining({
id: expect.any(String),
email: expect.any(String),
phone: expect.any(Object),
identification: expect.any(Object),
address: expect.any(Object),
date_last_updated: expect.any(String),
}));
});
});
Loading