public string RequestToken() { var gateway = config.GetGateway(); var clientToken = gateway.ClientToken.Generate(); return(clientToken); }
public IHttpActionResult GetNew() { var gateway = _config.GetGateway(); var clientToken = gateway.ClientToken.generate(); return(Content(HttpStatusCode.OK, clientToken)); }
public string Get() { var gateway = _config.GetGateway(); var clientToken = gateway.ClientToken.generate(); return(clientToken); }
public object CreateToken() { var gateway = Config.GetGateway(); var clienttoken = gateway.ClientToken.Generate(); return(clienttoken); }
public object GenerateToken() { var gateway = _braintreeConfiguration.GetGateway(); var clientToken = gateway.ClientToken.Generate(); return(clientToken); }
/**********************************PAYPAL SECTION*********************************/ /// <summary> /// Method which returns a view to retrieve customers paypal payment details /// </summary> /// <returns>PayPalPaymentViewModel to the view</returns> public ActionResult PayPalPayment() { if (Session["ShippingDetails"] == null) { return RedirectToAction("ConfirmAddress"); } PayPalViewModel ppvm = new PayPalViewModel(); ppvm.Amount = Convert.ToDouble(Session["OrderAmount"]); ShippingDetails sd = (ShippingDetails)Session["ShippingDetails"]; //add on shipping cost if (sd.fastShipping == true) { ppvm.Amount += 3.50; } var gateway = config.GetGateway(); var clientToken = gateway.ClientToken.generate(); ViewBag.ClientToken = clientToken; return View(ppvm); }
public async Task<PaymentsTopicViewModel> GetViewModel(PaymentFormBindingModel bindingModel = null) { /*------------------------------------------------------------------------------------------------------------------------ | Establish variables \-----------------------------------------------------------------------------------------------------------------------*/ var braintreeGateway = _braintreeConfiguration.GetGateway(); var clientToken = braintreeGateway.ClientToken.Generate(); /*------------------------------------------------------------------------------------------------------------------------ | Establish view model \-----------------------------------------------------------------------------------------------------------------------*/ var viewModel = await _topicMappingService.MapAsync<PaymentsTopicViewModel>(CurrentTopic); viewModel.BindingModel = bindingModel; /*------------------------------------------------------------------------------------------------------------------------ | Pass client token to model \-----------------------------------------------------------------------------------------------------------------------*/ if (viewModel != null) { viewModel.ClientToken = clientToken; } /*------------------------------------------------------------------------------------------------------------------------ | Return topic view \-----------------------------------------------------------------------------------------------------------------------*/ return viewModel; }
public IActionResult GetClientToken() { var gateway = braintreeConfiguration.GetGateway(); var clientToken = gateway.ClientToken.Generate(); var clientTokenResponse = new ClientTokenResponse(clientToken); return(new JsonResult(clientTokenResponse)); }
public ActionResult New() { var gateway = Config.GetGateway(); var clientToken = gateway.ClientToken.Generate(); ViewBag.ClientToken = clientToken; return(View()); }
public ActionResult New(int?designId) { var gateway = config.GetGateway(); var clientToken = gateway.ClientToken.Generate(); ViewBag.ClientToken = clientToken; ViewBag.DesignId = designId.GetValueOrDefault(); return(View()); }
// GET: Payments public ActionResult Index() { var gateway = BraintreeConfiguration.GetGateway(); var clientToken = gateway.ClientToken.Generate(); ViewBag.ClientToken = clientToken; return(View()); }
public ActionResult checkout(string userid, string jobid) { var gateway = config.GetGateway(); var clientToken = gateway.ClientToken.generate(); ViewBag.ClientToken = clientToken; //Check for this jobid,userid,transaction Id status if (!string.IsNullOrEmpty(userid) && !string.IsNullOrEmpty(jobid)) { userid = EncrytDecrypt.passwordDecrypt(userid.ToString(), true); jobid = EncrytDecrypt.passwordDecrypt(jobid.ToString(), true); try { var table = new DataTable(); SqlConnection conn = new SqlConnection("Data source=148.72.232.166; Database=hardyhat;User Id=vineshnilesh888;Password=VineshNilesh88"); conn.Open(); SqlCommand cmd = new SqlCommand("select * from [vineshnilesh888].[tbl_JobPayment] where Fk_JobId=" + jobid + " and UserId='" + userid + "';", conn); // create data adapter SqlDataAdapter da = new SqlDataAdapter(cmd); // this will query your database and return the result to your datatable da.Fill(table); conn.Close(); da.Dispose(); if (table.Rows.Count == 0) { //insert into the job payment table...!!! Decimal companyFee = Convert.ToDecimal("2.00"); conn.Open(); SqlCommand cmdInsert = new SqlCommand("insert into [vineshnilesh888].[tbl_JobPayment] (Fk_JobId,UserId,Amount) values(" + jobid + ",'" + userid + "'," + companyFee + ");", conn); int id = cmdInsert.ExecuteNonQuery(); conn.Close(); string pk_paymentId = Convert.ToString(id); clsSession.paymentID = pk_paymentId; Console.WriteLine("Inserting Data Successfully"); } else if (Convert.ToString(table.Rows[0]["PaymentStatus"]) == "submitted_for_settlement") { return(RedirectToRoute("error-authorized")); } else { string pk_paymentId = Convert.ToString(table.Rows[0]["Pk_JobPaymentId"]); clsSession.paymentID = pk_paymentId; } } catch (Exception e) { } } else { return(RedirectToRoute("error-authorized")); } return(View()); }
public ActionResult PaymentDetails() { //Brain tree functionality that sets up a gateway and gets a client token which is returned var gateway = config.GetGateway(); var clientToken = gateway.ClientToken.generate(); ViewBag.ClientToken = clientToken; return(View()); }
public ActionResult New() { var gateway = config.GetGateway(); var clientToken = gateway.ClientToken.Generate( new ClientTokenRequest { CustomerId = "a68d1c1a-7c6c-46d3-9208-4fcf38727912" } ); ViewBag.ClientToken = clientToken; return(View()); }
public ActionResult PostNewJob() { // The viewBags will be used to display all the cuurent Location, job types and job sectors in the system ViewBag.LocationCategoryId = new SelectList(db.Locations, "LocationCategoryId", "LocationName"); ViewBag.JobSectorCategoryId = new SelectList(db.JobSectors, "JobSectorCategoryId", "SectorName"); ViewBag.JobTypeCategoryId = new SelectList(db.JobTypes, "JobTypeCategoryId", "JobTypeName"); // Derived from BrainTree tutorial - generating a unique client token var gateway = config.GetGateway(); var clientToken = gateway.ClientToken.generate(); ViewBag.ClientToken = clientToken; return(View()); }
/// <summary> /// Method which displays view which allows user to pay view paypal /// </summary> /// <returns>the paypal payment viewmodel to the view</returns> public ActionResult PayPalPayment() { string id = GetCurrentUser().Id; var fine = uow.FineRepository.Get(m => m.User.Id.Equals(id)); //create viewmodel and populate PayPalViewModel ppvm = new PayPalViewModel(); ppvm.Amount = Convert.ToDouble(fine.Amount); var gateway = config.GetGateway(); var clientToken = gateway.ClientToken.generate(); ViewBag.ClientToken = clientToken; return(View(ppvm)); }
protected async override Task Handle(DeletePaymentMethod request, CancellationToken cancellationToken) { var account = await _account.FindAccountByIdAsync(request.AccountId); var gateway = _braintreeConfiguration.GetGateway(); if (account.SubscriptionId == null) { gateway.PaymentMethod.Delete(request.PaymentMethodId); await _account.SaveChangesAsync(); } else { var currentSubscription = await gateway.Subscription.FindAsync(account.SubscriptionId); var planId = PlanTiers.ConvertPlanNameToInt(request.Plan); if (request.Plan != "Free") { account.PaymentMethodDeletedPlan = request.Plan; await _downgradeRepository.Add(request.AccountId, currentSubscription.BillingPeriodEndDate.GetValueOrDefault(), planId); } account.RemovePaymentMethodId(); gateway.PaymentMethod.Delete(request.PaymentMethodId); await _account.SaveChangesAsync(); } }
public async Task <bool> Handle(CreateSubscription request, CancellationToken cancellationToken) { var account = await _account.FindAccountByIdAsync(request.AccountId); if (account.HasSubscription()) { return(true); } var gateway = _braintreeConfiguration.GetGateway(); var planId = SubscriptionHelper.ConvertPlanToBrainTreeType(request.Plan); var subscriptionId = Guid.NewGuid().ToString(); var createSubscriptionRequest = new SubscriptionRequest { PaymentMethodToken = account.PaymentMethodId, PlanId = planId, Id = subscriptionId, }; var createSubscriptionResult = gateway.Subscription.Create(createSubscriptionRequest); if (createSubscriptionResult.IsSuccess()) { account.UpdateSubscriptionId(createSubscriptionRequest.Id); await _account.SaveChangesAsync(); return(true); } return(false); }
public async Task <bool> Handle(AddPayment request, CancellationToken cancellationToken) { var gateway = _braintreeConfiguration.GetGateway(); var account = await _account.FindAccountByIdAsync(request.AccountId); var customer = await gateway.Customer.FindAsync(account.CustomerId); var result = new PaymentMethodRequest() { CustomerId = customer.Id, PaymentMethodNonce = request.PaymentMethodNonce, Token = Guid.NewGuid().ToString() }; Result <PaymentMethod> response = await gateway.PaymentMethod.CreateAsync(result); account.PaymentMethodId = result.Token; if (response.IsSuccess()) { await _account.SaveChangesAsync(); return(true); } return(false); }
public HttpResponseMessage BraintreeRegisterClient() { if (Common.IsTokenAuthenticated(Request.Headers, ref _userId, ref _strJSONContent)) { var gateway = config.GetGateway(); var clientToken = gateway.ClientToken.Generate(); UserLoginVM _UserLoginVM = _userBLL.GetUserDetails(_userId); var request = new CustomerRequest { FirstName = _UserLoginVM.FirstName, LastName = _UserLoginVM.LastName, Company = "SHPOT", Email = _UserLoginVM.Email, Phone = _UserLoginVM.HeaderToken, Website = ConfigurationManager.AppSettings["APIURL"] }; Result <Customer> result = gateway.Customer.Create(request); bool success = result.IsSuccess(); if (success) { string customerId = result.Target.Id; _strJSONContent.Append("{\"ClientToken\":\"" + clientToken + "\","); _strJSONContent.Append("\"CustomerId\":\"" + customerId + "\"}"); _UserLoginVM.BrainTreeClientToken = clientToken; _UserLoginVM.BrainTreeCustomerID = customerId; _UserLoginVM = _userBLL.UpdateBrainTreeDetails(_UserLoginVM); } else { _strJSONContent.Append("{\"status\":\"Failed\"}"); } return(Common.ResponseOutput(_strJSONContent)); } else { return(Common.ResponseOutput(_strJSONContent)); } }
// GET api/cient_token public IHttpActionResult Get() { var gateway = config.GetGateway(); JsonResult jsonResult = new JsonResult(); jsonResult.client_token = gateway.ClientToken.generate(); return Ok(jsonResult); }
public async Task <bool> Handle(ChangeSubscription request, CancellationToken cancellationToken) { var account = await _account.FindAccountByIdAsync(request.AccountId); if (account.HasPaymentMethod()) { var gateway = _braintreeConfiguration.GetGateway(); var plans = await gateway.Plan.AllAsync(); var plan = (from p in plans where p.Name == request.Plan select p).FirstOrDefault(); var planId = SubscriptionHelper.ConvertPlanToBrainTreeType(request.Plan); var accountDiscount = await _accountDiscountRepository.GetUnredeemedDiscountByAccountIdAsync(request.AccountId); var updateSubscriptionRequest = new SubscriptionRequest { PaymentMethodToken = account.PaymentMethodId, PlanId = planId, Price = plan.Price, }; if (accountDiscount != null) { var discount = await _discountRepository.GetDiscountByIdAsync(accountDiscount.DiscountId); updateSubscriptionRequest.Discounts = new DiscountsRequest { Add = new AddDiscountRequest[] { new AddDiscountRequest { InheritedFromId = discount.Id.ToString(), Amount = DiscountCalculator.CalculateDiscount( price: plan.Price.GetValueOrDefault(), percentage: discount.Percentage), NumberOfBillingCycles = discount.BillingCycles } }, }; accountDiscount.ApplyDiscountToSubscription(); } var updateSubscriptionResult = await gateway.Subscription.UpdateAsync(account.SubscriptionId, updateSubscriptionRequest); if (updateSubscriptionResult.IsSuccess()) { await _accountDiscountRepository.SaveChangesAsync(); return(true); } } return(false); }
public async Task <IActionResult> Index(int?id) { Checkout checkout = new Checkout(); if (id == null) { return(NotFound()); } checkout.User = await _context.User .FirstOrDefaultAsync(m => m.Id == id); if (checkout.User == null) { return(NotFound()); } checkout.UserId = checkout.User.Id; ViewBag.ClientToken = _paymentConfig.GetGateway().ClientToken.Generate(); return(View(checkout)); }
public IActionResult Create(ProductPurchase model) { var gateway = config.GetGateway(); var request = new TransactionRequest { Amount = Convert.ToDecimal(60), PaymentMethodNonce = model.Nonce, Customer = new CustomerRequest //Adds customer since they have not booked before { FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, Phone = model.PhoneNumber, Id = model.userid }, Options = new TransactionOptionsRequest { SubmitForSettlement = true }, BillingAddress = new AddressRequest { FirstName = model.FirstName, LastName = model.LastName, StreetAddress = model.AddressLine1, ExtendedAddress = model.AddressLine2, Locality = model.City, PostalCode = model.PostCode }, }; //request.LineItems = cart.CartItems.Select(x => new Braintree.TransactionLineItemRequest //{ // Name = x.Product.Name, // Description = x.Product.Description, // ProductCode = x.ProductID.ToString(), // Quantity = x.Quantity, // UnitAmount = x.Product.Price, // TotalAmount = x.Product.Price * x.Quantity, // LineItemKind = Braintree.TransactionLineItemKind.DEBIT //}).ToArray(); Result <Transaction> result = gateway.Transaction.Sale(request); if (result.IsSuccess()) { //EmailDetails(newReservation).Wait(); return(View("Success")); } return(View("Failure")); }
public async Task<PaymentsTopicViewModel> GetViewModel(PaymentFormBindingModel bindingModel = null) { /*------------------------------------------------------------------------------------------------------------------------ | Establish variables \-----------------------------------------------------------------------------------------------------------------------*/ var braintreeGateway = _braintreeConfiguration.GetGateway(); var clientToken = braintreeGateway.ClientToken.Generate(); /*------------------------------------------------------------------------------------------------------------------------ | Establish view model \-----------------------------------------------------------------------------------------------------------------------*/ var viewModel = new PaymentsTopicViewModel { ClientToken = clientToken, BindingModel = bindingModel }; viewModel = (PaymentsTopicViewModel)await _topicMappingService.MapAsync(CurrentTopic, viewModel).ConfigureAwait(true); /*------------------------------------------------------------------------------------------------------------------------ | Return topic view \-----------------------------------------------------------------------------------------------------------------------*/ return viewModel; }
public async Task <CardInfoDto> Handle(GetPaymentMethod request, CancellationToken cancellationToken) { var gateway = _braintreeConfiguration.GetGateway(); var account = await _account.FindAccountByIdAsync(request.AccountId); if (account.HasPaymentMethod()) { CreditCard creditCard = (CreditCard)await gateway.PaymentMethod.FindAsync(account.PaymentMethodId); var creditCardInfo = new CardInfoDto() { CardType = creditCard.CardType.ToString(), ExpirationDate = creditCard.ExpirationDate, LastFourDigits = creditCard.LastFour }; return(creditCardInfo); } return(null); }
public IHttpActionResult transaction(FormData formData) { JsonResult jsonResult = new JsonResult(); var gateway = config.GetGateway(); string nonceFromClient = formData.nonce; decimal amountFromClient = Convert.ToDecimal(formData.amount); var request = new TransactionRequest { Amount = amountFromClient, PaymentMethodNonce = nonceFromClient, Options = new TransactionOptionsRequest { SubmitForSettlement = true } }; Result <Transaction> result = gateway.Transaction.Sale(request); if (result.IsSuccess()) { Transaction transaction = result.Target; jsonResult.message = "created " + transaction.Id + " authorized"; } else if (result.Transaction != null) { jsonResult.message = ""; } else { string errorMessages = ""; foreach (ValidationError error in result.Errors.DeepAll()) { errorMessages += "Error: " + (int)error.Code + " - " + error.Message + "\n"; } jsonResult.message = errorMessages; } return(Ok(jsonResult)); }
public async Task <Account> Handle(CreateAccountModel request, CancellationToken cancellationToken) { var gateway = _braintreeConfiguration.GetGateway(); var account = await _accountRepository.FindAccountByEmailAsync(request.Email); if (account != null) { return(account); } var fullName = request.FullName.Split(' ', 2); var paymentRequest = new CustomerRequest { FirstName = fullName[0], LastName = fullName[1], Email = request.Email }; Result <Customer> customerResult = await gateway.Customer.CreateAsync(paymentRequest); bool success = customerResult.IsSuccess(); var customerId = customerResult.Target.Id; account = new Account(_accountRepository.NextId(), request.Email) { FullName = request.FullName, PictureUrl = request.PictureUrl, CustomerId = customerId }; _accountRepository.AddAccount(account); await _accountRepository.SaveChangesAsync(); return(account); }
protected async override Task Handle(UpdateSubscriptionPaymentMethod request, CancellationToken cancellationToken) { var account = await _account.FindAccountByIdAsync(request.AccountId); var accountPlan = await _accountPlan.FindAccountPlanByAccountIdAsync(request.AccountId); var gateway = _braintreeConfiguration.GetGateway(); var subscriptionId = Guid.NewGuid().ToString(); if (account.HasPaymentMethodDeletedPlan()) { var downgrade = await _downgradeRepository.GetDowngradeByAccountIdAsync(request.AccountId); var createSubscriptionRequest = new SubscriptionRequest { PaymentMethodToken = account.PaymentMethodId, PlanId = SubscriptionHelper.ConvertPlanToBrainTreeType(account.PaymentMethodDeletedPlan), Id = subscriptionId, }; var createSubscriptionResult = gateway.Subscription.Create(createSubscriptionRequest); account.UpdateSubscriptionId(createSubscriptionRequest.Id); account.RemovePaymentMethodDeletedPlan(); await _downgradeRepository.Remove(downgrade); await _account.SaveChangesAsync(); } else { var subscriptionUpdatedResult = await gateway.Subscription.UpdateAsync(account.SubscriptionId, new SubscriptionRequest { PaymentMethodToken = account.PaymentMethodId, }); } }
public async Task <bool> Handle(ChangePlan request, CancellationToken cancellationToken) { var account = await _accountRepository.FindAccountByIdAsync(request.AccountId); var accountPlan = await _accountPlan.FindAccountPlanByAccountIdAsync(request.AccountId); var gateway = _braintreeConfiguration.GetGateway(); var currentSubscription = await gateway.Subscription.FindAsync(account.SubscriptionId); var planId = PlanTiers.ConvertPlanNameToInt(request.Plan); var downgrading = accountPlan.IsNewPlanLessThanCurrentPlan(planId); if (downgrading) { var downgrade = await _downgradeRepository.GetDowngradeByAccountIdAsync(account.Id); if (downgrade != null) { downgrade.BillingCycleEnd = currentSubscription.BillingPeriodEndDate.GetValueOrDefault(); downgrade.PlanId = planId; } else { await _downgradeRepository.Add( accountId : request.AccountId, billingCycleEnd : currentSubscription.BillingPeriodEndDate.GetValueOrDefault(), planId : planId); } } else { accountPlan.ChangePlan(planId); } await _accountPlan.SaveChangesAsync(); return(true); }