Example #1
0
        internal virtual void MapResponseValues(JsonDoc doc)
        {
            TotalCount = doc.GetValue <int>("total_count");

            MerchantId   = doc.GetValue <string>("merchant_id");
            MerchantName = doc.GetValue <string>("merchant_name");
            AccountId    = doc.GetValue <string>("account_id");
            AccountName  = doc.GetValue <string>("account_name");
            if (!string.IsNullOrEmpty(ResultsField))
            {
                RawResults = doc.GetEnumerator(ResultsField) as List <JsonDoc>;
            }
        }
Example #2
0
 internal virtual void MapResponseValues(JsonDoc doc)
 {
     TotalRecords = doc.GetValue <int>("TotalRecords");
     RawResults   = doc.GetEnumerator("Results") as List <JsonDoc>;
     Timestamp    = doc.GetValue <DateTime?>("Timestamp", (input) => {
         if (input != null)
         {
             return(DateTime.Parse(input.ToString()));
         }
         return(null);
     });
     StatusCode      = doc.GetValue <int>("StatusCode");
     ResponseMessage = doc.GetValue <string>("ResponseMessage");
 }
Example #3
0
        protected override void MapResponse(JsonDoc response)
        {
            base.MapResponse(response);

            Assignments = new ShiftAssignments();

            // if we have a row, then it's an array
            if (response.Has("row"))
            {
                foreach (var row in response.GetEnumerator("row"))
                {
                    AddAssignment(row);
                }
            }
            else
            {
                AddAssignment(response);
            }
        }
Example #4
0
        private Customer HydrateCustomer(JsonDoc response)
        {
            var customer = new Customer {
                Key         = response.GetValue <string>("customerKey"),
                Id          = response.GetValue <string>("customerIdentifier"),
                FirstName   = response.GetValue <string>("firstName"),
                LastName    = response.GetValue <string>("lastName"),
                Company     = response.GetValue <string>("company"),
                Status      = response.GetValue <string>("customerStatus"),
                Title       = response.GetValue <string>("title"),
                Department  = response.GetValue <string>("department"),
                Email       = response.GetValue <string>("primaryEmail"),
                HomePhone   = response.GetValue <string>("phoneDay"),
                WorkPhone   = response.GetValue <string>("phoneEvening"),
                MobilePhone = response.GetValue <string>("phoneMobile"),
                Fax         = response.GetValue <string>("fax"),
                Address     = new Address {
                    StreetAddress1 = response.GetValue <string>("addressLine1"),
                    StreetAddress2 = response.GetValue <string>("addressLine2"),
                    City           = response.GetValue <string>("city"),
                    Province       = response.GetValue <string>("stateProvince"),
                    PostalCode     = response.GetValue <string>("zipPostalCode"),
                    Country        = response.GetValue <string>("country")
                }
            };

            if (response.Has("paymentMethods"))
            {
                customer.PaymentMethods = new List <RecurringPaymentMethod>();
                foreach (JsonDoc paymentResponse in response.GetEnumerator("paymentMethods"))
                {
                    var paymentMethod = HydratePaymentMethod(paymentResponse);
                    if (paymentMethod != null)
                    {
                        customer.PaymentMethods.Add(paymentMethod);
                    }
                }
            }

            return(customer);
        }
        internal override void FromJson(JsonDoc doc, PayrollEncoder encoder)
        {
            base.FromJson(doc, encoder);

            if (Description == null)
            {
                Description = doc.GetValue <string>("LaborFieldTitle");
            }

            if (doc.Has("laborfieldLookups"))
            {
                Lookup = new List <LaborFieldLookup>();
                foreach (var lookup in doc.GetEnumerator("laborfieldLookups"))
                {
                    Lookup.Add(new LaborFieldLookup {
                        Description = lookup.GetValue <string>("laborFieldDescription"),
                        Value       = lookup.GetValue <string>("laborFieldValue")
                    });
                }
            }
        }
Example #6
0
        private Transaction MapResponse(string rawResponse)
        {
            JsonDoc doc = JsonDoc.Parse(rawResponse);

            ThreeDSecure secureEcom = new ThreeDSecure();

            // check enrolled
            secureEcom.ServerTransactionId = doc.GetValue <string>("server_trans_id");
            if (doc.Has("enrolled"))
            {
                secureEcom.Enrolled = doc.GetValue <string>("enrolled");
            }
            secureEcom.IssuerAcsUrl = doc.GetValue <string>("method_url", "challenge_request_url");

            // get authentication data
            secureEcom.AcsTransactionId             = doc.GetValue <string>("acs_trans_id");
            secureEcom.DirectoryServerTransactionId = doc.GetValue <string>("ds_trans_id");
            secureEcom.AuthenticationType           = doc.GetValue <string>("authentication_type");
            secureEcom.AuthenticationValue          = doc.GetValue <string>("authentication_value");
            secureEcom.Eci                        = doc.GetValue <int>("eci");
            secureEcom.Status                     = doc.GetValue <string>("status");
            secureEcom.StatusReason               = doc.GetValue <string>("status_reason");
            secureEcom.AuthenticationSource       = doc.GetValue <string>("authentication_source");
            secureEcom.MessageCategory            = doc.GetValue <string>("message_category");
            secureEcom.MessageVersion             = doc.GetValue <string>("message_version");
            secureEcom.AcsInfoIndicator           = doc.GetArray <string>("acs_info_indicator");
            secureEcom.DecoupledResponseIndicator = doc.GetValue <string>("decoupled_response_indicator");
            secureEcom.WhitelistStatus            = doc.GetValue <string>("whitelist_status");
            secureEcom.ExemptReason               = doc.GetValue <string>("eos_reason");
            if (secureEcom.ExemptReason == ExemptReason.APPLY_EXEMPTION.ToString())
            {
                secureEcom.ExemptStatus = ExemptStatus.TRANSACTION_RISK_ANALYSIS;
            }

            // challenge mandated
            if (doc.Has("challenge_mandated"))
            {
                secureEcom.ChallengeMandated = doc.GetValue <bool>("challenge_mandated");
            }

            // initiate authentication
            secureEcom.CardHolderResponseInfo = doc.GetValue <string>("cardholder_response_info");

            // device_render_options
            if (doc.Has("device_render_options"))
            {
                JsonDoc renderOptions = doc.Get("device_render_options");
                secureEcom.SdkInterface = renderOptions.GetValue <string>("sdk_interface");
                secureEcom.SdkUiType    = renderOptions.GetArray <string>("sdk_ui_type");
            }

            // message_extension
            if (doc.Has("message_extension"))
            {
                secureEcom.MessageExtensions = new List <MessageExtension>();
                foreach (JsonDoc messageExtension in doc.GetEnumerator("message_extension"))
                {
                    MessageExtension msgExtension = new MessageExtension
                    {
                        CriticalityIndicator = messageExtension.GetValue <string>("criticality_indicator"),
                        MessageExtensionData = messageExtension.GetValue <JsonDoc>("data")?.ToString(),
                        MessageExtensionId   = messageExtension.GetValue <string>("id"),
                        MessageExtensionName = messageExtension.GetValue <string>("name")
                    };
                    secureEcom.MessageExtensions.Add(msgExtension);
                }
            }

            // versions
            secureEcom.DirectoryServerEndVersion   = doc.GetValue <string>("ds_protocol_version_end");
            secureEcom.DirectoryServerStartVersion = doc.GetValue <string>("ds_protocol_version_start");
            secureEcom.AcsEndVersion   = doc.GetValue <string>("acs_protocol_version_end");
            secureEcom.AcsStartVersion = doc.GetValue <string>("acs_protocol_version_start");

            // payer authentication request
            if (doc.Has("method_data"))
            {
                JsonDoc methodData = doc.Get("method_data");
                secureEcom.PayerAuthenticationRequest = methodData.GetValue <string>("encoded_method_data");
            }
            else if (doc.Has("encoded_creq"))
            {
                secureEcom.PayerAuthenticationRequest = doc.GetValue <string>("encoded_creq");
            }

            Transaction response = new Transaction {
                ThreeDSecure = secureEcom
            };

            return(response);
        }