public void MicrosoftPaymentMethodDataInitsWithNoArgs() { var msPaymentMethodData = new MicrosoftPayMethodData(); Assert.NotNull(msPaymentMethodData); Assert.IsType <MicrosoftPayMethodData>(msPaymentMethodData); }
public void ConvertsToPaymentMethodData() { var msPaymentMethodData = new MicrosoftPayMethodData(); var convertedPaymentMethodData = msPaymentMethodData.ToPaymentMethodData(); Assert.NotNull(convertedPaymentMethodData); Assert.IsType <PaymentMethodData>(convertedPaymentMethodData); var supportMethods = convertedPaymentMethodData.SupportedMethods; Assert.IsType <List <string> >(supportMethods); Assert.True(supportMethods.Contains("https://pay.microsoft.com/microsoftpay")); Assert.Equal(msPaymentMethodData, convertedPaymentMethodData.Data); }
public void MicrosoftPaymentMethodDataInitsWithTestMode(bool testMode, string expectedModeValue) { var merchantId = "bestMerchant123"; var supportedNetworks = new List <string>() { "networkA", "networkB" }; var supportedTypes = new List <string>() { "credit", "debit" }; var msPaymentMethodData = new MicrosoftPayMethodData(merchantId, supportedNetworks, supportedTypes, testMode); Assert.NotNull(msPaymentMethodData); Assert.IsType <MicrosoftPayMethodData>(msPaymentMethodData); Assert.Equal(merchantId, msPaymentMethodData.MerchantId); Assert.Equal(supportedNetworks, msPaymentMethodData.SupportedNetworks); Assert.Equal(supportedTypes, msPaymentMethodData.SupportedTypes); Assert.Equal(expectedModeValue, msPaymentMethodData.Mode); }
private static PaymentRequest BuildPaymentRequest(string cartId, CatalogItem item, MicrosoftPayMethodData methodData) { return(new PaymentRequest { Id = cartId, Expires = TimeSpan.FromDays(1).ToString(), MethodData = new List <PaymentMethodData> { methodData.ToPaymentMethodData() }, Details = new PaymentDetails { Total = new PaymentItem { Label = Resources.Wallet_Label_Total, Amount = new PaymentCurrencyAmount { Currency = item.Currency, Value = Convert.ToString(item.Price, CultureInfo.InvariantCulture) }, Pending = true }, DisplayItems = new List <PaymentItem> { new PaymentItem { Label = item.Title, Amount = new PaymentCurrencyAmount { Currency = item.Currency, Value = item.Price.ToString(CultureInfo.InvariantCulture) } }, new PaymentItem { Label = Resources.Wallet_Label_Shipping, Amount = new PaymentCurrencyAmount { Currency = item.Currency, Value = "0.00" }, Pending = true }, new PaymentItem { Label = Resources.Wallet_Label_Tax, Amount = new PaymentCurrencyAmount { Currency = item.Currency, Value = "0.00" }, Pending = true } } }, Options = new PaymentOptions { RequestShipping = true, RequestPayerEmail = true, RequestPayerName = true, RequestPayerPhone = true, ShippingType = PaymentShippingTypes.Shipping } }); }