Esempio n. 1
0
        //public override ProcessPaymentResult ProcessPayment(ProcessPaymentRequest processPaymentRequest)
        //{
        //    var result = new ProcessPaymentResult();
        //    var settings = CommonServices.Settings.LoadSetting<GTPaySettings>(processPaymentRequest.StoreId);

        //    result.AllowStoringCreditCardNumber = true;

        //    switch (settings.TransactionStatus)
        //    {
        //        case TransactionStatus.Pending:
        //            result.NewPaymentStatus = PaymentStatus.Pending;
        //            break;
        //        case TransactionStatus.Authorize:
        //            result.NewPaymentStatus = PaymentStatus.Authorized;
        //            break;
        //        case TransactionStatus.Paid:
        //            result.NewPaymentStatus = PaymentStatus.Paid;
        //            break;
        //        default:
        //            result.AddError(T("Common.Payment.TranactionTypeNotSupported"));
        //            return result;
        //    }

        //    return result;
        //}


        /// <summary>
        /// Post process payment (used by payment gateways that require redirecting to a third-party URL)
        /// </summary>
        /// <param name="postProcessPaymentRequest">Payment info required for an order processing</param>
        public override void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            if (postProcessPaymentRequest.Order.PaymentStatus == Core.Domain.Payments.PaymentStatus.Paid)
            {
                return;
            }

            int selectedCurrencyId = Convert.ToInt32(_httpContext.Session[_gatewayLuncher.SelectedCurrencyId]);
            GTPaySupportedCurrency supportedCurrency = _supportedCurrencyService.GetSupportedCurrencyById(selectedCurrencyId);

            if (supportedCurrency == null || supportedCurrency.Id <= 0)
            {
                throw new ArgumentNullException(_localizationService.GetResource("Plugins.SmartStore.GTPay.SupportedCurrencyNullArgument"));
                //throw new ArgumentNullException("supportedCurrency retreival failed! Please try again");
            }

            GTPaySettings gtpaysettings = _httpContext.Session[_gatewayLuncher.GTPaySettings] as GTPaySettings;

            if (gtpaysettings == null)
            {
                throw new ArgumentNullException(_localizationService.GetResource("Plugins.SmartStore.GTPay.GTPaySettingsNullArgument"));
                //throw new ArgumentNullException("GTPaySettings could not be retreived! Please try again, but contact your system administrator after three unsuccessful trials");
            }

            _gatewayLuncher.Lunch(postProcessPaymentRequest, supportedCurrency, gtpaysettings, _httpContext);
        }