Skipping Checkout Screens

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 13 años
This is probably right in front of me but hopefully someone can put me right!

I am creating a custom payment provider. Have looked through the posts on doing it but I'm missing one bit of information.

It will be the only payment method and I want to skip the "Payment" checkout step, avoiding the input of selecting a method and entering card details, jumping right to the final confirmation screen so I can send the user to the remote payment page.

I can't find any configuration way of doing this and I've been carefully avoiding modifying the Nop source to preserve my upgrade-ability.

Any suggestions would be greatly appreciated.

G.
Hace 13 años
I don't believe this is possible without making code changes.  If you're able to make code changes, then if you wanted to skip the Payment Method selection (e.g., because you only have one payment method) you could add something like the code shown below in bold to the BindData() method in CheckoutPaymentMethod.ascx (this is using the 1.7 codebase)


            if (boundPaymentMethods.Count == 0)
            {
                if (hasButtonMethods)
                {
                    phSelectPaymentMethod.Visible = false;
                    pnlPaymentMethodsError.Visible = false;

                    //no reward points in this case
                    pnlRewardPoints.Visible = false;
                }
                else
                {
                    phSelectPaymentMethod.Visible = false;
                    pnlPaymentMethodsError.Visible = true;                    
                    lPaymentMethodsError.Text = GetLocaleResourceString("Checkout.NoPaymentMethods");

                    //no reward points in this case
                    pnlRewardPoints.Visible = false;
                }
            }
            else if (boundPaymentMethods.Count == 1)
            {
                PaymentMethodSelected(boundPaymentMethods[0].PaymentMethodId);
            }
            else
            {
                phSelectPaymentMethod.Visible = true;
                pnlPaymentMethodsError.Visible = false;
                dlPaymentMethod.DataSource = boundPaymentMethods;
                dlPaymentMethod.DataBind();
            }

If  you wanted to skip the PaymentInfo page then you could add some further code at the end of the BindData() method in CheckPaymentInfo.ascx

            else if (paymentMethod != null && paymentMethod.IsActive)
            {
                this.PaymentInfo = this.GetPaymentInfo();
                var args1 = new CheckoutStepEventArgs() { PaymentInfoEntered = true };
                OnCheckoutStepChanged(args1);
                if (!this.OnePageCheckout)
                    Response.Redirect("~/checkoutconfirm.aspx");
            }

However you would need to recompile the application after these changes.  Someone may have a better solution to this requirement...
Hace 13 años
No, I really like that. I'll create a copy of the ascx in another location so it doesn't get overwritten when I upgrade and then modify it. Very neat solution.

Many thanks indeed for taking the time to have a look!

G.
Hace 13 años
Only thing is... Not sure what:

PaymentMethodSelected(boundPaymentMethods[0].PaymentMethodId);

actually is supposed to be doing as PaymentMethodSelected isn't a method in the user control. Am I missing something (I'm also using 1.70).

G.
Hace 13 años
Apologies, that's a method I added (forgot about that!) ;-)

private void PaymentMethodSelected(int paymentMethodId)
        {
            NopContext.Current.User = CustomerManager.SetLastPaymentMethodId(NopContext.Current.User.CustomerId, paymentMethodId);
            var args1 = new CheckoutStepEventArgs() { PaymentMethodSelected = true };
            OnCheckoutStepChanged(args1);
            if (!this.OnePageCheckout)
                Response.Redirect("~/checkoutpaymentinfo.aspx");
        }
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.