Exemplo n.º 1
0
 public static IQrInfo SetPlainCreditTransfer(this QrInfo qr)
 {
     qr.Segments.Add(new QrDataObject("29200016A000000677010111"));
     qr.CreditTransfer = new CreditTransfer {
         MerchantPresentedQR = true
     };
     return(qr);
 }
Exemplo n.º 2
0
 public static void ValidateWith(this QrInfo qr, QrInfo expected, bool skipChecksum = true)
 {
     if (skipChecksum)
     {
         qr.Segments.Remove(qr.Segments.FirstOrDefault(it => it.Identifier == QrIdentifier.CRC));
         expected.Segments.Remove(expected.Segments.FirstOrDefault(it => it.Identifier == QrIdentifier.CRC));
     }
     qr.Should().BeEquivalentTo(expected);
 }
Exemplo n.º 3
0
        public void DefaultDynamicBillPaymentQRMustBeReadable()
        {
            var qrCode   = PPay.DynamicQR.CreateBillPaymentQrCode();
            var actual   = sut.Read(qrCode);
            var expected = new QrInfo()
                           .InitializeDefault(staticQr: false)
                           .SetPlainBillPayment();

            actual.ValidateWith(expected);
        }
Exemplo n.º 4
0
        public void DefaultStaticCreditTransferQRMustBeReadable()
        {
            var qrCode   = PPay.StaticQR.CreateCreditTransferQrCode();
            var actual   = sut.Read(qrCode);
            var expected = new QrInfo()
                           .InitializeDefault()
                           .SetPlainCreditTransfer();

            actual.ValidateWith(expected);
        }
Exemplo n.º 5
0
        public static QrInfo InitializeDefault(this QrInfo qr, bool staticQr = true, CurrencyCode currency = CurrencyCode.THB, string country = "TH")
        {
            var PointOfInitiationMethod = staticQr ? emv.Static : emv.Dynamic;

            qr.Segments.Add(new QrDataObject("000201"));
            qr.Segments.Add(new QrDataObject($"0102{PointOfInitiationMethod}"));
            qr.Segments.Add(new QrDataObject($"5303{((int)currency).ToString("000")}"));
            qr.Segments.Add(new QrDataObject($"5802{country}"));
            return(qr);
        }
Exemplo n.º 6
0
        public void DefaultStaticBillPaymentQRMustBeReadable()
        {
            var qrCode   = PPay.StaticQR.GetBillPaymentQR();
            var actual   = sut.Read(qrCode);
            var expected = new QrInfo()
                           .InitializeDefault()
                           .SetPlanBillPayment();

            actual.ValidateWith(expected);
        }
Exemplo n.º 7
0
        public void DefaultDynamicCreditTransferQRMustBeReadable()
        {
            var qrCode   = PPay.DynamicQR.GetCreditTransferQR();
            var actual   = sut.Read(qrCode);
            var expected = new QrInfo()
                           .InitializeDefault(staticQr: false)
                           .SetPlanCreditTransfer();

            actual.ValidateWith(expected);
        }
Exemplo n.º 8
0
 public static IQrInfo SetPlainBillPayment(this QrInfo qr)
 {
     qr.Segments.Add(new QrDataObject("30200016A000000677010112"));
     qr.BillPayment = new BillPayment();
     return(qr);
 }
Exemplo n.º 9
0
 public static QrInfo SetPlanCreditTransfer(this QrInfo qr)
 {
     qr.Segments.Add(new QrDataObject("29200016A000000677010111"));
     qr.CreditTransfer = new CreditTransfer(true);
     return(qr);
 }