midtrans

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewSnapFromInvoice added in v1.2.0

func NewSnapFromInvoice(inv *invoice.Invoice) (*midsnap.Request, error)

NewSnapFromInvoice create snap charge request

Types

type Gateway

type Gateway struct {
	SnapV2Gateway SnapGateway
	// contains filtered or unexported fields
}

Gateway stores go-midtrans gateway and client

func NewGateway

func NewGateway(creds localconfig.APICredential) *Gateway

NewGateway creates new midtrans payment gateway

func (Gateway) NotificationValidationKey

func (g Gateway) NotificationValidationKey() string

NotificationValidationKey returns midtrans server key used for validating midtransa transaction status

type SnapGateway

type SnapGateway interface {
	CreateTransaction(req *snap.Request) (*snap.Response, *midtrans.Error)
}

type TransactionStatus

type TransactionStatus struct {
	ID                     uint64    `json:"id" gorm:"primary_key"`
	CreatedAt              time.Time `json:"created_at" gorm:"not null;"`
	UpdatedAt              time.Time `json:"updated_at" gorm:"not null;"`
	StatusCode             string    `json:"status_code" gorm:"not null"`
	StatusMessage          string    `json:"status_message" gorm:"type:text;not null"`
	SignKey                string    `json:"signature_key" gorm:"type:text;column:signature_key;not null"`
	Bank                   string    `json:"bank"`
	FraudStatus            string    `json:"fraud_status" gorm:"not null"`
	PaymentType            string    `json:"payment_type" gorm:"not null"`
	OrderID                string    `json:"order_id" gorm:"not null;unique_index:order_id_k"`
	TransactionID          string    `json:"transaction_id"  gorm:"not null;unique_index:transaction_id_k"`
	TransactionTime        time.Time `json:"-" gorm:"not null"`
	TransactionStatus      string    `json:"transaction_status" gorm:"not null"`
	GrossAmount            string    `json:"gross_amount" gorm:"not null"`
	MaskedCard             string    `json:"masked_card"`
	Currency               string    `json:"currency" gorm:"not null"`
	CardType               string    `json:"card_type"`
	ChannelResponseCode    string    `json:"channel_response_code" gorm:"not null"`
	ChannelResponseMessage string    `json:"channel_response_message"`
	ApprovalCode           string    `json:"approval_code"`
}

TransactionStatus is object used to store notification from midtrans

func (TransactionStatus) IsValid

func (m TransactionStatus) IsValid(authKey string) error

IsValid checks whether the status sent is indeed sent by midtrans by validating the data against its authentication key. See https://snap-docs.midtrans.com/#handling-notifications

func (TransactionStatus) TableName

func (TransactionStatus) TableName() string

TableName returns the gorm table name

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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