public ActionResult GetPaymentMethods() { int id = 0; Int32.TryParse(Request.Form["productId"], out id); Product product = db.Products.First(m => m.ID == (id)); if (product != null) { PriceSetting ps = new PriceSetting(product.PriceSettingId); string locale = Request.Form["language"] + "-" + Request.Form["country"]; ps.LOCALE = locale; PaymentMethodResponse paymentObject = ps.ListPaymentMethods(); if (paymentObject.RESPONSE.ContainsKey("error")) { return(Json(new { success = false, message = "Error" }, JsonRequestBehavior.AllowGet)); } else { List <Hashtable> paymentMethods = paymentObject.PaymentMethods(); return(PartialView("_PaymentMethodButtons", paymentMethods)); } } else { return(Json(new { success = false, message = "Error" }, JsonRequestBehavior.AllowGet)); } }
public async Task DoNotRetrievePricingWhenIncludeIsNull() { // When: retrieving the ideal method with the include parameter set to null PaymentMethodResponse paymentMethod = await this._paymentMethodClient.GetPaymentMethodAsync(PaymentMethod.Ideal, includePricing : null); // Then: Issuers should not be included Assert.IsNull(paymentMethod.Pricing); }
public async Task DoNotRetrieveIssuersWhenIncludeIsFalse() { // When: retrieving the ideal method with the include parameter set to false PaymentMethodResponse paymentMethod = await this._paymentMethodClient.GetPaymentMethodAsync(PaymentMethod.Ideal, false); // Then: Issuers should not be included Assert.IsNull(paymentMethod.Issuers); }
public void CanRetrievePaymentMethod(PaymentMethod paymentMethod) { // If: We request a payment method from the api PaymentMethodResponse paymentMethodResponse = this._paymentMethodClient.GetPaymentMethodAsync(paymentMethod).Result; // Then: Id should be equal to our enum Assert.IsNotNull(paymentMethodResponse); Assert.AreEqual(paymentMethod, paymentMethodResponse.Id); }
public async Task CanRetrievePricing() { // When: retrieving the ideal method we can include the issuers PaymentMethodResponse paymentMethod = await this._paymentMethodClient.GetPaymentMethodAsync(PaymentMethod.Ideal, includePricing : true); // Then: We should have one or multiple issuers Assert.IsNotNull(paymentMethod); Assert.IsTrue(paymentMethod.Pricing.Any()); }
public async Task CanRetrieveSinglePaymentMethod(PaymentMethod method) { // When: retrieving a payment method PaymentMethodResponse paymentMethod = await this._paymentMethodClient.GetPaymentMethodAsync(method); // Then: Make sure it can be retrieved Assert.IsNotNull(paymentMethod); Assert.IsNotNull(paymentMethod.Id); Assert.AreEqual(method, paymentMethod.Id); }
public async Task EnablePaymentMethodAsync_WhenEnablingPaymentMethodForCurrentProfile_PaymentMethodIsReturned() { // Given // When: We enable a payment method for the current profile PaymentMethodResponse paymentMethodResponse = await this._profileClient.EnablePaymentMethodAsync(PaymentMethod.CreditCard); // Then: Make sure a payment method is returned Assert.IsNotNull(paymentMethodResponse); Assert.AreEqual(PaymentMethod.CreditCard, paymentMethodResponse.Id); }
public void ListPaymentMethodsReturnsAllKnownPaymentMethods() { // If: We request all payment methods from the api ListResponse <PaymentMethodResponse> paymentMethodList = this._paymentMethodClient.GetPaymentMethodListAsync(0, 100).Result; Array paymentMethodEnumValues = Enum.GetValues(typeof(PaymentMethod)); // Then: Make sure the list of payment methods is the same as our PaymentMethod enum Assert.AreEqual(paymentMethodEnumValues.Length - 1, paymentMethodList.TotalCount); foreach (PaymentMethod paymentMethodEnum in paymentMethodEnumValues) { // We exlude direct debit for now, because it can't be tested in testmode anymore if (paymentMethodEnum != PaymentMethod.DirectDebit) { PaymentMethodResponse paymentResponse = paymentMethodList.Data.FirstOrDefault(x => x.Id == paymentMethodEnum); Assert.IsNotNull(paymentResponse); } } }
public async Task EnablePaymentMethodAsync_WhenEnablingPaymentMethodForProfile_PaymentMethodIsReturned() { // Given: We retrieve the profile from the API ProfileClient profileClient = new ProfileClient("abcde"); // Set access token ListResponse <ProfileResponse> allProfiles = await profileClient.GetProfileListAsync(); if (allProfiles.Items.Count == 0) { Assert.Inconclusive("No profiles found. Unable to continue test"); } ProfileResponse profileToTestWith = allProfiles.Items.First(); // When: We enable a payment method for the given profile PaymentMethodResponse paymentMethodResponse = await profileClient.EnablePaymentMethodAsync(profileToTestWith.Id, PaymentMethod.Ideal); // Then: Make sure a payment method is returned Assert.IsNotNull(paymentMethodResponse); Assert.AreEqual(PaymentMethod.Ideal, paymentMethodResponse.Id); }