public PayExPaymentProcessor(
     CurrencySettings currencySettings,
     ICheckoutAttributeParser checkoutAttributeParser,
     ICurrencyService currencyService,
     IHttpContextAccessor httpContextAccessor,
     ILocalizationService localizationService,
     ILogger logger,
     IOrderService orderService,
     IPayExAgreementService payExAgreementService,
     IPaymentService paymentService,
     ISettingService settingService,
     IStoreContext storeContext,
     ITaxService taxService,
     IWebHelper webHelper,
     IWorkContext workContext,
     PayExAgreementObjectContext payExAgreementObjectContext,
     PayExPaymentSettings payExPaymentSettings)
 {
     _currencySettings        = currencySettings;
     _checkoutAttributeParser = checkoutAttributeParser;
     _currencyService         = currencyService;
     _httpContextAccessor     = httpContextAccessor;
     _localizationService     = localizationService;
     _logger                      = logger;
     _orderService                = orderService;
     _payExAgreementService       = payExAgreementService;
     _paymentService              = paymentService;
     _settingService              = settingService;
     _storeContext                = storeContext;
     _taxService                  = taxService;
     _webHelper                   = webHelper;
     _workContext                 = workContext;
     _payExAgreementObjectContext = payExAgreementObjectContext;
     _payExPaymentSettings        = payExPaymentSettings;
 }
        public override void Install()
        {
            // Do not overwrite existing settings.
            if (string.IsNullOrEmpty(_payExPaymentSettings.EncryptionKey))
            {
                var settings = new PayExPaymentSettings
                {
                    UseTestEnvironment = true,
                    AccountNumber      = 0,
                    //EncryptionKey = "your encryption key",
                    TransactionMode    = TransactionMode.AuthorizeAndCapture,
                    AgreementMaxAmount = 20000M,
                };
                _settingService.SaveSetting(settings);
            }

            _localizationService.AddOrUpdatePluginLocaleResource("Plugins.FriendlyName.Payments.PayEx", "Debit/Credit card");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.UseTestEnvironment", "Use test environment");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.UseTestEnvironment.Hint",
                "Uses the test service instead of the production service. Don't forget to update your account number and encryption key.");
            _localizationService.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayEx.Fields.AdditionalFee", "Additional fee");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.AdditionalFee.Hint",
                "Enter an additional fee to charge your customers when using this payment method.");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.PassProductNamesAndTotals", "Pass product names and totals");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.PassProductNamesAndTotals.Hint",
                "Check if product names and order totals should be passed to PayEx, instead of just order total.");
            _localizationService.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayEx.Fields.AccountNumber", "Account number");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.AccountNumber.Hint", "Specify your account number with PayEx.");
            _localizationService.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayEx.Fields.EncryptionKey", "Encryption key");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.EncryptionKey.Hint", "Specify the encryption key for this account.");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.TransactionModeValues", "Transaction mode credit card");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.TransactionModeValues.Hint",
                "When using Authorize, you will need to perform Capture manually to complete the transaction. When using Authorize and Capture, the sale will be completed instantly. Authorize is only possible with card payments.");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.ValidateOrderTotal", "Validate order total");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.ValidateOrderTotal.Hint",
                "Check if we should validate our order total with the actual amount received from PayEx upon completing the transaction.");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.CurrencyNotes",
                "If you're using this gateway ensure that your primary store currency is supported by PayEx.");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.TransactionCallbackNotes",
                "It is required by PayEx that you use Transaction Callback to ensure Direct Debit payment info is received, and it's recommended for Credit Card payments. Enter the following URL for Transaction Callback in PayEx Merchant Admin:");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.RedirectionTip",
                "You will be redirected to the PayEx site to complete the payment, once you click Confirm.");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.PaymentFailedPageTitle", "Your payment could not be processed");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.PaymentFailedInfo",
                "You may try to pay the order again by going to order details. If you wish to use another payment method you may place the order again by clicking order details. Please do not hesitate to contact us if you need any help.");

            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.AllowCreateAgreement", "Allow save credit card");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.AllowCreateAgreement.Hint",
                "Check to enable the customer to save a reference to a payment agreement on the initial purchase to be used for subsequent orders (AutoPay).");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.AgreementMaxAmount", "Max amount for saved payments");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.Fields.AgreementMaxAmount.Hint",
                "Enter a maximum amount that should be allowed for purchases made using saved payment agreements.");
            _localizationService.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayEx.NewCard", "New card");
            _localizationService.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayEx.SavedCards", "Saved cards");
            _localizationService.AddOrUpdatePluginLocaleResource("Plugins.Payments.PayEx.CreateAgreement", "Save my card");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.CreateAgreementMotivation",
                "- safely with PayEx. Your saved card may be used for future purchases.");
            _localizationService.AddOrUpdatePluginLocaleResource(
                "Plugins.Payments.PayEx.CreateAgreementInfo",
                @"The credit card information entered in the next step will be safely saved by our payment provider PayEx. In future checkouts you may choose the same credit card without having to enter the information again.
You may be prompted to enter your 3D secure code via an external link to your bank if you choose to save your credit card information.");

            if (PaymentView == PaymentViewCreditCard)
            {
                _payExAgreementObjectContext.Install();
            }

            base.Install();
        }