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.
- package/README.md +155 -0
- package/dist/auth/auth.service.d.ts +10 -0
- package/dist/auth/auth.service.js +88 -0
- package/dist/auth/auth.service.js.map +1 -0
- package/dist/customer/customer.service.d.ts +191 -0
- package/dist/customer/customer.service.js +76 -0
- package/dist/customer/customer.service.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +69 -0
- package/dist/index.js.map +1 -0
- package/dist/invoice/invoice.service.d.ts +76 -0
- package/dist/invoice/invoice.service.js +58 -0
- package/dist/invoice/invoice.service.js.map +1 -0
- package/dist/sdk.config.d.ts +6 -0
- package/dist/sdk.config.js +5 -0
- package/dist/sdk.config.js.map +1 -0
- package/dist/transaction/transaction.service.d.ts +145 -0
- package/dist/transaction/transaction.service.js +66 -0
- package/dist/transaction/transaction.service.js.map +1 -0
- package/manual.txt +47 -0
- package/package.json +37 -0
- package/src/auth/auth.service.ts +63 -0
- package/src/customer/customer.service.ts +325 -0
- package/src/index.ts +44 -0
- package/src/invoice/invoice.service.ts +161 -0
- package/src/sdk.config.ts +21 -0
- package/src/transaction/transaction.service.ts +261 -0
- package/tsconfig.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
## Prospay NestJS SDK
|
|
2
|
+
|
|
3
|
+
This package is a **NestJS-based SDK** for integrating with Prospay services, including:
|
|
4
|
+
|
|
5
|
+
- **Customer onboarding**
|
|
6
|
+
- **Order transactions**
|
|
7
|
+
- **Invoice generation**
|
|
8
|
+
|
|
9
|
+
It is designed to be reused across multiple projects so that you configure it once and use typed NestJS services instead of manually wiring HTTP calls every time.
|
|
10
|
+
|
|
11
|
+
### Prerequisites
|
|
12
|
+
|
|
13
|
+
- **Node.js**: v18 or later (recommended)
|
|
14
|
+
- **Package manager**: `npm` (comes with Node), or `yarn` / `pnpm`
|
|
15
|
+
- **NestJS**: Your project should be a NestJS application (v11 recommended to match this SDK).
|
|
16
|
+
|
|
17
|
+
### Installation
|
|
18
|
+
|
|
19
|
+
Once this SDK is published to your private registry or npm, install it in your Nest app:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npm install prospay-sdk
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Quick start
|
|
26
|
+
|
|
27
|
+
Register the SDK module in your root `AppModule` (or any feature module):
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { Module } from '@nestjs/common';
|
|
31
|
+
import { ProspaySdkModule } from 'prospay-sdk';
|
|
32
|
+
|
|
33
|
+
@Module({
|
|
34
|
+
imports: [
|
|
35
|
+
ProspaySdkModule.register({
|
|
36
|
+
productId: 'YOUR_PRODUCT_ID',
|
|
37
|
+
productApiKey: 'YOUR_PRODUCT_API_KEY',
|
|
38
|
+
baseUrl: 'https://sandbox.prospay.tech', // or your prod URL, e.g. https://prospay.tech
|
|
39
|
+
}),
|
|
40
|
+
],
|
|
41
|
+
})
|
|
42
|
+
export class AppModule {}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Available services and methods
|
|
46
|
+
|
|
47
|
+
All services are registered in the module and can be injected anywhere in your Nest app.
|
|
48
|
+
|
|
49
|
+
## Service manual
|
|
50
|
+
|
|
51
|
+
Below is a concise map of each service, its methods, and the underlying Prospay endpoints.
|
|
52
|
+
|
|
53
|
+
### Auth (`ProspayAuthService`)
|
|
54
|
+
- `authenticate()` → `POST /auth/api/v1.0/authenz/token?action=verify`
|
|
55
|
+
Headers auto-built: `timestamp`, `resourceId` (productId), `keyhash` (bcrypt of `timestamp.productId.productApiKey`). Returns auth payload (use its token in `Authorization` for other calls).
|
|
56
|
+
|
|
57
|
+
### Customers (`ProspayCustomerService`)
|
|
58
|
+
- `createCustomer(authToken, payload)` → `POST /customer/api/v3.0/customers`
|
|
59
|
+
- `updateCustomer(authToken, customerId, payload)` → `PATCH /customer/api/v3.0/customers/{customerId}/`
|
|
60
|
+
- `updateCustomerStatus(authToken, customerId, { productId, status })` → `PATCH /customer/api/v3.0/customers/{customerId}/`
|
|
61
|
+
- `getCustomerById(authToken, customerId)` → `GET /customer/api/v3.0/customers/{customerId}?filter=all`
|
|
62
|
+
- `searchCustomers(authToken, params)` → `GET /customer/api/v3.0/customers/search?filter=...&mobileNumber=...&productCustomerId=...&customerType=...`
|
|
63
|
+
|
|
64
|
+
### Transactions (`ProspayTransactionService`)
|
|
65
|
+
- `createTransaction(authToken, payload)` → `POST /uts/api/transactions`
|
|
66
|
+
- `addChargesToTransaction(authToken, transactionId, payload)` → `POST /uts/api/transactions/{transactionId}/charges`
|
|
67
|
+
- `searchTransactions(authToken, payload)` → `POST /uts/api/transactions/search`
|
|
68
|
+
- `getChargeSummary(authToken, { startDate, endDate })` → `GET /uts/api/transactions/charge-summary/?startDate=...&endDate=...`
|
|
69
|
+
|
|
70
|
+
### Invoices (`ProspayInvoiceService`)
|
|
71
|
+
- `generateInvoice(authToken, payload, callbackUrl?)` → `POST /invoices/api/v2.0/generateInvoice`
|
|
72
|
+
- `generateBulkInvoice(authToken, payload, callbackUrl?)` → `POST /invoices/api/v2.0/generateBulkInvoice`
|
|
73
|
+
- Single-range payload: top-level fields (`startDate`, `endDate`, etc.).
|
|
74
|
+
- Multi-invoice payload: pass a `data` array (same endpoint).
|
|
75
|
+
- `getInvoiceStatus(authToken, refId)` → `GET /invoices/api/v2.0/invoice-status/{refId}`
|
|
76
|
+
|
|
77
|
+
### Example snippets
|
|
78
|
+
|
|
79
|
+
Authenticate and create a customer:
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
const authRes = await this.auth.authenticate();
|
|
83
|
+
const token = authRes?.token ?? authRes?.accessToken ?? authRes?.jwt;
|
|
84
|
+
|
|
85
|
+
await this.customers.createCustomer(token, {
|
|
86
|
+
productId: 'SMEINFUL',
|
|
87
|
+
productCustomerId: 'MGC2',
|
|
88
|
+
orgName: 'Mega city',
|
|
89
|
+
customerType: 'cp',
|
|
90
|
+
contacts: { email: 'kalamandhir@gmail.com', mobileNumber: '9110334567' },
|
|
91
|
+
});
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Create a transaction:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
await this.tx.createTransaction(token, {
|
|
98
|
+
customerId: 'SMEINFUL000000000679668',
|
|
99
|
+
entityType: 'order',
|
|
100
|
+
referenceId: 'REF17735672330',
|
|
101
|
+
currency: 'INR',
|
|
102
|
+
vertical: 'customer',
|
|
103
|
+
charges: [
|
|
104
|
+
{
|
|
105
|
+
head: 'OTHER HANDLING CHARGES - ECOM (FOV & FSC)',
|
|
106
|
+
amount: 10050,
|
|
107
|
+
hsnOrSac: '998314',
|
|
108
|
+
isBillable: true,
|
|
109
|
+
absorbedBy: 'customer',
|
|
110
|
+
transactionType: 'credit',
|
|
111
|
+
breakup: [
|
|
112
|
+
{ head: 'CGST', amount: 5025, appliedOn: ['base_amount'], tags: ['tax', 'gst'] },
|
|
113
|
+
{ head: 'SGST', amount: 5025, appliedOn: ['base_amount'], tags: ['tax', 'gst'] },
|
|
114
|
+
],
|
|
115
|
+
metadata: [
|
|
116
|
+
{ key: 'tax_rate', value: '18%' },
|
|
117
|
+
{ key: 'calculation_method', value: 'percentage' },
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
});
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Generate an invoice and check status:
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
const gen = await this.invoice.generateInvoice(token, {
|
|
128
|
+
templateName: 'IF_Invoice',
|
|
129
|
+
productId: 'SMEINFUL',
|
|
130
|
+
startDate: '2025-11-01',
|
|
131
|
+
endDate: '2025-11-30',
|
|
132
|
+
buyer_customerId: 'SMEINFUL000000000679668',
|
|
133
|
+
seller_customerId: 'SMEINFUL000000000679668',
|
|
134
|
+
due_date: '2025-12-15',
|
|
135
|
+
invoice_no: 'PERFORMA-SF-8922-1',
|
|
136
|
+
invoice_date: '12-12-2025',
|
|
137
|
+
invoice_period: '01-November-2025 TO 30-November-2025',
|
|
138
|
+
}, 'https://your-callback.example');
|
|
139
|
+
|
|
140
|
+
const status = await this.invoice.getInvoiceStatus(token, gen.refId);
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Error handling
|
|
144
|
+
|
|
145
|
+
- All HTTP errors throw (Axios behavior). In your app, `try/catch` and inspect `err.response.status` and `err.response.data`.
|
|
146
|
+
- Some APIs return structured errors (e.g., transactions conflict, customer exists). The SDK types capture common success shapes; errors are surfaced as thrown responses so you can branch by status/message.
|
|
147
|
+
|
|
148
|
+
### Configuration notes
|
|
149
|
+
|
|
150
|
+
- `productId` and `productApiKey` are required; `baseUrl` is configurable (set to sandbox or prod).
|
|
151
|
+
- If you omit `baseUrl`, the SDK defaults to `https://sandbox.prospay.tech`.
|
|
152
|
+
- Timestamp and bcrypt hash for auth are handled internally; you only need to supply the product credentials.
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HttpService } from '@nestjs/axios';
|
|
2
|
+
import { ProspaySdkOptions } from '../sdk.config';
|
|
3
|
+
export declare class ProspayAuthService {
|
|
4
|
+
private readonly http;
|
|
5
|
+
private readonly options;
|
|
6
|
+
private readonly baseUrl;
|
|
7
|
+
constructor(http: HttpService, options: ProspaySdkOptions);
|
|
8
|
+
private generateKeyHash;
|
|
9
|
+
authenticate(): Promise<any>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
48
|
+
exports.ProspayAuthService = void 0;
|
|
49
|
+
const common_1 = require("@nestjs/common");
|
|
50
|
+
const axios_1 = require("@nestjs/axios");
|
|
51
|
+
const rxjs_1 = require("rxjs");
|
|
52
|
+
const bcrypt = __importStar(require("bcryptjs"));
|
|
53
|
+
const sdk_config_1 = require("../sdk.config");
|
|
54
|
+
let ProspayAuthService = class ProspayAuthService {
|
|
55
|
+
constructor(http, options) {
|
|
56
|
+
var _a;
|
|
57
|
+
this.http = http;
|
|
58
|
+
this.options = options;
|
|
59
|
+
this.baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : 'https://sandbox.prospay.tech';
|
|
60
|
+
}
|
|
61
|
+
async generateKeyHash(timestamp) {
|
|
62
|
+
const raw = `${timestamp}.${this.options.productId}.${this.options.productApiKey}`;
|
|
63
|
+
const saltRounds = 10;
|
|
64
|
+
return bcrypt.hash(raw, saltRounds);
|
|
65
|
+
}
|
|
66
|
+
async authenticate() {
|
|
67
|
+
const timestamp = Math.floor(new Date().getTime() / 1000);
|
|
68
|
+
const keyhash = await this.generateKeyHash(timestamp);
|
|
69
|
+
const url = `${this.baseUrl}/auth/api/v1.0/authenz/token`;
|
|
70
|
+
const response$ = this.http.post(url, null, {
|
|
71
|
+
params: { action: 'verify' },
|
|
72
|
+
headers: {
|
|
73
|
+
timestamp: String(timestamp),
|
|
74
|
+
resourceId: this.options.productId,
|
|
75
|
+
keyhash,
|
|
76
|
+
},
|
|
77
|
+
});
|
|
78
|
+
const response = await (0, rxjs_1.lastValueFrom)(response$);
|
|
79
|
+
return response.data;
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
exports.ProspayAuthService = ProspayAuthService;
|
|
83
|
+
exports.ProspayAuthService = ProspayAuthService = __decorate([
|
|
84
|
+
(0, common_1.Injectable)(),
|
|
85
|
+
__param(1, (0, common_1.Inject)(sdk_config_1.PROSPAY_SDK_OPTIONS)),
|
|
86
|
+
__metadata("design:paramtypes", [axios_1.HttpService, Object])
|
|
87
|
+
], ProspayAuthService);
|
|
88
|
+
//# sourceMappingURL=auth.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.service.js","sourceRoot":"","sources":["../../src/auth/auth.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,yCAA4C;AAC5C,+BAAqC;AACrC,iDAAmC;AACnC,8CAAuE;AAGhE,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAG7B,YACmB,IAAiB,EAEjB,OAA0B;;QAF1B,SAAI,GAAJ,IAAI,CAAa;QAEjB,YAAO,GAAP,OAAO,CAAmB;QAE3C,IAAI,CAAC,OAAO,GAAG,MAAA,OAAO,CAAC,OAAO,mCAAI,8BAA8B,CAAC;IACnE,CAAC;IAMO,KAAK,CAAC,eAAe,CAAC,SAAiB;QAC7C,MAAM,GAAG,GAAG,GAAG,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC;QAEnF,MAAM,UAAU,GAAG,EAAE,CAAC;QACtB,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACtC,CAAC;IAWD,KAAK,CAAC,YAAY;QAChB,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;QAC1D,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QAEtD,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,OAAO,8BAA8B,CAAC;QAE1D,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAC9B,GAAG,EACH,IAAI,EACJ;YACE,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE;YAC5B,OAAO,EAAE;gBACP,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC;gBAC5B,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS;gBAClC,OAAO;aACR;SACF,CACF,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAa,EAAC,SAAS,CAAC,CAAC;QAChD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF,CAAA;AArDY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,gCAAmB,CAAC,CAAA;qCADL,mBAAW;GAJzB,kBAAkB,CAqD9B"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { HttpService } from '@nestjs/axios';
|
|
2
|
+
export interface CreateCustomerDto {
|
|
3
|
+
productId: string;
|
|
4
|
+
productCustomerId: string;
|
|
5
|
+
orgName: string;
|
|
6
|
+
customerType: string;
|
|
7
|
+
contacts: {
|
|
8
|
+
email: string;
|
|
9
|
+
mobileNumber: string;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface UpdateCustomerDto {
|
|
13
|
+
productId?: string;
|
|
14
|
+
creditPeriodInDays?: string;
|
|
15
|
+
uin?: string;
|
|
16
|
+
preferences?: {
|
|
17
|
+
isMainOrg?: boolean;
|
|
18
|
+
mainOrgCustomerId?: string;
|
|
19
|
+
shareWallet?: boolean;
|
|
20
|
+
customerIdForWallet?: string;
|
|
21
|
+
shareKYC?: boolean;
|
|
22
|
+
customerIdForKYC?: string;
|
|
23
|
+
paymentType?: string;
|
|
24
|
+
};
|
|
25
|
+
isDeliveryAllowed?: boolean;
|
|
26
|
+
billingType?: string;
|
|
27
|
+
invoiceGenerationPeriod?: string;
|
|
28
|
+
CIN?: string;
|
|
29
|
+
status?: string;
|
|
30
|
+
creditlimit?: number;
|
|
31
|
+
contacts?: {
|
|
32
|
+
email?: string;
|
|
33
|
+
mobileNumber?: string;
|
|
34
|
+
};
|
|
35
|
+
industryType?: string;
|
|
36
|
+
KYC?: {
|
|
37
|
+
businessType?: string;
|
|
38
|
+
isGSTRegistered?: boolean;
|
|
39
|
+
GST?: string;
|
|
40
|
+
customerConsent?: boolean;
|
|
41
|
+
};
|
|
42
|
+
address?: {
|
|
43
|
+
line1?: string;
|
|
44
|
+
line2?: string;
|
|
45
|
+
city?: string;
|
|
46
|
+
state?: string;
|
|
47
|
+
pincode?: string;
|
|
48
|
+
stateCode?: string;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export interface UpdateCustomerStatusDto {
|
|
52
|
+
productId: string;
|
|
53
|
+
status: string;
|
|
54
|
+
}
|
|
55
|
+
export interface ProspayCreateCustomerResponse {
|
|
56
|
+
status: number;
|
|
57
|
+
message: string;
|
|
58
|
+
data: {
|
|
59
|
+
customerId: string;
|
|
60
|
+
customerData: any;
|
|
61
|
+
virtualAccountNo: string | null;
|
|
62
|
+
uin: string | null;
|
|
63
|
+
qrString: string | null;
|
|
64
|
+
isDeliveryAllowed: boolean;
|
|
65
|
+
creditPeriodInDays: string;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export interface ProspayErrorResponse {
|
|
69
|
+
message: string;
|
|
70
|
+
}
|
|
71
|
+
export interface ProspayUpdateCustomerResponse {
|
|
72
|
+
status: number;
|
|
73
|
+
message: string;
|
|
74
|
+
data: {
|
|
75
|
+
uin: string;
|
|
76
|
+
creditPeriodInDays: string;
|
|
77
|
+
customerId: string;
|
|
78
|
+
customerData: any;
|
|
79
|
+
kycData: any;
|
|
80
|
+
creditLimit: {
|
|
81
|
+
walletId: string;
|
|
82
|
+
oldCreditLimit: number;
|
|
83
|
+
newCreditLimit: number;
|
|
84
|
+
newAvailableBalance: number;
|
|
85
|
+
currency: string;
|
|
86
|
+
updatedAt: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export interface ProspayUpdateCustomerStatusResponse {
|
|
91
|
+
status: number;
|
|
92
|
+
message: string;
|
|
93
|
+
data: {
|
|
94
|
+
uin: string;
|
|
95
|
+
creditPeriodInDays: number;
|
|
96
|
+
customerId: string;
|
|
97
|
+
customerData: any;
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export interface ProspayGetCustomerByIdResponseItem {
|
|
101
|
+
onBoardedDate: string;
|
|
102
|
+
kycStatus: string | null;
|
|
103
|
+
virtualAccountNo: {
|
|
104
|
+
customer: any;
|
|
105
|
+
};
|
|
106
|
+
qrString: string | null;
|
|
107
|
+
creditPeriodInDays: number;
|
|
108
|
+
productId: string;
|
|
109
|
+
productCustomerId: string;
|
|
110
|
+
customerId: string;
|
|
111
|
+
isMainOrg: boolean;
|
|
112
|
+
mainOrgCustomerId: string | null;
|
|
113
|
+
businessType: string | null;
|
|
114
|
+
payment_type: string;
|
|
115
|
+
billingType: string;
|
|
116
|
+
productOrgId: string;
|
|
117
|
+
invoiceGenerationPeriod: string;
|
|
118
|
+
cin: string | null;
|
|
119
|
+
uin: string | null;
|
|
120
|
+
orgId: string;
|
|
121
|
+
tenantId: string;
|
|
122
|
+
isGstRegistered: boolean | null;
|
|
123
|
+
name: string;
|
|
124
|
+
industryType: string | null;
|
|
125
|
+
contact: {
|
|
126
|
+
email: string;
|
|
127
|
+
mobileNumber: string;
|
|
128
|
+
};
|
|
129
|
+
customerType: string[];
|
|
130
|
+
isDeliveryAllowed: boolean;
|
|
131
|
+
status: string;
|
|
132
|
+
productName: string;
|
|
133
|
+
orgName: string;
|
|
134
|
+
businessSegment: string;
|
|
135
|
+
bankDetails: {
|
|
136
|
+
bankName: string | null;
|
|
137
|
+
ifscCode: string | null;
|
|
138
|
+
accountNo: string | null;
|
|
139
|
+
accountHolderName: string | null;
|
|
140
|
+
account_type: string | null;
|
|
141
|
+
UPI_id: string | null;
|
|
142
|
+
bankBranch: string | null;
|
|
143
|
+
};
|
|
144
|
+
aadhar: string | null;
|
|
145
|
+
businessPAN: string | null;
|
|
146
|
+
signatoryPAN: string | null;
|
|
147
|
+
GST: string | null;
|
|
148
|
+
tan: string | null;
|
|
149
|
+
DL: string | null;
|
|
150
|
+
signatoryPanfromGST: string | null;
|
|
151
|
+
businessPanfromGST: string | null;
|
|
152
|
+
signatoryPanfromAadhar: string | null;
|
|
153
|
+
address: {
|
|
154
|
+
addressLine1: string | null;
|
|
155
|
+
addressLine2: string | null;
|
|
156
|
+
state: string | null;
|
|
157
|
+
pinCode: string | null;
|
|
158
|
+
city: string | null;
|
|
159
|
+
stateCode: string | null;
|
|
160
|
+
};
|
|
161
|
+
hoDetails: any;
|
|
162
|
+
kyc: any;
|
|
163
|
+
creditlimit: number;
|
|
164
|
+
creditbalance: number;
|
|
165
|
+
}
|
|
166
|
+
export interface ProspayGetCustomerByIdResponse {
|
|
167
|
+
status: number;
|
|
168
|
+
message: string;
|
|
169
|
+
data: ProspayGetCustomerByIdResponseItem[];
|
|
170
|
+
cached: boolean;
|
|
171
|
+
}
|
|
172
|
+
export interface SearchCustomersParams {
|
|
173
|
+
filter?: string;
|
|
174
|
+
mobileNumber?: string;
|
|
175
|
+
productCustomerId?: string;
|
|
176
|
+
customerType?: string;
|
|
177
|
+
}
|
|
178
|
+
export interface ProspaySearchCustomersResponse {
|
|
179
|
+
status: number;
|
|
180
|
+
message: string;
|
|
181
|
+
data: any;
|
|
182
|
+
}
|
|
183
|
+
export declare class ProspayCustomerService {
|
|
184
|
+
private readonly http;
|
|
185
|
+
constructor(http: HttpService);
|
|
186
|
+
createCustomer(authToken: string, payload: CreateCustomerDto): Promise<ProspayCreateCustomerResponse>;
|
|
187
|
+
updateCustomer(authToken: string, customerId: string, payload: UpdateCustomerDto): Promise<ProspayUpdateCustomerResponse>;
|
|
188
|
+
updateCustomerStatus(authToken: string, customerId: string, payload: UpdateCustomerStatusDto): Promise<ProspayUpdateCustomerStatusResponse>;
|
|
189
|
+
getCustomerById(authToken: string, customerId: string): Promise<ProspayGetCustomerByIdResponse>;
|
|
190
|
+
searchCustomers(authToken: string, params: SearchCustomersParams): Promise<ProspaySearchCustomersResponse>;
|
|
191
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
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.ProspayCustomerService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const axios_1 = require("@nestjs/axios");
|
|
15
|
+
const rxjs_1 = require("rxjs");
|
|
16
|
+
let ProspayCustomerService = class ProspayCustomerService {
|
|
17
|
+
constructor(http) {
|
|
18
|
+
this.http = http;
|
|
19
|
+
}
|
|
20
|
+
async createCustomer(authToken, payload) {
|
|
21
|
+
const response$ = this.http.post('/customer/api/v3.0/customers', 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 updateCustomer(authToken, customerId, payload) {
|
|
31
|
+
const response$ = this.http.patch(`/customer/api/v3.0/customers/${customerId}/`, 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 updateCustomerStatus(authToken, customerId, payload) {
|
|
41
|
+
const response$ = this.http.patch(`/customer/api/v3.0/customers/${customerId}/`, 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 getCustomerById(authToken, customerId) {
|
|
51
|
+
const response$ = this.http.get(`/customer/api/v3.0/customers/${customerId}`, {
|
|
52
|
+
params: { filter: 'all' },
|
|
53
|
+
headers: {
|
|
54
|
+
Authorization: authToken,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const response = await (0, rxjs_1.lastValueFrom)(response$);
|
|
58
|
+
return response.data;
|
|
59
|
+
}
|
|
60
|
+
async searchCustomers(authToken, params) {
|
|
61
|
+
const response$ = this.http.get('/customer/api/v3.0/customers/search', {
|
|
62
|
+
params,
|
|
63
|
+
headers: {
|
|
64
|
+
Authorization: authToken,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const response = await (0, rxjs_1.lastValueFrom)(response$);
|
|
68
|
+
return response.data;
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
exports.ProspayCustomerService = ProspayCustomerService;
|
|
72
|
+
exports.ProspayCustomerService = ProspayCustomerService = __decorate([
|
|
73
|
+
(0, common_1.Injectable)(),
|
|
74
|
+
__metadata("design:paramtypes", [axios_1.HttpService])
|
|
75
|
+
], ProspayCustomerService);
|
|
76
|
+
//# sourceMappingURL=customer.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customer.service.js","sourceRoot":"","sources":["../../src/customer/customer.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,yCAA4C;AAC5C,+BAAqC;AAmM9B,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IACjC,YAA6B,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;IAAG,CAAC;IAOlD,KAAK,CAAC,cAAc,CAClB,SAAiB,EACjB,OAA0B;QAE1B,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,cAAc,CAClB,SAAiB,EACjB,UAAkB,EAClB,OAA0B;QAE1B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAC/B,gCAAgC,UAAU,GAAG,EAC7C,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;IASD,KAAK,CAAC,oBAAoB,CACxB,SAAiB,EACjB,UAAkB,EAClB,OAAgC;QAEhC,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAC/B,gCAAgC,UAAU,GAAG,EAC7C,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,eAAe,CACnB,SAAiB,EACjB,UAAkB;QAElB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAC7B,gCAAgC,UAAU,EAAE,EAC5C;YACE,MAAM,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE;YACzB,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;IAQD,KAAK,CAAC,eAAe,CACnB,SAAiB,EACjB,MAA6B;QAE7B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAC7B,qCAAqC,EACrC;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;AA7HY,wDAAsB;iCAAtB,sBAAsB;IADlC,IAAA,mBAAU,GAAE;qCAEwB,mBAAW;GADnC,sBAAsB,CA6HlC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import 'reflect-metadata';
|
|
2
|
+
import { DynamicModule } from '@nestjs/common';
|
|
3
|
+
import { ProspaySdkOptions } from './sdk.config';
|
|
4
|
+
export declare class ProspaySdkModule {
|
|
5
|
+
static register(options: ProspaySdkOptions): DynamicModule;
|
|
6
|
+
}
|
|
7
|
+
export * from '@nestjs/common';
|
|
8
|
+
export * from './auth/auth.service';
|
|
9
|
+
export * from './customer/customer.service';
|
|
10
|
+
export * from './transaction/transaction.service';
|
|
11
|
+
export * from './invoice/invoice.service';
|
|
12
|
+
export * from './sdk.config';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
14
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
+
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;
|
|
17
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
+
};
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
var ProspaySdkModule_1;
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.ProspaySdkModule = void 0;
|
|
25
|
+
require("reflect-metadata");
|
|
26
|
+
const common_1 = require("@nestjs/common");
|
|
27
|
+
const axios_1 = require("@nestjs/axios");
|
|
28
|
+
const auth_service_1 = require("./auth/auth.service");
|
|
29
|
+
const customer_service_1 = require("./customer/customer.service");
|
|
30
|
+
const transaction_service_1 = require("./transaction/transaction.service");
|
|
31
|
+
const invoice_service_1 = require("./invoice/invoice.service");
|
|
32
|
+
const sdk_config_1 = require("./sdk.config");
|
|
33
|
+
let ProspaySdkModule = ProspaySdkModule_1 = class ProspaySdkModule {
|
|
34
|
+
static register(options) {
|
|
35
|
+
var _a;
|
|
36
|
+
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : 'https://sandbox.prospay.tech';
|
|
37
|
+
return {
|
|
38
|
+
module: ProspaySdkModule_1,
|
|
39
|
+
imports: [
|
|
40
|
+
axios_1.HttpModule.register({
|
|
41
|
+
baseURL: baseUrl,
|
|
42
|
+
timeout: 5000,
|
|
43
|
+
}),
|
|
44
|
+
],
|
|
45
|
+
providers: [
|
|
46
|
+
{
|
|
47
|
+
provide: sdk_config_1.PROSPAY_SDK_OPTIONS,
|
|
48
|
+
useValue: options,
|
|
49
|
+
},
|
|
50
|
+
auth_service_1.ProspayAuthService,
|
|
51
|
+
customer_service_1.ProspayCustomerService,
|
|
52
|
+
transaction_service_1.ProspayTransactionService,
|
|
53
|
+
invoice_service_1.ProspayInvoiceService,
|
|
54
|
+
],
|
|
55
|
+
exports: [auth_service_1.ProspayAuthService, customer_service_1.ProspayCustomerService, transaction_service_1.ProspayTransactionService, invoice_service_1.ProspayInvoiceService],
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.ProspaySdkModule = ProspaySdkModule;
|
|
60
|
+
exports.ProspaySdkModule = ProspaySdkModule = ProspaySdkModule_1 = __decorate([
|
|
61
|
+
(0, common_1.Module)({})
|
|
62
|
+
], ProspaySdkModule);
|
|
63
|
+
__exportStar(require("@nestjs/common"), exports);
|
|
64
|
+
__exportStar(require("./auth/auth.service"), exports);
|
|
65
|
+
__exportStar(require("./customer/customer.service"), exports);
|
|
66
|
+
__exportStar(require("./transaction/transaction.service"), exports);
|
|
67
|
+
__exportStar(require("./invoice/invoice.service"), exports);
|
|
68
|
+
__exportStar(require("./sdk.config"), exports);
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,4BAA0B;AAC1B,2CAAuD;AACvD,yCAA2C;AAC3C,sDAAyD;AACzD,kEAAqE;AACrE,2EAA8E;AAC9E,+DAAkE;AAClE,6CAAsE;AAG/D,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,MAAM,CAAC,QAAQ,CAAC,OAA0B;;QACxC,MAAM,OAAO,GAAG,MAAA,OAAO,CAAC,OAAO,mCAAI,8BAA8B,CAAC;QAElE,OAAO;YACL,MAAM,EAAE,kBAAgB;YACxB,OAAO,EAAE;gBACP,kBAAU,CAAC,QAAQ,CAAC;oBAClB,OAAO,EAAE,OAAO;oBAChB,OAAO,EAAE,IAAI;iBACd,CAAC;aACH;YACD,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,gCAAmB;oBAC5B,QAAQ,EAAE,OAAO;iBAClB;gBACD,iCAAkB;gBAClB,yCAAsB;gBACtB,+CAAyB;gBACzB,uCAAqB;aACtB;YACD,OAAO,EAAE,CAAC,iCAAkB,EAAE,yCAAsB,EAAE,+CAAyB,EAAE,uCAAqB,CAAC;SACxG,CAAC;IACJ,CAAC;CACF,CAAA;AAzBY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,gBAAgB,CAyB5B;AAED,iDAA+B;AAC/B,sDAAoC;AACpC,8DAA4C;AAC5C,oEAAkD;AAClD,4DAA0C;AAC1C,+CAA6B"}
|