paytonz-node-api-sdk 1.0.0

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.
Files changed (97) hide show
  1. package/README.md +743 -0
  2. package/lib/CpaySDK.d.ts +30 -0
  3. package/lib/CpaySDK.js +35 -0
  4. package/lib/CpaySDKBase.d.ts +30 -0
  5. package/lib/CpaySDKBase.js +216 -0
  6. package/lib/CryptoNowSDK.d.ts +30 -0
  7. package/lib/CryptoNowSDK.js +35 -0
  8. package/lib/CryptoNowSDKBase.d.ts +30 -0
  9. package/lib/CryptoNowSDKBase.js +216 -0
  10. package/lib/PaytonzSDK.d.ts +28 -0
  11. package/lib/PaytonzSDK.js +33 -0
  12. package/lib/PaytonzSDKBase.d.ts +30 -0
  13. package/lib/PaytonzSDKBase.js +198 -0
  14. package/lib/auth/auth.d.ts +9 -0
  15. package/lib/auth/auth.interface.d.ts +25 -0
  16. package/lib/auth/auth.interface.js +2 -0
  17. package/lib/auth/auth.js +37 -0
  18. package/lib/checkout/checkout.d.ts +24 -0
  19. package/lib/checkout/checkout.interface.d.ts +94 -0
  20. package/lib/checkout/checkout.interface.js +2 -0
  21. package/lib/checkout/checkout.js +215 -0
  22. package/lib/client/client.d.ts +11 -0
  23. package/lib/client/client.interface.d.ts +45 -0
  24. package/lib/client/client.interface.js +2 -0
  25. package/lib/client/client.js +62 -0
  26. package/lib/constant.d.ts +1 -0
  27. package/lib/constant.js +4 -0
  28. package/lib/currency/currency.d.ts +10 -0
  29. package/lib/currency/currency.interface.d.ts +20 -0
  30. package/lib/currency/currency.interface.js +2 -0
  31. package/lib/currency/currency.js +50 -0
  32. package/lib/external/external.d.ts +13 -0
  33. package/lib/external/external.interface.d.ts +59 -0
  34. package/lib/external/external.interface.js +12 -0
  35. package/lib/external/external.js +64 -0
  36. package/lib/external/external.solana.d.ts +9 -0
  37. package/lib/external/external.solana.js +47 -0
  38. package/lib/index.d.ts +5 -0
  39. package/lib/index.js +28 -0
  40. package/lib/interfaces/cpay.interface.d.ts +20 -0
  41. package/lib/interfaces/cpay.interface.js +2 -0
  42. package/lib/interfaces/cryptonow.interface.d.ts +20 -0
  43. package/lib/interfaces/cryptonow.interface.js +2 -0
  44. package/lib/interfaces/paytonz.interface.d.ts +20 -0
  45. package/lib/interfaces/paytonz.interface.js +2 -0
  46. package/lib/multisend/multisend.d.ts +11 -0
  47. package/lib/multisend/multisend.interface.d.ts +28 -0
  48. package/lib/multisend/multisend.interface.js +2 -0
  49. package/lib/multisend/multisend.js +75 -0
  50. package/lib/swap/swap.d.ts +11 -0
  51. package/lib/swap/swap.interface.d.ts +84 -0
  52. package/lib/swap/swap.interface.js +2 -0
  53. package/lib/swap/swap.js +75 -0
  54. package/lib/transaction/transaction.d.ts +9 -0
  55. package/lib/transaction/transaction.interface.d.ts +82 -0
  56. package/lib/transaction/transaction.interface.js +2 -0
  57. package/lib/transaction/transaction.js +34 -0
  58. package/lib/utils/httpClient.d.ts +9 -0
  59. package/lib/utils/httpClient.js +64 -0
  60. package/lib/wallet/wallet.d.ts +16 -0
  61. package/lib/wallet/wallet.interface.d.ts +60 -0
  62. package/lib/wallet/wallet.interface.js +2 -0
  63. package/lib/wallet/wallet.js +107 -0
  64. package/lib/wallet/wallet.signature.d.ts +14 -0
  65. package/lib/wallet/wallet.signature.js +104 -0
  66. package/lib/withdrawal/withdrawal.d.ts +14 -0
  67. package/lib/withdrawal/withdrawal.interface.d.ts +79 -0
  68. package/lib/withdrawal/withdrawal.interface.js +14 -0
  69. package/lib/withdrawal/withdrawal.js +104 -0
  70. package/package.json +26 -0
  71. package/src/PaytonzSDK.ts +41 -0
  72. package/src/PaytonzSDKBase.ts +252 -0
  73. package/src/auth/auth.interface.ts +26 -0
  74. package/src/auth/auth.ts +31 -0
  75. package/src/checkout/checkout.interface.ts +110 -0
  76. package/src/checkout/checkout.ts +279 -0
  77. package/src/constant.ts +1 -0
  78. package/src/currency/currency.interface.ts +21 -0
  79. package/src/currency/currency.ts +60 -0
  80. package/src/external/external.interface.ts +65 -0
  81. package/src/external/external.solana.ts +54 -0
  82. package/src/external/external.ts +73 -0
  83. package/src/index.ts +5 -0
  84. package/src/interfaces/paytonz.interface.ts +23 -0
  85. package/src/multisend/multisend.interface.ts +32 -0
  86. package/src/multisend/multisend.ts +91 -0
  87. package/src/swap/swap.interface.ts +90 -0
  88. package/src/swap/swap.ts +93 -0
  89. package/src/transaction/transaction.interface.ts +76 -0
  90. package/src/transaction/transaction.ts +35 -0
  91. package/src/utils/httpClient.ts +60 -0
  92. package/src/wallet/wallet.interface.ts +67 -0
  93. package/src/wallet/wallet.signature.ts +106 -0
  94. package/src/wallet/wallet.ts +103 -0
  95. package/src/withdrawal/withdrawal.interface.ts +89 -0
  96. package/src/withdrawal/withdrawal.ts +135 -0
  97. package/tsconfig.json +21 -0
@@ -0,0 +1,33 @@
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.PaytonzSDK = void 0;
7
+ const auth_1 = require("./auth/auth");
8
+ const checkout_1 = __importDefault(require("./checkout/checkout"));
9
+ const currency_1 = require("./currency/currency");
10
+ const external_1 = __importDefault(require("./external/external"));
11
+ const multisend_1 = require("./multisend/multisend");
12
+ const swap_1 = require("./swap/swap");
13
+ const transaction_1 = __importDefault(require("./transaction/transaction"));
14
+ const wallet_1 = require("./wallet/wallet");
15
+ const withdrawal_1 = require("./withdrawal/withdrawal");
16
+ class PaytonzSDK {
17
+ /**
18
+ * @param parameters
19
+ */
20
+ constructor(parameters) {
21
+ this.wallet = new wallet_1.Wallet(parameters);
22
+ this.currency = new currency_1.Currency(parameters);
23
+ this.withdrawal = new withdrawal_1.Withdrawal(parameters);
24
+ this.multisend = new multisend_1.Multisend(parameters);
25
+ this.checkout = new checkout_1.default(parameters);
26
+ this.transaction = new transaction_1.default(parameters);
27
+ this.externalCall = new external_1.default(parameters);
28
+ this.auth = new auth_1.Auth(parameters);
29
+ this.swap = new swap_1.Swap(parameters);
30
+ }
31
+ }
32
+ exports.PaytonzSDK = PaytonzSDK;
33
+ exports.default = PaytonzSDK;
@@ -0,0 +1,30 @@
1
+ import { PaytonzToken } from "./interfaces/paytonz.interface";
2
+ import { Options as HttpOptions } from "./utils/httpClient";
3
+ export interface PaytonzSDKBaseOptions {
4
+ publicKey?: string;
5
+ privateKey?: string;
6
+ walletId?: string;
7
+ passphrase?: string;
8
+ errLogger?: (mssage: string, ...arg: any[]) => void;
9
+ outLogger?: (mssage: string, ...arg: any[]) => void;
10
+ httpOptions?: HttpOptions;
11
+ url?: {
12
+ rest?: string;
13
+ };
14
+ }
15
+ export declare class PaytonzSDKBase {
16
+ protected options: Required<PaytonzSDKBaseOptions>;
17
+ constructor(options?: Partial<PaytonzSDKBaseOptions>);
18
+ protected setOptions(options?: Partial<PaytonzSDKBaseOptions>): void;
19
+ protected _request: <T>(path: string, options: HttpOptions) => Promise<T>;
20
+ protected request: <T>(path: string, options: HttpOptions) => Promise<T>;
21
+ protected auth_get: <T = any>(path: string, params: Record<string, any>, token: string) => Promise<T>;
22
+ protected auth_post: <T = any>(path: string, data: Record<string, any>, token: string) => Promise<T>;
23
+ protected post: <T = any>(path: string, data: Record<string, any>) => Promise<T>;
24
+ protected auth_delete: <T = any>(path: string, data: Record<string, any>, token: string) => Promise<T>;
25
+ protected auth_patch: <T = any>(path: string, data: Record<string, any>, token: string) => Promise<T>;
26
+ protected errLogger: (msg: string, ...arg: any[]) => void;
27
+ protected outLogger: (msg: string, ...arg: any[]) => void;
28
+ protected auth(publicKey: string, privateKey: string, walletId?: string, passphrase?: string): Promise<PaytonzToken>;
29
+ protected getToken(isWallet?: boolean): Promise<string>;
30
+ }
@@ -0,0 +1,198 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.PaytonzSDKBase = void 0;
27
+ const dayjs_1 = __importDefault(require("dayjs"));
28
+ const utc_1 = __importDefault(require("dayjs/plugin/utc"));
29
+ const lodash_1 = __importDefault(require("lodash"));
30
+ const constant_1 = require("./constant");
31
+ const httpClient_1 = require("./utils/httpClient");
32
+ dayjs_1.default.extend(utc_1.default);
33
+ const DEFAUTL_HTTP_OPTIONS = {
34
+ headers: {
35
+ "Content-Type": "application/json",
36
+ "User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36",
37
+ },
38
+ timeout: 6000,
39
+ };
40
+ class PaytonzSDKBase {
41
+ constructor(options) {
42
+ this.options = {};
43
+ this._request = (path, options) => {
44
+ return (0, httpClient_1.request)(path, lodash_1.default.merge({}, this.options.httpOptions, options))
45
+ .then((data) => {
46
+ try {
47
+ const json = JSON.parse(data);
48
+ if (json) {
49
+ return json.data || json;
50
+ }
51
+ else {
52
+ this.errLogger(options.method, "-", path, json.data.message);
53
+ return Promise.reject(json.data.message);
54
+ }
55
+ }
56
+ catch (error) {
57
+ this.errLogger(options.method, "-", path, "Parse Error", error);
58
+ return Promise.reject(error);
59
+ }
60
+ })
61
+ .catch((err) => {
62
+ this.errLogger(options.method, "-", path, err);
63
+ return Promise.reject(err);
64
+ });
65
+ };
66
+ this.request = (path, options) => {
67
+ if (!this.options.url.rest) {
68
+ return Promise.reject("Rest url is required.");
69
+ }
70
+ return this._request(`${this.options.url.rest}${path}`, options);
71
+ };
72
+ this.auth_get = (path, params = {}, token) => {
73
+ if (!this.options.url.rest) {
74
+ return Promise.reject("Rest url is required.");
75
+ }
76
+ const PATH = `${this.options.url.rest}${path}`;
77
+ return this._request(PATH, {
78
+ method: "GET",
79
+ headers: {
80
+ Authorization: `Bearer ${token}`,
81
+ },
82
+ searchParams: params,
83
+ });
84
+ };
85
+ this.auth_post = (path, data, token) => {
86
+ const PATH = `${this.options.url.rest}${path}`;
87
+ const { idempotencyKey } = data, payload = __rest(data, ["idempotencyKey"]);
88
+ const headers = {
89
+ Authorization: `Bearer ${token}`,
90
+ };
91
+ if (idempotencyKey) {
92
+ headers["idempotency-key"] = idempotencyKey;
93
+ }
94
+ return this._request(PATH, {
95
+ method: "POST",
96
+ headers,
97
+ json: payload,
98
+ });
99
+ };
100
+ this.post = (path, data) => {
101
+ const PATH = `${this.options.url.rest}${path}`;
102
+ return this._request(PATH, {
103
+ method: "POST",
104
+ json: data,
105
+ });
106
+ };
107
+ this.auth_delete = (path, data, token) => {
108
+ const PATH = `${this.options.url.rest}${path}`;
109
+ return this._request(PATH, {
110
+ method: "DELETE",
111
+ headers: {
112
+ Authorization: `Bearer ${token}`,
113
+ },
114
+ json: data,
115
+ });
116
+ };
117
+ this.auth_patch = (path, data, token) => {
118
+ const PATH = `${this.options.url.rest}${path}`;
119
+ return this._request(PATH, {
120
+ method: "PATCH",
121
+ headers: {
122
+ Authorization: `Bearer ${token}`,
123
+ },
124
+ json: data,
125
+ });
126
+ };
127
+ this.errLogger = (msg, ...arg) => {
128
+ if (typeof this.options.errLogger === "function") {
129
+ this.options.errLogger(msg, ...arg);
130
+ return;
131
+ }
132
+ const prefix = `[${(0, dayjs_1.default)()
133
+ .utcOffset(8)
134
+ .format("YYYY-MM-DD HH:mm:ss")}] [ERROR] `;
135
+ console.error(`${prefix} ${msg}`, ...arg);
136
+ };
137
+ this.outLogger = (msg, ...arg) => {
138
+ if (typeof this.options.outLogger === "function") {
139
+ this.options.outLogger(msg, ...arg);
140
+ return;
141
+ }
142
+ const prefix = `[${(0, dayjs_1.default)()
143
+ .utcOffset(8)
144
+ .format("YYYY-MM-DD HH:mm:ss")}] [INFO] `;
145
+ console.log(`${prefix} ${msg}`, ...arg);
146
+ };
147
+ if (!options) {
148
+ return;
149
+ }
150
+ this.setOptions(options);
151
+ }
152
+ setOptions(options = {}) {
153
+ const { httpOptions, url } = options, otherOptions = __rest(options, ["httpOptions", "url"]);
154
+ lodash_1.default.merge(this.options, {
155
+ httpOptions: lodash_1.default.merge({}, DEFAUTL_HTTP_OPTIONS, httpOptions || {}),
156
+ url: Object.assign({ rest: constant_1.REST_URL }, (url || {})),
157
+ });
158
+ if (otherOptions) {
159
+ lodash_1.default.merge(this.options, otherOptions);
160
+ }
161
+ }
162
+ auth(publicKey, privateKey, walletId, passphrase) {
163
+ if (this.options.publicKey && this.options.privateKey) {
164
+ const path = `/api/public/auth`;
165
+ let data = {
166
+ publicKey,
167
+ privateKey,
168
+ };
169
+ if (walletId) {
170
+ data = Object.assign(data, { walletId });
171
+ if (!passphrase) {
172
+ throw new Error("Passphrase is required.");
173
+ }
174
+ data = Object.assign(data, { passphrase });
175
+ }
176
+ return this.request(`${path}`, {
177
+ method: "POST",
178
+ json: data,
179
+ });
180
+ }
181
+ else {
182
+ throw new Error("Keys is required.");
183
+ }
184
+ }
185
+ getToken(isWallet = false) {
186
+ var _a, _b;
187
+ return __awaiter(this, void 0, void 0, function* () {
188
+ if (isWallet) {
189
+ if (!this.options.walletId || !this.options.passphrase) {
190
+ throw new Error("WalletId and passphrase is required.");
191
+ }
192
+ }
193
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey, (_a = this.options) === null || _a === void 0 ? void 0 : _a.walletId, (_b = this.options) === null || _b === void 0 ? void 0 : _b.passphrase);
194
+ return token;
195
+ });
196
+ }
197
+ }
198
+ exports.PaytonzSDKBase = PaytonzSDKBase;
@@ -0,0 +1,9 @@
1
+ import { PaytonzSDKBase, PaytonzSDKBaseOptions } from "../PaytonzSDKBase";
2
+ import { RegisterInfo, RegisterOptions } from "./auth.interface";
3
+ export interface PaytonzSDKOptions extends PaytonzSDKBaseOptions {
4
+ }
5
+ export declare class Auth extends PaytonzSDKBase {
6
+ constructor(parameters: PaytonzSDKOptions);
7
+ register(options: RegisterOptions): Promise<RegisterInfo>;
8
+ login(): Promise<string>;
9
+ }
@@ -0,0 +1,25 @@
1
+ export interface RegisterOptions {
2
+ email: string;
3
+ password: string;
4
+ inviterId?: string;
5
+ roles: string[];
6
+ agent?: string;
7
+ }
8
+ export interface RegisterInfo {
9
+ wallets: {
10
+ id: string;
11
+ address: string;
12
+ privateKey: string;
13
+ mnemonic: string;
14
+ actualBalance: string;
15
+ systemBalance: string;
16
+ passphrase: string;
17
+ nodeType: string;
18
+ }[];
19
+ apiKey: {
20
+ publicKey: string;
21
+ privateKey: string;
22
+ };
23
+ merchantId: string;
24
+ userId: string;
25
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Auth = void 0;
13
+ const PaytonzSDKBase_1 = require("../PaytonzSDKBase");
14
+ class Auth extends PaytonzSDKBase_1.PaytonzSDKBase {
15
+ constructor(parameters) {
16
+ super(parameters);
17
+ }
18
+ register(options) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ try {
21
+ const path = `/api/public/auth/register`;
22
+ return this.post(`${path}`, Object.assign({}, options));
23
+ }
24
+ catch (err) {
25
+ throw err;
26
+ }
27
+ });
28
+ }
29
+ login() {
30
+ var _a, _b;
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey, (_a = this.options) === null || _a === void 0 ? void 0 : _a.walletId, (_b = this.options) === null || _b === void 0 ? void 0 : _b.passphrase);
33
+ return token;
34
+ });
35
+ }
36
+ }
37
+ exports.Auth = Auth;
@@ -0,0 +1,24 @@
1
+ import { PaytonzSDKBase, PaytonzSDKBaseOptions } from "../PaytonzSDKBase";
2
+ import { BasePaginationOptions } from "../interfaces/paytonz.interface";
3
+ import { CheckoutChargeListInfo, CheckoutInfo, CheckoutListInfo, CreateCartOptions, CreateDonationOptions, CreateSaleOptions, CreateSaleTokenOptions, SaleTokenEstimateMaxOptions, UpdateCartOptions, UpdateDonationOptions, UpdateSaleOptions, UpdateSaleTokenOptions } from "./checkout.interface";
4
+ export interface PaytonzSDKOptions extends PaytonzSDKBaseOptions {
5
+ }
6
+ export declare class Checkout extends PaytonzSDKBase {
7
+ constructor(parameters: PaytonzSDKOptions);
8
+ list(options: BasePaginationOptions, accessToken?: string): Promise<CheckoutListInfo>;
9
+ info(checkoutId: string, accessToken?: string): Promise<CheckoutInfo>;
10
+ remove(checkoutId: string, accessToken?: string): Promise<boolean>;
11
+ createDonation(options: CreateDonationOptions, accessToken?: string): Promise<CheckoutInfo>;
12
+ createSale(options: CreateSaleOptions, accessToken?: string): Promise<CheckoutInfo>;
13
+ createSaleToken(options: CreateSaleTokenOptions, accessToken?: string): Promise<CheckoutInfo>;
14
+ createCart(options: CreateCartOptions, accessToken?: string): Promise<CheckoutInfo>;
15
+ saleTokenEstimateMax(options: SaleTokenEstimateMaxOptions, accessToken?: string): Promise<{
16
+ max: string;
17
+ }>;
18
+ updateDonation(checkoutId: string, options: UpdateDonationOptions, accessToken?: string): Promise<CheckoutInfo>;
19
+ updateSale(checkoutId: string, options: UpdateSaleOptions, accessToken?: string): Promise<CheckoutInfo>;
20
+ updateSaleToken(checkoutId: string, options: UpdateSaleTokenOptions, accessToken?: string): Promise<CheckoutInfo>;
21
+ updateCart(checkoutId: string, options: UpdateCartOptions, accessToken?: string): Promise<CheckoutInfo>;
22
+ chargeList(checkoutId: string, options?: BasePaginationOptions, accessToken?: string): Promise<CheckoutChargeListInfo>;
23
+ }
24
+ export default Checkout;
@@ -0,0 +1,94 @@
1
+ export interface CheckoutInfo {
2
+ _id: string;
3
+ identifier: string;
4
+ currencies: string[];
5
+ createdAt: string;
6
+ updatedAt: string;
7
+ organizationName?: string;
8
+ type: string;
9
+ merchant: string;
10
+ expireTime: number;
11
+ description: string;
12
+ collectName: boolean;
13
+ collectEmail: boolean;
14
+ fiatCurrency?: string;
15
+ price?: string;
16
+ productName?: string;
17
+ fixed?: boolean;
18
+ max?: string;
19
+ min?: string;
20
+ tradedCurrency?: string;
21
+ tradedWallet?: string;
22
+ accentColor?: string;
23
+ backgroundColor?: string;
24
+ logoImage?: string;
25
+ image?: string;
26
+ metadata?: Record<string, any>;
27
+ }
28
+ export interface CheckoutListInfo {
29
+ entities: CheckoutInfo[];
30
+ page: number;
31
+ pages: number;
32
+ countItem: number;
33
+ }
34
+ export interface CheckoutChargeListInfo {
35
+ entities: {
36
+ id: boolean;
37
+ systemStatus: string;
38
+ createdAt: string;
39
+ }[];
40
+ page: number;
41
+ pages: number;
42
+ countItem: number;
43
+ }
44
+ export interface CreateCheckoutBaseOptions {
45
+ expireTime: number;
46
+ currencies: string[];
47
+ collectName?: boolean;
48
+ collectEmail?: boolean;
49
+ description: string;
50
+ linkImage?: string;
51
+ linkLogoImage?: string;
52
+ metadata?: Record<string, any>;
53
+ accentColor?: string;
54
+ backgroundColor?: string;
55
+ }
56
+ export interface UpdateCheckoutBaseOptions {
57
+ deleteImage?: boolean;
58
+ deleteLogoImage?: boolean;
59
+ }
60
+ export interface CreateDonationOptions extends CreateCheckoutBaseOptions {
61
+ organizationName: string;
62
+ }
63
+ export interface UpdateDonationOptions extends CreateDonationOptions, UpdateCheckoutBaseOptions {
64
+ }
65
+ export interface CreateSaleOptions extends CreateCheckoutBaseOptions {
66
+ productName: string;
67
+ price: string;
68
+ fiatCurrency: string;
69
+ }
70
+ export interface UpdateSaleOptions extends CreateSaleOptions, UpdateCheckoutBaseOptions {
71
+ }
72
+ export interface CreateCartOptions extends CreateCheckoutBaseOptions {
73
+ cartName: string;
74
+ fiatCurrency: string;
75
+ }
76
+ export interface UpdateCartOptions extends CreateCartOptions, UpdateCheckoutBaseOptions {
77
+ }
78
+ export interface CreateSaleTokenOptions extends CreateCheckoutBaseOptions {
79
+ productName: string;
80
+ price?: string;
81
+ min: string;
82
+ max: string;
83
+ fiatCurrency?: string;
84
+ fixed: string;
85
+ tradedCurrency: string;
86
+ tradedWallet: string;
87
+ }
88
+ export interface UpdateSaleTokenOptions extends CreateSaleTokenOptions, UpdateCheckoutBaseOptions {
89
+ }
90
+ export interface SaleTokenEstimateMaxOptions {
91
+ tradedWallet: string;
92
+ tradedCurrency: string;
93
+ checkoutId?: string;
94
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,215 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.Checkout = void 0;
13
+ const PaytonzSDKBase_1 = require("../PaytonzSDKBase");
14
+ class Checkout extends PaytonzSDKBase_1.PaytonzSDKBase {
15
+ constructor(parameters) {
16
+ super(parameters);
17
+ }
18
+ list(options, accessToken) {
19
+ return __awaiter(this, void 0, void 0, function* () {
20
+ try {
21
+ if (!accessToken) {
22
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey);
23
+ accessToken = token;
24
+ }
25
+ const path = `/api/public/checkout`;
26
+ return this.auth_get(`${path}`, Object.assign({}, options), accessToken);
27
+ }
28
+ catch (err) {
29
+ throw err;
30
+ }
31
+ });
32
+ }
33
+ info(checkoutId, accessToken) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ try {
36
+ if (!accessToken) {
37
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey);
38
+ accessToken = token;
39
+ }
40
+ const path = `/api/public/checkout/${checkoutId}`;
41
+ return this.auth_get(`${path}`, {}, accessToken);
42
+ }
43
+ catch (err) {
44
+ throw err;
45
+ }
46
+ });
47
+ }
48
+ remove(checkoutId, accessToken) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ try {
51
+ if (!accessToken) {
52
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey);
53
+ accessToken = token;
54
+ }
55
+ const path = `/api/public/checkout/${checkoutId}`;
56
+ return this.auth_delete(`${path}`, {}, accessToken);
57
+ }
58
+ catch (err) {
59
+ throw err;
60
+ }
61
+ });
62
+ }
63
+ createDonation(options, accessToken) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ try {
66
+ if (!accessToken) {
67
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey);
68
+ accessToken = token;
69
+ }
70
+ const path = `/api/public/checkout/donation`;
71
+ return this.auth_post(`${path}`, options, accessToken);
72
+ }
73
+ catch (err) {
74
+ throw err;
75
+ }
76
+ });
77
+ }
78
+ createSale(options, accessToken) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ try {
81
+ if (!accessToken) {
82
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey);
83
+ accessToken = token;
84
+ }
85
+ const path = `/api/public/checkout/sale`;
86
+ return this.auth_post(`${path}`, options, accessToken);
87
+ }
88
+ catch (err) {
89
+ throw err;
90
+ }
91
+ });
92
+ }
93
+ createSaleToken(options, accessToken) {
94
+ return __awaiter(this, void 0, void 0, function* () {
95
+ try {
96
+ if (!accessToken) {
97
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey);
98
+ accessToken = token;
99
+ }
100
+ const path = `/api/public/checkout/saleToken`;
101
+ return this.auth_post(`${path}`, options, accessToken);
102
+ }
103
+ catch (err) {
104
+ throw err;
105
+ }
106
+ });
107
+ }
108
+ createCart(options, accessToken) {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ try {
111
+ if (!accessToken) {
112
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey);
113
+ accessToken = token;
114
+ }
115
+ const path = `/api/public/checkout/cart`;
116
+ return this.auth_post(`${path}`, options, accessToken);
117
+ }
118
+ catch (err) {
119
+ throw err;
120
+ }
121
+ });
122
+ }
123
+ saleTokenEstimateMax(options, accessToken) {
124
+ return __awaiter(this, void 0, void 0, function* () {
125
+ try {
126
+ if (!accessToken) {
127
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey);
128
+ accessToken = token;
129
+ }
130
+ const path = `/api/public/checkout/saleToken/estimateMax`;
131
+ return this.auth_post(`${path}`, options, accessToken);
132
+ }
133
+ catch (err) {
134
+ throw err;
135
+ }
136
+ });
137
+ }
138
+ updateDonation(checkoutId, options, accessToken) {
139
+ return __awaiter(this, void 0, void 0, function* () {
140
+ try {
141
+ if (!accessToken) {
142
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey);
143
+ accessToken = token;
144
+ }
145
+ const path = `/api/public/checkout/${checkoutId}/donation`;
146
+ return this.auth_patch(`${path}`, options, accessToken);
147
+ }
148
+ catch (err) {
149
+ throw err;
150
+ }
151
+ });
152
+ }
153
+ updateSale(checkoutId, options, accessToken) {
154
+ return __awaiter(this, void 0, void 0, function* () {
155
+ try {
156
+ if (!accessToken) {
157
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey);
158
+ accessToken = token;
159
+ }
160
+ const path = `/api/public/checkout/${checkoutId}/sale`;
161
+ return this.auth_patch(`${path}`, options, accessToken);
162
+ }
163
+ catch (err) {
164
+ throw err;
165
+ }
166
+ });
167
+ }
168
+ updateSaleToken(checkoutId, options, accessToken) {
169
+ return __awaiter(this, void 0, void 0, function* () {
170
+ try {
171
+ if (!accessToken) {
172
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey);
173
+ accessToken = token;
174
+ }
175
+ const path = `/api/public/checkout/${checkoutId}/saleToken`;
176
+ return this.auth_patch(`${path}`, options, accessToken);
177
+ }
178
+ catch (err) {
179
+ throw err;
180
+ }
181
+ });
182
+ }
183
+ updateCart(checkoutId, options, accessToken) {
184
+ return __awaiter(this, void 0, void 0, function* () {
185
+ try {
186
+ if (!accessToken) {
187
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey);
188
+ accessToken = token;
189
+ }
190
+ const path = `/api/public/checkout/${checkoutId}/cart`;
191
+ return this.auth_patch(`${path}`, options, accessToken);
192
+ }
193
+ catch (err) {
194
+ throw err;
195
+ }
196
+ });
197
+ }
198
+ chargeList(checkoutId, options, accessToken) {
199
+ return __awaiter(this, void 0, void 0, function* () {
200
+ try {
201
+ if (!accessToken) {
202
+ const { token } = yield this.auth(this.options.publicKey, this.options.privateKey);
203
+ accessToken = token;
204
+ }
205
+ const path = `/api/public/checkout/${checkoutId}/charge-list`;
206
+ return this.auth_get(`${path}`, Object.assign({}, options), accessToken);
207
+ }
208
+ catch (err) {
209
+ throw err;
210
+ }
211
+ });
212
+ }
213
+ }
214
+ exports.Checkout = Checkout;
215
+ exports.default = Checkout;