pg

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2022 License: MIT Imports: 8 Imported by: 0

README

GO Payment Gateway

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 (
	Production env = "production"
	Staging    env = "staging"
)

Variables

View Source
var (
	ErrInvalidParameter = errors.New("parameter invalid")
	ErrNilCredentials   = errors.New("credentials nil")
)
View Source
var DefaultConfig = &Config{
	Environment: Staging,
	Logging:     true,
	LogFunc:     utils.NewLogger(),
}

DefaultConfig define all default value of configuration payment gateway

Functions

This section is empty.

Types

type Config

type Config struct {
	// Set the environment gateway
	//
	// Default: Staging
	Environment env `json:"environment"`

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

	// Format log when Logging is set to true
	//
	// Default: logrus.TextFormatter | [ts] - [level] - [message]
	LogFunc *logrus.Logger `json:"log_func"`
}

type Credentials

type Credentials struct {
	// key client of Payment Gateway
	//
	// Default: ""
	ClientId string `json:"client_id"`

	// secret client of Payment Gateway
	//
	// Default: ""
	ClientSecret string `json:"client_secret"`
}

type Midtrans

type Midtrans struct {
	// contains filtered or unexported fields
}

Midtrans configuration

type PG

type PG struct {
	// contains filtered or unexported fields
}

func New

func New(cfg ...*Config) *PG

New creates a new Payment Gateway instance

func (*PG) CreateEWalletCharge

func (p *PG) CreateEWalletCharge(e *mds.EWallet) (*mds.ChargeResponse, error)

CreateEWalletCharge charge a payment e-wallet to payment gateway midtrans

func (*PG) CreateEWalletChargeWithContext

func (p *PG) CreateEWalletChargeWithContext(ctx context.Context, e *mds.EWallet) (*mds.ChargeResponse, error)

CreateEWalletChargeWithContext charge a payment e-wallet with context

func (*PG) SetMidtransCredentials

func (p *PG) SetMidtransCredentials(clientSecret string) error

SetMidtransCredentials for access Midtrans Core API

func (*PG) SetProduction

func (p *PG) SetProduction()

SetProduction environment and base url gateway

func (*PG) SetXenditCredentials

func (p *PG) SetXenditCredentials(clientSecret string) error

SetXenditCredentials for access Xendit API

type Xendit

type Xendit struct {
	// contains filtered or unexported fields
}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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