RazorCart provides the ability to extend most of it's core functionality by plugging in your own custom programming logic, in this article you are about to implement your own custom gateway to accept payments using your c# code.
- Microsoft Visual Studio 2012 or newer
- C# development skills
1. The first step is to download the Visual Studio example project:
2. Unzip the file you just downloaded and place the Library folder in your DNN root folder
3. Open the project in Visual Studio, you will see that the project contains two classes, CustomDirectGateway & CustomHostedGateway which inherited from RazorCart.Service.Gateway.PaymentGateway
4. Gateway Properties:
- TestMode: When the gateway initialized this value will be passed to the gateway, it either true or false based on the payment store setting.
- HostedReturnUrl: This is the url that should be sent to the hosted gateway if the user returned to the store page.
- NotificationUrl: Also used in hosted gateways, after the user submit the payment this is where should the gateway post the payment status form to.
- AcceptedCards: A list of the Credit Card types that should be only accepted based on store settings.
5. Gateway Methods:
- ProcessMode: set this value to Direct or Hosted GatewayProcessMode based on the gateway type you are implementing.
- Process: This function will be called to submit the payment info and return the status response of the gateway, there are three types of the return value (PaymentStatus, SubscriptionStatus or PaymentUri)
- HandleReturn: When the gateway calls the NotificationUrl, this is where you need to handle and return the PaymentStatus response to update the order payment info
Building & Deploying
After you build your gateway plugin assembly and deploy it to your DNN\bin folder, you will need to create a payment method and set it to use this gateway, the implemented gateways will automatically shown on the drop-down gateway list, and will be called once the user checkout using the associated payment method.
To access the Payment Setup page click on the Admin Menu in your DNN portal, then select RazorCart Admin Console:
You will be taken to the dashboard of your store.
From the left-side menu go to Store Setup > Payment
Create or Edit an existing payment method, type the name of the payment method, this name will be shown on the checkout screen and on the admin screen as well, select the method type (CreditCard, ACHChecking & ACHSavings) are the only methods that allow you to use the gateway payment processing, now after you choose one of these methods select the name of the custom gateway you have implemented from the gateway drop-down menu
Save the payment method and click the back button, now you can see that you have created a new payment method that will be using the custom gateway you have implemented
If you have any questions, please do not hesitate to use our Contact Us
form, we are more than happy to help.