prospay-sdk 1.0.0 → 1.1.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/dist/index.d.ts +1 -0
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/payment/payment.service.d.ts +76 -0
- package/dist/payment/payment.service.js +66 -0
- package/dist/payment/payment.service.js.map +1 -0
- package/dist/transaction/transaction.service.d.ts +0 -1
- package/manual.txt +26 -0
- package/package.json +1 -1
- package/src/index.ts +4 -2
- package/src/payment/payment.service.ts +151 -0
- package/src/transaction/transaction.service.ts +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -29,6 +29,7 @@ const auth_service_1 = require("./auth/auth.service");
|
|
|
29
29
|
const customer_service_1 = require("./customer/customer.service");
|
|
30
30
|
const transaction_service_1 = require("./transaction/transaction.service");
|
|
31
31
|
const invoice_service_1 = require("./invoice/invoice.service");
|
|
32
|
+
const payment_service_1 = require("./payment/payment.service");
|
|
32
33
|
const sdk_config_1 = require("./sdk.config");
|
|
33
34
|
let ProspaySdkModule = ProspaySdkModule_1 = class ProspaySdkModule {
|
|
34
35
|
static register(options) {
|
|
@@ -51,8 +52,9 @@ let ProspaySdkModule = ProspaySdkModule_1 = class ProspaySdkModule {
|
|
|
51
52
|
customer_service_1.ProspayCustomerService,
|
|
52
53
|
transaction_service_1.ProspayTransactionService,
|
|
53
54
|
invoice_service_1.ProspayInvoiceService,
|
|
55
|
+
payment_service_1.ProspayPaymentService,
|
|
54
56
|
],
|
|
55
|
-
exports: [auth_service_1.ProspayAuthService, customer_service_1.ProspayCustomerService, transaction_service_1.ProspayTransactionService, invoice_service_1.ProspayInvoiceService],
|
|
57
|
+
exports: [auth_service_1.ProspayAuthService, customer_service_1.ProspayCustomerService, transaction_service_1.ProspayTransactionService, invoice_service_1.ProspayInvoiceService, payment_service_1.ProspayPaymentService],
|
|
56
58
|
};
|
|
57
59
|
}
|
|
58
60
|
};
|
|
@@ -65,5 +67,6 @@ __exportStar(require("./auth/auth.service"), exports);
|
|
|
65
67
|
__exportStar(require("./customer/customer.service"), exports);
|
|
66
68
|
__exportStar(require("./transaction/transaction.service"), exports);
|
|
67
69
|
__exportStar(require("./invoice/invoice.service"), exports);
|
|
70
|
+
__exportStar(require("./payment/payment.service"), exports);
|
|
68
71
|
__exportStar(require("./sdk.config"), exports);
|
|
69
72
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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;
|
|
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,+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;gBACrB,uCAAqB;aACtB;YACD,OAAO,EAAE,CAAC,iCAAkB,EAAE,yCAAsB,EAAE,+CAAyB,EAAE,uCAAqB,EAAE,uCAAqB,CAAC;SAC/H,CAAC;IACJ,CAAC;CACF,CAAA;AA1BY,4CAAgB;2BAAhB,gBAAgB;IAD5B,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,gBAAgB,CA0B5B;AAED,iDAA+B;AAC/B,sDAAoC;AACpC,8DAA4C;AAC5C,oEAAkD;AAClD,4DAA0C;AAC1C,4DAA0C;AAC1C,+CAA6B"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { HttpService } from '@nestjs/axios';
|
|
2
|
+
export interface GenerateQrDto {
|
|
3
|
+
customerId: string;
|
|
4
|
+
amountInPaise: number;
|
|
5
|
+
productId: string;
|
|
6
|
+
productOrderId: string;
|
|
7
|
+
callbackUrl: string;
|
|
8
|
+
reason?: string;
|
|
9
|
+
contacts?: {
|
|
10
|
+
name?: string;
|
|
11
|
+
email?: string;
|
|
12
|
+
mobileNumber?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface OrderInformation {
|
|
16
|
+
itemName: string;
|
|
17
|
+
price: number;
|
|
18
|
+
quantity: number;
|
|
19
|
+
}
|
|
20
|
+
export interface GeneratePaymentLinkDto {
|
|
21
|
+
customerId: string;
|
|
22
|
+
amountInPaise: number;
|
|
23
|
+
productId: string;
|
|
24
|
+
productOrderId: string;
|
|
25
|
+
callbackUrl: string;
|
|
26
|
+
reason?: string;
|
|
27
|
+
contacts?: {
|
|
28
|
+
name?: string;
|
|
29
|
+
email?: string;
|
|
30
|
+
mobileNumber?: string;
|
|
31
|
+
};
|
|
32
|
+
orderInformation?: OrderInformation;
|
|
33
|
+
}
|
|
34
|
+
export interface ProspayPaymentResponse {
|
|
35
|
+
status: number;
|
|
36
|
+
message: string;
|
|
37
|
+
data?: any;
|
|
38
|
+
}
|
|
39
|
+
export interface ProspayGenerateQrResponse {
|
|
40
|
+
success: boolean;
|
|
41
|
+
orderId: string;
|
|
42
|
+
txnId: string;
|
|
43
|
+
qrCode: string;
|
|
44
|
+
providerName: string;
|
|
45
|
+
}
|
|
46
|
+
export interface ProspayGetPaymentStatusData {
|
|
47
|
+
paymentTxnId: string;
|
|
48
|
+
productOrderId: string;
|
|
49
|
+
paymemtOrderId: string;
|
|
50
|
+
payment_status: string;
|
|
51
|
+
paymentTxnType: string;
|
|
52
|
+
paymentAmount: number;
|
|
53
|
+
paymentDate: string;
|
|
54
|
+
}
|
|
55
|
+
export interface ProspayGetPaymentStatusResponse {
|
|
56
|
+
status: number;
|
|
57
|
+
message: string;
|
|
58
|
+
data: ProspayGetPaymentStatusData;
|
|
59
|
+
}
|
|
60
|
+
export interface RefundPaymentDto {
|
|
61
|
+
productId: string;
|
|
62
|
+
customerId: string;
|
|
63
|
+
originalProductOrderId: string;
|
|
64
|
+
productRefundId: string;
|
|
65
|
+
amountWithGSTInPaise: number;
|
|
66
|
+
amountWithoutGSTInPaise: number;
|
|
67
|
+
reason?: string;
|
|
68
|
+
}
|
|
69
|
+
export declare class ProspayPaymentService {
|
|
70
|
+
private readonly http;
|
|
71
|
+
constructor(http: HttpService);
|
|
72
|
+
generateQr(authToken: string, payload: GenerateQrDto): Promise<ProspayGenerateQrResponse>;
|
|
73
|
+
generatePaymentLink(authToken: string, payload: GeneratePaymentLinkDto): Promise<ProspayPaymentResponse>;
|
|
74
|
+
refundPayment(authToken: string, productOrderId: string, payload: RefundPaymentDto): Promise<ProspayPaymentResponse>;
|
|
75
|
+
getPaymentStatus(authToken: string, productOrderId: string): Promise<ProspayGetPaymentStatusResponse>;
|
|
76
|
+
}
|
|
@@ -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.ProspayPaymentService = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const axios_1 = require("@nestjs/axios");
|
|
15
|
+
const rxjs_1 = require("rxjs");
|
|
16
|
+
let ProspayPaymentService = class ProspayPaymentService {
|
|
17
|
+
constructor(http) {
|
|
18
|
+
this.http = http;
|
|
19
|
+
}
|
|
20
|
+
async generateQr(authToken, payload) {
|
|
21
|
+
const response$ = this.http.post('/payments/api/v2.0/QR', 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 generatePaymentLink(authToken, payload) {
|
|
31
|
+
const response$ = this.http.post('/payments/api/v2.0/paymentLink', 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 refundPayment(authToken, productOrderId, payload) {
|
|
41
|
+
const response$ = this.http.post(`/payments/api/v2.0/payment/${productOrderId}/refund`, 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 getPaymentStatus(authToken, productOrderId) {
|
|
51
|
+
const response$ = this.http.get(`/payments/api/v2.0/payment/${productOrderId}/status`, {
|
|
52
|
+
headers: {
|
|
53
|
+
Authorization: authToken,
|
|
54
|
+
'Content-Type': 'application/json',
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
const response = await (0, rxjs_1.lastValueFrom)(response$);
|
|
58
|
+
return response.data;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
exports.ProspayPaymentService = ProspayPaymentService;
|
|
62
|
+
exports.ProspayPaymentService = ProspayPaymentService = __decorate([
|
|
63
|
+
(0, common_1.Injectable)(),
|
|
64
|
+
__metadata("design:paramtypes", [axios_1.HttpService])
|
|
65
|
+
], ProspayPaymentService);
|
|
66
|
+
//# sourceMappingURL=payment.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.service.js","sourceRoot":"","sources":["../../src/payment/payment.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAC5C,yCAA4C;AAC5C,+BAAqC;AA8E9B,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAChC,YAA6B,IAAiB;QAAjB,SAAI,GAAJ,IAAI,CAAa;IAAG,CAAC;IAElD,KAAK,CAAC,UAAU,CACd,SAAiB,EACjB,OAAsB;QAEtB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,uBAAuB,EAAE,OAAO,EAAE;YACjE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS;gBACxB,cAAc,EAAE,kBAAkB;aACnC;SACF,CAAC,CAAC;QACH,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAa,EAAC,SAAS,CAAC,CAAC;QAChD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,mBAAmB,CACvB,SAAiB,EACjB,OAA+B;QAE/B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAC9B,gCAAgC,EAChC,OAAO,EACP;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS;gBACxB,cAAc,EAAE,kBAAkB;aACnC;SACF,CACF,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAa,EAAC,SAAS,CAAC,CAAC;QAChD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,aAAa,CACjB,SAAiB,EACjB,cAAsB,EACtB,OAAyB;QAEzB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAC9B,8BAA8B,cAAc,SAAS,EACrD,OAAO,EACP;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS;gBACxB,cAAc,EAAE,kBAAkB;aACnC;SACF,CACF,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAa,EAAC,SAAS,CAAC,CAAC;QAChD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,SAAiB,EACjB,cAAsB;QAEtB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAC7B,8BAA8B,cAAc,SAAS,EACrD;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,SAAS;gBACxB,cAAc,EAAE,kBAAkB;aACnC;SACF,CACF,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,IAAA,oBAAa,EAAC,SAAS,CAAC,CAAC;QAChD,OAAO,QAAQ,CAAC,IAAI,CAAC;IACvB,CAAC;CACF,CAAA;AAtEY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAEwB,mBAAW;GADnC,qBAAqB,CAsEjC"}
|
package/manual.txt
CHANGED
|
@@ -7,15 +7,19 @@ ProspayCustomerService
|
|
|
7
7
|
- createCustomer(authToken, payload): POST /customer/api/v3.0/customers
|
|
8
8
|
Inputs (body): productId, productCustomerId, orgName, customerType, contacts { email, mobileNumber }.
|
|
9
9
|
Success: `{ status, message, data: { customerId, customerData, virtualAccountNo, uin, qrString, isDeliveryAllowed, creditPeriodInDays } }`.
|
|
10
|
+
|
|
10
11
|
- updateCustomer(authToken, customerId, payload): PATCH /customer/api/v3.0/customers/{customerId}/
|
|
11
12
|
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
13
|
Success: `{ status, message, data: { uin, creditPeriodInDays, customerId, customerData, kycData, creditLimit: { walletId, oldCreditLimit, newCreditLimit, newAvailableBalance, currency, updatedAt } } }`.
|
|
14
|
+
|
|
13
15
|
- updateCustomerStatus(authToken, customerId, payload): PATCH /customer/api/v3.0/customers/{customerId}/
|
|
14
16
|
Inputs (body): productId, status.
|
|
15
17
|
Success: `{ status, message, data: { uin, creditPeriodInDays, customerId, customerData } }`.
|
|
18
|
+
|
|
16
19
|
- getCustomerById(authToken, customerId): GET /customer/api/v3.0/customers/{customerId}?filter=all
|
|
17
20
|
Inputs: headers => Authorization; query => filter=all.
|
|
18
21
|
Success: `{ status, message, data: [customerProfile...], cached }` (profiles include contact, KYC, credit, bank, address, flags).
|
|
22
|
+
|
|
19
23
|
- searchCustomers(authToken, params): GET /customer/api/v3.0/customers/search
|
|
20
24
|
Inputs (query): filter?, mobileNumber?, productCustomerId?, customerType?; headers => Authorization.
|
|
21
25
|
Success: `{ status, message, data }` (structure depends on search result).
|
|
@@ -24,9 +28,11 @@ ProspayInvoiceService
|
|
|
24
28
|
- generateBulkInvoice(authToken, payload, callbackUrl?): POST /invoices/api/v2.0/generateBulkInvoice
|
|
25
29
|
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
30
|
Success: `{ status: "ok", message: "Process initiated for generating invoice", refId }`.
|
|
31
|
+
|
|
27
32
|
- generateInvoice(authToken, payload, callbackUrl?): POST /invoices/api/v2.0/generateInvoice
|
|
28
33
|
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
34
|
Success: `{ status: "ok", message: "Process initiated for generating invoice", refId }`.
|
|
35
|
+
|
|
30
36
|
- getInvoiceStatus(authToken, refId): GET /invoices/api/v2.0/invoice-status/{refId}
|
|
31
37
|
Inputs: path => refId; headers => Authorization, Content-Type.
|
|
32
38
|
Success: `{ refId, overallStatus, templateName, productId, statistics: { total, success, failed, processing }, invoices: [{ invoiceId, status, createdAt, customerId, pdfUrl?, completedAt?, error?, errorDetails? }] }`.
|
|
@@ -35,13 +41,33 @@ ProspayTransactionService
|
|
|
35
41
|
- createTransaction(authToken, payload): POST /uts/api/transactions
|
|
36
42
|
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
43
|
Success: `{ success: true, requestId, path, timestamp, data: { transactionId, summary: { transactionAmount, billableAmount, totalCreditAmount, totalDebitAmount } } }`.
|
|
44
|
+
|
|
38
45
|
- addChargesToTransaction(authToken, transactionId, payload): POST /uts/api/transactions/{transactionId}/charges
|
|
39
46
|
Inputs (body): charges: [{ head, amount, hsnOrSac, isBillable, absorbedBy, transactionType, chargedAt?, appliedOn?, tags?, breakup?, metadata? }]; path => transactionId.
|
|
40
47
|
Success: `{ success: true, requestId, path, timestamp, data: { transactionId, addedChargesSummary: { transactionAmount, billableAmount, totalCreditAmount, totalDebitAmount }, transactionSummary: { transactionAmount, billableAmount, totalCreditAmount, totalDebitAmount } } }`.
|
|
48
|
+
|
|
41
49
|
- searchTransactions(authToken, payload): POST /uts/api/transactions/search
|
|
42
50
|
Inputs (body): page, limit, transactionFilters { customerIds?, transactionDateRange? { start, end } }.
|
|
43
51
|
Success: `{ success: true, requestId, path, timestamp, data: { items: [...], pagination: { total, page, limit, totalPages } } }`.
|
|
52
|
+
|
|
44
53
|
- getChargeSummary(authToken, params): GET /uts/api/transactions/charge-summary/
|
|
45
54
|
Inputs (query): startDate (YYYY-MM-DD), endDate (YYYY-MM-DD); headers => Authorization.
|
|
46
55
|
Success: `{ success: true, requestId, path, timestamp, data: [{ chargeHead, hsnOrSac, vertical, taxableAmount, cgstRate, cgst, sgstRate, sgst, igstRate, igst, totalTaxRate, totalTax, netAmount }, ...] }`.
|
|
47
56
|
|
|
57
|
+
ProspayPaymentService
|
|
58
|
+
- generateQr(authToken, payload): POST /payments/api/v2.0/QR
|
|
59
|
+
Inputs (body): customerId, amountInPaise, productId, productOrderId, callbackUrl, reason?, contacts { name?, email?, mobileNumber? }.
|
|
60
|
+
Success: `{ success, orderId, txnId, qrCode, providerName }`.
|
|
61
|
+
|
|
62
|
+
- generatePaymentLink(authToken, payload): POST /payments/api/v2.0/paymentLink
|
|
63
|
+
Inputs (body): customerId, amountInPaise, productId, productOrderId, callbackUrl, reason?, contacts { name?, email?, mobileNumber? }, orderInformation? { itemName, price, quantity }.
|
|
64
|
+
Success: `{ status, message, data }` (data may include payment link metadata).
|
|
65
|
+
|
|
66
|
+
- refundPayment(authToken, productOrderId, payload): POST /payments/api/v2.0/payment/{productOrderId}/refund
|
|
67
|
+
Inputs (path): productOrderId; body: productId, customerId, originalProductOrderId, productRefundId, amountWithGSTInPaise, amountWithoutGSTInPaise, reason?.
|
|
68
|
+
Success: `{ status, message, data }`.
|
|
69
|
+
|
|
70
|
+
- getPaymentStatus(authToken, productOrderId): GET /payments/api/v2.0/payment/{productOrderId}/status
|
|
71
|
+
Inputs: path => productOrderId; headers => Authorization.
|
|
72
|
+
Success: `{ status, message, data: { paymentTxnId, productOrderId, paymemtOrderId, payment_status, paymentTxnType, paymentAmount, paymentDate } }`.
|
|
73
|
+
Errors: e.g. `{ message: "orderId not found" }`.
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { ProspayAuthService } from './auth/auth.service';
|
|
|
5
5
|
import { ProspayCustomerService } from './customer/customer.service';
|
|
6
6
|
import { ProspayTransactionService } from './transaction/transaction.service';
|
|
7
7
|
import { ProspayInvoiceService } from './invoice/invoice.service';
|
|
8
|
+
import { ProspayPaymentService } from './payment/payment.service';
|
|
8
9
|
import { PROSPAY_SDK_OPTIONS, ProspaySdkOptions } from './sdk.config';
|
|
9
10
|
|
|
10
11
|
@Module({})
|
|
@@ -29,8 +30,9 @@ export class ProspaySdkModule {
|
|
|
29
30
|
ProspayCustomerService,
|
|
30
31
|
ProspayTransactionService,
|
|
31
32
|
ProspayInvoiceService,
|
|
33
|
+
ProspayPaymentService,
|
|
32
34
|
],
|
|
33
|
-
exports: [ProspayAuthService, ProspayCustomerService, ProspayTransactionService, ProspayInvoiceService],
|
|
35
|
+
exports: [ProspayAuthService, ProspayCustomerService, ProspayTransactionService, ProspayInvoiceService, ProspayPaymentService],
|
|
34
36
|
};
|
|
35
37
|
}
|
|
36
38
|
}
|
|
@@ -40,5 +42,5 @@ export * from './auth/auth.service';
|
|
|
40
42
|
export * from './customer/customer.service';
|
|
41
43
|
export * from './transaction/transaction.service';
|
|
42
44
|
export * from './invoice/invoice.service';
|
|
45
|
+
export * from './payment/payment.service';
|
|
43
46
|
export * from './sdk.config';
|
|
44
|
-
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { Injectable } from '@nestjs/common';
|
|
2
|
+
import { HttpService } from '@nestjs/axios';
|
|
3
|
+
import { lastValueFrom } from 'rxjs';
|
|
4
|
+
|
|
5
|
+
export interface GenerateQrDto {
|
|
6
|
+
customerId: string;
|
|
7
|
+
amountInPaise: number;
|
|
8
|
+
productId: string;
|
|
9
|
+
productOrderId: string;
|
|
10
|
+
callbackUrl: string;
|
|
11
|
+
reason?: string;
|
|
12
|
+
contacts?: {
|
|
13
|
+
name?: string;
|
|
14
|
+
email?: string;
|
|
15
|
+
mobileNumber?: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface OrderInformation {
|
|
20
|
+
itemName: string;
|
|
21
|
+
price: number;
|
|
22
|
+
quantity: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface GeneratePaymentLinkDto {
|
|
26
|
+
customerId: string;
|
|
27
|
+
amountInPaise: number;
|
|
28
|
+
productId: string;
|
|
29
|
+
productOrderId: string;
|
|
30
|
+
callbackUrl: string;
|
|
31
|
+
reason?: string;
|
|
32
|
+
contacts?: {
|
|
33
|
+
name?: string;
|
|
34
|
+
email?: string;
|
|
35
|
+
mobileNumber?: string;
|
|
36
|
+
};
|
|
37
|
+
orderInformation?: OrderInformation;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface ProspayPaymentResponse {
|
|
41
|
+
status: number;
|
|
42
|
+
message: string;
|
|
43
|
+
data?: any;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ProspayGenerateQrResponse {
|
|
47
|
+
success: boolean;
|
|
48
|
+
orderId: string;
|
|
49
|
+
txnId: string;
|
|
50
|
+
qrCode: string;
|
|
51
|
+
providerName: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface ProspayGetPaymentStatusData {
|
|
55
|
+
paymentTxnId: string;
|
|
56
|
+
productOrderId: string;
|
|
57
|
+
paymemtOrderId: string;
|
|
58
|
+
payment_status: string;
|
|
59
|
+
paymentTxnType: string;
|
|
60
|
+
paymentAmount: number;
|
|
61
|
+
paymentDate: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface ProspayGetPaymentStatusResponse {
|
|
65
|
+
status: number;
|
|
66
|
+
message: string;
|
|
67
|
+
data: ProspayGetPaymentStatusData;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface RefundPaymentDto {
|
|
71
|
+
productId: string;
|
|
72
|
+
customerId: string;
|
|
73
|
+
originalProductOrderId: string;
|
|
74
|
+
productRefundId: string;
|
|
75
|
+
amountWithGSTInPaise: number;
|
|
76
|
+
amountWithoutGSTInPaise: number;
|
|
77
|
+
reason?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@Injectable()
|
|
81
|
+
export class ProspayPaymentService {
|
|
82
|
+
constructor(private readonly http: HttpService) {}
|
|
83
|
+
|
|
84
|
+
async generateQr(
|
|
85
|
+
authToken: string,
|
|
86
|
+
payload: GenerateQrDto,
|
|
87
|
+
): Promise<ProspayGenerateQrResponse> {
|
|
88
|
+
const response$ = this.http.post('/payments/api/v2.0/QR', payload, {
|
|
89
|
+
headers: {
|
|
90
|
+
Authorization: authToken,
|
|
91
|
+
'Content-Type': 'application/json',
|
|
92
|
+
},
|
|
93
|
+
});
|
|
94
|
+
const response = await lastValueFrom(response$);
|
|
95
|
+
return response.data;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async generatePaymentLink(
|
|
99
|
+
authToken: string,
|
|
100
|
+
payload: GeneratePaymentLinkDto,
|
|
101
|
+
): Promise<ProspayPaymentResponse> {
|
|
102
|
+
const response$ = this.http.post(
|
|
103
|
+
'/payments/api/v2.0/paymentLink',
|
|
104
|
+
payload,
|
|
105
|
+
{
|
|
106
|
+
headers: {
|
|
107
|
+
Authorization: authToken,
|
|
108
|
+
'Content-Type': 'application/json',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
);
|
|
112
|
+
const response = await lastValueFrom(response$);
|
|
113
|
+
return response.data;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async refundPayment(
|
|
117
|
+
authToken: string,
|
|
118
|
+
productOrderId: string,
|
|
119
|
+
payload: RefundPaymentDto,
|
|
120
|
+
): Promise<ProspayPaymentResponse> {
|
|
121
|
+
const response$ = this.http.post(
|
|
122
|
+
`/payments/api/v2.0/payment/${productOrderId}/refund`,
|
|
123
|
+
payload,
|
|
124
|
+
{
|
|
125
|
+
headers: {
|
|
126
|
+
Authorization: authToken,
|
|
127
|
+
'Content-Type': 'application/json',
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
);
|
|
131
|
+
const response = await lastValueFrom(response$);
|
|
132
|
+
return response.data;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async getPaymentStatus(
|
|
136
|
+
authToken: string,
|
|
137
|
+
productOrderId: string,
|
|
138
|
+
): Promise<ProspayGetPaymentStatusResponse> {
|
|
139
|
+
const response$ = this.http.get(
|
|
140
|
+
`/payments/api/v2.0/payment/${productOrderId}/status`,
|
|
141
|
+
{
|
|
142
|
+
headers: {
|
|
143
|
+
Authorization: authToken,
|
|
144
|
+
'Content-Type': 'application/json',
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
);
|
|
148
|
+
const response = await lastValueFrom(response$);
|
|
149
|
+
return response.data;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -35,7 +35,7 @@ export interface CreateTransactionDto {
|
|
|
35
35
|
entityType: string; // e.g. "order"
|
|
36
36
|
referenceId: string;
|
|
37
37
|
currency: string; // e.g. "INR"
|
|
38
|
-
vertical: string; // e.g. "customer"
|
|
38
|
+
// vertical: string; // e.g. "customer"
|
|
39
39
|
charges: TransactionCharge[];
|
|
40
40
|
}
|
|
41
41
|
|