/// <summary>
    /// Saves the data.
    /// </summary>
    protected override void SaveStepData(object sender, StepEventArgs e)
    {
        base.SaveStepData(sender, e);

        if (PaymentGatewayProvider != null)
        {
            // Process inserted custom payment data from the payment form
            PaymentGatewayProvider.ProcessCustomData();
        }
    }
    /// <summary>
    /// Validates data.
    /// </summary>
    protected override void ValidateStepData(object sender, StepEventArgs e)
    {
        base.ValidateStepData(sender, e);

        if (!StopProcessing && (PaymentGatewayProvider != null))
        {
            if (PaymentGatewayProvider.ValidateCustomData() != "")
            {
                e.CancelEvent = true;
            }
        }
    }
    protected void btnProcessPayment_Click(object sender, EventArgs e)
    {
        if (PaymentGatewayProvider != null && PaymentGatewayProvider.OrderId > 0)
        {
            // Validate data if web part is not placed in wizard
            if (!String.IsNullOrEmpty(mPaymentDataForm.ValidateData()))
            {
                // Do not continue if validation failed
                return;
            }

            // Prevent duplicit payment
            if (PaymentGatewayProvider.IsPaymentCompleted)
            {
                ShowError(ResHelper.GetString("paymentgateway.form.duplicitpayment"));
                return;
            }

            PaymentResultInfo result = null;

            // Skip payment when user is not authorized
            if (PaymentGatewayProvider.IsUserAuthorizedToFinishPayment(MembershipContext.AuthenticatedUser, ShoppingCart, !IsLiveSite))
            {
                var data = mPaymentDataForm.GetPaymentGatewayData();
                result = Service.Resolve <IPaymentGatewayProcessor>().ProcessPayment(PaymentGatewayProvider, data);
            }

            // Show info message
            if (!string.IsNullOrEmpty(PaymentGatewayProvider.InfoMessage))
            {
                lblInfo.Visible = true;
                lblInfo.Text    = PaymentGatewayProvider.InfoMessage;
            }

            // Show error message
            if (!string.IsNullOrEmpty(PaymentGatewayProvider.ErrorMessage))
            {
                ShowError(PaymentGatewayProvider.ErrorMessage);
            }

            if (PaymentGatewayProvider.UseDelayedPayment())
            {
                // Process succesfull authorization of delayed payment
                HandleDelayedPaymentResult(result);
            }
            else
            {
                // Redirect after successful direct payment
                HandleDirectPaymentResult(result);
            }
        }
    }
Exemple #4
0
        public CommerceConfiguration(SiteSettings siteSettings)
        {
            configPrefix = $"Site{siteSettings.SiteId.ToInvariantString()}-";

            LoadConfigSettings();

            PaymentGatewayProvider gatewayProvider = PaymentGatewayManager.Providers[PrimaryPaymentGateway];

            if (gatewayProvider != null)
            {
                paymentGateway = gatewayProvider.GetPaymentGateway();
            }
        }
Exemple #5
0
    protected void btnProcessPayment_Click(object sender, EventArgs e)
    {
        if ((PaymentGatewayProvider != null) && (orderId > 0))
        {
            // Validate data if web part is not placed in wizard
            if (!String.IsNullOrEmpty(PaymentGatewayProvider.ValidateCustomData()))
            {
                // Do not continue if validation failed
                return;
            }

            PaymentGatewayProvider.ProcessCustomData();

            // Skip payment when already paid or user is not authorized
            if (!PaymentGatewayProvider.IsPaymentCompleted &&
                PaymentGatewayProvider.IsUserAuthorizedToFinishPayment(MembershipContext.AuthenticatedUser, ShoppingCart, !IsLiveSite))
            {
                // Process payment
                PaymentGatewayProvider.ProcessPayment();
            }

            // Show info message
            if (PaymentGatewayProvider.InfoMessage != "")
            {
                lblInfo.Visible = true;
                lblInfo.Text    = PaymentGatewayProvider.InfoMessage;
            }

            // Show error message
            if (PaymentGatewayProvider.ErrorMessage != "")
            {
                ShowError(PaymentGatewayProvider.ErrorMessage);
            }

            // Redirect after successful payment
            if (PaymentGatewayProvider.IsPaymentCompleted && !string.IsNullOrEmpty(RedirectAfterPurchase))
            {
                URLHelper.Redirect(RedirectAfterPurchase);
            }
            else
            {
                URLHelper.Redirect("https://pilot-payflowpro.paypal.com");
            }
        }
    }