We will use this class for creating methods which are not part of payment procedure. The accesstype wants to use certain APIs of payment gateway which are very useful to it. For instance, The accesstype needs to verify whether the added credentials of payment gateway is valid or not. We will cover only 2 methods in this class as this 2 methods are needed in the accesstype.

We have already created one payment adapter gem for razorpay payment gateway. In which the accesstype is initializing the razorpay management as below,

credentials = {'app_key'=>'<APP_KEY_OF_RAZORPAY>', 'secret'=> '<SECRET_KEY_OF_RAZORPAY>', 'enabled'=>true, 'webhook_secret'=>'12345a'}
accesstype_razorpay = credentials, environment: '<live or sandbox>')

In the same above manner management should be done for other payment gateways. After initialization of the management class, accesstype will call different instance methods like crendetials_valid? and create_plan.


This is mandatory method which must need to present in management class. This method will check whether given credentials are valid or not. There might be already API available on many payment gateways for verifying the credentials.


This method won’t expect any argument.


This method must return the boolean.


This method will be used for creating the plan on the payment gateway. It is specially required for recurring payments and its optional method. When someone creates a plan on the accesstype it will also try to link the accesstype plan with the payment gateway’s plan. Many payment gateways like Razorpay, PayPal and Stripe have this feature to create a plan on their server and purchase recurring subscription for that plan.

subscription_plan Hash object
Subscription Plan Object

This method will expect response as below,

#<AccesstypeRazorpay::PaymentResult:0x00007fa33e48afb0 @payment_type="razorpay", @success=true, @plan_id= "plan_2y198414194", @payload=nil, @end_timestamp= nil, @payment_gateway_fee=nil, @payment_token=nil, @status=nil, @amount_currency=nil, @amount_cents=nil, @international=nil, @skip_invoice=nil, @metadata=nil, @external_payment_id=nil, @external_payment_id=nil,  @payment_gateway_fee_currency=nil, @external_refund_id=nil>