The Direct Payment Gateway Provider allows you to plug in your own payment gateway code. This article includes a sample Visual Studio project and explains how to develop your own payment gateway project that plugs into SmithCart.
The following are the requirements to implement a custom gateway provider:
- Visual Studio 2012 or greater
- C# programming language and framework knowledge
- DNN v7.1 or greater installed
- SmithCart v6.92 or greater installed
- Developer API doc from the payment gateway you want to integrate
Download Payment Gateway Project
1. The first step is to download the sample Visual Studio payment gateway project below:
2. Unzip the file you just downloaded
Example Payment Gateway Project
1. Double click on the TransFirstGatewayProvider.sln
2. After you double click on the solution, Visual Studio should load and open the project and your solution explorer should be displayed as follows:
If you want to create your own visual studio project you should create a .Net Class Library project.
3. In solution explorer, expand the "References" and the following 4 references are required:
4. In solution explorer, double click on "TransFirstDirectGatewayProvider.cs" to open it.
At the top of the cs file you will need the following 4 using statements:
If the payment gateway you are integrating with requires any service or web references you will need to add those and include the using statements if required. In the example gateway project, the TransFirst payment gateway requires the following 2 web references:
The TransFirst web references require the following 2 using statements:
5. Namespace and Class
6. The following changes need to be made to the web.config located in the root of your DNN install:
<section name="payment" requirePermission="false" type="DotNetNuke.Framework.Providers.ProviderConfigurationHandler, DotNetNuke" />
<add name="BuyNowGatewayProvider" type="Smith.Providers.Payments.BuyNowGatewayProvider, SmithBuyNow" />
<add name="TransFirstDirectGatewayProvider" type="Smith.Providers.Payments.TransFirstDirectGatewayProvider, TransFirstGatewayProvider"
merchantID="XXXXXX" merchantKey="XXXXXXXXXXXX" testMode="true" authorizeOnly="false" />
The merchantID and merchantKey highlighted above are your gateway credentials provided to you by your payment gateway company when you signed up.
6. Build the project in Visual Studio and place the assembly (dll) in the /bin folder located off the root of your DNN install.
Last Step - In SmithCart
The last step is to tell SmithCart you are using a custom gateway:
- Go to your DNN site and login as admin
- Navigate to the page where you added the BuyNow module
- From the Store Admin menu select payment setup as follows:
- Select the "Payment Gateway" tab:
- From the payment gateway dropdown, select "Custom Payment Provider"
- You don't need to enter your gateway credentials here as they are referenced from your web.config
- Click the "Save" button to save the custom payment provider as your new gateway.
- Add a product to your cart and test your new payment gateway.