Direct PayPal payment

This article shows how to redirect the customer directly to the payment gateway after clicking "Add to cart" button. This is mostly required when the membership is payed or by donations. 

In this sample zip package you will find the code of mentioned process below - sample.

You need to ensure that your PayPal payment method is registered, see:

Then you need to copy the PayPalStep.ascx file from the package to your web folder and  register it as your custom checkout process step dialog and set it as the first step of the checkout process, see:

How does it work?

1) Site visitor clicks “Add to shopping cart” button
2) Site visitor is redirected to the first step of the checkout process which is your custom step (PayPal.ascx)
3) Site visitor is immediately redirected to the PayPal with initialized payment request – it is managed by PayPal provider and you don’t have to care about it.

Code in the package is commented so you can study it to understand the process and add some custom functionality if required.

In version 5 you need to pass the currency ID to the shopping cart. In sample code below is described how to get the main currency:

CurrencyInfo currency = new CurrencyInfo();
currency = CurrencyInfoProvider.GetMainCurrency();

And then you need to add the ID to the shopping cart:

this.ShoppingCartInfoObj.ShoppingCartCurrencyID = currency.CurrencyID;

See also:

Applies to: Kentico CMS 3.1
Share this article on   LinkedIn

Juraj Ondrus

Hi, I am the Technical support leader at Kentico. I'm here to help you use Kentico and get as much as possible out of it.