@payriff-sdk/node 0.0.0-stage → 0.1.3

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.
@@ -0,0 +1,408 @@
1
+ export type Currency = 'AZN' | 'USD' | 'EUR' | 'PKR' | 'AED' | 'SAR';
2
+ export type Language = 'AZ' | 'EN' | 'RU' | 'AR';
3
+ export type Operation = 'PURCHASE' | 'PRE_AUTH' | 'COMPLETE' | 'REFUND' | 'REVERSE';
4
+ export type AutoPaymentType = 'NONE' | 'DEFAULT' | 'RECURRING';
5
+ export type InstallmentProductType = 'BIRKART' | 'ALLBALI' | 'BOLKART' | 'TAMKART';
6
+ export type InstallmentPeriod = 'PERIOD' | 'PERIOD_1' | 'PERIOD_2' | 'PERIOD_3' | 'PERIOD_4' | 'PERIOD_5' | 'PERIOD_6' | 'PERIOD_7' | 'PERIOD_8' | 'PERIOD_9' | 'PERIOD_10' | 'PERIOD_11' | 'PERIOD_12' | 'PERIOD_13' | 'PERIOD_14' | 'PERIOD_15' | 'PERIOD_16' | 'PERIOD_17' | 'PERIOD_18' | 'PERIOD_19' | 'PERIOD_20' | 'PERIOD_21' | 'PERIOD_22' | 'PERIOD_23' | 'PERIOD_24';
7
+ type Open<T extends string> = T | (string & {});
8
+ export type PaymentStatus = Open<'CREATED' | 'APPROVED' | 'CANCELED' | 'DECLINED' | 'REFUNDED' | 'PREAUTH_APPROVED' | 'EXPIRED' | 'REVERSE' | 'PARTIAL_REFUND' | 'PARTIAL' | 'ACCEPTED' | 'REFUND_IN_PROGRESS' | 'CASH' | 'PENDING' | 'PREAUTH_EXPIRED' | 'IN_REVIEW'>;
9
+ export type CardSaveStatus = Open<'CREATED' | 'VERIFIED' | 'REVERSED' | 'REVERSE_FAILED' | 'DECLINED' | 'EXPIRED'>;
10
+ export type TransferState = Open<'CREATED' | 'IN_PROGRESS' | 'NOT_FOUND' | 'FAIL' | 'SUCCESS' | 'DAILY_PAYOUT_LIMIT_EXCEEDED'>;
11
+ export type InvoiceStatus = Open<'PENDING' | 'ERROR' | 'EXPIRED' | 'PARTIAL' | 'COMPLETE' | 'CASH' | 'DECLINED' | 'CANCELED'>;
12
+ export interface Installment {
13
+ type: InstallmentProductType;
14
+ period: InstallmentPeriod;
15
+ }
16
+ export interface CardData {
17
+ pan: string;
18
+ cardHolder: string;
19
+ expiryMonth: string | number;
20
+ expiryYear: string | number;
21
+ cvv: string;
22
+ }
23
+ export interface CreateOrderParams {
24
+ amount: number;
25
+ currency?: Currency;
26
+ language?: Language;
27
+ operation?: Operation;
28
+ description?: string;
29
+ callbackUrl?: string;
30
+ redirectUrl?: string;
31
+ cardSave?: boolean;
32
+ threeDS?: boolean;
33
+ autoPaymentType?: AutoPaymentType;
34
+ installment?: Installment;
35
+ fullName?: string;
36
+ phoneNumber?: string;
37
+ metadata?: Record<string, string>;
38
+ fields?: Record<string, string>;
39
+ requestRrn?: string;
40
+ }
41
+ export interface RefundParams {
42
+ orderId: string;
43
+ amount?: number;
44
+ refundReason?: string;
45
+ callbackUrl?: string;
46
+ }
47
+ export interface CompleteParams {
48
+ orderId: string;
49
+ amount?: number;
50
+ callbackUrl?: string;
51
+ }
52
+ export interface DirectPayParams {
53
+ amount: number;
54
+ description: string;
55
+ card: CardData;
56
+ operation?: Operation;
57
+ currency?: Currency;
58
+ callbackUrl?: string;
59
+ threeDS?: boolean;
60
+ customFields?: Record<string, string>;
61
+ cardSave?: boolean;
62
+ requestRrn?: string;
63
+ }
64
+ export interface AutoPayParams {
65
+ cardUuid: string;
66
+ amount: number;
67
+ description: string;
68
+ operation?: Operation;
69
+ currency?: Currency;
70
+ callbackUrl?: string;
71
+ threeDS?: boolean;
72
+ oneClickPayment?: boolean;
73
+ requestRrn?: string;
74
+ }
75
+ export interface CardSaveParams {
76
+ customerRef: string;
77
+ callbackUrl: string;
78
+ description?: string;
79
+ language?: Language;
80
+ metadata?: Record<string, string>;
81
+ idempotencyKey?: string;
82
+ }
83
+ export interface PayoutParams {
84
+ transferAmount: number;
85
+ description: string;
86
+ fullName: string;
87
+ finCode: string;
88
+ cardPan?: string;
89
+ bankName?: string;
90
+ cardType?: string;
91
+ requestRrn?: string;
92
+ customerCode?: string;
93
+ voen?: string;
94
+ birthDate?: string;
95
+ callbackUrl?: string;
96
+ idempotencyKey?: string;
97
+ }
98
+ export interface InvoiceCreateParams {
99
+ amount?: number;
100
+ amountDynamic?: boolean;
101
+ currency?: Currency;
102
+ language?: Language;
103
+ fullName?: string;
104
+ email?: string;
105
+ phoneNumber?: string;
106
+ description?: string;
107
+ customMessage?: string;
108
+ expireDate?: Date | string;
109
+ approveUrl?: string;
110
+ cancelUrl?: string;
111
+ declineUrl?: string;
112
+ redirectUrl?: string;
113
+ installmentProductType?: InstallmentProductType;
114
+ installmentPeriod?: number;
115
+ directPay?: boolean;
116
+ sendSms?: boolean;
117
+ sendWhatsapp?: boolean;
118
+ sendEmail?: boolean;
119
+ metadata?: Record<string, string>;
120
+ externalTransactionId?: string;
121
+ }
122
+ export interface PageParams {
123
+ page?: number;
124
+ size?: number;
125
+ }
126
+ export interface TransactionFilter extends PageParams {
127
+ orderId?: string;
128
+ rrn?: string;
129
+ status?: PaymentStatus;
130
+ amount?: string;
131
+ description?: string;
132
+ name?: string;
133
+ fullName?: string;
134
+ cardNumber?: string;
135
+ bookingId?: string;
136
+ invoiceCode?: string;
137
+ from?: Date | string;
138
+ to?: Date | string;
139
+ }
140
+ export interface PayoutFilter extends PageParams {
141
+ rrn?: string;
142
+ status?: TransferState;
143
+ amount?: string;
144
+ description?: string;
145
+ fullName?: string;
146
+ finCode?: string;
147
+ bankSource?: string;
148
+ from?: Date | string;
149
+ to?: Date | string;
150
+ }
151
+ export interface Page<T> {
152
+ content: T[];
153
+ totalElements: number;
154
+ totalPages: number;
155
+ number: number;
156
+ size: number;
157
+ first: boolean;
158
+ last: boolean;
159
+ }
160
+ export interface CardDetails {
161
+ maskedPan?: string;
162
+ brand?: string;
163
+ uuid?: string;
164
+ cardHolderName?: string;
165
+ phoneNumber?: string;
166
+ }
167
+ export interface OrderTransaction {
168
+ uuid?: string;
169
+ createdDate?: string;
170
+ status?: string;
171
+ channel?: string;
172
+ channelType?: string;
173
+ requestRrn?: string;
174
+ responseRrn?: string;
175
+ externalRrn?: string;
176
+ pan?: string;
177
+ paymentWay?: string;
178
+ cardDetails?: CardDetails;
179
+ cardUuid?: string;
180
+ recurrenceId?: number;
181
+ responseDescription?: string;
182
+ merchantCategory?: string;
183
+ installment?: Installment;
184
+ }
185
+ export interface OrderInfo {
186
+ orderId: string;
187
+ externalTransactionId?: string;
188
+ invoiceUuid?: string;
189
+ amount?: number;
190
+ currencyType?: Currency;
191
+ merchantName?: string;
192
+ commission?: number;
193
+ commissionRate?: number;
194
+ paidAmount?: number;
195
+ extraPayment?: number;
196
+ operationType?: Operation;
197
+ paymentStatus?: PaymentStatus;
198
+ auto?: boolean;
199
+ createdDate?: string;
200
+ description?: string;
201
+ metadata?: string;
202
+ idempotencyKey?: string;
203
+ transactions?: OrderTransaction[];
204
+ }
205
+ export interface CreateOrderResponse {
206
+ orderId: string;
207
+ sessionId?: string;
208
+ paymentUrl?: string;
209
+ previewUrl?: string;
210
+ transactionId?: number;
211
+ commissionRate?: number;
212
+ amount?: number;
213
+ fee?: number;
214
+ totalAmount?: number;
215
+ }
216
+ export interface DirectPayResponse {
217
+ orderId: string;
218
+ threeDS?: boolean;
219
+ redirect?: boolean;
220
+ redirectUrl?: string;
221
+ paymentUrl?: string;
222
+ transactionResponse?: OrderTransaction;
223
+ }
224
+ export interface TransactionResponse {
225
+ redirect?: boolean;
226
+ redirectUrl?: string;
227
+ threeDS?: boolean;
228
+ accessUrl?: string;
229
+ channel?: string;
230
+ transactionResult?: DirectPayResponse;
231
+ }
232
+ export interface AutoPayResponse {
233
+ orderId: string;
234
+ paymentUrl?: string;
235
+ description?: string;
236
+ amount?: number;
237
+ commission?: number;
238
+ commissionRate?: number;
239
+ currencyType?: Currency;
240
+ operationType?: Operation;
241
+ paymentStatus?: PaymentStatus;
242
+ auto?: boolean;
243
+ createdDate?: string;
244
+ transactions?: OrderTransaction[];
245
+ transactionResponseDto?: TransactionResponse;
246
+ }
247
+ export interface CardSaveResponse {
248
+ cardSaveId: string;
249
+ orderId?: string;
250
+ sessionId?: string;
251
+ paymentUrl?: string;
252
+ amount?: number;
253
+ currency?: Currency;
254
+ status?: CardSaveStatus;
255
+ }
256
+ export interface CardSaveDetails {
257
+ cardSaveId: string;
258
+ orderId?: string;
259
+ status?: CardSaveStatus;
260
+ cardUuid?: string;
261
+ maskedPan?: string;
262
+ cardBrand?: string;
263
+ amount?: number;
264
+ currency?: Currency;
265
+ customerRef?: string;
266
+ createdDate?: string;
267
+ verifiedDate?: string;
268
+ }
269
+ export interface SavedCard {
270
+ cardUuid: string;
271
+ maskedPan?: string;
272
+ cardBrand?: string;
273
+ createdDate?: string;
274
+ }
275
+ export interface Transaction {
276
+ id?: number;
277
+ applicationId?: number;
278
+ orderId?: string;
279
+ sessionId?: string;
280
+ uuid?: string;
281
+ rrn?: string;
282
+ externalRrn?: string;
283
+ amount?: number;
284
+ paidAmount?: number;
285
+ refundAmount?: number;
286
+ restOfAmount?: number;
287
+ amountWithoutFee?: number;
288
+ payriffAmount?: number;
289
+ commissionRate?: number;
290
+ extraPayment?: number;
291
+ currencyType?: Currency;
292
+ paymentStatus?: PaymentStatus;
293
+ paymentSource?: string;
294
+ description?: string;
295
+ responseDescription?: string;
296
+ orderLanguage?: Language;
297
+ tariffType?: string;
298
+ source?: string;
299
+ fullName?: string;
300
+ phoneNumber?: string;
301
+ bookingId?: string;
302
+ invoiceCode?: string;
303
+ pan?: string;
304
+ cardBrand?: string;
305
+ paymentRoute?: string;
306
+ paymentWay?: string;
307
+ transitId?: string;
308
+ createdDate?: string;
309
+ lastModifiedDate?: string;
310
+ }
311
+ export interface PayoutResult {
312
+ finalState?: string;
313
+ state?: string;
314
+ stateDescription?: string;
315
+ currentDepositBalance?: number;
316
+ walletHistoryId?: number;
317
+ bankName?: string;
318
+ }
319
+ export interface PayoutStatus {
320
+ bankName?: string;
321
+ state?: TransferState;
322
+ cardPan?: string;
323
+ transferAmount?: number;
324
+ createdDate?: string;
325
+ formattedDate?: string;
326
+ transferType?: string;
327
+ merchant?: string;
328
+ description?: string;
329
+ fullName?: string;
330
+ finCode?: string;
331
+ }
332
+ export interface PayoutSummary {
333
+ id?: number;
334
+ requestRrn?: string;
335
+ transferAmount?: number;
336
+ amountWithFee?: number;
337
+ fee?: number;
338
+ createdDate?: string;
339
+ state?: TransferState;
340
+ stateDescription?: string;
341
+ cardPan?: string;
342
+ finCode?: string;
343
+ fullName?: string;
344
+ description?: string;
345
+ }
346
+ export interface Invoice {
347
+ id?: number;
348
+ merchantId?: string;
349
+ uuid?: string;
350
+ invoiceUuid: string;
351
+ invoiceCode?: string;
352
+ invoiceStatus?: InvoiceStatus;
353
+ paymentUrl?: string;
354
+ amount?: number;
355
+ totalAmount?: number;
356
+ payriffAmount?: number;
357
+ payriffFee?: number;
358
+ payriffFixedFeeAmount?: number;
359
+ currencyType?: Currency;
360
+ languageType?: Language;
361
+ paymentType?: string;
362
+ fullName?: string;
363
+ email?: string;
364
+ phoneNumber?: string;
365
+ description?: string;
366
+ customMessage?: string;
367
+ expireDate?: string;
368
+ createdDate?: string;
369
+ approveURL?: string;
370
+ cancelURL?: string;
371
+ declineURL?: string;
372
+ active?: boolean;
373
+ sendSms?: boolean;
374
+ }
375
+ export interface InvoiceDetails {
376
+ id?: number;
377
+ merchantId?: string;
378
+ uuid?: string;
379
+ invoiceUuid: string;
380
+ invoiceCode?: string;
381
+ invoiceStatus?: InvoiceStatus;
382
+ baseUrl?: string;
383
+ amount?: number;
384
+ totalAmount?: number;
385
+ payriffAmount?: number;
386
+ payriffFee?: number;
387
+ payriffFixedFeeAmount?: number;
388
+ currencyType?: Currency;
389
+ languageType?: Language;
390
+ paymentType?: string;
391
+ fullName?: string;
392
+ email?: string;
393
+ phoneNumber?: string;
394
+ description?: string;
395
+ expireDate?: string;
396
+ paymentDay?: string;
397
+ expireDay?: string;
398
+ createdDate?: string;
399
+ approveURL?: string;
400
+ cancelURL?: string;
401
+ declineURL?: string;
402
+ active?: boolean;
403
+ installmentPeriod?: number;
404
+ source?: string;
405
+ directPay?: boolean;
406
+ metadata?: string;
407
+ }
408
+ export {};
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/util.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export declare function required<T>(value: T | null | undefined, name: string): T;
2
+ export declare function pathSegment(value: string, name: string): string;
3
+ export declare function compact(values: Record<string, unknown>): Record<string, unknown>;
4
+ export declare function nonEmpty<T extends object>(value: T | undefined): T | undefined;
5
+ export declare function formatDateTime(value: Date | string | undefined): string | undefined;
6
+ export declare function formatFilterDate(value: Date | string | undefined, name: string): string | undefined;
package/dist/util.js ADDED
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.required = required;
4
+ exports.pathSegment = pathSegment;
5
+ exports.compact = compact;
6
+ exports.nonEmpty = nonEmpty;
7
+ exports.formatDateTime = formatDateTime;
8
+ exports.formatFilterDate = formatFilterDate;
9
+ function required(value, name) {
10
+ if (value === undefined || value === null) {
11
+ throw new TypeError(`${name} is required`);
12
+ }
13
+ return value;
14
+ }
15
+ function pathSegment(value, name) {
16
+ if (typeof value !== 'string' || value.trim() === '') {
17
+ throw new TypeError(`${name} must not be blank`);
18
+ }
19
+ return encodeURIComponent(value);
20
+ }
21
+ function compact(values) {
22
+ const out = {};
23
+ for (const [key, value] of Object.entries(values)) {
24
+ if (value !== undefined && value !== null)
25
+ out[key] = value;
26
+ }
27
+ return out;
28
+ }
29
+ function nonEmpty(value) {
30
+ return value && Object.keys(value).length > 0 ? value : undefined;
31
+ }
32
+ function pad(n) {
33
+ return String(n).padStart(2, '0');
34
+ }
35
+ function formatDateTime(value) {
36
+ if (value === undefined || typeof value === 'string')
37
+ return value;
38
+ return `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(value.getDate())}`
39
+ + `T${pad(value.getHours())}:${pad(value.getMinutes())}:${pad(value.getSeconds())}`;
40
+ }
41
+ const ISO_DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
42
+ function formatFilterDate(value, name) {
43
+ if (value === undefined)
44
+ return undefined;
45
+ if (typeof value === 'string') {
46
+ const m = ISO_DATE.exec(value);
47
+ if (!m)
48
+ throw new TypeError(`${name} must be a Date or a YYYY-MM-DD string`);
49
+ return `${m[3]}.${m[2]}.${m[1]}`;
50
+ }
51
+ return `${pad(value.getDate())}.${pad(value.getMonth() + 1)}.${value.getFullYear()}`;
52
+ }
@@ -0,0 +1 @@
1
+ export declare const VERSION = "0.1.3";
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VERSION = void 0;
4
+ exports.VERSION = '0.1.3';
@@ -0,0 +1,2 @@
1
+ import type { OrderInfo } from './types';
2
+ export declare function parseOrderCallback(body: string | Buffer | object): OrderInfo;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseOrderCallback = parseOrderCallback;
4
+ const NOT_A_CALLBACK = 'Not a Payriff order callback';
5
+ function parseOrderCallback(body) {
6
+ let root = body;
7
+ if (typeof body === 'string' || Buffer.isBuffer(body)) {
8
+ try {
9
+ root = JSON.parse(body.toString());
10
+ }
11
+ catch (e) {
12
+ throw new TypeError(NOT_A_CALLBACK, { cause: e });
13
+ }
14
+ }
15
+ const payload = isObject(root) ? root.payload : undefined;
16
+ if (!isObject(payload) || payload.orderId === undefined || payload.orderId === null) {
17
+ throw new TypeError(NOT_A_CALLBACK);
18
+ }
19
+ return payload;
20
+ }
21
+ function isObject(value) {
22
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
23
+ }
package/package.json CHANGED
@@ -1,6 +1,35 @@
1
1
  {
2
2
  "name": "@payriff-sdk/node",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.3",
4
+ "description": "Node.js client for the Payriff merchant API",
5
+ "license": "MIT",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "engines": {
12
+ "node": ">=20"
13
+ },
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.build.json",
16
+ "test": "tsc -p tsconfig.json && node --test \"build/test/**/*.test.js\"",
17
+ "prepare": "npm run build"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/PayRiff/payriff-node.git"
25
+ },
26
+ "keywords": [
27
+ "payriff",
28
+ "payments",
29
+ "azerbaijan"
30
+ ],
31
+ "devDependencies": {
32
+ "@types/node": "^26.6.4",
33
+ "typescript": "^7.0.2"
34
+ }
35
+ }