@100pay-hq/100pay.js 1.0.2 → 1.1.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/README.md ADDED
@@ -0,0 +1,188 @@
1
+ # 100Pay Checkout
2
+
3
+ Accept crypto payments on your website in 3 mins
4
+
5
+ <!--
6
+ ## ✋ ✋ PACKAGE HAS BEEN DISCONTINUED
7
+ ## Please 👉 [click here](https://npmjs.com/@100pay-hq/checkout) for the updated package 📦 -->
8
+
9
+ ## Getting Started
10
+
11
+ Before you can start accepting crypto payments, you need to create a [100pay account](https://100pay.co) and obtain your API keys from the [100Developers platform](https://100pay.co)
12
+
13
+ For API documentation, please click here 👉 [100Developers API documentation](https://documenter.getpostman.com/view/13045730/2s93RMUatE)
14
+
15
+ ## Features
16
+
17
+ * Verify Crypto payments
18
+ * Bulk Transfers
19
+ * Crypto Transfers
20
+ * Crypto Payments
21
+
22
+ ## Installation
23
+
24
+ Install the package using npm:
25
+
26
+ ```bash
27
+ npm install @100pay-hq/100pay.js
28
+ ```
29
+
30
+ Or using yarn:
31
+
32
+ ```bash
33
+ yarn add @100pay-hq/100pay.js
34
+ ```
35
+
36
+ ## TypeScript Support
37
+
38
+ This package is fully written in TypeScript and includes type definitions. No additional type packages are required.
39
+
40
+ ## Breaking Changes from JavaScript Version
41
+
42
+ The TypeScript version includes some breaking changes from the original JavaScript version:
43
+
44
+ 1. The SDK now uses `axios` instead of `request` for HTTP requests
45
+ 2. Proper error handling with typed errors (`PaymentVerificationError`)
46
+ 3. Stricter type checking for method parameters and return values
47
+ 4. Constructor now requires an object with `publicKey` and `secretKey` properties
48
+
49
+ ## Usage
50
+
51
+ ### TypeScript
52
+
53
+ ```typescript
54
+ import { _100Pay } from '@100pay-hq/100pay.js';
55
+
56
+ // Initialize the 100Pay client
57
+ const payClient = new _100Pay({
58
+ publicKey: 'your_public_key',
59
+ secretKey: 'your_secret_key'
60
+ });
61
+
62
+ // Verify a transaction
63
+ async function verifyTransaction(transactionId: string) {
64
+ try {
65
+ const result = await payClient.verify(transactionId);
66
+
67
+ if (result.status === 'success') {
68
+ console.log('Transaction verified:', result.data);
69
+ return result.data;
70
+ } else {
71
+ console.error('Verification failed:', result.message);
72
+ return null;
73
+ }
74
+ } catch (error) {
75
+ if (error instanceof Error) {
76
+ console.error('Error:', error.message);
77
+ }
78
+ throw error;
79
+ }
80
+ }
81
+ ```
82
+
83
+ ### JavaScript (CommonJS)
84
+
85
+ ```javascript
86
+ const { _100Pay } = require('@100pay-hq/100pay.js');
87
+
88
+ // Initialize the 100Pay client
89
+ const payClient = new _100Pay({
90
+ publicKey: 'your_public_key',
91
+ secretKey: 'your_secret_key'
92
+ });
93
+
94
+ // Verify a transaction
95
+ async function verifyTransaction(transactionId) {
96
+ try {
97
+ const result = await payClient.verify(transactionId);
98
+
99
+ if (result.status === 'success') {
100
+ console.log('Transaction verified:', result.data);
101
+ return result.data;
102
+ } else {
103
+ console.error('Verification failed:', result.message);
104
+ return null;
105
+ }
106
+ } catch (error) {
107
+ console.error('Error:', error.message);
108
+ throw error;
109
+ }
110
+ }
111
+ ```
112
+
113
+ ## API Reference
114
+
115
+ ### Constructor
116
+
117
+ ```typescript
118
+ new _100Pay({
119
+ publicKey: string;
120
+ secretKey: string;
121
+ })
122
+ ```
123
+
124
+ | Parameter | Type | Description |
125
+ |-----------|------|-------------|
126
+ | publicKey | string | Your 100Pay public API key |
127
+ | secretKey | string | Your 100Pay secret API key |
128
+
129
+ ### Methods
130
+
131
+ #### verify(transactionId: string): Promise<VerifyResponse>
132
+
133
+ Verifies a crypto payment transaction.
134
+
135
+ | Parameter | Type | Description |
136
+ |-----------|------|-------------|
137
+ | transactionId | string | The ID of the transaction to verify |
138
+
139
+ Returns a Promise that resolves to a `VerifyResponse` object:
140
+
141
+ ```typescript
142
+ interface VerifyResponse {
143
+ status: 'success' | 'error';
144
+ data: TransactionData | Record<string, never>;
145
+ message?: string;
146
+ }
147
+ ```
148
+
149
+ ## Development
150
+
151
+ ### Setup
152
+
153
+ 1. Clone the repository:
154
+
155
+ ```bash
156
+ git clone https://github.com/shop100global/100pay.js.git
157
+ cd 100pay.js
158
+ ```
159
+
160
+ 2. Install dependencies:
161
+
162
+ ```bash
163
+ npm install
164
+ ```
165
+
166
+ 3. Build the project:
167
+
168
+ ```bash
169
+ npm run build
170
+ ```
171
+
172
+ ### Scripts
173
+
174
+ The following npm scripts are available:
175
+
176
+ * `npm run build` - Build the TypeScript code
177
+ * `npm run build:clean` - Clean the dist directory and build
178
+ * `npm run type-check` - Check TypeScript types without emitting files
179
+ * `npm run test` - Run tests
180
+ * `npm run test:watch` - Run tests in watch mode
181
+ * `npm run test:coverage` - Run tests with coverage report
182
+ * `npm run lint` - Lint the code
183
+ * `npm run lint:fix` - Lint and fix code
184
+ * `npm run verify` - Run linting, tests, and build
185
+
186
+ ## Note on HTTP Client
187
+
188
+ This package has migrated from the deprecated `request` library to `axios` for making HTTP requests. This provides better TypeScript support and improved error handling.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,84 @@
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
+ const axios_1 = __importDefault(require("axios"));
7
+ const index_1 = require("../index");
8
+ jest.mock("axios");
9
+ describe("Pay100", () => {
10
+ const config = {
11
+ publicKey: "test_public_key",
12
+ secretKey: "test_secret_key",
13
+ };
14
+ let pay100;
15
+ beforeEach(() => {
16
+ pay100 = new index_1.Pay100(config);
17
+ jest.clearAllMocks();
18
+ });
19
+ describe("verify", () => {
20
+ it("should successfully verify a transaction", async () => {
21
+ const mockResponse = {
22
+ status: "completed",
23
+ amount: "100",
24
+ currency: "USDT",
25
+ };
26
+ axios_1.default.mockResolvedValueOnce({
27
+ data: mockResponse,
28
+ });
29
+ const result = await pay100.verify("valid_transaction_id");
30
+ expect(result).toEqual({
31
+ status: "success",
32
+ data: mockResponse,
33
+ });
34
+ expect(axios_1.default).toHaveBeenCalledWith({
35
+ method: "POST",
36
+ url: "https://api.100pay.co/api/v1/pay/crypto/payment/valid_transaction_id",
37
+ headers: {
38
+ "api-key": config.publicKey,
39
+ },
40
+ });
41
+ });
42
+ it("should handle empty response data", async () => {
43
+ axios_1.default.mockResolvedValueOnce({
44
+ data: null,
45
+ });
46
+ const result = await pay100.verify("transaction_id");
47
+ expect(result).toEqual({
48
+ status: "error",
49
+ data: {},
50
+ message: "Something went wrong, be sure you supplied a valid payment id.",
51
+ });
52
+ });
53
+ it("should handle invalid API key error", async () => {
54
+ axios_1.default.mockResolvedValueOnce({
55
+ data: "Access Denied, Invalid KEY supplied",
56
+ });
57
+ const result = await pay100.verify("transaction_id");
58
+ expect(result).toEqual({
59
+ status: "error",
60
+ data: {},
61
+ message: "Access Denied, Invalid KEY supplied",
62
+ });
63
+ });
64
+ it("should handle invalid payment ID error", async () => {
65
+ axios_1.default.mockResolvedValueOnce({
66
+ data: "invalid payment id supplied",
67
+ });
68
+ const result = await pay100.verify("invalid_id");
69
+ expect(result).toEqual({
70
+ status: "error",
71
+ data: {},
72
+ });
73
+ });
74
+ it("should handle network errors", async () => {
75
+ const networkError = new Error("Network Error");
76
+ Object.defineProperty(networkError, "isAxiosError", { value: true });
77
+ axios_1.default.mockRejectedValueOnce(networkError);
78
+ await expect(pay100.verify("transaction_id")).rejects.toThrow(
79
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-call
80
+ new index_1.PaymentVerificationError("Network Error"));
81
+ });
82
+ });
83
+ });
84
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/__tests__/index.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M,CAAC,gBAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO;YAC3D,oGAAoG;YACpG,IAAI,gCAAwB,CAAC,eAAe,CAAC,CAC9C,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,25 @@
1
+ interface IPay100Config {
2
+ publicKey: string;
3
+ secretKey: string;
4
+ }
5
+ interface ITransactionData {
6
+ [key: string]: unknown;
7
+ }
8
+ interface IVerifyResponse {
9
+ status: "success" | "error";
10
+ data: ITransactionData | Record<string, never>;
11
+ message?: string;
12
+ }
13
+ export declare class PaymentVerificationError extends Error {
14
+ status: string;
15
+ data: Record<string, never>;
16
+ constructor(message: string);
17
+ }
18
+ export declare class Pay100 {
19
+ private publicKey;
20
+ private secretKey;
21
+ constructor({ publicKey, secretKey }: IPay100Config);
22
+ verify: (transactionId: string) => Promise<IVerifyResponse>;
23
+ }
24
+ export {};
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,UAAU,aAAa;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAGD,UAAU,gBAAgB;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAWD,UAAU,eAAe;IACvB,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC;IAC5B,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAGD,qBAAa,wBAAyB,SAAQ,KAAK;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;gBAEhB,OAAO,EAAE,MAAM;CAM5B;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,SAAS,CAAS;gBAEd,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,aAAa;IAKnD,MAAM,GAAU,eAAe,MAAM,KAAG,OAAO,CAAC,eAAe,CAAC,CAmE9D;CACH"}
package/dist/index.js ADDED
@@ -0,0 +1,81 @@
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.Pay100 = exports.PaymentVerificationError = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ // Error type for payment verification
9
+ class PaymentVerificationError extends Error {
10
+ constructor(message) {
11
+ super(message);
12
+ this.name = "PaymentVerificationError";
13
+ this.status = "error";
14
+ this.data = {};
15
+ }
16
+ }
17
+ exports.PaymentVerificationError = PaymentVerificationError;
18
+ class Pay100 {
19
+ constructor({ publicKey, secretKey }) {
20
+ this.verify = async (transactionId) => {
21
+ try {
22
+ const response = await (0, axios_1.default)({
23
+ method: "POST",
24
+ url: `https://api.100pay.co/api/v1/pay/crypto/payment/${transactionId}`,
25
+ headers: {
26
+ "api-key": this.publicKey,
27
+ },
28
+ });
29
+ // Handle empty response
30
+ if (!response.data) {
31
+ return {
32
+ status: "error",
33
+ data: {},
34
+ message: "Something went wrong, be sure you supplied a valid payment id.",
35
+ };
36
+ }
37
+ // Handle string responses which indicate errors
38
+ if (typeof response.data === "string") {
39
+ if (response.data === "Access Denied, Invalid KEY supplied") {
40
+ return {
41
+ status: "error",
42
+ data: {},
43
+ message: "Access Denied, Invalid KEY supplied",
44
+ };
45
+ }
46
+ if (response.data === "invalid payment id supplied") {
47
+ return {
48
+ status: "error",
49
+ data: {},
50
+ };
51
+ }
52
+ }
53
+ // Validate and transform response data to ensure type safety
54
+ const responseData = response.data;
55
+ // Ensure the response data is an object that can be safely cast to ITransactionData
56
+ const transactionData = responseData && typeof responseData === "object"
57
+ ? responseData
58
+ : {};
59
+ // Return successful response with properly typed data
60
+ return {
61
+ status: "success",
62
+ data: transactionData,
63
+ };
64
+ }
65
+ catch (error) {
66
+ // Handle Axios errors
67
+ if (axios_1.default.isAxiosError(error)) {
68
+ const axiosError = error;
69
+ throw new PaymentVerificationError(axiosError.message ||
70
+ "Something went wrong, be sure you supplied a valid payment id.");
71
+ }
72
+ // Handle other errors
73
+ throw new PaymentVerificationError(error instanceof Error ? error.message : "An unknown error occurred");
74
+ }
75
+ };
76
+ this.publicKey = publicKey;
77
+ this.secretKey = secretKey;
78
+ }
79
+ }
80
+ exports.Pay100 = Pay100;
81
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,kDAAyD;AA4BzD,sCAAsC;AACtC,MAAa,wBAAyB,SAAQ,KAAK;IAIjD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,0BAA0B,CAAC;QACvC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;IACjB,CAAC;CACF;AAVD,4DAUC;AAED,MAAa,MAAM;IAIjB,YAAY,EAAE,SAAS,EAAE,SAAS,EAAiB;QAKnD,WAAM,GAAG,KAAK,EAAE,aAAqB,EAA4B,EAAE;YACjE,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAmC,MAAM,IAAA,eAAK,EAAC;oBAC3D,MAAM,EAAE,MAAM;oBACd,GAAG,EAAE,mDAAmD,aAAa,EAAE;oBACvE,OAAO,EAAE;wBACP,SAAS,EAAE,IAAI,CAAC,SAAS;qBAC1B;iBACF,CAAC,CAAC;gBAEH,wBAAwB;gBACxB,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;oBACnB,OAAO;wBACL,MAAM,EAAE,OAAO;wBACf,IAAI,EAA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3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CAsEF;AA7ED,wBA6EC"}
package/package.json CHANGED
@@ -1,10 +1,25 @@
1
1
  {
2
2
  "name": "@100pay-hq/100pay.js",
3
- "version": "1.0.2",
3
+ "version": "1.1.1",
4
4
  "description": "100Pay.js is the official Nodejs API wrapper SDK that lets you easily verify crypto payments, run bulk payout, transfer assets and many more.",
5
- "main": "index.js",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "LICENSE",
10
+ "README.md"
11
+ ],
6
12
  "scripts": {
7
- "test": "test"
13
+ "test": "jest",
14
+ "test:watch": "jest --watch",
15
+ "test:coverage": "jest --coverage",
16
+ "build": "tsc",
17
+ "build:clean": "rm -rf dist && tsc",
18
+ "type-check": "tsc --noEmit",
19
+ "lint": "eslint . --ext .ts",
20
+ "lint:fix": "eslint . --ext .ts --fix",
21
+ "verify": "npm run lint && npm run test && npm run build",
22
+ "prepare": "npm run verify"
8
23
  },
9
24
  "repository": {
10
25
  "type": "git",
@@ -24,5 +39,21 @@
24
39
  "bugs": {
25
40
  "url": "https://github.com/shop100global/100pay.js/issues"
26
41
  },
27
- "homepage": "https://github.com/shop100global/100pay.js#readme"
28
- }
42
+ "homepage": "https://github.com/shop100global/100pay.js#readme",
43
+ "devDependencies": {
44
+ "@eslint/js": "^9.23.0",
45
+ "@types/jest": "^29.5.14",
46
+ "@types/node": "^22.13.14",
47
+ "@typescript-eslint/eslint-plugin": "^8.28.0",
48
+ "@typescript-eslint/parser": "^8.28.0",
49
+ "eslint": "^9.23.0",
50
+ "globals": "^16.0.0",
51
+ "jest": "^29.7.0",
52
+ "ts-jest": "^29.3.0",
53
+ "typescript": "^5.8.2"
54
+ },
55
+ "dependencies": {
56
+ "axios": "^1.8.4"
57
+ },
58
+ "type": "module"
59
+ }
package/README.MD DELETED
@@ -1,22 +0,0 @@
1
- # 100Pay Checkout
2
-
3
- Accept crypto payments on your website in 3 mins
4
-
5
- <!--
6
- ## ✋ ✋ PACKAGE HAS BEEN DISCONTINUED
7
- ## Please 👉 [click here](https://npmjs.com/@100pay-hq/checkout) for the updated package 📦 -->
8
-
9
- ## Getting Started
10
-
11
- # 🏄 🚀
12
-
13
- Before you can start accepting crypto payments, you need to create a [100pay account](https://100pay.co) and obtain your api keys from the [100Developers platform](https://100pay.co)
14
-
15
- For API documentation, please click here 👉 [100Developers API documentation](https://documenter.getpostman.com/view/13045730/2s93RMUatE)
16
-
17
- ## Features
18
-
19
- * Verify Crypto payments
20
- * Bulk Transfers
21
- * Crypto Transfers
22
- * Crypto Payments
package/index.js DELETED
@@ -1,53 +0,0 @@
1
- const request = require('request');
2
- class _100Pay{
3
- public_key
4
- secret_key
5
- constructor(pub, sec){
6
- this.public_key = pub
7
- this.secret_key = sec
8
- }
9
- verify = async (id) => {
10
- return new Promise((resolve, reject) => {
11
- let response_data = {}
12
- var options = {
13
- 'method': 'POST',
14
- 'url': `https://api.100pay.co/api/v1/pay/crypto/payment/${id}`,
15
- 'headers': {
16
- 'api-key': `${this.public_key}`
17
- }
18
- };
19
- request(options, function (error, response) {
20
- if (error) {
21
- response_data.status = 'error'
22
- response_data.data = {}
23
- response_data.message = "Something went wrong, be sure you supplied a valid payment id."
24
- reject(response_data)
25
- } else {
26
- if(response.body === '') {
27
- response_data.status = 'error'
28
- response_data.data = {}
29
- response_data.message = "Something went wrong, be sure you supplied a valid payment id."
30
- return resolve(response_data)
31
- }
32
- if(response.body === 'Access Denied, Invalid KEY supplied'){
33
- response_data.status = 'error'
34
- response_data.data = {}
35
- response_data.message = "Access Denied, Invalid KEY supplied"
36
- return resolve(response_data)
37
- }
38
- if(response.body === 'invalid payment id supplied'){
39
- response_data.status = 'error'
40
- response_data.data = {}
41
- return resolve(response_data)
42
- }
43
- response_data.status = "success"
44
- const _response = JSON.parse(response.body);
45
- response_data.data = _response;
46
- resolve(response_data)
47
- }
48
- });
49
- })
50
- }
51
-
52
- }
53
- module.exports._100Pay = _100Pay;
package/update-package.js DELETED
@@ -1,40 +0,0 @@
1
- const fs = require('fs');
2
- const { execSync } = require('child_process');
3
-
4
- // Read the current package.json file
5
- const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
6
-
7
- // Increment the version (you can choose 'patch', 'minor', or 'major')
8
- const versionType = process.argv[2] || 'patch';
9
- const currentVersion = packageJson.version;
10
-
11
- const newVersion = incrementVersion(currentVersion, versionType);
12
- packageJson.version = newVersion;
13
-
14
- // Write the updated package.json back to the file
15
- fs.writeFileSync('./package.json', JSON.stringify(packageJson, null, 2));
16
-
17
- // Run npm version command to update the package.json and create a git tag
18
- execSync(`npm version ${versionType}`, { stdio: 'inherit' });
19
-
20
- console.log(`Version updated to ${newVersion}`);
21
-
22
- function incrementVersion(version, type) {
23
- const parts = version.split('.');
24
- switch (type) {
25
- case 'major':
26
- parts[0] = String(parseInt(parts[0]) + 1);
27
- parts[1] = '0';
28
- parts[2] = '0';
29
- break;
30
- case 'minor':
31
- parts[1] = String(parseInt(parts[1]) + 1);
32
- parts[2] = '0';
33
- break;
34
- case 'patch':
35
- default:
36
- parts[2] = String(parseInt(parts[2]) + 1);
37
- break;
38
- }
39
- return parts.join('.');
40
- }