Example #1
0
        public void GetHtmlNoOnOptionsTest()
        {
            IOptions options = new VisaOptions("apiKey", 21.21M, CurrencyCodes.USD, null);

            string result = options.GetOptionString();

            Assert.IsNull(result);
        }
Example #2
0
        public void GetHtmlNoPaymentRequestTest()
        {
            IOptions options = new VisaOptions("apiKey", 21.21M, CurrencyCodes.USD, OnOptions)
            {
                InitOptions = new InitOptions
                {
                    ApiKey         = "apiKey",
                    PaymentRequest = null
                }
            };

            string result = options.GetOptionString();

            Assert.IsNull(result);
        }
Example #3
0
        public void GetHtmlTest()
        {
            IOptions options = new VisaOptions("apiKey", 21.21M, CurrencyCodes.USD, OnOptions);

            string result = options.GetOptionString();

            Assert.IsNotNull(result);
            Assert.IsTrue(result.Contains("onVisaCheckoutReady(){"));
            Assert.IsTrue(result.Contains("<div class=\"v-checkout-wrapper\""));
            Assert.IsTrue(result.Contains("V.init({"));
            Assert.IsTrue(result.Contains("\"apikey\":\"apiKey\""));
            Assert.IsTrue(result.Contains("\"subtotal\":\"21.21\""));
            Assert.IsTrue(result.Contains("\"currencyCode\":\"USD\""));
            Assert.IsTrue(result.Contains("V.on"));
            Assert.IsTrue(result.Contains(VisaOptions.ProductionSdkUrl));
        }
 /// <summary>
 /// Write the Visa Checkout button and Javascript
 /// </summary>
 /// <param name="helper">The <see cref="HtmlHelper"/></param>
 /// <param name="options">The options for the Visa Checkout button and Javascript <see cref="VisaOptions"/></param>
 /// <returns>The <see cref="HtmlString"/> to render the button</returns>
 /// <exception cref="ArgumentNullException">Thrown when a required parameter is missing</exception>
 public static MvcHtmlString WriteVisaCheckoutLink(this HtmlHelper helper, VisaOptions options)
 {
     return(new MvcHtmlString(options.GetOptionString()));
 }