-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
16 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1 @@ | ||
import QRCode from 'qrcode'; | ||
import { QRResult, UPIIntentParams } from './types/upiqr'; | ||
/** | ||
* Generates a UPI QR code and intent URL. | ||
* @param {UPIIntentParams} params - The UPI intent parameters. | ||
* @param {QRCode.QRCodeToDataURLOptions} [qrOptions] - Optional QR code generation options. | ||
* @returns {Promise<QRResult>} - A promise that resolves to the QR code and intent URL. | ||
*/ | ||
export default function upiqr({ payeeVPA: pa, payeeName: pn, payeeMerchantCode: mc, transactionId: tid, transactionRef: tr, transactionNote: tn, amount: am, minimumAmount: mam, currency: cu, }: UPIIntentParams, qrOptions?: QRCode.QRCodeToDataURLOptions): Promise<QRResult>; | ||
import QRCode from'qrcode';import{QRResult,UPIIntentParams}from'./types/upiqr';export default function upiqr({payeeVPA:pa,payeeName:pn,payeeMerchantCode:mc,transactionId:tid,transactionRef:tr,transactionNote:tn,amount:am,minimumAmount:mam,currency:cu,}:UPIIntentParams,qrOptions?:QRCode.QRCodeToDataURLOptions):Promise<QRResult>; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,3 @@ | ||
/** | ||
* Supported image types for the QR code. | ||
*/ | ||
export type ImageType = 'png' | 'jpeg' | 'webp'; | ||
/** | ||
* Base64 encoded image string. | ||
* @template imageType - The type of the image. | ||
*/ | ||
export type Base64<imageType extends ImageType> = `data:image/${imageType};base64,${string}`; | ||
/** | ||
* Parameters for generating UPI intent. | ||
*/ | ||
export interface UPIIntentParams { | ||
payeeVPA: string; | ||
payeeName: string; | ||
payeeMerchantCode?: string; | ||
transactionId?: string; | ||
transactionRef?: string; | ||
transactionNote?: string; | ||
amount?: string; | ||
minimumAmount?: string; | ||
currency?: string; | ||
transactionRefUrl?: string; | ||
} | ||
/** | ||
* Result of the UPI QR code generation. | ||
*/ | ||
export interface QRResult { | ||
qr: Base64<ImageType>; | ||
intent: string; | ||
} | ||
|
||
export type ImageType='png'|'jpeg'|'webp';export type Base64<imageType extends ImageType>=`data:image/${imageType};base64,${string}`;export interface UPIIntentParams{payeeVPA:string;payeeName:string;payeeMerchantCode?:string;transactionId?:string;transactionRef?:string;transactionNote?:string;amount?:string;minimumAmount?:string;currency?:string;transactionRefUrl?:string;} | ||
export interface QRResult{qr:Base64<ImageType>;intent:string;} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters