@qrph/qrph
Version:
Library for parsing and encoding QRPH strings.
60 lines • 4.51 kB
JavaScript
import { describe, expect, it } from "vitest";
import { decodeQRPHFromText } from "./decodeQRPH.js";
import { encodeQRPHToText } from "./encodeQRPH.js";
const examples = {
gcash: {
gongcha: "00020101021128620011ph.ppmi.p2m0111GXCHPHM2XXX032121702000000060243306005030005204581253036085802PH5908Gong Cha60037626104122462660012ph.ppmi.qrph0309GCRD0000105212170500000670039620680708GEN0000863049B84",
shakeshack: "00020101021128620011ph.ppmi.p2m0111GXCHPHM2XXX032121702000005555771775205030005204581453036085802PH5924Specialty Food Retailers6006Makati6104122162620012ph.ppmi.qrph0305SHS0105212170500000555291087540708GEN000876304B258",
dcdelights: "00020101021127830012com.p2pqrpay0111GXCHPHM2XXX02089996440303152170200000006560417DWQM4TK3JDNWF7Y0M5204601653036085802PH5910DCDELIGHTS6011HOLY SPIRIT6104123463045D31",
bliss: "00020101021127830012com.p2pqrpay0111GXCHPHM2XXX02089996440303152170200000006560417DWQM4TK3JDNWVJGXW5204601653036085802PH5910BR****N S.6014TUASON POINT, 6104123463045508",
},
maya: {
ministop_old: "00020101021128500011ph.ppmi.p2m0111PAPHPHM1XXX030910047922705033105204549953036085802PH5917MINISTOP RUBLOU 26006CAINTA62430014com.paymaya.qr0521ViAPi11goYYWR7Pf3QAg66304A213",
xiaomi: "00020101021128500011ph.ppmi.p2m0111PAPHPHM1XXX030920039094905033105204481253036085802PH5910MI SM AURA6006TAGUIG62430014com.paymaya.qr0521T35s7ZwW3hKEHYCaFPPVo6304C56C",
sansrival: "00020101021128500011ph.ppmi.p2m0111PAPHPHM1XXX030920084191405033105204549953036085802PH5920SANS RIVAL FOOD MAIN6009DUMAGUETE62440014com.paymaya.qr0522TLSQGxwVi1XdHjGFDyuSft63049976",
habitual: "00020101021128500011ph.ppmi.p2m0111PAPHPHM1XXX030920043695405033105204581453036085802PH5922HABITUAL COFFEE MAKATI6006MAKATI62440014com.paymaya.qr0522KCkvHvVRjJb1dbwfB4qLDd630471F7",
},
securityBank: {
midsummer: "00020101021128800011ph.ppmi.p2m0111SETCPHMM000031652673772400104790419000000000005625447205030105204074253036085802PH5910MID SUMMER6009CEBU CITY6104600062310013com.ppmi.qrph0303***0503***88470012ph.ppmi.qrph0127SETCPHMM000526737724001047963044D55",
},
aub: {
yayoi: "00020101021128530011ph.ppmi.p2m0111AUBKPHMMXXX031210255000078905030105204581253036085502015802PH5925AUB YAYOI ONE BONIFACIO H6011MANDALUYONG80900012ph.ppmi.qrph0170https://app.wepayez.com/spay/payMoneyNew/102550000789/30038685/SPAY_PC88330012ph.ppmi.qrph0113COM.SWIFTPASS63044F70",
},
shopee: {
sansrival: "00020101021128460011ph.ppmi.p2m0111SHPHPHM2XXX03052196805033005204581453036085802PH5907SR MAIN6015Negros Oriental6104620088290012ph.ppmi.qrph0109ShopeePay63041EF8",
},
bpi: {
sansrival: "00020101021128560011ph.ppmi.p2m0111BOPIPHMMXXX031524081000000213505033115204074253036085802PH5907SR MAIN6009Dumaguete63045DBE",
},
bdo: {
sansrival: "00020101021128650011ph.ppmi.p2m0111BNORPHMMXXX031091843340270410918433402705033105204581453036085802PH5920SANS RIVAL FOOD DEVE6015NEGROS ORIENTAL62560011ph.ppmi.p2m0525116540002715169960576232907083614093088320012ph.ppmi.qrph011211654000271563047EB6",
},
paymongo: {
lazada: "00020101021228790011ph.ppmi.p2m0111PAEYPHM2XXX0324urLmCGCBdgRHfgT6ypDjpNsp041003030028860503010520460125303608540820035.385802PH5906Lazada6015Bonifacio Globa62430012ph.ppmi.qrph0306uuW5FD05062110000803***88440012ph.ppmi.qrph0124urLmCGCBdgRHfgT6ypDjpNsp630425A0",
},
};
const EXAMPLES = [
["GCash - Gongcha", examples.gcash.gongcha],
["GCash - Shakeshack", examples.gcash.shakeshack],
["GCash - DCDelights", examples.gcash.dcdelights],
["GCash - Bliss", examples.gcash.bliss],
["Maya - Ministop (old)", examples.maya.ministop_old],
["Maya - Xiaomi", examples.maya.xiaomi],
["Maya - Sansrival", examples.maya.sansrival],
["Maya - Habitual", examples.maya.habitual],
["Security Bank - Midsummer", examples.securityBank.midsummer],
["AUB - Yayoi", examples.aub.yayoi],
["Shopee - Sansrival", examples.shopee.sansrival],
["BPI - Sansrival", examples.bpi.sansrival],
["BDO - Sansrival", examples.bdo.sansrival],
["PayMongo - Lazada", examples.bdo.sansrival],
];
describe("decodeQRText", () => {
it("should be invertible", () => {
console.log(decodeQRPHFromText(examples.gcash.gongcha));
for (const [name, example] of EXAMPLES) {
expect(encodeQRPHToText(decodeQRPHFromText(example)), name).toBe(example);
}
});
});
//# sourceMappingURL=decodeQRPH.test.js.map