prospay-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.
@@ -0,0 +1,76 @@
1
+ import { HttpService } from '@nestjs/axios';
2
+ export interface GenerateBulkInvoiceDto {
3
+ templateName: string;
4
+ productId: string;
5
+ startDate: string;
6
+ endDate: string;
7
+ buyer_customerId: string;
8
+ seller_customerId: string;
9
+ due_date: string;
10
+ invoice_no: string;
11
+ invoice_date: string;
12
+ invoice_period: string;
13
+ }
14
+ export interface ProspayGenerateInvoiceResponse {
15
+ status: string;
16
+ message: string;
17
+ refId: string;
18
+ }
19
+ export interface BulkInvoiceItem {
20
+ endDate: string;
21
+ startDate: string;
22
+ buyer_customerId: string;
23
+ seller_customerId: string;
24
+ productId: string;
25
+ due_date: string;
26
+ invoice_no: string;
27
+ invoice_date: string;
28
+ invoice_period: string;
29
+ }
30
+ export interface GenerateBulkInvoiceBatchDto {
31
+ templateName: string;
32
+ data: BulkInvoiceItem[];
33
+ }
34
+ export interface GenerateInvoiceDto {
35
+ templateName: string;
36
+ productId: string;
37
+ startDate: string;
38
+ endDate: string;
39
+ buyer_customerId: string;
40
+ seller_customerId: string;
41
+ due_date: string;
42
+ invoice_no: string;
43
+ invoice_date: string;
44
+ invoice_period: string;
45
+ }
46
+ export interface InvoiceStatusStatistics {
47
+ total: number;
48
+ success: number;
49
+ failed: number;
50
+ processing: number;
51
+ }
52
+ export interface InvoiceStatusItem {
53
+ invoiceId: string | null;
54
+ status: string;
55
+ createdAt: string;
56
+ customerId: string;
57
+ pdfUrl?: string;
58
+ completedAt?: string;
59
+ error?: string;
60
+ errorDetails?: any;
61
+ }
62
+ export interface ProspayInvoiceStatusResponse {
63
+ refId: string;
64
+ overallStatus: string;
65
+ templateName: string | null;
66
+ productId: string;
67
+ statistics: InvoiceStatusStatistics;
68
+ invoices: InvoiceStatusItem[];
69
+ }
70
+ export declare class ProspayInvoiceService {
71
+ private readonly http;
72
+ constructor(http: HttpService);
73
+ generateBulkInvoice(authToken: string, payload: GenerateBulkInvoiceDto, callbackUrl?: string): Promise<ProspayGenerateInvoiceResponse>;
74
+ generateInvoice(authToken: string, payload: GenerateInvoiceDto, callbackUrl?: string): Promise<ProspayGenerateInvoiceResponse>;
75
+ getInvoiceStatus(authToken: string, refId: string): Promise<ProspayInvoiceStatusResponse>;
76
+ }
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ProspayInvoiceService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const axios_1 = require("@nestjs/axios");
15
+ const rxjs_1 = require("rxjs");
16
+ let ProspayInvoiceService = class ProspayInvoiceService {
17
+ constructor(http) {
18
+ this.http = http;
19
+ }
20
+ async generateBulkInvoice(authToken, payload, callbackUrl) {
21
+ const response$ = this.http.post('/invoices/api/v2.0/generateBulkInvoice', payload, {
22
+ headers: {
23
+ Authorization: authToken,
24
+ 'Content-Type': 'application/json',
25
+ ...(callbackUrl ? { 'callback-url': callbackUrl } : {}),
26
+ },
27
+ });
28
+ const response = await (0, rxjs_1.lastValueFrom)(response$);
29
+ return response.data;
30
+ }
31
+ async generateInvoice(authToken, payload, callbackUrl) {
32
+ const response$ = this.http.post('/invoices/api/v2.0/generateInvoice', payload, {
33
+ headers: {
34
+ Authorization: authToken,
35
+ 'Content-Type': 'application/json',
36
+ ...(callbackUrl ? { 'callback-url': callbackUrl } : {}),
37
+ },
38
+ });
39
+ const response = await (0, rxjs_1.lastValueFrom)(response$);
40
+ return response.data;
41
+ }
42
+ async getInvoiceStatus(authToken, refId) {
43
+ const response$ = this.http.get(`/invoices/api/v2.0/invoice-status/${refId}`, {
44
+ headers: {
45
+ Authorization: authToken,
46
+ 'Content-Type': 'application/json',
47
+ },
48
+ });
49
+ const response = await (0, rxjs_1.lastValueFrom)(response$);
50
+ return response.data;
51
+ }
52
+ };
53
+ exports.ProspayInvoiceService = ProspayInvoiceService;
54
+ exports.ProspayInvoiceService = ProspayInvoiceService = __decorate([
55
+ (0, common_1.Injectable)(),
56
+ __metadata("design:paramtypes", [axios_1.HttpService])
57
+ ], ProspayInvoiceService);
58
+ //# sourceMappingURL=invoice.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoice.service.js","sourceRoot":"","sources":["../../src/invoice/invoice.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,yCAA4C;AAC5C,+BAAqC;AA+E9B,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,YAA6B,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;IAAG,CAAC;IAOlD,KAAK,CAAC,mBAAmB,CACvB,SAAiB,EACjB,OAA+B,EAC/B,WAAoB;QAEpB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAC9B,wCAAwC,EACxC,OAAO,EACP;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS;gBACxB,cAAc,EAAE,kBAAkB;gBAClC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxD;SACF,CACF,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAa,EAAC,SAAS,CAAC,CAAC;QAChD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAOD,KAAK,CAAC,eAAe,CACnB,SAAiB,EACjB,OAA2B,EAC3B,WAAoB;QAEpB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAC9B,oCAAoC,EACpC,OAAO,EACP;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS;gBACxB,cAAc,EAAE,kBAAkB;gBAClC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACxD;SACF,CACF,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAa,EAAC,SAAS,CAAC,CAAC;QAChD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAOD,KAAK,CAAC,gBAAgB,CACpB,SAAiB,EACjB,KAAa;QAEb,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAC7B,qCAAqC,KAAK,EAAE,EAC5C;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS;gBACxB,cAAc,EAAE,kBAAkB;aACnC;SACF,CACF,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAa,EAAC,SAAS,CAAC,CAAC;QAChD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF,CAAA;AA7EY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAEwB,mBAAW;GADnC,qBAAqB,CA6EjC"}
@@ -0,0 +1,6 @@
1
+ export declare const PROSPAY_SDK_OPTIONS = "PROSPAY_SDK_OPTIONS";
2
+ export interface ProspaySdkOptions {
3
+ productId: string;
4
+ productApiKey: string;
5
+ baseUrl?: string;
6
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PROSPAY_SDK_OPTIONS = void 0;
4
+ exports.PROSPAY_SDK_OPTIONS = 'PROSPAY_SDK_OPTIONS';
5
+ //# sourceMappingURL=sdk.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.config.js","sourceRoot":"","sources":["../src/sdk.config.ts"],"names":[],"mappings":";;;AAAa,QAAA,mBAAmB,GAAG,qBAAqB,CAAC"}
@@ -0,0 +1,145 @@
1
+ import { HttpService } from '@nestjs/axios';
2
+ export interface TransactionChargeBreakup {
3
+ head: string;
4
+ amount: number;
5
+ appliedOn: string[];
6
+ tags: string[];
7
+ }
8
+ export interface TransactionChargeMetadata {
9
+ key: string;
10
+ value: string;
11
+ }
12
+ export interface TransactionCharge {
13
+ head: string;
14
+ amount: number;
15
+ hsnOrSac: string;
16
+ isBillable: boolean;
17
+ absorbedBy: string;
18
+ transactionType: string;
19
+ chargedAt?: string;
20
+ breakup?: TransactionChargeBreakup[];
21
+ metadata?: TransactionChargeMetadata[];
22
+ }
23
+ export interface CreateTransactionDto {
24
+ customerId: string;
25
+ entityType: string;
26
+ referenceId: string;
27
+ currency: string;
28
+ vertical: string;
29
+ charges: TransactionCharge[];
30
+ }
31
+ export interface AddChargesToTransactionDto {
32
+ charges: TransactionCharge[];
33
+ }
34
+ export interface TransactionDateRangeFilter {
35
+ start: string;
36
+ end: string;
37
+ }
38
+ export interface TransactionSearchFilters {
39
+ customerIds?: string[];
40
+ transactionDateRange?: TransactionDateRangeFilter;
41
+ }
42
+ export interface SearchTransactionsDto {
43
+ page: number;
44
+ limit: number;
45
+ transactionFilters: TransactionSearchFilters;
46
+ }
47
+ export interface ChargeSummaryParams {
48
+ startDate: string;
49
+ endDate: string;
50
+ }
51
+ export interface ProspayCreateTransactionSuccessResponse {
52
+ success: true;
53
+ requestId: string;
54
+ path: string;
55
+ timestamp: string;
56
+ data: {
57
+ transactionId: string;
58
+ summary: {
59
+ transactionAmount: number;
60
+ billableAmount: number;
61
+ totalCreditAmount: number;
62
+ totalDebitAmount: number;
63
+ };
64
+ };
65
+ }
66
+ export interface ProspayCreateTransactionErrorResponse {
67
+ success: false;
68
+ requestId: string;
69
+ path: string;
70
+ timestamp: string;
71
+ error: {
72
+ code: string;
73
+ errors: {
74
+ message: string;
75
+ field: string;
76
+ value: string;
77
+ }[];
78
+ };
79
+ }
80
+ export interface ProspayAddChargesSuccessResponse {
81
+ success: true;
82
+ requestId: string;
83
+ path: string;
84
+ timestamp: string;
85
+ data: {
86
+ transactionId: string;
87
+ addedChargesSummary: {
88
+ transactionAmount: number;
89
+ billableAmount: number;
90
+ totalCreditAmount: number;
91
+ totalDebitAmount: number;
92
+ };
93
+ transactionSummary: {
94
+ transactionAmount: number;
95
+ billableAmount: number;
96
+ totalCreditAmount: number;
97
+ totalDebitAmount: number;
98
+ };
99
+ };
100
+ }
101
+ export interface ProspaySearchTransactionsResponse {
102
+ success: true;
103
+ requestId: string;
104
+ path: string;
105
+ timestamp: string;
106
+ data: {
107
+ items: any[];
108
+ pagination: {
109
+ total: number;
110
+ page: number;
111
+ limit: number;
112
+ totalPages: number;
113
+ };
114
+ };
115
+ }
116
+ export interface ProspayChargeSummaryItem {
117
+ chargeHead: string;
118
+ hsnOrSac: string;
119
+ vertical: string;
120
+ taxableAmount: number;
121
+ cgstRate: number;
122
+ cgst: number;
123
+ sgstRate: number;
124
+ sgst: number;
125
+ igstRate: number;
126
+ igst: number;
127
+ totalTaxRate: number;
128
+ totalTax: number;
129
+ netAmount: number;
130
+ }
131
+ export interface ProspayChargeSummaryResponse {
132
+ success: true;
133
+ requestId: string;
134
+ path: string;
135
+ timestamp: string;
136
+ data: ProspayChargeSummaryItem[];
137
+ }
138
+ export declare class ProspayTransactionService {
139
+ private readonly http;
140
+ constructor(http: HttpService);
141
+ createTransaction(authToken: string, payload: CreateTransactionDto): Promise<ProspayCreateTransactionSuccessResponse>;
142
+ addChargesToTransaction(authToken: string, transactionId: string, payload: AddChargesToTransactionDto): Promise<ProspayAddChargesSuccessResponse>;
143
+ searchTransactions(authToken: string, payload: SearchTransactionsDto): Promise<ProspaySearchTransactionsResponse>;
144
+ getChargeSummary(authToken: string, params: ChargeSummaryParams): Promise<ProspayChargeSummaryResponse>;
145
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ProspayTransactionService = void 0;
13
+ const common_1 = require("@nestjs/common");
14
+ const axios_1 = require("@nestjs/axios");
15
+ const rxjs_1 = require("rxjs");
16
+ let ProspayTransactionService = class ProspayTransactionService {
17
+ constructor(http) {
18
+ this.http = http;
19
+ }
20
+ async createTransaction(authToken, payload) {
21
+ const response$ = this.http.post('/uts/api/transactions', payload, {
22
+ headers: {
23
+ Authorization: authToken,
24
+ 'Content-Type': 'application/json',
25
+ },
26
+ });
27
+ const response = await (0, rxjs_1.lastValueFrom)(response$);
28
+ return response.data;
29
+ }
30
+ async addChargesToTransaction(authToken, transactionId, payload) {
31
+ const response$ = this.http.post(`/uts/api/transactions/${transactionId}/charges`, payload, {
32
+ headers: {
33
+ Authorization: authToken,
34
+ 'Content-Type': 'application/json',
35
+ },
36
+ });
37
+ const response = await (0, rxjs_1.lastValueFrom)(response$);
38
+ return response.data;
39
+ }
40
+ async searchTransactions(authToken, payload) {
41
+ const response$ = this.http.post('/uts/api/transactions/search', payload, {
42
+ headers: {
43
+ Authorization: authToken,
44
+ 'Content-Type': 'application/json',
45
+ },
46
+ });
47
+ const response = await (0, rxjs_1.lastValueFrom)(response$);
48
+ return response.data;
49
+ }
50
+ async getChargeSummary(authToken, params) {
51
+ const response$ = this.http.get('/uts/api/transactions/charge-summary/', {
52
+ params,
53
+ headers: {
54
+ Authorization: authToken,
55
+ },
56
+ });
57
+ const response = await (0, rxjs_1.lastValueFrom)(response$);
58
+ return response.data;
59
+ }
60
+ };
61
+ exports.ProspayTransactionService = ProspayTransactionService;
62
+ exports.ProspayTransactionService = ProspayTransactionService = __decorate([
63
+ (0, common_1.Injectable)(),
64
+ __metadata("design:paramtypes", [axios_1.HttpService])
65
+ ], ProspayTransactionService);
66
+ //# sourceMappingURL=transaction.service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.service.js","sourceRoot":"","sources":["../../src/transaction/transaction.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,yCAA4C;AAC5C,+BAAqC;AA8J9B,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IACpC,YAA6B,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;IAAG,CAAC;IAOlD,KAAK,CAAC,iBAAiB,CACrB,SAAiB,EACjB,OAA6B;QAE7B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAC9B,uBAAuB,EACvB,OAAO,EACP;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS;gBACxB,cAAc,EAAE,kBAAkB;aACnC;SACF,CACF,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAa,EAAC,SAAS,CAAC,CAAC;QAChD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAOD,KAAK,CAAC,uBAAuB,CAC3B,SAAiB,EACjB,aAAqB,EACrB,OAAmC;QAEnC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAC9B,yBAAyB,aAAa,UAAU,EAChD,OAAO,EACP;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS;gBACxB,cAAc,EAAE,kBAAkB;aACnC;SACF,CACF,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAa,EAAC,SAAS,CAAC,CAAC;QAChD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAOD,KAAK,CAAC,kBAAkB,CACtB,SAAiB,EACjB,OAA8B;QAE9B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAC9B,8BAA8B,EAC9B,OAAO,EACP;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS;gBACxB,cAAc,EAAE,kBAAkB;aACnC;SACF,CACF,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAa,EAAC,SAAS,CAAC,CAAC;QAChD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAOD,KAAK,CAAC,gBAAgB,CACpB,SAAiB,EACjB,MAA2B;QAE3B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAC7B,uCAAuC,EACvC;YACE,MAAM;YACN,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS;aACzB;SACF,CACF,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAa,EAAC,SAAS,CAAC,CAAC;QAChD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF,CAAA;AAlGY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;qCAEwB,mBAAW;GADnC,yBAAyB,CAkGrC"}
package/manual.txt ADDED
@@ -0,0 +1,47 @@
1
+ ProspayAuthService
2
+ - authenticate(): POST {baseUrl}/auth/api/v1.0/authenz/token?action=verify
3
+ Inputs: headers => timestamp (epoch seconds), resourceId (productId), keyhash (bcrypt of `${timestamp}.${productId}.${productApiKey}`); no body.
4
+ Success: `{ status, message?, token?, ... }` (auth token payload). Base URL defaults to https://sandbox.prospay.tech.
5
+
6
+ ProspayCustomerService
7
+ - createCustomer(authToken, payload): POST /customer/api/v3.0/customers
8
+ Inputs (body): productId, productCustomerId, orgName, customerType, contacts { email, mobileNumber }.
9
+ Success: `{ status, message, data: { customerId, customerData, virtualAccountNo, uin, qrString, isDeliveryAllowed, creditPeriodInDays } }`.
10
+ - updateCustomer(authToken, customerId, payload): PATCH /customer/api/v3.0/customers/{customerId}/
11
+ Inputs (body): any subset of creditPeriodInDays, uin, preferences { isMainOrg, mainOrgCustomerId, shareWallet, customerIdForWallet, shareKYC, customerIdForKYC, paymentType }, isDeliveryAllowed, billingType, invoiceGenerationPeriod, CIN, status, creditlimit, contacts { email, mobileNumber }, industryType, KYC { businessType, isGSTRegistered, GST, customerConsent }, address { line1, line2, city, state, pincode, stateCode }, productId.
12
+ Success: `{ status, message, data: { uin, creditPeriodInDays, customerId, customerData, kycData, creditLimit: { walletId, oldCreditLimit, newCreditLimit, newAvailableBalance, currency, updatedAt } } }`.
13
+ - updateCustomerStatus(authToken, customerId, payload): PATCH /customer/api/v3.0/customers/{customerId}/
14
+ Inputs (body): productId, status.
15
+ Success: `{ status, message, data: { uin, creditPeriodInDays, customerId, customerData } }`.
16
+ - getCustomerById(authToken, customerId): GET /customer/api/v3.0/customers/{customerId}?filter=all
17
+ Inputs: headers => Authorization; query => filter=all.
18
+ Success: `{ status, message, data: [customerProfile...], cached }` (profiles include contact, KYC, credit, bank, address, flags).
19
+ - searchCustomers(authToken, params): GET /customer/api/v3.0/customers/search
20
+ Inputs (query): filter?, mobileNumber?, productCustomerId?, customerType?; headers => Authorization.
21
+ Success: `{ status, message, data }` (structure depends on search result).
22
+
23
+ ProspayInvoiceService
24
+ - generateBulkInvoice(authToken, payload, callbackUrl?): POST /invoices/api/v2.0/generateBulkInvoice
25
+ Inputs (body): templateName, productId, startDate (YYYY-MM-DD), endDate (YYYY-MM-DD), buyer_customerId, seller_customerId, due_date (YYYY-MM-DD), invoice_no, invoice_date (DD-MM-YYYY), invoice_period; headers => Authorization, Content-Type, optional callback-url.
26
+ Success: `{ status: "ok", message: "Process initiated for generating invoice", refId }`.
27
+ - generateInvoice(authToken, payload, callbackUrl?): POST /invoices/api/v2.0/generateInvoice
28
+ Inputs (body): templateName, productId, startDate (YYYY-MM-DD), endDate (YYYY-MM-DD), buyer_customerId, seller_customerId, due_date (YYYY-MM-DD), invoice_no, invoice_date (DD-MM-YYYY), invoice_period; headers => Authorization, Content-Type, optional callback-url.
29
+ Success: `{ status: "ok", message: "Process initiated for generating invoice", refId }`.
30
+ - getInvoiceStatus(authToken, refId): GET /invoices/api/v2.0/invoice-status/{refId}
31
+ Inputs: path => refId; headers => Authorization, Content-Type.
32
+ Success: `{ refId, overallStatus, templateName, productId, statistics: { total, success, failed, processing }, invoices: [{ invoiceId, status, createdAt, customerId, pdfUrl?, completedAt?, error?, errorDetails? }] }`.
33
+
34
+ ProspayTransactionService
35
+ - createTransaction(authToken, payload): POST /uts/api/transactions
36
+ Inputs (body): customerId, entityType (e.g., "order"), referenceId, currency (e.g., "INR"), vertical (e.g., "customer"), charges: [{ head, amount, hsnOrSac, isBillable, absorbedBy, transactionType, chargedAt?, appliedOn?, tags?, breakup?, metadata? }].
37
+ Success: `{ success: true, requestId, path, timestamp, data: { transactionId, summary: { transactionAmount, billableAmount, totalCreditAmount, totalDebitAmount } } }`.
38
+ - addChargesToTransaction(authToken, transactionId, payload): POST /uts/api/transactions/{transactionId}/charges
39
+ Inputs (body): charges: [{ head, amount, hsnOrSac, isBillable, absorbedBy, transactionType, chargedAt?, appliedOn?, tags?, breakup?, metadata? }]; path => transactionId.
40
+ Success: `{ success: true, requestId, path, timestamp, data: { transactionId, addedChargesSummary: { transactionAmount, billableAmount, totalCreditAmount, totalDebitAmount }, transactionSummary: { transactionAmount, billableAmount, totalCreditAmount, totalDebitAmount } } }`.
41
+ - searchTransactions(authToken, payload): POST /uts/api/transactions/search
42
+ Inputs (body): page, limit, transactionFilters { customerIds?, transactionDateRange? { start, end } }.
43
+ Success: `{ success: true, requestId, path, timestamp, data: { items: [...], pagination: { total, page, limit, totalPages } } }`.
44
+ - getChargeSummary(authToken, params): GET /uts/api/transactions/charge-summary/
45
+ Inputs (query): startDate (YYYY-MM-DD), endDate (YYYY-MM-DD); headers => Authorization.
46
+ Success: `{ success: true, requestId, path, timestamp, data: [{ chargeHead, hsnOrSac, vertical, taxableAmount, cgstRate, cgst, sgstRate, sgst, igstRate, igst, totalTaxRate, totalTax, netAmount }, ...] }`.
47
+
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "prospay-sdk",
3
+ "version": "1.0.0",
4
+ "description": "NestJS-based SDK for Prospay customer onboarding, order, and invoicing APIs.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "scripts": {
8
+ "build": "tsc -p tsconfig.json",
9
+ "build:watch": "ts-node-dev --respawn --transpile-only src/index.ts",
10
+ "test": "echo \"No tests yet\" && exit 0"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://preetihaloli1@bitbucket.org/delcaperadmin/prospay-sdk.git"
15
+ },
16
+ "keywords": [],
17
+ "author": "",
18
+ "license": "ISC",
19
+ "bugs": {
20
+ "url": "https://bitbucket.org/delcaperadmin/prospay-sdk/issues"
21
+ },
22
+ "homepage": "https://bitbucket.org/delcaperadmin/prospay-sdk#readme",
23
+ "dependencies": {
24
+ "@nestjs/axios": "^4.0.1",
25
+ "@nestjs/common": "^11.1.9",
26
+ "@nestjs/core": "^11.1.9",
27
+ "bcryptjs": "^3.0.3",
28
+ "reflect-metadata": "^0.2.2",
29
+ "rxjs": "^7.8.2"
30
+ },
31
+ "devDependencies": {
32
+ "@types/node": "^24.10.1",
33
+ "ts-node": "^10.9.2",
34
+ "ts-node-dev": "^2.0.0",
35
+ "typescript": "^5.9.3"
36
+ }
37
+ }
@@ -0,0 +1,63 @@
1
+ import { Inject, Injectable } from '@nestjs/common';
2
+ import { HttpService } from '@nestjs/axios';
3
+ import { lastValueFrom } from 'rxjs';
4
+ import * as bcrypt from 'bcryptjs';
5
+ import { PROSPAY_SDK_OPTIONS, ProspaySdkOptions } from '../sdk.config';
6
+
7
+ @Injectable()
8
+ export class ProspayAuthService {
9
+ private readonly baseUrl: string;
10
+
11
+ constructor(
12
+ private readonly http: HttpService,
13
+ @Inject(PROSPAY_SDK_OPTIONS)
14
+ private readonly options: ProspaySdkOptions,
15
+ ) {
16
+ this.baseUrl = options.baseUrl ?? 'https://sandbox.prospay.tech';
17
+ }
18
+
19
+ /**
20
+ * Generate a bcrypt hash for the auth header based on:
21
+ * ${timestamp}.${productId}.${productApiKey}
22
+ */
23
+ private async generateKeyHash(timestamp: number): Promise<string> {
24
+ const raw = `${timestamp}.${this.options.productId}.${this.options.productApiKey}`;
25
+ // Default salt rounds = 10 as per typical bcrypt usage.
26
+ const saltRounds = 10;
27
+ return bcrypt.hash(raw, saltRounds);
28
+ }
29
+
30
+ /**
31
+ * Call Prospay auth endpoint (sandbox by default) and return the response.
32
+ * Endpoint:
33
+ * POST {baseUrl}/auth/api/v1.0/authenz/token?action=verify
34
+ * Headers:
35
+ * timestamp: epoch seconds
36
+ * resourceId: productId
37
+ * keyhash: bcrypt hash of `${timestamp}.${productId}.${productApiKey}`
38
+ */
39
+ async authenticate(): Promise<any> {
40
+ const timestamp = Math.floor(new Date().getTime() / 1000);
41
+ const keyhash = await this.generateKeyHash(timestamp);
42
+
43
+ const url = `${this.baseUrl}/auth/api/v1.0/authenz/token`;
44
+
45
+ const response$ = this.http.post(
46
+ url,
47
+ null,
48
+ {
49
+ params: { action: 'verify' },
50
+ headers: {
51
+ timestamp: String(timestamp),
52
+ resourceId: this.options.productId,
53
+ keyhash,
54
+ },
55
+ },
56
+ );
57
+
58
+ const response = await lastValueFrom(response$);
59
+ return response.data;
60
+ }
61
+ }
62
+
63
+