public IActionResult Post([FromBody] BraintreeViewModel value) { var nonce = value.Nonce; var amount = value.Amount; var request = new TransactionRequest { Amount = Convert.ToDecimal(amount), PaymentMethodNonce = nonce, Options = new TransactionOptionsRequest { SubmitForSettlement = true } }; var result = gateway.Transaction.Sale(request); if (result.Target.ProcessorResponseText.Equals("Approved")) { return(Ok(result)); } else { return(NotFound()); } }
public ActionResult CreditCard() { var customer = HttpContext.GetCustomer(); if (!PaymentOptionProvider.PaymentMethodSelectionIsValid(AppLogic.ro_PMCreditCard, customer)) { NoticeProvider.PushNotice( message: "Invalid payment method! Please choose another.", type: NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } //Decide which form to display if (AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWBRAINTREE) { var processor = GatewayLoader.GetProcessor(Gateway.ro_GWBRAINTREE); var clientToken = processor.ObtainBraintreeToken(); if (string.IsNullOrEmpty(clientToken)) { NoticeProvider.PushNotice("Our credit card processor is currently excperiencing difficulties. Please try another payment method or contact us for assistance.", NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var braintreeModel = new BraintreeViewModel(token: clientToken, scriptUrl: AppLogic.AppConfig("Braintree.ScriptUrl")); return(View(ViewNames.BraintreeCreditCard, braintreeModel)); } else { var ccModel = BuildCheckoutCreditCardViewModel(customer); return(View(ViewNames.CreditCard, ccModel)); } }
public ActionResult CreditCard() { var customer = HttpContext.GetCustomer(); if (!PaymentOptionProvider.PaymentMethodSelectionIsValid(AppLogic.ro_PMCreditCard, customer)) { NoticeProvider.PushNotice( message: AppLogic.GetString("checkout.paymentmethodnotallowed"), type: NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } //Decide which form to display if (AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWBRAINTREE) { var processor = GatewayLoader.GetProcessor(Gateway.ro_GWBRAINTREE); var clientToken = processor.ObtainBraintreeToken(); if (string.IsNullOrEmpty(clientToken)) { NoticeProvider.PushNotice(AppLogic.GetString("braintree.creditcardunavailable"), NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var braintreeModel = new BraintreeViewModel(token: clientToken, scriptUrl: AppLogic.AppConfig("Braintree.ScriptUrl")); return(View(ViewNames.BraintreeCreditCard, braintreeModel)); } else if (AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWACCEPTJS) { var liveMode = AppLogic.AppConfigBool("UseLiveTransactions"); var cart = CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, AppLogic.StoreID()); var acceptJsModel = new AcceptJsViewModel( clientKey: liveMode ? AppLogic.AppConfig("AcceptJs.Live.ClientKey") : AppLogic.AppConfig("AcceptJs.Test.ClientKey"), apiLoginId: liveMode ? AppLogic.AppConfig("AcceptJs.Live.ApiLoginId") : AppLogic.AppConfig("AcceptJs.Test.ApiLoginId"), scriptUrlHostedForm: liveMode ? AppLogic.AppConfig("AcceptJs.Form.Hosted.Live.Url") : AppLogic.AppConfig("AcceptJs.Form.Hosted.Test.Url"), scriptUrlOwnForm: liveMode ? AppLogic.AppConfig("AcceptJs.Form.Own.Live.Url") : AppLogic.AppConfig("AcceptJs.Form.Own.Test.Url")); return(View(ViewNames.AcceptJsCreditCard, acceptJsModel)); } else if (AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWSAGEPAYPI) { var processor = (ISagePayPiGatewayProcessor)GatewayLoader.GetProcessor(Gateway.ro_GWSAGEPAYPI); var clientMerchantSessionKey = processor.ObtainSagePayPiMerchantSessionKey(); if (string.IsNullOrEmpty(clientMerchantSessionKey)) { NoticeProvider.PushNotice(AppLogic.GetString("sagepaypi.creditcardunavailable"), NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var sagePayPiModel = new SagePayPiViewModel(merchantSessionKey: clientMerchantSessionKey, scriptUrl: AppLogic.AppConfigBool("UseLiveTransactions") ? AppLogic.AppConfig("SagePayPi.LiveScriptUrl") : AppLogic.AppConfig("SagePayPi.TestScriptUrl"), validateCreditCardNumber: AppLogic.AppConfigBool("ValidateCreditCardNumbers")); return(View(ViewNames.SagePayPiCreditCard, sagePayPiModel)); } else { var ccModel = BuildCheckoutCreditCardViewModel(customer); return(View(ViewNames.CreditCard, ccModel)); } }