/// <summary> /// Retrieves the list of prices of the provided instrument names /// http://developer.oanda.com/rest-live-v20/pricing-ep/ /// </summary> /// <param name="account">the account to retrieve the list for</param> /// <param name="instruments">the instruments to retrieve prices for</param> /// <param name="requestParams">optional additional parameters for the request (name, value pairs)</param> /// <returns>List of Price objects (or empty list, if no orders)</returns> public static async Task <List <Price> > GetPriceListAsync(string account, List <string> instruments, Dictionary <string, string> requestParams = null) { string requestString = Server(EServer.Account) + "accounts/" + account + "/pricing"; // instruments should only be in the list if (requestParams != null) { if (requestParams.Count > 0) { if (requestParams.ContainsKey("instruments")) { requestParams.Remove("instruments"); } } } if (instruments == null) { throw new ArgumentException("List of instruments cannot be null."); } string instrumentsParam = GetCommaSeparatedList(instruments); requestString += "?instruments=" + Uri.EscapeDataString(instrumentsParam); PricingResponse response = await MakeRequestAsync <PricingResponse>(requestString, "GET", requestParams); var prices = new List <Price>(); prices.AddRange(response.prices); return(prices); }
public async Task <IActionResult> CreateInvoice(PurchaseForm purchaseForm) { purchaseForm.PersonalInformation.Email = User.Identity.IsAuthenticated ? User.Identity.Name : purchaseForm.PersonalInformation.Email; purchaseForm = LolModelExtenstion.AssignModel(purchaseForm, TempData["OrderModel"].ToString()); //recheck price because they could edit the request PricingResponse Pricing = ValidatePricing(purchaseForm); purchaseForm.Pricing = Pricing.Price.ToString(); purchaseForm.Discount = Pricing.DiscountModel; if (User.Identity.IsAuthenticated) { var user = await _userManager.FindByEmailAsync(User.Identity.Name); purchaseForm.ClientAssignedTo = user; } //validation string validationResult = ValidatePaymentInformation(purchaseForm); if (!string.IsNullOrEmpty(validationResult)) { TempData.Put("purchaseForm", purchaseForm); TempData["validationResult"] = validationResult; return(RedirectToAction("Details", "Invoice", new { data = EncryptionHelper.Encrypt(purchaseForm.PurchaseType.ToString()), dest = EncryptionHelper.Encrypt("LolBoosting") })); } if (purchaseForm.PersonalInformation.PaymentMethod == "Paypal") { var paypalResult = PayPalV2.createOrder(Pricing.Price.ToString()); purchaseForm.PayPalApproval = paypalResult.ApprovalURL; purchaseForm.PayPalCapture = paypalResult.CaptureURL; TempData.Put("purchaseForm", purchaseForm); return(Redirect(paypalResult.ApprovalURL)); } else { try { var result = StripePayments.StripePaymentsForm(purchaseForm.PersonalInformation.Email, purchaseForm.PersonalInformation.stripeToken, Pricing.Price.ToString()); if (result.Status == "succeeded" && result.Paid) { TempData.Put("purchaseForm", purchaseForm); return(RedirectToAction("InvoiceComplete", "Invoice")); } } catch (Exception e) { TempData["StripePayment"] = "Stripe Payment has failed, please check your details and try again"; return(RedirectToAction("soloboosting", "lolboosting")); } //something went wrong return(View()); } }
private static void TestObject(PricingResponse pricingResponse) { Assert.AreEqual(pricingResponse.Status, "0"); Assert.AreEqual(pricingResponse.Destinations.Count, 25); Assert.AreEqual(pricingResponse.Destinations[0].Country, "Default"); Assert.AreEqual(pricingResponse.Destinations[0].Operator, "Default"); Assert.AreEqual(pricingResponse.Destinations[0].Mcc, "Default"); Assert.AreEqual(pricingResponse.Destinations[0].Mnc, "Default"); Assert.AreEqual(pricingResponse.Destinations[0].Price, "2.0000"); Assert.AreEqual(pricingResponse.Destinations[0].Currency, "MYR"); }
public IActionResult CreateLolOrder(PurchaseForm purchaseForm) { //recheck price because they could edit the request PricingResponse Pricing = JsonConvert.DeserializeObject <PricingResponse>(JsonConvert.SerializeObject(PricingController.SoloPricing(purchaseForm).Value)); purchaseForm.Pricing = Pricing.Price.ToString(); purchaseForm.Discount = Pricing.DiscountModel; if (purchaseForm.PersonalInformation.PaymentMethod == "Paypal") { var paypalResult = PayPalV2.createOrder(Pricing.Price.ToString()); purchaseForm.PayPalApproval = paypalResult.ApprovalURL; purchaseForm.PayPalCapture = paypalResult.CaptureURL; TempData["purchaseFormlData"] = JsonConvert.SerializeObject(purchaseForm); return(Redirect(paypalResult.ApprovalURL)); } else { try { string email = string.Empty; if (User.Identity.IsAuthenticated) { email = User.Identity.Name; } else { email = purchaseForm.PersonalInformation.Email; } var result = StripePayments.StripePaymentsForm(email, purchaseForm.PersonalInformation.stripeToken, Pricing.Price.ToString()); if (result.Status == "succeeded" && result.Paid) { TempData["purchaseFormlData"] = JsonConvert.SerializeObject(purchaseForm); return(RedirectToAction("PurchaseQuote", "Quote")); } } catch (Exception e) { TempData["StripePayment"] = "Stripe Payment has failed, please check your details and try again"; return(RedirectToAction("soloboosting", "lolboosting")); } //something went wrong return(View()); } }
public IActionResult CreateDuo(Models.BoostingModel BoostingModel, Models.PersonalInformation PersonalInformation) { PurchaseForm purchaseForm = new PurchaseForm { BoostingModel = BoostingModel, PersonalInformation = PersonalInformation }; PricingResponse Pricing = JsonConvert.DeserializeObject <PricingResponse>(JsonConvert.SerializeObject(PricingController.DuoPricing(purchaseForm).Value)); purchaseForm.Pricing = Pricing.Price; purchaseForm.Discount = Pricing.DiscountModel; purchaseForm.PurchaseType = PurchaseType.DuoBoosting; if (PersonalInformation.PaymentMethod == "Paypal") { var paypalResult = PayPalV2.createOrder(Pricing.Price.ToString()); purchaseForm.PayPalApproval = paypalResult.ApprovalURL; purchaseForm.PayPalCapture = paypalResult.CaptureURL; TempData["purchaseFormlData"] = JsonConvert.SerializeObject(purchaseForm); return(Redirect(paypalResult.ApprovalURL)); } else { try { var result = StripePayments.StripePaymentsForm(PersonalInformation, Pricing.Price.ToString()); if (result.Status == "succeeded" && result.Paid) { TempData["purchaseFormlData"] = JsonConvert.SerializeObject(purchaseForm); return(RedirectToAction("PurchaseQuote", "Quote")); } } catch (Exception e) { TempData["StripePayment"] = "Stripe Payment has failed, please check your details and try again"; return(RedirectToAction("duoboosting", "lolboosting")); } //something went wrong return(View()); } }
public async Task Test_Pricing_request__Correct_response(object input) { // Prepare PricingRequest request = (PricingRequest)input; // Pre-validate Assert.NotNull(request); // Perform PricingResponse response = await _adapter.GetPriceDetails(request); // Post-validate Assert.NotNull(response); Assert.Equal(request.Header.DistributorId, response.Header.DistributorId); Assert.True(!string.IsNullOrWhiteSpace(response.Header.ExternalOrderNumber)); if (!string.IsNullOrWhiteSpace(request.Header.ExternalOrderNumber)) { Assert.Equal(request.Header.ExternalOrderNumber, response.Header.ExternalOrderNumber); } Assert.Equal(request.Lines.Length, response.Lines.Length); Assert.True(response.Header.TotalDue > 0); Assert.True(response.Header.VolumePoints > 0); }