public void GetHtmlTest() { IOptions options = new PaymentRequestOptions(); string result = options.GetOptionString(); Assert.IsNotNull(result); Assert.IsTrue(result.Contains("\"paymentRequest\":{")); }
public void GetHtmlWithCustomDataTest() { IOptions options = new PaymentRequestOptions(); ((PaymentRequestOptions)options).CustomData.Add("test1", "value1"); ((PaymentRequestOptions)options).CustomData.Add("test2", "value2"); string result = options.GetOptionString(); Assert.IsNotNull(result); Assert.IsTrue(result.Contains("\"paymentRequest\":{")); Assert.IsTrue(result.Contains("\"customData\":{\"nvPair\":[{\"name\":\"test1\",\"value\":\"value1\"},{\"name\":\"test2\",\"value\":\"value2\"}]")); }
public void PaymentRequest_GivenValidConstructorArguments_FormatsListItemTaxToTwoPlaces() { //arrange var siteSettings = new SiteSetting(); var siteProfile = new SiteProfile(); //act var options = new PaymentRequestOptions(siteProfile, siteSettings, ConfigurationStubs.ProductionCheckoutUri); var sut = new PaymentRequest(CartViewStubs.Get(), options); var actual = sut.ItemList.items.FirstOrDefault()?.tax.Split('.')[1]; //assert Assert.Equal(2, actual?.Length); }
public void PaymentRequest_GivenValidConstructorArguments_FormatsTaxWithToDecimalPlaces() { //arrange var siteSettings = new SiteSetting(); var siteProfile = new SiteProfile(); //act var options = new PaymentRequestOptions(siteProfile, siteSettings, ConfigurationStubs.ProductionCheckoutUri); var sut = new PaymentRequest(CartViewStubs.Get(), options); var actual = sut.Tax.Split('.')[1]; //assert Assert.Equal(2, actual.Length); }
public void PaymentRequest_GivenAValidUri_SetsRedirectUrlCorrectly() { //arrange var siteSettings = new SiteSetting(); var siteProfile = new SiteProfile(); //act var options = new PaymentRequestOptions(siteProfile, siteSettings, ConfigurationStubs.ProductionCheckoutUri); var sut = new PaymentRequest(CartViewStubs.Get(), options); var actual = sut.ReturnUrl; //asserts Assert.Equal("https://bluetapecrew.com/checkoutreview", actual); }
public async Task <string> Start(string sessionId, Uri requestUri, bool isSandbox) { var settings = await _siteSettingsService.Get(); var profile = await _siteSettingsService.GetSiteProfile(); var cart = await _cartService.GetCartViewModel(sessionId); var paymentRequestOptions = new PaymentRequestOptions(profile, settings, requestUri, isSandbox); var paymentRequest = new PaymentRequest(cart.Items, paymentRequestOptions); var redirectUrl = _paypalService.PayWithPaypal(paymentRequest); return(redirectUrl); }
public void GetHtmlWithOptionsTest() { IOptions options = new PaymentRequestOptions { CurrencyCode = CurrencyCodes.USD, Subtotal = 21.21M }; string result = options.GetOptionString(); Assert.IsNotNull(result); Assert.IsTrue(result.Contains("\"paymentRequest\":{")); Assert.IsTrue(result.Contains("\"currencyCode\":\"USD\"")); Assert.IsTrue(result.Contains("\"subtotal\":\"21.21\"")); }
public async Task GetApiContext_GivenAPaymentRequestWithValidApiCredentials_ReturnsAnApiContextWithAValidRequestId() { //arrange var settings = await _settings.Get(); var profile = await _settings.GetSiteProfile(); var sut = _fixture.Resolve <IPaypalService>(); var options = new PaymentRequestOptions(profile, settings, _fixture.ProductionCheckoutUri); var paymentRequest = new PaymentRequest(CartViewStubs.Get(), options); //act var apiContext = sut.GetApiContext(paymentRequest); //assert Assert.Equal(36, apiContext.RequestId.Length); }
public async Task PaymentCreate_GivenAValidPaymentAndApiContext_ReturnsAValidCreatedPayment() { //arrange var settings = await _settings.Get(); var profile = await _settings.GetSiteProfile(); var sut = _fixture.Resolve <IPaypalService>(); var options = new PaymentRequestOptions(profile, settings, _fixture.ProductionCheckoutUri); var paymentRequest = new PaymentRequest(CartViewStubs.Get(), options); //act var apiContext = sut.GetApiContext(paymentRequest); var payment = sut.GetPayment(paymentRequest); var createdPayment = payment.Create(apiContext); //assert Assert.Equal("created", createdPayment.state); }