pg

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 31, 2022 License: MIT Imports: 13 Imported by: 0

README

GO Payment Gateway

GoDoc Coverage Status Go Report Card

SDK GO for Payment Gateway in Indonesia. Currently only supports Midtrans Core API, Xendit API, and OY! Indonesia.


View table of contents

Payment Channels Supported

We're supporting the payments:

  • Bank Transfer via Virtual Account (BCA, BNI, BRI, Mandiri, Permata, and other's Bank) with closed or open amount.
  • EWallet (GOPAY, OVO, DANA, LinkAja, ShopeePay) with OneTime Payment or Linked Account.
  • Credit or Debit Card with/without installment.
  • Recurring payment with Credit Card, GOPAY.
  • Retail Outlet (Alfamart, Indomaret, Alfamidi, and other's RO).
  • Cardless Credit (Kredivo, Akulaku, Indodana, and other's credit).

License

MIT. Copyright 2022 by pandudpn

Documentation

Index

Constants

View Source
const Version string = "v1.0.0"

Version library go-pg

Variables

View Source
var (
	ErrUnimplemented      = errors.New("not yet implement for this payment method")
	ErrMissingParameter   = errors.New("missing parameter")
	ErrInvalidParameter   = errors.New("parameter invalid")
	ErrMissingCredentials = errors.New("missing credentials")
	ErrInvalidCredentials = errors.New("invalid credentials")
	ErrMinAmount          = errors.New("minimum transaction with e-wallet is Rp100 or ₱1")
	ErrInvalidPhoneNumber = errors.New("numeric only with min length 2 or max length 13 digit. start with +62 for ID or +63 for PH")
)
View Source
var (
	True  bool = true
	False bool = false
)
View Source
var DefaultOptions = &Options{
	Environment: SandBox,
}

DefaultOptions define all default value of configuration options payment gateway

Functions

func DisableLogging added in v0.2.0

func DisableLogging()

DisableLogging set configuration for disable logging

func NewLogger added in v0.2.0

func NewLogger() *logrus.Logger

NewLogger create instance of Logging

Types

type ApiRequest added in v0.2.0

type ApiRequest struct {
	// HttpClient http client request
	HttpClient *http.Client

	// Logging logging interface
	Logging Logging
}

func (*ApiRequest) Call added in v0.2.0

func (a *ApiRequest) Call(ctx context.Context, httpMethod, url string, header http.Header, body, result interface{}) error

func (*ApiRequest) DoRequest added in v0.2.0

func (a *ApiRequest) DoRequest(req *http.Request, result interface{}) error

DoRequest to client with some params

type ApiRequestInterface added in v0.2.0

type ApiRequestInterface interface {
	// Call do request to target
	Call(ctx context.Context, httpMethod, url string, header http.Header, body, result interface{}) error

	// DoRequest to target
	DoRequest(req *http.Request, result interface{}) error
}

ApiRequestInterface defines all api request

func DefaultApiRequest added in v0.2.0

func DefaultApiRequest() ApiRequestInterface

DefaultApiRequest is default of ApiRequest instance

type EnvironmentType added in v0.2.0

type EnvironmentType string
const (
	// Production environment type for go live to real customer
	Production EnvironmentType = "production"

	// SandBox is staging (for development)
	SandBox EnvironmentType = "sandBox"
)

type Logging added in v0.2.0

type Logging interface {
	// Print write debug message without format into stdout
	Print(args ...interface{})

	// Printf write debug message with format into stdout
	Printf(format string, args ...interface{})

	// Println write debug message with new line into stdout
	Println(args ...interface{})

	// Warn write warn message without format into stdout
	Warn(args ...interface{})

	// Warnf write warn message with format into stdout
	Warnf(format string, args ...interface{})

	// Error write error message without format into stdout
	Error(args ...interface{})

	// Errorf print error message with format
	Errorf(format string, args ...interface{})
}

Logging define all method to be implemented as logging only support print, warn and error

var Log Logging

Log global variable to use as a logging interface

type Options added in v0.2.0

type Options struct {
	// Environment used for create transaction
	// Possible values are 'Production' or 'SandBox'
	//
	// Default: SandBox
	Environment EnvironmentType

	// ClientId is client_id from payment gateway
	// it can be apiKey or something like that
	ClientId string

	// ServerKey is client_secret from payment gateway
	ServerKey string

	// ApiCall interface to request outside
	//
	// Default: DefaultApiRequest
	ApiCall ApiRequestInterface

	// When set to true, this will log your request, response or error to stdout
	// Use logrus as logging
	//
	// Default: true
	Logging *bool
}

Options is the wrap of the params needed for API Call

func NewOption added in v0.2.0

func NewOption(opts ...*Options) (*Options, error)

NewOption will create an instance of configuration Options

type PaymentGatewayProvider added in v0.2.0

type PaymentGatewayProvider int

Directories

Path Synopsis
example
gateway

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL