Ejemplo n.º 1
0
        public VisaOptions(string apiKey, decimal subTotal, CurrencyCodes currencyCode, OnOptions on)
        {
            InitOptions = new InitOptions
            {
                ApiKey         = apiKey,
                PaymentRequest = new PaymentRequestOptions
                {
                    CurrencyCode = currencyCode,
                    Subtotal     = subTotal
                }
            };

            On = on;

            ButtonOptions = new ButtonOptions();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the options HTML.
        /// </summary>
        /// <returns></returns>
        public string GetOptionString()
        {
            if (InitOptions == null)
            {
                throw new ArgumentNullException("InitOptions cannot be null");
            }

            if (ButtonOptions == null)
            {
                throw new ArgumentNullException("ButtonOptions cannot be null");
            }

            if (On == null)
            {
                throw new ArgumentNullException("On event handlers cannot be null");
            }

            StringBuilder sb  = new StringBuilder();
            TagBuilder    tag = new TagBuilder("script");

            tag.Attributes.Add("type", "text/javascript");
            tag.InnerHtml = string.Format("function onVisaCheckoutReady(){{{0}{1}}}", InitOptions.GetOptionString(), On.GetOptionString());

            sb.Append(tag.ToString()).Append("\r\n");

            tag = new TagBuilder("div");
            tag.Attributes.Add("class", "v-checkout-wrapper");
            tag.InnerHtml = string.Format("{0}\r\n{1}", ButtonOptions.GetOptionString(), TellMeMoreLinkOptions == null ? "" : TellMeMoreLinkOptions.GetOptionString());

            sb.Append(tag.ToString());

            tag = new TagBuilder("script");
            tag.Attributes.Add("type", "text/javascript");
            tag.Attributes.Add("src", Environment.IsSandbox ? SandboxSdkUrl : ProductionSdkUrl);

            sb.Append(tag.ToString());

            return(sb.ToString());
        }