internal override void WriteXml(XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("billing_info"); // Start: billing_info

            //if a recurly js token is supplied we don't want to send billing info here
            if (string.IsNullOrEmpty(TokenId))
            {
                xmlWriter.WriteStringIfValid("first_name", FirstName);
                xmlWriter.WriteStringIfValid("last_name", LastName);
                xmlWriter.WriteStringIfValid("name_on_account", NameOnAccount);
                xmlWriter.WriteStringIfValid("address1", Address1);
                xmlWriter.WriteStringIfValid("address2", Address2);
                xmlWriter.WriteStringIfValid("city", City);
                xmlWriter.WriteStringIfValid("state", State);
                xmlWriter.WriteStringIfValid("zip", PostalCode);
                xmlWriter.WriteStringIfValid("country", Country);
                xmlWriter.WriteStringIfValid("phone", PhoneNumber);
                xmlWriter.WriteStringIfValid("vat_number", VatNumber);
                xmlWriter.WriteStringIfValid("currency", Currency);

                if (!IpAddress.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("ip_address", IpAddress);
                }
                else
                {
                    Debug.WriteLine("Recurly Client Library: Recording IP Address is strongly recommended.");
                }

                if (!CreditCardNumber.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("number", CreditCardNumber);
                    xmlWriter.WriteElementString("month", ExpirationMonth.AsString());
                    xmlWriter.WriteElementString("year", ExpirationYear.AsString());

                    xmlWriter.WriteStringIfValid("verification_value", VerificationValue);
                }

                if (!AccountNumber.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("routing_number", RoutingNumber);
                    xmlWriter.WriteElementString("account_number", AccountNumber);
                    xmlWriter.WriteElementString("account_type", AccountType.ToString().EnumNameToTransportCase());
                }

                if (!PaypalBillingAgreementId.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("paypal_billing_agreement_id", PaypalBillingAgreementId);
                }

                if (!AmazonBillingAgreementId.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("amazon_billing_agreement_id", AmazonBillingAgreementId);
                }
            }

            xmlWriter.WriteStringIfValid("token_id", TokenId);

            xmlWriter.WriteEndElement(); // End: billing_info
        }
Ejemplo n.º 2
0
        public override IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (UserName.IsNullOrEmpty())
            {
                yield return(new ValidationResult(Messages.EmailIsRequired, new[] { nameof(UserName) }));
            }

            if (validationContext.ObjectInstance != null &&
                ValidateContextCreate.Equals(validationContext.ObjectInstance.ToString()))
            {
                if (IpAddress.IsNullOrEmpty())
                {
                    yield return(new ValidationResult(Messages.IpAddressRequired, new[] { nameof(IpAddress) }));
                }

                if (ServerPath.IsNullOrEmpty())
                {
                    yield return(new ValidationResult(Messages.ServerPathRequired, new[] { nameof(ServerPath) }));
                }
            }
        }
Ejemplo n.º 3
0
        internal override void WriteXml(XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("billing_info"); // Start: billing_info
            xmlWriter.WriteStringIfValid("first_name", FirstName);
            xmlWriter.WriteStringIfValid("last_name", LastName);
            xmlWriter.WriteStringIfValid("address1", Address1);
            xmlWriter.WriteStringIfValid("address2", Address2);
            xmlWriter.WriteStringIfValid("city", City);
            xmlWriter.WriteStringIfValid("state", State);
            xmlWriter.WriteStringIfValid("zip", PostalCode);
            xmlWriter.WriteStringIfValid("country", Country);
            xmlWriter.WriteStringIfValid("phone", PhoneNumber);

            xmlWriter.WriteStringIfValid("vat_number", VatNumber);

            if (!IpAddress.IsNullOrEmpty())
            {
                xmlWriter.WriteElementString("ip_address", IpAddress);
            }
            else
            {
                Debug.WriteLine("Recurly Client Library: Recording IP Address is strongly recommended.");
            }

            if (!CreditCardNumber.IsNullOrEmpty())
            {
                xmlWriter.WriteElementString("number", CreditCardNumber);
                xmlWriter.WriteElementString("month", ExpirationMonth.AsString());
                xmlWriter.WriteElementString("year", ExpirationYear.AsString());

                xmlWriter.WriteStringIfValid("verification_value", VerificationValue);
            }

            xmlWriter.WriteStringIfValid("token_id", TokenId);

            xmlWriter.WriteEndElement(); // End: billing_info
        }
Ejemplo n.º 4
0
        public override IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            if (UserName.IsNullOrEmpty())
            {
                yield return(new ValidationResult(Messages.EmailIsRequired, new[] { nameof(UserName) }));
            }

            if (!ValidateContextCreate.Equals(validationContext?.ObjectInstance?.ToString(),
                                              System.StringComparison.Ordinal))
            {
                yield break;
            }


            if (IpAddress.IsNullOrEmpty())
            {
                yield return(new ValidationResult(Messages.IpAddressRequired, new[] { nameof(IpAddress) }));
            }

            if (ServerPath.IsNullOrEmpty())
            {
                yield return(new ValidationResult(Messages.ServerPathRequired, new[] { nameof(ServerPath) }));
            }
        }
Ejemplo n.º 5
0
        internal override void WriteXml(XmlTextWriter xmlWriter)
        {
            xmlWriter.WriteStartElement("billing_info"); // Start: billing_info

            //if a recurly js token is supplied we don't want to send billing info here
            if (string.IsNullOrEmpty(TokenId))
            {
                xmlWriter.WriteStringIfValid("first_name", FirstName);
                xmlWriter.WriteStringIfValid("last_name", LastName);
                xmlWriter.WriteStringIfValid("company", Company);
                xmlWriter.WriteStringIfValid("name_on_account", NameOnAccount);
                xmlWriter.WriteStringIfValid("address1", Address1);
                xmlWriter.WriteStringIfValid("address2", Address2);
                xmlWriter.WriteStringIfValid("city", City);
                xmlWriter.WriteStringIfValid("state", State);
                xmlWriter.WriteStringIfValid("zip", PostalCode);
                xmlWriter.WriteStringIfValid("country", Country);
                xmlWriter.WriteStringIfValid("phone", PhoneNumber);
                xmlWriter.WriteStringIfValid("vat_number", VatNumber);
                xmlWriter.WriteStringIfValid("currency", Currency);

                if (!IpAddress.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("ip_address", IpAddress);
                }
                else
                {
                    Debug.WriteLine("Recurly Client Library: Recording IP Address is strongly recommended.");
                }

                if (!CreditCardNumber.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("number", CreditCardNumber);
                    xmlWriter.WriteElementString("month", ExpirationMonth.AsString());
                    xmlWriter.WriteElementString("year", ExpirationYear.AsString());

                    xmlWriter.WriteStringIfValid("verification_value", VerificationValue);
                }

                if (!AccountNumber.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("routing_number", RoutingNumber);
                    xmlWriter.WriteElementString("account_number", AccountNumber);
                    xmlWriter.WriteElementString("account_type", AccountType.ToString().EnumNameToTransportCase());
                }

                if (!PaypalBillingAgreementId.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("paypal_billing_agreement_id", PaypalBillingAgreementId);
                }

                if (!AmazonBillingAgreementId.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("amazon_billing_agreement_id", AmazonBillingAgreementId);
                }

                if (!AmazonRegion.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("amazon_region", AmazonRegion);
                }

                if (ExternalHppType.HasValue)
                {
                    xmlWriter.WriteElementString("external_hpp_type", ExternalHppType.Value.ToString().EnumNameToTransportCase());
                }

                if (!GatewayCode.IsNullOrEmpty())
                {
                    xmlWriter.WriteElementString("gateway_code", GatewayCode);
                    xmlWriter.WriteElementString("gateway_token", GatewayToken);

                    // EnumNameToTransportCase() turns MasterCard into "master_card",
                    // but it needs to be "master" for the server to accept it.
                    // Check for this edge case before writing the card_type tag.
                    var card = CardType.ToString().EnumNameToTransportCase();
                    if (card == "master_card")
                    {
                        card = "master";
                    }

                    xmlWriter.WriteElementString("card_type", card);
                }
            }

            xmlWriter.WriteStringIfValid("token_id", TokenId);

            xmlWriter.WriteEndElement(); // End: billing_info
        }