### Setting Merchant Account Identifier (FPS ID) Source: https://github.com/ous50/hkqr-fps/blob/master/README.md Provides examples for setting the merchant's account identifier using their 7-digit or 9-digit FPS ID. The method names differ slightly between HKQR and FPS classes. ```typescript // For HKQR HKQR.setMerchantAccountFPSId(1234567); // For FPS FPS.setFPSId("1234567"); ``` -------------------------------- ### Set Payment Provider and Bank Code Source: https://context7.com/ous50/hkqr-fps/llms.txt Allows specifying the payment service provider or bank for an FPS transaction using predefined constants. This is useful for directing payments to specific institutions. Example shows setting HSBC as the bank. ```typescript import { FPS } from 'hkqr-fps'; const fps = new FPS(); fps.setBank(FPS.BANK_HSBC); // HSBC fps.setFPSId('1234567'); fps.setAmount(100); const result = fps.generate(); // Available bank constants: // Banks: // FPS.BANK_HSBC // '004' - HSBC // FPS.BANK_BANK_OF_CHINA // '012' - Bank of China // FPS.BANK_STANDARD_CHARTERED // '003' - Standard Chartered // FPS.BANK_HANG_SANG // '024' - Hang Seng Bank // FPS.BANK_EAST_ASIA // '015' - Bank of East Asia // FPS.BANK_DBS // '016' - DBS Bank // FPS.BANK_CITIBANK // '250' - Citibank // SVF (Stored Value Facilities): // FPS.BANK_ALIPAY // '948' - Alipay HK // FPS.BANK_WECHAT // '931' - WeChat Pay HK // FPS.BANK_PAYME // '954' - PayMe // FPS.BANK_OCTOPUS // '949' - Octopus // FPS.BANK_TAP_N_GO // '935' - Tap & Go // FPS.BANK_TNG // '947' - TNG Wallet ``` -------------------------------- ### Browser Usage Without Module System (HTML/JavaScript) Source: https://context7.com/ous50/hkqr-fps/llms.txt Demonstrates how to use the HKQR-FPS library directly in an HTML file without requiring a module system or bundler. It shows setting FPS ID, amount, bill number, generating a QR code, and parsing an existing QR code. ```html FPS QR Code Generator ``` -------------------------------- ### Project Versions Source: https://github.com/ous50/hkqr-fps/blob/master/docs/classes/HKQR.html This section lists the supported versions for the /ous50/hkqr-fps project. ```APIDOC ## Project Versions This API supports the following project versions for `/ous50/hkqr-fps`: * `1520` * `1711` * `1731` * `1740` * `1750` * `1761` * `1771` * `1799` * `2741` * `2791` * `2842` * `3000` * `3001` * `3002` * `3003` * `3004` * `3005` * `3006` * `3007` * `3008` * `3009` * `3010` * `3011` * `3012` * `3013` * `3014` * `3015` * `3016` * `3017` * `3018` * `3019` * `3020` * `3021` * `3022` * `3023` * `3024` * `3025` * `3026` * `3027` * `3028` * `3029` * `3030` * `3031` * `3032` * `3033` * `3034` * `3035` * `3036` * `3037` * `3038` * `3039` * `3040` * `3041` * `3042` * `3043` * `3044` * `3045` * `3046` * `3047` * `3048` * `3049` * `3050` * `3051` * `3052` * `3053` * `3054` * `3055` * `3056` * `3057` * `3058` * `3059` * `3060` * `3061` * `3062` * `3063` * `3064` * `3065` * `3066` * `3067` * `3068` * `3069` * `3070` * `3071` * `3072` * `3073` * `3074` * `3075` * `3076` * `3077` * `3078` * `3079` * `3080` * `3081` * `3082` * `3083` * `3084` * `3085` * `3086` * `3087` * `3088` * `3089` * `3090` * `3091` * `3092` * `3093` * `3094` * `3095` * `3096` * `3097` * `3098` * `3099` * `3100` * `3101` * `3102` * `3103` * `3104` * `3105` * `3106` * `3107` * `3108` * `3109` * `3110` * `3111` * `3112` * `3113` * `3114` * `3115` * `3116` * `3117` * `3118` * `3119` * `3120` * `3121` * `3122` * `3123` * `3124` * `3125` * `3126` * `3127` * `3128` * `3129` * `3130` * `3131` * `3132` * `3133` * `3134` * `3135` * `3136` * `3137` * `3138` * `3139` * `3140` * `3141` * `3142` * `3143` * `3144` * `3145` * `3146` * `3147` * `3148` * `3149` * `3150` * `3151` * `3152` * `3153` * `3154` * `3155` * `3156` * `3157` * `3158` * `3159` * `3160` * `3161` * `3162` * `3163` * `3164` * `3165` * `3166` * `3167` * `3168` * `3169` * `3170` * `3171` * `3172` * `3173` * `3174` * `3175` * `3176` * `3177` * `3178` * `3179` * `3180` * `3181` * `3182` * `3183` * `3184` * `3185` * `3186` * `3187` * `3188` * `3189` * `3190` * `3191` * `3192` * `3193` * `3194` * `3195` * `3196` * `3197` * `3198` * `3199` * `3200` * `3201` * `3202` * `3203` * `3204` * `3205` * `3206` * `3207` * `3208` * `3209` * `3210` * `3211` * `3212` * `3213` * `3214` * `3215` * `3216` * `3217` * `3218` * `3219` * `3220` * `3221` * `3222` * `3223` * `3224` * `3225` * `3226` * `3227` * `3228` * `3229` * `3230` * `3231` * `3232` * `3233` * `3234` * `3235` * `3236` * `3237` * `3238` * `3239` * `3240` * `3241` * `3242` * `3243` * `3244` * `3245` * `3246` * `3247` * `3248` * `3249` * `3250` * `3251` * `3252` * `3253` * `3254` * `3255` * `3256` * `3257` * `3258` * `3259` * `3260` * `3261` * `3262` * `3263` * `3264` * `3265` * `3266` * `3267` * `3268` * `3269` * `3270` * `3271` * `3272` * `3273` * `3274` * `3275` * `3276` * `3277` * `3278` * `3279` * `3280` * `3281` * `3282` * `3283` * `3284` * `3285` * `3286` * `3287` * `3288` * `3289` * `3290` * `3291` * `3292` * `3293` * `3294` * `3295` * `3296` * `3297` * `3298` * `3299` * `3351` * `3352` * `3353` * `3354` * `3355` * `3356` * `3357` * `3358` * `3359` * `3360` * `3361` * `3362` * `3363` * `3364` * `3365` * `3366` * `3367` * `3368` * `3369` * `3370` * `3371` * `3372` * `3373` * `3374` * `3375` * `3376` * `3377` * `3378` * `3379` * `3380` * `3381` * `3382` * `3383` * `3384` * `3385` * `3386` * `3387` * `3388` * `3389` * `3390` * `3391` * `3392` * `3393` * `3394` * `3395` * `3396` * `3397` * `3398` * `3399` * `3400` * `3401` * `3402` * `3403` * `3404` * `3405` * `3406` * `3407` * `3408` * `3409` * `3410` * `3411` * `3412` * `3413` * `3414` * `3415` * `3416` * `3417` * `3418` * `3419` * `3420` * `3421` * `3422` * `3423` * `3424` * `3425` * `3426` * `3427` * `3428` * `3429` * `3430` * `3431` * `3432` * `3433` * `3434` * `3435` * `3436` * `3437` * `3438` * `3439` * `3440` * `3441` * `3501` * `3502` * `3503` * `3504` * `3505` * `3506` * `3507` * `3508` * `3509` * `3510` * `3511` * `3512` * `3513` * `3514` * `3515` * `3516` * `3517` * `3518` * `3519` * `3520` * `3521` * `3522` * `3523` * `3524` * `3525` * `3526` * `3527` * `3528` * `3529` * `3530` * `3531` * `3532` * `3533` * `3534` * `3535` * `3536` * `3537` * `3538` * `3539` * `3540` * `3541` * `3542` * `3543` * `3544` * `3545` * `3546` * `3547` * `3548` * `3549` * `3550` * `3551` * `3552` * `3553` * `3554` * `3555` * `3556` * `3557` * `3558` * `3559` * `3560` * `3561` * `3562` * `3563` * `3564` * `3565` * `3566` * `3567` * `3568` * `3569` * `3570` * `3571` * `3572` * `3573` * `3574` * `3575` * `3576` * `3577` * `3578` * `3579` * `3580` * `3581` * `3582` * `3583` * `3584` * `3585` * `3586` * `3587` * `3588` * `3589` * `3590` * `3591` * `3592` * `3593` * `3594` * `3595` * `3596` * `3597` * `3598` * `3599` * `3600` * `3601` * `3602` * `3603` * `3604` * `3605` * `3606` * `3607` * `3608` * `3609` * `3610` * `3611` * `3612` * `3613` * `3614` * `3615` * `3616` * `3617` * `3618` * `3619` * `3620` * `3621` * `3622` * `3623` * `3624` * `3625` * `3626` * `3627` * `3628` * `3629` * `3630` * `3631` * `3632` * `3633` * `3634` * `3635` * `3636` * `3637` * `3638` * `3639` * `3640` * `3641` * `3642` * `3643` * `3644` * `3645` * `3646` * `3647` * `3648` * `3649` * `3650` * `3651` * `3652` ``` -------------------------------- ### Handle Static vs Dynamic QR Codes (TypeScript) Source: https://context7.com/ous50/hkqr-fps/llms.txt Demonstrates how to configure QR codes for static (reusable) and dynamic (single-use) payment scenarios using the FPS class. It covers setting the QR code type and checking the current type. ```typescript import { FPS } from 'hkqr-fps'; // Static QR Code (default) - reusable, amount can be changed by payer const staticFps = new FPS(); staticFps.setStatic(); staticFps.setFPSId('1234567'); // Do not set amount for static QR - payer enters amount const staticResult = staticFps.generate(); console.log('Static QR:', staticResult.data); // Dynamic QR Code - single use, fixed amount const dynamicFps = new FPS(); dynamicFps.setDynamic(); dynamicFps.setFPSId('1234567'); dynamicFps.setAmount(100.00); dynamicFps.setBillNumber('INV-001'); const dynamicResult = dynamicFps.generate(); console.log('Dynamic QR:', dynamicResult.data); // Check QR code type if (staticFps.isStatic()) { console.log('This is a static QR code'); } ``` -------------------------------- ### Generate Full-Featured HKQR Code (TypeScript) Source: https://context7.com/ous50/hkqr-fps/llms.txt Creates a comprehensive HKQR code using the HKQR class, including merchant information, localization, convenience fees, and billing details. This allows for detailed transaction configurations. ```typescript import { HKQR } from 'hkqr-fps'; const hkqr = new HKQR(); // Merchant account setup hkqr.setMerchantAccountFPSId('1234567'); hkqr.setMerchantAccountParticipantCode(HKQR.BANK_HSBC); // Merchant information hkqr.setMerchantName('My Shop Ltd'); hkqr.setMerchantCity('Hong Kong'); hkqr.setPostalCode('999077'); hkqr.setMerchantCategory('5812'); // Restaurants // Transaction details hkqr.setTransactionAmount(150.50, 2); // 2 decimal places hkqr.setTransactionCurrency(HKQR.CURRENCY_HKD); // Convenience fee (3% service charge) hkqr.setConvenienceFeePercent(3.0, 2); // Billing information hkqr.setBillNumber('BILL-2024-001'); hkqr.setReferenceLabel('Table 5 Order'); hkqr.setStoreLabel('Central Branch'); hkqr.setTerminalLabel('POS-01'); // Localized merchant name (Chinese) hkqr.setLocalizedMerchantName('我的商店有限公司', HKQR.LANGUAGE_CHINESE); hkqr.setLocalizedMerchantCity('香港'); const result = hkqr.generate(); if (!result.isError()) { console.log(result.data); // Full HKQR string with all features included } ``` -------------------------------- ### Setting Billing Information (Reference Label) Source: https://github.com/ous50/hkqr-fps/blob/master/README.md Demonstrates setting a reference detail for the billing information. This method is consistent across both HKQR and FPS classes. ```typescript // For HKQR HKQR.setReferenceLabel("Payment for services"); // For FPS FPS.setReference("Payment for services"); ``` -------------------------------- ### Generating Final QR Code Output Source: https://github.com/ous50/hkqr-fps/blob/master/README.md Explains how to use the `generate` method to produce the final output string required for creating a QR code. This method is consistent across both HKQR and FPS classes. ```typescript // For HKQR let qrCodeOutputHKQR = HKQR.generate(); // For FPS let qrCodeOutputFPS = FPS.generate(); ``` -------------------------------- ### Setting Transaction Amount Source: https://github.com/ous50/hkqr-fps/blob/master/README.md Illustrates how to set the transaction amount. The HKQR class offers an additional `fraction` parameter for formatting, while the FPS class takes a number directly. ```typescript // For HKQR with specific fraction HKQR.setTransactionAmount(100.50, 2); // For HKQR with default fraction handling HKQR.setTransactionAmount("100.50"); // For FPS FPS.setAmount(100.50); ``` -------------------------------- ### Static Currency Constants Source: https://github.com/ous50/hkqr-fps/blob/master/docs/classes/FPS.html Provides access to predefined currency constants, such as the United States Dollar. ```APIDOC ## Static CURRENCY_USD ### Description Represents the currency code for United States Dollar. ### Method GET ### Endpoint `/api/currency/usd` (Conceptual) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **currency** (string) - The currency code 'USD' #### Response Example ```json { "currency": "USD" } ``` ``` -------------------------------- ### Importing HKQR Class in TypeScript Source: https://github.com/ous50/hkqr-fps/blob/master/README.md Demonstrates how to import the HKQR class from the library in a TypeScript project. It shows two common import methods: named import and default import. ```typescript import { HKQR } from "./src"; // or import HKQR from "./src/HKQR"; let qrCode = new HKQR(); ``` -------------------------------- ### Currency Accessors Source: https://github.com/ous50/hkqr-fps/blob/master/docs/classes/FPS.html Provides static accessors for different currency codes. ```APIDOC ## Currency Accessors ### Static CURRENCY_HKD - **Description**: Hong Kong Dollar. - **Returns**: "HKD" ### Static CURRENCY_CNY - **Description**: Chinese Yuan Renminbi. - **Returns**: "CNY" ### Static CURRENCY_TWD - **Description**: Taiwan New Dollar. - **Returns**: "TWD" ``` -------------------------------- ### setCustomerLabel API Source: https://github.com/ous50/hkqr-fps/blob/master/docs/interfaces/IHKQR_CODE.html Sets a customer label. This method requires a string input for the customer label. ```APIDOC ## setCustomerLabel ### Description Sets a customer label. This method requires a string input for the customer label. ### Method POST (Assumed, as it's a configuration setter) ### Endpoint /ous50/hkqr-fps/config/customerLabel ### Parameters #### Query Parameters - **x** (string) - Required - The customer label to set. ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. - **message** (string) - A confirmation message. ``` -------------------------------- ### Using HKQR in HTML without Modules Source: https://github.com/ous50/hkqr-fps/blob/master/README.md Illustrates how to include the pre-compiled Webpack JavaScript file in an HTML document to use the HKQR class without requiring module import syntax. ```html // index.html // index.js let qrCode = new HKQR(); ``` -------------------------------- ### Billing Data Methods Source: https://github.com/ous50/hkqr-fps/blob/master/docs/classes/FPS.html Provides methods to retrieve billing-related information. ```APIDOC ## GET /api/billing/bill-number ### Description Retrieves the billing number for transactions. ### Method GET ### Endpoint `/api/billing/bill-number` ### Parameters None ### Request Example None ### Response #### Success Response (200) - **response** (object) - The response object containing billing details. #### Response Example ```json { "response": { ... } } ``` ``` ```APIDOC ## GET /api/billing/reference ### Description Retrieves the reference of a transaction. ### Method GET ### Endpoint `/api/billing/reference` ### Parameters None ### Request Example None ### Response #### Success Response (200) - **response** (object) - The response object containing transaction reference details. #### Response Example ```json { "response": { ... } } ``` ``` -------------------------------- ### Point of Initiation Properties Source: https://github.com/ous50/hkqr-fps/blob/master/docs/classes/FPS.html Details the property related to the point of initiation for a transaction. ```APIDOC ## Point of Initiation Properties ### Private Optional initiationPoint - **Description**: Specifies the point of initiation for the transaction. - **Type**: POINT_OF_INITIATION - **Default**: "11" ``` -------------------------------- ### Set Complete Billing Information (TypeScript) Source: https://context7.com/ous50/hkqr-fps/llms.txt Establishes comprehensive transaction and customer details for detailed record-keeping, including bill number, reference label, customer mobile, store label, loyalty number, customer label, terminal label, transaction purpose, and customer data request. Generates a QR code and allows retrieval of individual billing fields. ```typescript import { HKQR } from 'hkqr-fps'; const hkqr = new HKQR(); hkqr.setMerchantAccountFPSId('1234567'); hkqr.setTransactionAmount(500.00, 2); // Comprehensive billing data hkqr.setBillNumber('INV-2024-12345'); hkqr.setReferenceLabel('Annual Membership Fee'); hkqr.setCustomerMobileNumber('+852-98765432'); hkqr.setStoreLabel('Online Store'); hkqr.setLoyaltyNumber('LOYALTY123456'); hkqr.setCustomerLabel('CUST-001'); hkqr.setTerminalLabel('WEB-CHECKOUT-01'); hkqr.setTransactionPurpose('Membership renewal'); hkqr.setCustomerDataRequest('Receipt via email'); // Generate QR code const result = hkqr.generate(); if (!result.isError()) { console.log('QR Code Generated:', result.data); } // Retrieve individual billing fields console.log('Bill Number:', hkqr.getBillNumber().data); console.log('Reference:', hkqr.getReferenceLabel().data); console.log('Store:', hkqr.getStoreLabel().data); ``` -------------------------------- ### FPS Participant List Configuration Source: https://github.com/ous50/hkqr-fps/blob/master/docs/index.html Defines a comprehensive mapping of participant codes to their corresponding string identifiers. This list includes various banks and financial institutions participating in the FPS system. ```typescript const FPS_PARTICIPANT_LIST: { [key: string]: string } = { "003": "STANDARD CHARTERED BANK (HONG KONG) LIMITED", "004": "The Hongkong and Shanghai Banking Corporation Limited", "009": "China Construction Bank (Asia) Corporation Limited", "012": "Bank of China (Hong Kong) Limited", "014": "Bank of China (Hong Kong) Limited", "015": "The Bank of East Asia, Limited", "016": "DBS Bank (Hong Kong) Ltd.", "019": "Bank of China (Hong Kong) Limited", "020": "CMB Wing Lung Bank Limited", "024": "Hang Seng Bank Ltd.", "025": "Shanghai Commercial Bank Limited", "026": "Bank of China (Hong Kong) Limited", "027": "Bank of Communications Co., Ltd. Hong Kong Branch", "028": "Public Bank (Hong Kong) Limited", "029": "INDUSTRIAL AND COMMERCIAL BANK OF CHINA (ASIA) LIMITED", "030": "Bank of China (Hong Kong) Limited", "031": "Bank of China (Hong Kong) Limited", "033": "Bank of China (Hong Kong) Limited", "035": "OCBC Wing Hang Bank Limited", "036": "Bank of China (Hong Kong) Limited", "038": "Tai Yau Bank Limited", "039": "Chiyu Banking Corporation Limited", "040": "Dah Sing Bank, Limited", "041": "Chong Hing Bank Limited", "043": "Nanyang Commercial Bank, Limited", "044": "OCBC Wing Hang Bank Limited", "061": "TAI SANG BANK LTD.", "064": "Bank of China (Hong Kong) Limited", "070": "Bank of China (Hong Kong) Limited", "128": "Fubon Bank (Hong Kong) Limited", "250": "Citibank (Hong Kong) Limited", "929": "K & R INTERNATIONAL LIMITED", "930": "EPAYLINKS TECHNOLOGY CO., LIMITED", "931": "WeChat Pay Hong Kong Limited", "933": "33 Financial Services Limited", "934": "UniCard Solution Limited", "935": "HKT Payment Limited", "947": "TNG (Asia) Limited", "948": "Alipay Financial Services (HK) Limited", "949": "Octopus Cards Limited", "952": "Autotoll Limited", "954": "PayMe" }; ``` -------------------------------- ### Generate FPS QR Code with FPS ID Source: https://context7.com/ous50/hkqr-fps/llms.txt Generates a basic FPS payment QR code using a provided FPS ID, transaction amount, billing number, and reference. It utilizes the `FPS` class from the 'hkqr-fps' library. The output is a QR code string if generation is successful. ```typescript import { FPS } from 'hkqr-fps'; const fps = new FPS(); fps.setFPSId('1234567'); fps.setAmount(100.50); fps.setBillNumber('INV-2024-001'); fps.setReference('Payment for services'); const result = fps.generate(); if (!result.isError()) { const qrString = result.data; console.log(qrString); // Output: 00020101021126530012hk.com.hkicl02091234567520400005303344540610055802HK5902NA6002HK62290113INV-2024-0010512Payment for services6304XXXX } ``` -------------------------------- ### Setting Merchant Account Identifier (Email) Source: https://github.com/ous50/hkqr-fps/blob/master/README.md Demonstrates setting the merchant's email address as the account identifier. This functionality is available in both HKQR and FPS classes using the same method name. ```typescript // For HKQR HKQR.setMerchantAccountEmail("merchant@example.com"); // For FPS FPS.setEmail("merchant@example.com"); ``` -------------------------------- ### Bank Participant Accessors Source: https://github.com/ous50/hkqr-fps/blob/master/docs/classes/FPS.html Provides static accessors for various bank participants, including their codes and names. ```APIDOC ## Bank Participant Accessors ### Static BANK_HSBC - **Description**: The Hongkong and Shanghai Banking Corporation Limited. - **Returns**: "004" ### Static BANK_STANDARD_CHARTERED - **Description**: Standard Chartered Bank (Hong Kong) Limited. - **Returns**: "003" ### Static BANK_BANK_OF_CHINA - **Description**: Bank of China (Hong Kong) Limited. - **Returns**: "012" ### Static BANK_EAST_ASIA - **Description**: The Bank of East Asia, Limited. - **Returns**: "015" ### Static BANK_DBS - **Description**: DBS Bank (Hong Kong) Ltd. - **Returns**: "016" ### Static BANK_HANG_SANG - **Description**: Hang Seng Bank Ltd. - **Returns**: "024" ### Static BANK_CITIBANK - **Description**: Citibank (Hong Kong) Limited. - **Returns**: "250" ``` -------------------------------- ### Static FPS Identifier Constants Source: https://github.com/ous50/hkqr-fps/blob/master/docs/classes/FPS.html Provides access to predefined FPS identifier constants for various government departments and services. ```APIDOC ## Static FPS_EMAIL_IRD_PERSONAL_ASSESSMENT ### Description Represents the FPS email identifier for Inland Revenue Department - Personal Assessment. ### Method GET ### Endpoint `/api/fps/identifier/ird/personal_assessment` (Conceptual) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **identifier** (string) - The FPS email identifier. #### Response Example ```json { "identifier": "FPS_Identifier_CRC201D@ird.gov.hk" } ``` ``` ```APIDOC ## Static FPS_EMAIL_IRD_PROFITS_TAX ### Description Represents the FPS email identifier for Inland Revenue Department - Profits Tax. ### Method GET ### Endpoint `/api/fps/identifier/ird/profits_tax` (Conceptual) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **identifier** (string) - The FPS email identifier. #### Response Example ```json { "identifier": "FPS_Identifier_CRC201A@ird.gov.hk" } ``` ``` ```APIDOC ## Static FPS_EMAIL_IRD_SALARIES_TAX ### Description Represents the FPS email identifier for Inland Revenue Department - Salaries Tax. ### Method GET ### Endpoint `/api/fps/identifier/ird/salaries_tax` (Conceptual) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **identifier** (string) - The FPS email identifier. #### Response Example ```json { "identifier": "FPS_Identifier_CRC201B@ird.gov.hk" } ``` ``` ```APIDOC ## Static FPS_ID_CLP ### Description Represents the FPS ID for CLP Power Hong Kong Ltd. ### Method GET ### Endpoint `/api/fps/identifier/clp` (Conceptual) ### Parameters None ### Request Example None ### Response #### Success Response (200) - **fpsId** (string) - The FPS ID for CLP Power. #### Response Example ```json { "fpsId": "4853305" } ``` ``` -------------------------------- ### Handling Events and Errors Source: https://github.com/ous50/hkqr-fps/blob/master/README.md Explains how to work with the `Event` objects returned by most methods. It covers accessing data via `event.data` and checking for errors using `event.isError()` and retrieving error messages. ```typescript // Assuming 'event' is the result of a method call if (event.isError()) { console.error("Error: " + event.message); } else { console.log("Success: " + event.data); } ``` -------------------------------- ### Setting Billing Information (Bill Number) Source: https://github.com/ous50/hkqr-fps/blob/master/README.md Shows how to set a bill number or identifier provided by the merchant for billing purposes. This method is available in both HKQR and FPS classes. ```typescript // For HKQR HKQR.setBillNumber("INV-00123"); // For FPS FPS.setBillNumber("INV-00123"); ``` -------------------------------- ### HKQR Merchant Template List Constant Source: https://github.com/ous50/hkqr-fps/blob/master/docs/index.html Defines a read-only array of strings representing HKQR merchant template identifiers. This list is used to specify which merchant templates are valid or available within the system. It serves as a configuration setting for merchant template management. ```typescript const HKQR_MERCHANT_TEMPLATE_LIST: readonly string[] = ["26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51"]; ``` -------------------------------- ### Parsing and Updating Data from QR Code String Source: https://github.com/ous50/hkqr-fps/blob/master/README.md Demonstrates the usage of the `parse` method, which first calls `extract` and then updates the internal data if the extraction is successful. This is applicable to both HKQR and FPS classes. ```typescript // For HKQR let parsedDataHKQR = HKQR.parse(qrCodeString); // For FPS let parsedDataFPS = FPS.parse(qrCodeString); ``` -------------------------------- ### Generate FPS QR Code with Email Source: https://context7.com/ous50/hkqr-fps/llms.txt Generates an FPS QR code using an email address for payment identification. This supports standard email formats and specific constants for government departments like the Inland Revenue Department. It also allows setting the transaction amount and a reference note. ```typescript import { FPS } from 'hkqr-fps'; const fps = new FPS(); fps.setEmail('merchant@business.com'); fps.setAmount(250.75); fps.setReference('Invoice #12345'); const result = fps.generate(); if (!result.isError()) { console.log(result.data); } // Using government department email constants: fps.setEmail(FPS.FPS_EMAIL_IRD_PROFITS_TAX); // Inland Revenue - Profits Tax fps.setEmail(FPS.FPS_EMAIL_IRD_SALARIES_TAX); // Inland Revenue - Salaries Tax ``` -------------------------------- ### Set Dynamic QR Code (TypeScript) Source: https://github.com/ous50/hkqr-fps/blob/master/docs/interfaces/IFPS_CODE.html Enables dynamic QR code generation. This method takes no arguments and returns a Response object. ```typescript setDynamic(): Response ``` -------------------------------- ### Set Merchant Account Payment Identifiers (TypeScript) Source: https://context7.com/ous50/hkqr-fps/llms.txt Configures multiple payment identifiers for a merchant account, including FPS ID, mobile number, email, and bank participant code. It utilizes the 'hkqr-fps' library and returns payment network information upon successful retrieval. ```typescript import { HKQR } from 'hkqr-fps'; const hkqr = new HKQR(); // Set primary FPS ID hkqr.setMerchantAccountFPSId('1234567'); // Add mobile number for alternative payment method hkqr.setMerchantAccountMobile('+852-12345678'); // Add email for government or institutional payments hkqr.setMerchantAccountEmail('payment@company.com'); // Set bank participant code hkqr.setMerchantAccountParticipantCode(HKQR.BANK_HSBC); // Get all payment network information const networkResult = hkqr.getPaymentNetwork(); if (!networkResult.isError()) { console.log('Payment Methods:', networkResult.data); // { // "01": "004", // Bank code (HSBC) // "02": "1234567", // FPS ID // "03": "+852-12345678", // Mobile // "04": "payment@company.com" // Email // } } ``` -------------------------------- ### setCustomerDataRequest API Source: https://github.com/ous50/hkqr-fps/blob/master/docs/interfaces/IHKQR_CODE.html Sets customer data for the request. This method requires a string input for the customer data. ```APIDOC ## setCustomerDataRequest ### Description Sets customer data for the request. This method requires a string input for the customer data. ### Method POST (Assumed, as it's a configuration setter) ### Endpoint /ous50/hkqr-fps/config/customerDataRequest ### Parameters #### Query Parameters - **x** (string) - Required - The customer data to set. ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. - **message** (string) - A confirmation message. ``` -------------------------------- ### Parse Existing QR Code String Source: https://context7.com/ous50/hkqr-fps/llms.txt Parses an existing FPS QR code string to extract payment details. The `parse` method populates the `FPS` instance with data that can then be retrieved using getter methods like `getAmount`, `getBillNumber`, and `getReference`. ```typescript import { FPS } from 'hkqr-fps'; const qrString = '00020101021126530012hk.com.hkicl02091234567520400005303344540610055802HK5902NA6002HK62290113INV-2024-0010512Payment for services6304XXXX'; const fps = new FPS(); const result = fps.parse(qrString); if (!result.isError()) { // Data is now loaded into the fps instance const amount = fps.getAmount(true).data; // 100.50 as number const billNum = fps.getBillNumber().data; // 'INV-2024-001' const reference = fps.getReference().data; // 'Payment for services' const fpsId = fps.getFPSId().data; // '1234567' console.log(`Amount: $${amount}, Bill: ${billNum}`); } ``` -------------------------------- ### Set Amount (TypeScript) Source: https://github.com/ous50/hkqr-fps/blob/master/docs/interfaces/IFPS_CODE.html Sets the transaction amount. It accepts a number representing the amount and returns a Response object. ```typescript setAmount(x: number): Response ``` -------------------------------- ### Set Additional Information (TypeScript) Source: https://github.com/ous50/hkqr-fps/blob/master/docs/interfaces/IFPS_CODE.html Sets additional information for the transaction. It accepts a VALID_OBJECT as input and returns a Response object. ```typescript setAdditionalInfo(x: VALID_OBJECT): Response ``` -------------------------------- ### setLanguagePreference Source: https://github.com/ous50/hkqr-fps/blob/master/docs/classes/HKQR.html Allows setting the preferred language for localized information. Supports a wide range of language codes. ```APIDOC ## setLanguagePreference ### Description Set the language of localized information. ### Method POST ### Endpoint /ous50/hkqr-fps/setLanguagePreference ### Parameters #### Query Parameters - **x** (string) - Required - A language code from the supported list (e.g., 'ZH', 'EN', 'TW'). ### Request Example ```json { "x": "EN" } ``` ### Response #### Success Response (200) - **message** (string) - A confirmation message indicating the language preference has been set. #### Response Example ```json { "message": "Language preference set to EN" } ``` ```