Skip to content

Commit

Permalink
Merge pull request #297 from mercadopago/feature/add-point-of-interac…
Browse files Browse the repository at this point in the history
…tion-and-address-to-payer

Add Point of Interaction to the root and Address to Payer
  • Loading branch information
brunacamposxx authored Nov 29, 2023
2 parents b01f182 + d217fb6 commit 79d10bc
Show file tree
Hide file tree
Showing 26 changed files with 240 additions and 382 deletions.
38 changes: 5 additions & 33 deletions e2e/cardToken/create.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import MercadoPago, { CardToken, Customer, CustomerCard } from '@src/index';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';
import { createCardToken } from '@src/mocks/createCardToken';

describe('IT, create card token', () => {
test('should make a request and return created card token id', async () => {
const client = new MercadoPago({ accessToken: config.test_access_token });
Expand All @@ -9,12 +12,12 @@ describe('IT, create card token', () => {

const email = createEmailTestUser();
const emailBody = {
email: email,
email,
};
const createCustomer = await customer.create({ body: emailBody });
expect(createCustomer).toHaveProperty('id');

const createToken = await createCardToken();
const createToken = await createCardToken(client.accessToken);
const customerBody = {
token: createToken.id
};
Expand Down Expand Up @@ -42,35 +45,4 @@ describe('IT, create card token', () => {
security_code_length: expect.any(Number),
}));
});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}

async function createCardToken() {
const response = await fetch('https://api.mercadopago.com/v1/card_tokens', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + config.test_access_token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
site_id: 'MLB',
card_number: '5031433215406351',
expiration_year: '2025',
expiration_month: '11',
security_code: '123',
cardholder: {
identification: {
type: 'CPF',
number: '01234567890'
},
name: 'APRO'
}
})
});
return await response.json();
}
});
11 changes: 3 additions & 8 deletions e2e/customer/create.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import MercadoPago, { Customer } from '@src/index';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';

describe('IT customer, create', () => {
test('should create a client and match response object', async () => {
Expand All @@ -9,7 +10,7 @@ describe('IT customer, create', () => {
const email = createEmailTestUser();

const body = {
email: email,
email,
first_name: 'Jhon',
last_name: 'Doe',
phone: {
Expand All @@ -36,7 +37,7 @@ describe('IT customer, create', () => {
const createCustomer = await customer.create({ body });
expect(createCustomer).toHaveProperty('status', 'active');
expect(createCustomer).toEqual(expect.objectContaining({
email: email,
email,
first_name: 'Jhon',
last_name: 'Doe',
date_registered: '2023-10-20T11:37:30.000-04:00',
Expand Down Expand Up @@ -77,10 +78,4 @@ describe('IT customer, create', () => {
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;
}
});
9 changes: 2 additions & 7 deletions e2e/customer/get.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import MercadoPago, { Customer } from '@src/index';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';

describe('IT customer, get', () => {
test('should get a client and match response object', async () => {
Expand All @@ -9,7 +10,7 @@ describe('IT customer, get', () => {
const email = createEmailTestUser();

const body = {
email: email,
email,
};

const createCustomer = await customer.create({ body });
Expand All @@ -23,10 +24,4 @@ describe('IT customer, get', () => {
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;
}
});
10 changes: 2 additions & 8 deletions e2e/customer/remove.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import MercadoPago, { Customer } from '@src/index';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';

describe('IT customer, remove', () => {
test('should delete a customer and match response object', async () => {
Expand All @@ -9,7 +10,7 @@ describe('IT customer, remove', () => {
const email = createEmailTestUser();

const body = {
email: email,
email,
};

const createCustomer = await customer.create({ body });
Expand All @@ -30,12 +31,5 @@ describe('IT customer, remove', () => {
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;
}
});
9 changes: 2 additions & 7 deletions e2e/customer/update.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import MercadoPago, { Customer } from '@src/index';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';

describe('IT customer, update', () => {
test('should update a customer and match response object', async () => {
Expand All @@ -8,7 +9,7 @@ describe('IT customer, update', () => {

const email = createEmailTestUser();
const body = {
email: email,
email,
};

const createCustomer = await customer.create({ body });
Expand Down Expand Up @@ -40,10 +41,4 @@ describe('IT customer, update', () => {
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;
}
});
38 changes: 4 additions & 34 deletions e2e/customerCard/create.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MercadoPago, { Customer, CustomerCard } from '@src/index';
import fetch from 'node-fetch';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';
import { createCardToken } from '@src/mocks/createCardToken';

describe('Testing customer cards, create', () => {
test('should create customer card and match response object', async () => {
Expand All @@ -10,12 +11,12 @@ describe('Testing customer cards, create', () => {

const email = createEmailTestUser();
const emailBody = {
email: email,
email,
};
const createCustomer = await customer.create({ body: emailBody });
expect(createCustomer).toHaveProperty('id');

const createToken = await createCardToken();
const createToken = await createCardToken(client.accessToken);
const customerBody = {
token: createToken.id
};
Expand Down Expand Up @@ -59,35 +60,4 @@ describe('Testing customer cards, create', () => {
const removeCustomer = await customer.remove({ customerId: createCustomer.id });
expect(removeCustomer.api_response.status).toBe(200);
});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}

async function createCardToken() {
const response = await fetch('https://api.mercadopago.com/v1/card_tokens', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + config.test_access_token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
site_id: 'MLB',
card_number: '5031433215406351',
expiration_year: '2025',
expiration_month: '11',
security_code: '123',
cardholder: {
identification: {
type: 'CPF',
number: '01234567890'
},
name: 'APRO'
}
})
});
return await response.json();
}
});
38 changes: 4 additions & 34 deletions e2e/customerCard/get.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MercadoPago, { Customer, CustomerCard } from '@src/index';
import fetch from 'node-fetch';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';
import { createCardToken } from '@src/mocks/createCardToken';

describe('Testing customer card, get', () => {
test('should get customer card and match response object', async () => {
Expand All @@ -10,12 +11,12 @@ describe('Testing customer card, get', () => {

const email = createEmailTestUser();
const emailBody = {
email: email,
email,
};
const createCustomer = await customer.create({ body: emailBody });
expect(createCustomer).toHaveProperty('id');

const createToken = await createCardToken();
const createToken = await createCardToken(client.accessToken);
const customerBody = {
token: createToken.id
};
Expand Down Expand Up @@ -62,35 +63,4 @@ describe('Testing customer card, get', () => {
const removeCustomer = await customer.remove({ customerId: createCustomer.id });
expect(removeCustomer.api_response.status).toBe(200);
});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}

async function createCardToken() {
const response = await fetch('https://api.mercadopago.com/v1/card_tokens', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + config.test_access_token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
site_id: 'MLB',
card_number: '5031433215406351',
expiration_year: '2025',
expiration_month: '11',
security_code: '123',
cardholder: {
identification: {
type: 'CPF',
number: '01234567890'
},
name: 'APRO'
}
})
});
return await response.json();
}
});
38 changes: 4 additions & 34 deletions e2e/customerCard/list.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import MercadoPago, { Customer, CustomerCard } from '@src/index';
import fetch from 'node-fetch';
import { config } from '../e2e.config';
import { createEmailTestUser } from '@src/mocks/createEmailTestUser';
import { createCardToken } from '@src/mocks/createCardToken';

describe('Testing customer card, get', () => {
test('should get list of cards and match response object', async () => {
Expand All @@ -10,12 +11,12 @@ describe('Testing customer card, get', () => {

const email = createEmailTestUser();
const emailBody = {
email: email,
email,
};
const createCustomer = await customer.create({ body: emailBody });
expect(createCustomer).toHaveProperty('id');

const createToken = await createCardToken();
const createToken = await createCardToken(client.accessToken);
const customerBody = {
token: createToken.id
};
Expand Down Expand Up @@ -63,35 +64,4 @@ describe('Testing customer card, get', () => {
const removeCustomer = await customer.remove({ customerId: createCustomer.id });
expect(removeCustomer.api_response.status).toBe(200);
});

function createEmailTestUser() {
const random = Math.floor(Math.random() * 1000000);
const email = 'test_user' + random + '@testuser.com';
return email;
}

async function createCardToken() {
const response = await fetch('https://api.mercadopago.com/v1/card_tokens', {
method: 'POST',
headers: {
'Authorization': 'Bearer ' + config.test_access_token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
site_id: 'MLB',
card_number: '5031433215406351',
expiration_year: '2025',
expiration_month: '11',
security_code: '123',
cardholder: {
identification: {
type: 'CPF',
number: '01234567890'
},
name: 'APRO'
}
})
});
return await response.json();
}
});
Loading

0 comments on commit 79d10bc

Please sign in to comment.