Custom payment gateway question

Kevin de Groot asked on December 4, 2015 13:35

Dear Kentico,

I have a question about a Custom Payment gateway that I am making. The gateway itself is working but I have to make a redirect url that i have to send with the request to the payment provider (multisafepay). But where do I get the redirect url?

And when i have the redirect url (success or cancelled etc) how is the PN.aspx file included? or will the system automatically include the PN file?

Kind regards,

Kevin

Recent Answers


Michal Samuhel answered on December 21, 2015 16:03

Hello Kevin,

We have already solved this issue in a ticket, however I will compile the answer also in here, so that it is publicly available.

It really matters on the design of the gateway. Whether the you receive the payment information instantly as in this case you will have to create your own thank you page that will be populated by the data that you will receive from the payment provider page.

If the page supports IPN like in PayPal:

docs.kentico.com/display/K82/Configuring+PayPal#ConfiguringPayPal-IPN-InstantPaymentNotification

In this case the url is sent via request (in case of pay pall it is notify_url parameter) and it is taken from settingskey => PayPal settings in Kentico.

You will need to create custom settings for the Multisafepay gateway:

docs.kentico.com/display/K82/Adding+custom+website+settings

There you can get these settings via the SettingsKeyInfoProvider as in the following example:

            // IPN confirmation
            string url = SettingsKeyInfoProvider.GetValue(siteName + ".CMSPayPalNotifyUrl");
            if (url != "")
            {
                requestParams["notify_url"] = URLHelper.GetAbsoluteUrl(url);
            }
                  // Return Url
                   url = SettingsKeyInfoProvider.GetValue(siteName + ".CMSPayPalReturnUrl");
                   if (url != "")
                    {
                        url = URLHelper.GetAbsoluteUrl(url);
                        requestParams["return"] = PaymentOptionInfoProvider.ResolveUrlMacros(url,ShoppingCartInfoObj);
                    }
                  // Cancel Return Url
                  url = SettingsKeyInfoProvider.GetValue(siteName + ".CMSPaypalCancelReturnUrl");
                   if (url != "")
                   {
                       url = URLHelper.GetAbsoluteUrl(url);
                       requestParams["cancel_return"] = PaymentOptionInfoProvider.ResolveUrlMacros(url, ShoppingCartInfoObj);
                       }

As the PayPal and Multisafepay are a lot similar you should be able to use same approach and you can take a look at the PayPalIPN in CMS\CMSModules\Ecommerce\CMSPages .

Fact whether you will be redirected to order completed page depends on selected payment gateway, because for example in case of PayPal, you will be redirected to PayPal after the order is created and then there is different return URL in setting of PayPal payment gateway.it is up to you in your code to redirect user to some order completed page, or you can also get the one from your web part settings by using following code in context of your payment gateway class:

this.ShoppingCartControl.RedirectAfterPurchase

It is also a good suggestion to look at the webinar that covers complete creation of a custom payment gateway at : devnet.kentico.com/articles/developing-custom-payment-gateway

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.