Skip to content

Commit

Permalink
Merge pull request #359 from mercadopago/feature/add_header_x-test-token
Browse files Browse the repository at this point in the history
Feature: add header X-Test-Token
  • Loading branch information
andreagostinho-meli authored Jan 23, 2025
2 parents d43e5ac + 12773d5 commit bbda0cf
Show file tree
Hide file tree
Showing 7 changed files with 405 additions and 583 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
# Releases

## VERSION 2.3.0

- Add `X-Test-Token` header to request options

## VERSION 2.2.0

- Include `network_transaction_data` in `forward_data` in Payment

## VERSION 2.1.1

- Fix `X-Expand-Responde-Nodes` header to request options

## VERSION 2.1.0
Expand Down
972 changes: 391 additions & 581 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mercadopago",
"version": "2.2.0",
"version": "2.3.0",
"description": "Mercadopago SDK for Node.js",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export declare type Options = {
meliSessionId?: string;
expandResponseNodes?: string;
cardValidation?: string;
testToken?: boolean;
};

export declare interface SearchOptions {
Expand Down
3 changes: 2 additions & 1 deletion src/utils/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class AppConfig {
static readonly BASE_URL = 'https://api.mercadopago.com';
static readonly PRODUCT_ID = 'bc32b6ntrpp001u8nhkg';

static SDK_VERSION = '2.2.0';
static SDK_VERSION = '2.3.0';

static readonly Headers = {
AUTHORIZATION: 'Authorization',
Expand All @@ -20,6 +20,7 @@ export class AppConfig {
MELI_SESSION_ID: 'X-Meli-Session-Id',
EXPAND_RESPONDE_NODES: 'X-Expand-Responde-Nodes',
CARD_VALIDATION: 'X-Card-Validation',
TEST_TOKEN: 'X-Test-Token',
};

static getNodeVersion(): string {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/restClient/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class RestClient {
meliSessionId,
expandResponseNodes,
cardValidation,
testToken,
...customConfig
} = config || {};

Expand All @@ -85,6 +86,7 @@ class RestClient {
...(meliSessionId ? { [AppConfig.Headers.MELI_SESSION_ID]: meliSessionId } : {}),
...(expandResponseNodes ? { [AppConfig.Headers.EXPAND_RESPONDE_NODES]: expandResponseNodes } : {}),
...(cardValidation ? { [AppConfig.Headers.CARD_VALIDATION]: cardValidation } : {}),
...(testToken ? { [AppConfig.Headers.TEST_TOKEN]: testToken.toString() } : {}),
};

if (method && method !== 'GET') {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/restClient/restClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ describe('RestClient', () => {
expandResponseNodes: 'gateway.reference',
cardValidation: 'card_validation',
meliSessionId: 'device_id',
testToken: true,
});

expect(fetch).toHaveBeenCalledWith(expect.any(String), {
Expand All @@ -122,6 +123,7 @@ describe('RestClient', () => {
'X-Meli-Session-Id': 'device_id',
'X-Expand-Responde-Nodes': 'gateway.reference',
'X-Card-Validation': 'card_validation',
'X-Test-Token': 'true',
},
});
});
Expand Down

0 comments on commit bbda0cf

Please sign in to comment.