How to abstract payment gateways?

Hi Everyone,

I am working on a product and I want to integrate multiple payment gateways. The problem is I want to create an abstraction for many of the payment gateways out there. Currently I have the following gateways to work on,

  1. Paytm
  2. Razorpay
  3. Hyperpay
  4. Stripe
  5. Cybersource

Currently I have following abstraction:

package gateway

type Gateway interface {
	GenerateKey(amount int)
	Save()
	Authorize()
	Payment
}

type Payment interface {
	Charge(amount int)
	Refund(paymentId int,amount int)
}

All the above gateways behave differently and I would like to implement these under one roof. Any suggestion will be really helpful.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.