sdk-nave-nodejs 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +99 -0
- package/dist/.gitkeep +0 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/NaveClient.d.ts +27 -0
- package/dist/lib/NaveClient.js +108 -0
- package/dist/lib/NaveClient.js.map +1 -0
- package/dist/lib/client-types.d.ts +105 -0
- package/dist/lib/client-types.js +3 -0
- package/dist/lib/client-types.js.map +1 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Emilio Astarita
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
## NodeJS SDK for Nave Payment Platform
|
|
2
|
+
|
|
3
|
+
This is an unofficial SDK for integrating with the Nave Negocios platform using Node.js. It provides tools to manage orders, process payments, and handle authentication.
|
|
4
|
+
|
|
5
|
+
**Note**: This SDK is still under active development.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Official Platform Website:
|
|
9
|
+
https://navenegocios.ar/
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
Ensure you have Node.js v14 or later installed. Then, run the following command to install the SDK:
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
npm install sdk-nave-nodejs
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## Usage example
|
|
26
|
+
|
|
27
|
+
Below is an example of configuring and using the SDK:
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import {NaveClient} from "./NaveClient";
|
|
32
|
+
|
|
33
|
+
const client = new NaveClient({
|
|
34
|
+
environment: 'testing',
|
|
35
|
+
// These following details must be provided by Nave
|
|
36
|
+
clientId: '',
|
|
37
|
+
clientSecret: '',
|
|
38
|
+
audience: '',
|
|
39
|
+
storeId: '',
|
|
40
|
+
platform: '',
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// The client will automatically handle token provisioning and renewal.
|
|
44
|
+
const orderResult = await client.createOrder({
|
|
45
|
+
order_id: generatedOrderId,
|
|
46
|
+
mobile: false,
|
|
47
|
+
callback_url: `https://example.com/order-pending/${generatedOrderId}`,
|
|
48
|
+
payment_request: {
|
|
49
|
+
transactions: [
|
|
50
|
+
{
|
|
51
|
+
products: [
|
|
52
|
+
{
|
|
53
|
+
id: 'PROD01',
|
|
54
|
+
name: 'Camiseta',
|
|
55
|
+
description: 'Camiseta Roja',
|
|
56
|
+
quantity: 1,
|
|
57
|
+
unit_price: {
|
|
58
|
+
currency: 'ARS',
|
|
59
|
+
value: '100',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
amount: {
|
|
64
|
+
currency: 'ARS',
|
|
65
|
+
value: '100',
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
buyer: {
|
|
70
|
+
user_id: 'USER01',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
const orderStatus = await client.getOrder(order.data.payment_request_id);
|
|
77
|
+
|
|
78
|
+
console.log('Order status', orderStatus);
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Integration tests
|
|
86
|
+
|
|
87
|
+
There is a working example that runs against the testing environment and is enclosed in a Vitest test. You need to provide a valid `.env`
|
|
88
|
+
file with your testing credentials at the root of the project.
|
|
89
|
+
|
|
90
|
+
If you want to try it:
|
|
91
|
+
|
|
92
|
+
1. Git clone this repo
|
|
93
|
+
2. Install deps: `yarn install`
|
|
94
|
+
3. Provide the `.env` file copying the `.env.example` format
|
|
95
|
+
4. Run the suite `yarn run test`
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
package/dist/.gitkeep
ADDED
|
File without changes
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NaveClient = void 0;
|
|
4
|
+
const NaveClient_1 = require("./lib/NaveClient");
|
|
5
|
+
Object.defineProperty(exports, "NaveClient", { enumerable: true, get: function () { return NaveClient_1.NaveClient; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAErC,2FAFA,uBAAU,OAEA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { BodyNaveCreateOrder, ResponseNaveCancelOrder, ResponseNaveCreateOrder, ResponseNaveGetOrder, ResponseNaveToken } from './client-types';
|
|
2
|
+
export type Environment = 'production' | 'testing';
|
|
3
|
+
export declare class NaveClient {
|
|
4
|
+
private readonly headers;
|
|
5
|
+
private baseUrls;
|
|
6
|
+
private clientId;
|
|
7
|
+
private clientSecret;
|
|
8
|
+
private audience;
|
|
9
|
+
private storeId;
|
|
10
|
+
private platform;
|
|
11
|
+
private token;
|
|
12
|
+
constructor({ audience, clientSecret, clientId, environment, storeId, platform, }: {
|
|
13
|
+
clientId: string;
|
|
14
|
+
clientSecret: string;
|
|
15
|
+
audience: string;
|
|
16
|
+
environment?: Environment;
|
|
17
|
+
storeId: string;
|
|
18
|
+
platform: string;
|
|
19
|
+
});
|
|
20
|
+
fetchNewToken(cache?: boolean): Promise<ResponseNaveToken>;
|
|
21
|
+
ensureToken(): Promise<ResponseNaveToken>;
|
|
22
|
+
createOrder(order: Omit<BodyNaveCreateOrder, 'store_id' | 'platform'>): Promise<ResponseNaveCreateOrder>;
|
|
23
|
+
getOrder(paymentRequestId: string): Promise<ResponseNaveGetOrder>;
|
|
24
|
+
cancelOrder(paymentId: string): Promise<ResponseNaveCancelOrder>;
|
|
25
|
+
private ecommerceRequest;
|
|
26
|
+
private request;
|
|
27
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.NaveClient = void 0;
|
|
7
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
8
|
+
const ENVIRONMENT_URLS = Object.freeze({
|
|
9
|
+
production: {
|
|
10
|
+
security: 'https://services.apinaranja.com',
|
|
11
|
+
ecommerce: 'https://api.ranty.io',
|
|
12
|
+
},
|
|
13
|
+
testing: {
|
|
14
|
+
security: 'https://homoservices.apinaranja.com',
|
|
15
|
+
ecommerce: 'https://e3-api.ranty.io',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
class NaveClient {
|
|
19
|
+
headers = {};
|
|
20
|
+
baseUrls;
|
|
21
|
+
clientId;
|
|
22
|
+
clientSecret;
|
|
23
|
+
audience;
|
|
24
|
+
storeId;
|
|
25
|
+
platform;
|
|
26
|
+
token = null;
|
|
27
|
+
constructor({ audience, clientSecret, clientId, environment = 'testing', storeId, platform, }) {
|
|
28
|
+
this.baseUrls =
|
|
29
|
+
environment === 'production'
|
|
30
|
+
? ENVIRONMENT_URLS.production
|
|
31
|
+
: ENVIRONMENT_URLS.testing;
|
|
32
|
+
this.audience = audience;
|
|
33
|
+
this.clientSecret = clientSecret;
|
|
34
|
+
this.clientId = clientId;
|
|
35
|
+
this.storeId = storeId;
|
|
36
|
+
this.platform = platform;
|
|
37
|
+
this.headers = {
|
|
38
|
+
'Content-Type': 'application/json',
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
async fetchNewToken(cache = true) {
|
|
42
|
+
return this.request({
|
|
43
|
+
method: 'POST',
|
|
44
|
+
baseUrl: this.baseUrls.security,
|
|
45
|
+
path: '/security-ms/api/security/auth0/b2b/m2msPrivate',
|
|
46
|
+
body: {
|
|
47
|
+
audience: this.audience,
|
|
48
|
+
client_id: this.clientId,
|
|
49
|
+
client_secret: this.clientSecret,
|
|
50
|
+
cache,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
async ensureToken() {
|
|
55
|
+
if (!this.token || this.token.expires_in < Date.now()) {
|
|
56
|
+
this.token = await this.fetchNewToken();
|
|
57
|
+
}
|
|
58
|
+
return this.token;
|
|
59
|
+
}
|
|
60
|
+
async createOrder(order) {
|
|
61
|
+
return this.ecommerceRequest({
|
|
62
|
+
method: 'POST',
|
|
63
|
+
path: '/ecommerce/payment_request/external',
|
|
64
|
+
body: { ...order, store_id: this.storeId, platform: this.platform },
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async getOrder(paymentRequestId) {
|
|
68
|
+
return this.ecommerceRequest({
|
|
69
|
+
method: 'GET',
|
|
70
|
+
path: `/api/payment_requests/${paymentRequestId}`,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
async cancelOrder(paymentId) {
|
|
74
|
+
return this.ecommerceRequest({
|
|
75
|
+
method: 'GET',
|
|
76
|
+
path: `/api/payments/${paymentId}`,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
ecommerceRequest = async (reqOptions) => {
|
|
80
|
+
await this.ensureToken();
|
|
81
|
+
if (!this.token) {
|
|
82
|
+
throw new Error('Token not found');
|
|
83
|
+
}
|
|
84
|
+
return this.request({
|
|
85
|
+
...reqOptions,
|
|
86
|
+
baseUrl: this.baseUrls.ecommerce,
|
|
87
|
+
headers: { Authorization: `Bearer ${this.token.access_token}` },
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
request = async ({ method = 'GET', path, body, headers, newHeaders, baseUrl, }) => {
|
|
91
|
+
const url = `${baseUrl}${path}`;
|
|
92
|
+
const _headers = newHeaders
|
|
93
|
+
? newHeaders
|
|
94
|
+
: { ...this.headers, ...headers };
|
|
95
|
+
const res = await (0, node_fetch_1.default)(url, {
|
|
96
|
+
method,
|
|
97
|
+
headers: _headers,
|
|
98
|
+
body: method !== 'GET' && body ? JSON.stringify(body) : undefined,
|
|
99
|
+
});
|
|
100
|
+
if (!res.ok) {
|
|
101
|
+
console.log(`Error (${res.status}) fetching ${url} \nwith ${method} \n and Body: ${JSON.stringify(body)} \n and Headers: ${JSON.stringify(_headers)}`);
|
|
102
|
+
throw new Error(await res.text());
|
|
103
|
+
}
|
|
104
|
+
return res.json();
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
exports.NaveClient = NaveClient;
|
|
108
|
+
//# sourceMappingURL=NaveClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NaveClient.js","sourceRoot":"","sources":["../../src/lib/NaveClient.ts"],"names":[],"mappings":";;;;;;AAAA,4DAA+B;AAmB/B,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,UAAU,EAAE;QACV,QAAQ,EAAE,iCAAiC;QAC3C,SAAS,EAAE,sBAAsB;KAClC;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,qCAAqC;QAC/C,SAAS,EAAE,yBAAyB;KACrC;CACF,CAAC,CAAC;AAWH,MAAa,UAAU;IACJ,OAAO,GAA2B,EAAE,CAAC;IAC9C,QAAQ,CAAkC;IAC1C,QAAQ,CAAS;IACjB,YAAY,CAAS;IACrB,QAAQ,CAAS;IACjB,OAAO,CAAS;IAChB,QAAQ,CAAS;IACjB,KAAK,GAA6B,IAAI,CAAC;IAE/C,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,WAAW,GAAG,SAAS,EACvB,OAAO,EACP,QAAQ,GAQT;QACC,IAAI,CAAC,QAAQ;YACX,WAAW,KAAK,YAAY;gBAC1B,CAAC,CAAC,gBAAgB,CAAC,UAAU;gBAC7B,CAAC,CAAC,gBAAgB,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG;YACb,cAAc,EAAE,kBAAkB;SACnC,CAAC;IACJ,CAA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H,CAAC;YACF,MAAM,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;QACpC,CAAC;QAED,OAAO,GAAG,CAAC,IAAI,EAAgB,CAAC;IAClC,CAAC,CAAC;CACH;AA/HD,gCA+HC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
export interface ResponseNaveToken {
|
|
2
|
+
access_token: string;
|
|
3
|
+
scope: string;
|
|
4
|
+
expires_in: number;
|
|
5
|
+
token_type: string;
|
|
6
|
+
}
|
|
7
|
+
export interface NaveBuyer {
|
|
8
|
+
user_id: string;
|
|
9
|
+
doc_type?: string;
|
|
10
|
+
doc_number?: string;
|
|
11
|
+
user_email?: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
phone?: string;
|
|
14
|
+
billing_address?: NaveBillingAddress;
|
|
15
|
+
}
|
|
16
|
+
export type NaveBillingAddress = {
|
|
17
|
+
street_1: string;
|
|
18
|
+
street_2?: string;
|
|
19
|
+
city: string;
|
|
20
|
+
region: string;
|
|
21
|
+
country: string;
|
|
22
|
+
zip_code: string;
|
|
23
|
+
};
|
|
24
|
+
export type NaveProduct = {
|
|
25
|
+
id: string;
|
|
26
|
+
name: string;
|
|
27
|
+
description: string;
|
|
28
|
+
quantity: number;
|
|
29
|
+
unit_price: {
|
|
30
|
+
currency: string;
|
|
31
|
+
value: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
export interface BodyNaveCreateOrder {
|
|
35
|
+
/**
|
|
36
|
+
* Platform identifier: Provided by Nave
|
|
37
|
+
*/
|
|
38
|
+
platform: string;
|
|
39
|
+
/**
|
|
40
|
+
* Store identifier: Provided by Nave
|
|
41
|
+
*/
|
|
42
|
+
store_id: string;
|
|
43
|
+
/**
|
|
44
|
+
* Where the user is redirected after payment
|
|
45
|
+
* @todo Report nave: this is not a good name for a redirect url :/
|
|
46
|
+
*/
|
|
47
|
+
callback_url: string;
|
|
48
|
+
/**
|
|
49
|
+
* Order identifier in Merchant own platform
|
|
50
|
+
*/
|
|
51
|
+
order_id: string;
|
|
52
|
+
/**
|
|
53
|
+
* Is mobile ?
|
|
54
|
+
*/
|
|
55
|
+
mobile: boolean;
|
|
56
|
+
payment_request: {
|
|
57
|
+
transactions: {
|
|
58
|
+
products: NaveProduct[];
|
|
59
|
+
amount: {
|
|
60
|
+
currency: string;
|
|
61
|
+
value: string;
|
|
62
|
+
};
|
|
63
|
+
}[];
|
|
64
|
+
buyer: NaveBuyer;
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* How long it last the payment intention -- defaults 24 hours
|
|
68
|
+
*/
|
|
69
|
+
duration_time?: number;
|
|
70
|
+
}
|
|
71
|
+
export interface ResponseNaveCreateOrder {
|
|
72
|
+
data: {
|
|
73
|
+
transaction_id: string;
|
|
74
|
+
qr_data: string;
|
|
75
|
+
payment_request_id: string;
|
|
76
|
+
checkout_url: string;
|
|
77
|
+
amount: {
|
|
78
|
+
currency: string;
|
|
79
|
+
value: string;
|
|
80
|
+
};
|
|
81
|
+
redirect_to: string;
|
|
82
|
+
};
|
|
83
|
+
success: boolean;
|
|
84
|
+
message: string;
|
|
85
|
+
}
|
|
86
|
+
export interface ResponseNaveGetOrder {
|
|
87
|
+
id: string;
|
|
88
|
+
external_payment_id: string;
|
|
89
|
+
payment_id: string | null;
|
|
90
|
+
order_id: string;
|
|
91
|
+
expiration_date: string;
|
|
92
|
+
status: 'APPROVED' | 'REJECTED' | 'CANCELLED' | 'REFUNDED' | 'PENDING';
|
|
93
|
+
payment_request_id: string;
|
|
94
|
+
payment_check_url: string;
|
|
95
|
+
additional_info: {
|
|
96
|
+
order_id: string;
|
|
97
|
+
callback_url: string;
|
|
98
|
+
mobile: boolean;
|
|
99
|
+
platform: string;
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
export interface ResponseNaveCancelOrder {
|
|
103
|
+
status: 'CANCELLING';
|
|
104
|
+
message: string;
|
|
105
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-types.js","sourceRoot":"","sources":["../../src/lib/client-types.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sdk-nave-nodejs",
|
|
3
|
+
"description": "Nave SDK for Node.js",
|
|
4
|
+
"version": "0.0.1",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"files": ["dist", "README.md", "LICENCE"],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"test": "vitest run",
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"clean": "rm -rf ./dist/*"
|
|
14
|
+
},
|
|
15
|
+
"author": "Emilio Astarita (https://github.com/emilioastarita/)",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git@github.com:emilioastarita/sdk-nave-nodejs.git"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"api",
|
|
22
|
+
"nave",
|
|
23
|
+
"navenegocios",
|
|
24
|
+
"checkout",
|
|
25
|
+
"payment",
|
|
26
|
+
"ipn",
|
|
27
|
+
"sdk",
|
|
28
|
+
"integration"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"node-fetch": "^3.3.2"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"@total-typescript/tsconfig": "^1.0.4",
|
|
35
|
+
"@biomejs/biome": "^1.9.4",
|
|
36
|
+
"@types/node": "^22.13.14",
|
|
37
|
+
"dotenv": "^16.4.7",
|
|
38
|
+
"typescript": "^5.8.2",
|
|
39
|
+
"vitest": "^3.1.1"
|
|
40
|
+
}
|
|
41
|
+
}
|