@prospay/prospay-sdk
v1.1.14
Published
NestJS-based SDK for Prospay customer onboarding, order, and invoicing APIs.
Downloads
31
Keywords
Readme
Prospay NestJS SDK
This package is a NestJS-based SDK for integrating with Prospay services, including:
- Customer onboarding
- Order transactions
- Invoice generation
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.
Prerequisites
- Node.js: v18 or later (recommended)
- Package manager:
npm(comes with Node), oryarn/pnpm - NestJS: Your project should be a NestJS application (v11 recommended to match this SDK).
Installation
Once this SDK is published to your private registry or npm, install it in your Nest app:
npm install prospay-sdkQuick start
Register the SDK module in your root AppModule (or any feature module):
import { Module } from '@nestjs/common';
import { ProspaySdkModule } from 'prospay-sdk';
@Module({
imports: [
ProspaySdkModule.register({
productId: 'YOUR_PRODUCT_ID',
productApiKey: 'YOUR_PRODUCT_API_KEY',
baseUrl: 'https://sandbox.prospay.tech', // or your prod URL, e.g. https://prospay.tech
}),
],
})
export class AppModule {}Available services and methods
All services are registered in the module and can be injected anywhere in your Nest app.
Service manual
Below is a concise map of each service, its methods, and the underlying Prospay endpoints.
Auth (ProspayAuthService)
authenticate()→POST /auth/api/v1.0/authenz/token?action=verify
Headers auto-built:timestamp,resourceId(productId),keyhash(bcrypt oftimestamp.productId.productApiKey). Returns auth payload (use its token inAuthorizationfor other calls).
Customers (ProspayCustomerService)
createCustomer(authToken, payload)→POST /customer/api/v3.0/customersupdateCustomer(authToken, customerId, payload)→PATCH /customer/api/v3.0/customers/{customerId}/updateCustomerStatus(authToken, customerId, { productId, status })→PATCH /customer/api/v3.0/customers/{customerId}/getCustomerById(authToken, customerId)→GET /customer/api/v3.0/customers/{customerId}?filter=allsearchCustomers(authToken, params)→GET /customer/api/v3.0/customers/search?filter=...&mobileNumber=...&productCustomerId=...&customerType=...
Transactions (ProspayTransactionService)
createTransaction(authToken, payload)→POST /uts/api/transactionsaddChargesToTransaction(authToken, transactionId, payload)→POST /uts/api/transactions/{transactionId}/chargessearchTransactions(authToken, payload)→POST /uts/api/transactions/searchgetChargeSummary(authToken, customerId, { startDate, endDate })→GET /uts/api/transactions/charge-summary/{customerId}updateMetadata(authToken, transactionId, { metadata })→PATCH /uts/api/transactions/{transactionId}/metadatacancelTransaction(authToken, transactionId, { chargeIds?, reason })→POST /uts/api/transactions/{transactionId}/cancelmarkTransactionsReady(authToken, customerId, payload)→POST /uts/api/transactions/{customerId}/mark-readyunmarkTransactionsReady(authToken, customerId, payload)→POST /uts/api/transactions/{customerId}/unmark-ready
Invoices (ProspayInvoiceService)
generateInvoice(authToken, payload, callbackUrl?, proforma?, einvoice?)→POST /invoices/api/generateInvoicegenerateBulkInvoice(authToken, payload, callbackUrl?, proforma?, einvoice?)→POST /invoices/api/generateBulkInvoicegetInvoiceStatus(authToken, refId)→GET /invoices/api/invoice-status/{refId}getDynamicInvoices(authToken, query)→GET /invoices/api/dynamicInvoicesgenerateEInvoice(authToken, payload, callbackUrl)→POST /invoices/api/e-invoicecancelEInvoice(authToken, invoiceNo, cancelReason, callbackUrl)→DELETE /invoices/api/e-invoice/cancelgetEInvoiceStatus(authToken, refId)→GET /invoices/api/e-invoice/status/{refId}listInvoiceSeriesTokens(authToken)→GET /invoices/api/invoice-series-pattern/tokenscreateInvoiceSeriesPattern(authToken, payload)→POST /invoices/api/invoice-series-patternlistInvoiceSeriesPatterns(authToken)→GET /invoices/api/invoice-series-patternlinkTemplateToSeriesPattern(authToken, payload)→PUT /invoices/api/invoice-series-pattern/link-templateresetInvoiceSeriesCounter(authToken, payload)→POST /invoices/api/invoice-series/reset-countergenerateInvoiceFromProforma(authToken, payload, callbackUrl, einvoice?)→POST /invoices/api/generateInvoiceFromProforma
Ledger (ProspayLedgerService)
getCustomerSummary(authToken, params)→GET /uts/api/ledgers/customers/{customerId}/summarygetCustomerLedger(authToken, params)→GET /uts/api/ledgers/customers/{customerId}/ledgergetHeadSummary(authToken, query)→GET /uts/api/ledgers/reports/headsgetDateRangeSummary(authToken, params)→GET /uts/api/ledgers/customers/{customerId}/reports/date-rangegetTaxSummary(authToken, query)→GET /uts/api/ledgers/reports/taxgetProfitLossSummary(authToken, query)→GET /uts/api/ledgers/reports/profit-loss
Wallet (ProspayWalletService)
updateCreditLimit(authToken, walletId, payload)→PUT /uts/api/wallets/{walletId}/credit-limitchangeWalletStatus(authToken, walletId, payload)→PUT /uts/api/wallets/{walletId}/statusgetWalletBalance(authToken, walletId)→GET /uts/api/wallets/{walletId}/balancegetCustomerWallets(authToken, customerId)→GET /uts/api/wallets/customer/{customerId}searchWallets(authToken, payload)→POST /uts/api/wallets/searchgetWalletHistory(authToken, walletId, params)→GET /uts/api/wallets/{walletId}/historygetDailySnapshot(authToken, walletId, snapshotDate)→GET /uts/api/wallets/{walletId}/snapshotsgetCustomerSnapshots(authToken, customerId, snapshotDate)→GET /uts/api/wallets/customer/{customerId}/snapshotsaddParticipant(authToken, walletId, payload)→POST /uts/api/wallets/{walletId}/participantsremoveParticipant(authToken, walletId, customerId, payload)→DELETE /uts/api/wallets/{walletId}/participants/{customerId}getParticipants(authToken, walletId, params)→GET /uts/api/wallets/{walletId}/participants
Organizations (ProspayOrganizationService)
verifyKyc(authToken, id, payload)→PUT /wallet/api/v1.0/{id}/kycid: internal Tenant/organisation UUID.payload(VerifyKycDto): one of{ gst }{ businesspan }or{ signatorypan }{ aadhar }{ otp }(for Aadhaar OTP verification)
- Response:
{ data, status }(KYC provider response)
createOrganization(authToken, payload)→POST /wallet/api/v1.0/organisationspayload(CreateOrganizationDto):{ groupId?, name, industryType, businessType, gstRegistered, orgcode?, cin?, tan? }.- Response:
{ status: 201, data: { tenantId, id } }
updateOrganization(id, payload)→PUT /wallet/api/v1.0/organisations/{id}payload(UpdateOrganizationDto) patches Tenant fields.- Response:
{ status: 200, data: { message, id } }
getAllOrganizations(authToken, headers)→GET /wallet/api/v1.0/organisationsheaders:{ orgid?, tenantid? }plusAuthorization.- Behaviour depends on role in JWT (
TenantAdmin,SuperAdmin,OrgAdmin,ProductOwner). - Response:
{ data: TenantWithAddress[] }
updateBankDetails(authToken, id, payload)→PUT /wallet/api/v1.0/{id}/bankDetailspayload(UpdateBankDetailsDto):{ bankname, accountholdername, accountno, ifsccode }.- Response:
{ message: 'bankDetails updated successfully', status: 201 }
changeStatus(authToken, id, { action })→POST /wallet/api/v1.0/{id}?action=enable|disable- Only honoured for
SuperAdminin the service. - Response:
{ message: 'Status <action>', status: 200 }
- Only honoured for
getOrganization(orgId)→GET /wallet/api/v1.0/{orgId}/organisation- Response:
{ message: 'Success', data: TenantWithAddress | null }
- Response:
updateKycStatus(orgId, { action }, payload)→POST /wallet/api/v1.0/kycstatus/{orgId}?action=approve|disapprove|pending|completedpayload(KycStatusDto): optional{ message }for disapproval.- Sends email notifications from the service.
- Response:
{ message: 'Status <action>', status: 200 }
updatePaymentGatewayCut(authToken, orgId, payload)→PUT /wallet/api/v1.0/{orgId}/updatePaymentGatewayCutpayload(UpdatePaymentGatewayCutDto):{ cut, orgFees? }.- Response:
{ message: 'payment gateway cut updated successfully' }
Products (ProspayProductService)
createProduct(authToken, payload)→POST /product/api/v2.0/products/payloadisCreateProductDto(tenant + org + product master details).- Response:
{ data: ProductModel }
deleteProduct(authToken, id)→DELETE /product/api/v2.0/products/{id}idis the internal product UUID.- Response:
{ message: 'product removed successfully' }
findProductByRole(authToken, headers)→GET /product/api/v2.0/products/byRoleheaders:{ orgid, tenantid, resourceid? }on top ofAuthorization.- Response:
{ data: ProductWithBranchOrgs[] }
findAllProductsForOrg(authToken, headers)→GET /product/api/v2.0/products/headers:{ orgid, tenantid }.- Response:
{ data: ProductWithBranchOrgs[] }(cached per org in the service)
findAllProductsForTenant(authToken, headers)→GET /product/api/v2.0/products/dependentProductsheaders:{ orgid, tenantid }.- Response:
{ data: ProductWithBranchOrgs[] }
findProduct(id)→GET /product/api/v2.0/products/{id}/findProductidis the internal product UUID.- Response:
{ data: ProductWithBranchOrgs | null }
updateProductThreshold(authToken, id, { threshold })→PUT /product/api/v2.0/products/{id}/updateThreshold- Response:
{ message: 'Product threshold updated successfully' }
- Response:
fetchBranchOrgDetails(authToken, id)→GET /product/api/v2.0/products/{id}/fetchBranchOrgDetailsidis a branchOrgId.- Response:
{ data: BranchOrgModel | null, status: 200 }
findProductByCustomName(productid)→GET /product/api/v2.0/products/{productid}/findProductByCustomNameproductidis the external product code (e.g.WP...).- Response:
{ data: ProductModel | null }
fetchBranchOrgIdFromBranchCode(query)→GET /product/api/v2.0/products/branchorgsquery:{ stateCode?, productid? }.- Response:
{ data: { branchOrgDetails?, ProductDetails? }, status: 200 }
fetchBranchOrgDetail(id)→GET /product/api/v2.0/products/{id}/fetchBranchOrgDetailidis a branchOrgId.- Response:
{ data: BranchOrgModel | null, status: 200 }
findBranchByStateCode(authToken, stateCode)→GET /product/api/v2.0/products/findBranchByState/{stateCode}- Uses
req.user.resourceIdto resolve the product, then stateCode. - Response:
{ data: BranchOrgModel | null, status: 200 }
- Uses
updateProductBranchOrgs(authToken, productid, payload)→PUT /product/api/v2.0/products/{productid}/branchOrgsproductidis the external product code (e.g.WP...).payloadincludesbranchOrg[]with address + bank details.- Response:
{ message: 'Product updated successfully', createdBranchOrgs?, errors? }
fetchBranchOrg(authToken, id, branchOrgId)→GET /product/api/v2.0/products/{id}/branchorgs/{branchOrgId}- Currently implemented same as
fetchBranchOrgDetailin the service. - Response:
{ data: BranchOrgModel | null, status: 200 }
- Currently implemented same as
updateBranchOrg(authToken, id, branchOrgId, payload)→PATCH /product/api/v2.0/products/{id}/branchorgs/{branchOrgId}payloadis{ branchOrg: [ ...single branch payload... ] }.- Response:
{ message: 'branch org updated successfully', status: 200 }
listBranchOrgs(authToken, productid)→GET /product/api/v2.0/products/listBranchOrgs/{productid}productidis the external product code.- Response:
{ data: BranchOrgModel[], status: 200 }
fetchBranchOrgByHoId(authToken, id)→GET /product/api/v2.0/products/fetchBranchOrgByHoId/{id}idis a mapped HO id.- Response:
{ data: { orgName, gst, address, bankDetails, ... }, status: 200 }
Payment (ProspayPaymentService)
generateQr(authToken, payload)→POST /payments/api/v2.0/QRgeneratePaymentLink(authToken, payload)→POST /payments/api/v2.0/paymentLinkrefundPayment(authToken, productOrderId, payload)→POST /payments/api/v2.0/payment/{productOrderId}/refundgetPaymentStatus(authToken, productOrderId)→GET /payments/api/v2.0/payment/{productOrderId}/status
Example snippets
Authenticate and create a customer:
const authRes = await this.auth.authenticate();
const token = authRes?.token ?? authRes?.accessToken ?? authRes?.jwt;
await this.customers.createCustomer(token, {
productId: 'SMEINFUL',
productCustomerId: 'MGC2',
orgName: 'Mega city',
customerType: 'cp',
contacts: { email: '[email protected]', mobileNumber: '9110334567' },
});Create a transaction:
await this.tx.createTransaction(token, {
customerId: 'SMEINFUL000000000679668',
entityType: 'order',
referenceId: 'REF17735672330',
currency: 'INR',
vertical: 'customer',
charges: [
{
head: 'OTHER HANDLING CHARGES - ECOM (FOV & FSC)',
amount: 10050,
hsnOrSac: '998314',
isBillable: true,
absorbedBy: 'customer',
transactionType: 'credit',
breakup: [
{ head: 'CGST', amount: 5025, appliedOn: ['base_amount'], tags: ['tax', 'gst'] },
{ head: 'SGST', amount: 5025, appliedOn: ['base_amount'], tags: ['tax', 'gst'] },
],
metadata: [
{ key: 'tax_rate', value: '18%' },
{ key: 'calculation_method', value: 'percentage' },
],
},
],
});Generate an invoice and check status:
const gen = await this.invoice.generateInvoice(token, {
templateName: 'IF_Invoice',
startDate: '2025-11-01',
endDate: '2025-11-30',
buyer_customerId: 'SMEINFUL000000000679668',
seller_customerId: 'SMEINFUL000000000679668',
invoiceNo: 'PERFORMA-SF-8922-1'
}, 'https://your-callback.example', false, false);
const status = await this.invoice.getInvoiceStatus(token, gen.refId);
// Search dynamic invoices
const search = await this.invoice.getDynamicInvoices(token, {
templateName: 'IF_Invoice',
is_proforma: true,
page_no: 1,
page_limit: 10
});
// Generate E-invoice
const einv = await this.invoice.generateEInvoice(token, {
invoiceNo: 'INV-123',
billFrom: { /* ... */ },
billTo: { /* ... */ },
charges: [ /* ... */ ],
invoiceAmount: 1180
}, 'https://your-callback.example');
// Convert proforma to invoice
const convert = await this.invoice.generateInvoiceFromProforma(token, {
proformaData: [{ proformaInvoiceNumber: 'PERFORMA-SF-8922-1', customInvoiceNumber: 'INV-2025-001' }]
}, 'https://your-callback.example', true);Advanced Transaction Search
The searchTransactions method now supports deep filtering:
await this.tx.searchTransactions(token, {
page: 1,
limit: 20,
transactionFilters: {
customerIds: ['CUST1'],
entityTypes: ['order'],
transactionDateRange: { start: '2024-01-01', end: '2024-01-31' }
},
chargeFilters: {
heads: ['GST', 'PLATFORM_FEE'],
isBillable: true
},
sorting: { sortBy: 'transactionDate', sortOrder: 'DESC' },
includeOptions: { includeCharges: true, includeChargeBreakups: true }
});New Management Methods
- Metadata:
updateMetadata(token, txId, { metadata: [{ key: 'tag', value: 'val' }] }) - Cancellation:
cancelTransaction(token, txId, { reason: 'Double billing', chargeIds: ['ch1'] }) - Billing Workflow:
markTransactionsReady(token, custId, { markAllUnbilled: true }) - Correction:
unmarkTransactionsReady(token, custId, { transactionIds: ['tx1'] })
Error handling
- All HTTP errors throw (Axios behavior). In your app,
try/catchand inspecterr.response.statusanderr.response.data. - 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.
Configuration notes
productIdandproductApiKeyare required;baseUrlis configurable (set to sandbox or prod).- If you omit
baseUrl, the SDK defaults tohttps://sandbox.prospay.tech. - Timestamp and bcrypt hash for auth are handled internally; you only need to supply the product credentials.
