Categories

Payment Plugin

1 Introduction

This document is a guide for developers to the payment plugins of GrandNode. Payment plugins allow to use external payment infrastructure to pay for cart items requested by enduser.

2 Payment Controller Methods and Actions

PaymentController inherits from BasePaymentController

step1

Its declaration is pretty simple, it requires only 2 Actions to be implemented – one for getting payment info, second for validation

step2

Let’s look at a simple Payment Plugin Controller’s Actions

step3

GET and POST Configure()                         
for changing Settings (ConfigurationModel) in admin\configuration

GetPaymentInfo()
after user press continue in 4 section of Checkout, here is passed FormCollection with user input you can define your
own logic what to do with received values inside FormCollection

PaymentInfo()                                               
returns .cshtml with ViewModel (custom form and information for endcustomer)

ValidatePaymentForm()                            
gets usually  a FormCollection and validate it, returns IList<string> warnings

 

Other Payment Plugins can have more Actions, mostly depending on Provider Logic (PayPal, IPay, Przelewy24)

step4

Sometimes Controller can contain custom Actions depending on provider’s business logic, e.g. PayPal can make request to your app and return you result (success or denied) of transaction

  • IPNHandler()
  • PDTHanlder()
  • CancelOrder()

In this case, you have to register routes

step5

3 Payment Processor

Processor exists as mechanism that allows the plugin to be installed (adding locale string resources) and used by application.

It inherit from BasePlugin abstract, and IPaymentMethod interface.

step6

IPaymentMethod interface is pretty complex but to get it work, only few of its Methods must be implemented.

step7

step8

The essential (a must) are

  • ProcessPayment()                                  this method is called 1st for both standard and redirection  

                                                                         changes status to PaymentStatus.Pending

                                                                         returns typical payment info (credit card type, number, expiration etc.)

                                                                         among other custom things

  • PostProcessPayment()                           this method is called 2nd, only for redirection Payment Plugins
  • PaymentMethodType{}                           changes behavior of executing code (use both above methods or only 1st)

 

And optional Methods and Properties are (you can implement these to get extra behavior of your payment plugin)

  • HidePaymentMethod()                            under custom conditions don’t show endcustomer this Payment Plugin
  • GetAdditionalHandlingFee()                   establish your own price for using this Payment Plugin
  • Capture()                                                capture payment
  • Refund()                                                 refund payment
  • Void()                                                      void payment
  • ProcessRecurringPayment()                   recurring payment
  • CancelRecurringPayment()                       
  • CanRePostProcessPayment()                only for redirection Payment Plugins, returns bool whether it is possible to make a payment again
  • SupportCapture{}
  • SupportPartiallyRefund{}
  • SupportRefund{}
  • SupportVoid{}
  • RecurringPaymentType{}                       whether recurring payment is possible, and if it is manual or automatic
  • SkipPaymentInfo{}                                  under custom conditions you can skip 5th Checkout section
  • PaymentMethodDescription{}                 displays plain string information to endcustomer

 

The standard (as in other plugins) are

  • Install()
  • Uninstall()
  • GetControllerType()                               makes it possible to call Controller
  • GetPaymentInfoRoute()                         makes it possible to call PaymentInfo() Action
  • GetConfigurationRoute()                       makes it possible to call Configure() Action

 

back to top