UNPKG

@setu/upi-deep-links

Version:

NPM package to connect to Setu's UPI Deep Link APIs

180 lines (179 loc) 5.64 kB
import { AmountExactness, SetuError } from "../types"; export declare enum SetuEnv { SANDBOX = "SANDBOX", PRODUCTION = "PRODUCTION" } export declare enum AuthScheme { OAUTH = "OAUTH", JWT = "JWT" } export declare enum API { FETCH_TOKEN = "/auth/token", PAYMENT_LINK_BASE = "/payment-links", REFUND_BASE = "/refund", TRIGGER_MOCK_PAYMENT = "/triggers/funds/addCredit", EXPIRE_BILL = "/utilities/bills/%s/expire", REPORTS_BASE = "/reports" } export declare type SetuResponseBase<T> = { readonly status: number; readonly success: boolean; readonly error: SetuError; readonly data: T; }; export declare type BillStatus = "BILL_CREATED" | "PAYMENT_SUCCESSFUL" | "PAYMENT_FAILED" | "CREDIT_RECEIVED" | "SETTLEMENT_SUCCESSFUL" | "SETTLEMENT_FAILED" | "BILL_EXPIRED"; export declare type SetuUPIDeepLinkParams = { readonly schemeID: string; readonly secret: string; readonly productInstanceID: string; readonly mode: `${SetuEnv}`; readonly authType: `${AuthScheme}`; }; export declare type FetchTokenResponseData = { readonly expiresIn: number; readonly token: string; }; export declare type CreatePaymentLinkData = { readonly name?: string; readonly transactionNote?: string; readonly amount: Amount; readonly expiryDate?: string; readonly billerBillID: string; readonly amountExactness: AmountExactness; readonly validationRules?: ValidationRules; readonly settlement?: Settlement; readonly additionalInfo?: Record<string, string>; readonly campaignID?: string; }; export declare type Settlement = { readonly parts: readonly SettlementPart[]; readonly primaryAccount: Account; }; declare type SettlementPart = { readonly account: Account; readonly remarks: string; readonly split: Split; }; declare type Split = { readonly unit: string; readonly value: number; }; declare type Account = { readonly id: string; readonly ifsc: string; }; declare type Amount = { readonly currencyCode: string; readonly value: number; }; export declare type ValidationRules = { readonly amount?: AmountValidation; readonly sourceAccounts?: SourceAccounts; }; declare type AmountValidation = { readonly minimum: number; readonly maximum: number; }; declare type SourceAccounts = { readonly items: readonly SourceAccountItem[]; }; declare type SourceAccountItem = { readonly number: string; readonly ifsc: string; }; export declare type CreatePaymentLinkResponseData = { readonly name: string; readonly paymentLink: PaymentLink; readonly platformBillID: string; }; declare type PaymentLink = { readonly shortURL: string; readonly upiID: string; readonly upiLink: string; }; export declare type GetPaymentStatusResponseData = { readonly amountPaid: Amount; readonly billerBillID: string; readonly createdAt: string; readonly expiresAt: string; readonly name: string; readonly payerVpa: string; readonly paymentLink: PaymentLink; readonly platformBillID: string; readonly receipt: Receipt; readonly status: BillStatus; readonly transactionNote: string; }; declare type Receipt = { readonly date: string; readonly id: string; }; export declare type TriggerMockPaymentData = { readonly amount: number; readonly destinationAccount: DestinationAccount; readonly sourceAccount: DestinationAccount; readonly transactionReference: string; readonly type: "UPI" | "ACCOUNT"; }; declare type DestinationAccount = { readonly accountID: string; }; export declare type TriggerMockPaymentResponseData = { readonly utr: string; }; export declare type InitiateRefundData = { readonly refunds: readonly RefundRequestItem[]; }; declare type InitiateRefundPartialAmountParams = { readonly refundType: "PARTIAL"; readonly refundAmount: number; }; declare type InitiateRefundPartialAmount = { readonly refundType: "PARTIAL"; readonly refundAmount: Amount; }; declare type InitiateRefundFullAmount = { readonly refundType: "FULL"; }; export declare type InitiateRefundAmountParams = InitiateRefundPartialAmountParams | InitiateRefundFullAmount; declare type InitiateRefundAmount = InitiateRefundPartialAmount | InitiateRefundFullAmount; export declare type RefundRequestItem = InitiateRefundAmount & { readonly seqNo: number; readonly identifier: string; readonly identifierType: "BILL_ID"; readonly deductions?: readonly Deduction[]; }; export declare type Deduction = { readonly account: Account; readonly split: Split; }; export declare type InitiateRefundResponseData = { readonly batchID: string; readonly refunds: readonly RefundResponseDataItem[]; }; declare type RefundResponseErrorData = { readonly code: string; readonly detail: string; readonly title: string; }; declare type RefundStatus = "Created" | "MarkedForRefund" | "QueuedForRefund" | "Rejected" | "Initiated"; export declare type RefundResponseSuccessData = { readonly id: string; readonly billID: string; readonly transactionRefID: string; readonly status: RefundStatus; readonly amount: Amount; readonly deductions: readonly Deduction[]; readonly initiatedAt?: string; }; declare type RefundResponseDataItem = ({ readonly success: true; readonly seqNo: number; } & RefundResponseSuccessData) | ({ readonly success: false; readonly seqNo: number; } & RefundResponseErrorData); export declare type BatchRefundStatusResponseData = { readonly refunds: readonly RefundResponseSuccessData[]; }; export {};