Пример #1
0
        private void DecodeAccountInformation(ICollection <Tlv> tlvs, MerchantPayload merchantPayload)
        {
            var merchantAccountInfoTlvs = tlvs.Where(e => e.Tag >= 2 && e.Tag <= 51);

            if (merchantAccountInfoTlvs.Any())
            {
                merchantPayload.MerchantAccountInformation = new MerchantAccountInformationDictionary();
                foreach (var tlv in merchantAccountInfoTlvs)
                {
                    var accountInfo = new MerchantAccountInformation();
                    var globalUniqueIdentifierTlv = tlv.ChildNodes.FirstOrDefault(t => t.Tag == 0);
                    if (null != globalUniqueIdentifierTlv)
                    {
                        accountInfo.GlobalUniqueIdentifier = globalUniqueIdentifierTlv.Value;
                    }

                    var paymentNetworkSpecificTlvs = tlv.ChildNodes.Where(e => e.Tag >= 1 && e.Tag <= 99);
                    if (paymentNetworkSpecificTlvs.Any())
                    {
                        accountInfo.PaymentNetworkSpecific = new Dictionary <int, string>();
                        foreach (var item in paymentNetworkSpecificTlvs)
                        {
                            accountInfo.PaymentNetworkSpecific.Add(item.Tag, item.Value);
                        }
                    }

                    merchantPayload.MerchantAccountInformation.Add(tlv.Tag, accountInfo);
                }
            }
        }
Пример #2
0
        private void DecodeAccountInformation(ICollection <Tlv> tlvs, MerchantPayload merchantPayload)
        {
            var merchantAccountInfoTlvs = tlvs.Where(e => e.Tag >= 2 && e.Tag <= 51);

            if (merchantAccountInfoTlvs.Any())
            {
                merchantPayload.MerchantAccountInformation = new MerchantAccountInformationDictionary();
                foreach (var tlv in merchantAccountInfoTlvs)
                {
                    var accountInfo = new MerchantAccountInformation();

                    // Visa and MasterCard simply have card numbers in their reserved space (02 and 04 for example - Issue #2).
                    // If there are no child nodes, then the data for this tag is not a TLV string, we could probably assume it's the GlobalUniqueIdentifier since it's a required field.
                    if (!tlv.ChildNodes.Any())
                    {
                        accountInfo.GlobalUniqueIdentifier = tlv.Value;
                    }
                    else
                    {
                        var globalUniqueIdentifierTlv = tlv.ChildNodes.FirstOrDefault(t => t.Tag == 0);
                        if (null != globalUniqueIdentifierTlv)
                        {
                            accountInfo.GlobalUniqueIdentifier = globalUniqueIdentifierTlv.Value;

                            var paymentNetworkSpecificTlvs = tlv.ChildNodes.Where(e => e.Tag >= 1 && e.Tag <= 99);
                            if (paymentNetworkSpecificTlvs.Any())
                            {
                                accountInfo.PaymentNetworkSpecific = new Dictionary <int, string>();
                                foreach (var item in paymentNetworkSpecificTlvs)
                                {
                                    accountInfo.PaymentNetworkSpecific.Add(item.Tag, item.Value);
                                }
                            }
                        }
                    }

                    merchantPayload.MerchantAccountInformation.Add(tlv.Tag, accountInfo);
                }
            }
        }