Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add header X-Test-Token #359

Merged
merged 5 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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
Loading