mcpayment

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2020 License: MIT Imports: 14 Imported by: 0

README

sangu-mcpayment

GO library for API MC Payment mcpayment.com

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCodeNotFound      = "NOT_FOUND"
	ErrCodeAuth          = "AUTHENTICATION_ERROR"
	ErrCodeMissingData   = "MISSING_DATA"
	ErrCodeInvalidData   = "INVALID_DATA"
	ErrCodeSessExp       = "SESSION_EXPIRED"
	ErrCode500           = "INTERNAL_SERVER_ERROR"
	ErrCodeBank          = "BANK_ERROR"
	ErrCodeCard          = "CARD_ERROR"
	ErrCodePaymentSystem = "PAYMENT_SYSTEM_ERROR"
	ErrCodePayment       = "PAYMENT_ERROR"
)
View Source
var (
	// PaymentName for prefix logging
	PaymentName = "[MC Payment]"

	// ErrInvalidRequest error type for invalid request
	ErrInvalidRequest = errors.New("Invalid Request")

	// ErrUnauthorize error type for 401
	ErrUnauthorize = errors.New("Unauthorize")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	BaseURLToken     string
	BaseURLRecurring string
	XSignKey         string
	LogLevel         int
	IsEnvProduction  bool
	Logger           *log.Logger
	ReqTimeout       time.Duration
}

Client ...

func NewClient

func NewClient() Client

NewClient getting default client 0: No logging 1: Errors only 2: Errors + informational (default) 3: Errors + informational + debug

func (*Client) Call

func (c *Client) Call(method string, path string, header map[string]string, body io.Reader, respModel interface{}) error

Call call the API, respModel should pass by reference as it will be filled to corresponded struct

type IRecurringGateway

type IRecurringGateway interface {
	Create(req *RecrCreateReq) (resp RecrResp, err error)
	Get(registerID string) (resp RecrResp, err error)
	Update(registerID string, req *RecrUpdateReq) (resp RecrResp, err error)
	Enable(registerID string) (resp RecrResp, err error)
	Disable(registerID string) (resp RecrResp, err error)
	Finish(registerID string) (resp RecrResp, err error)
	ValidateSignKey(req RecrCallbackReq) bool
}

IRecurringGateway interface for recurringGateway

func NewRecurringGateway

func NewRecurringGateway(client Client) IRecurringGateway

NewRecurringGateway create instance of IRecurringGateway

type ITokenizationGateway

type ITokenizationGateway interface {
	Register(req *TokenizeRegisterReq) (resp TokenizeRegResp, err error)
	Get(registerID string) (resp TokenizeDetail, err error)
	Delete(token string) (resp TokenizeDetail, err error)
	ValidateSignKey(req TokenizeCallbackReq) bool
}

ITokenizationGateway interface for TokenizationGateway

func NewTokenizationGateway

func NewTokenizationGateway(client Client) ITokenizationGateway

type RecrCallbackReq

type RecrCallbackReq struct {
	ID           string      `json:"id"`
	RegisterID   string      `json:"register_id"`
	RecurNo      int         `json:"recur_no"`
	Status       string      `json:"status"`
	Amount       float64     `json:"amount"`
	Message      null.String `json:"message"`
	CreatedAt    string      `json:"created_at"`
	SignatureKey string      `json:"signature_key"`
}

RecrCallbackReq callback body request

type RecrCreateReq

type RecrCreateReq struct {
	RegisterID         string           `json:"register_id" valid:"required,length(1|100)"`
	Name               string           `json:"name" valid:"required,length(1|100)"`
	Amount             float64          `json:"amount" valid:"required,range(1|999999999999999)"`
	Token              string           `json:"token" valid:"required,length(1|500)"`
	CallbackURL        string           `json:"callback_url" valid:"required,url"`
	Schedule           RecrSchCreateReq `json:"schedule" valid:"required"`
	MissedChargeAction *string          `json:"missed_charge_action,omitempty" valid:"-,in(ignore|stop)"`
	TotalRecurrence    *int             `json:"total_recurrence,omitempty" valid:"-,range(1|2147483647)"`
}

RecrCreateReq body request for create recurring

type RecrDetailResp

type RecrDetailResp struct {
	ID                 string             `json:"id"`
	Status             string             `json:"status"`
	CreatedAt          string             `json:"created at"`
	RegisterID         string             `json:"register_id"`
	Name               string             `json:"name"`
	Amount             float64            `json:"amount"`
	Token              string             `json:"token"`
	CallbackURL        string             `json:"callback_url"`
	Schedule           RecrSchdDetailResp `json:"schedule"`
	MissedChargeAction string             `json:"missed_charge_action"`
	TotalRecurrence    int                `json:"total_recurrence"`
	Transactions       []RecrTrxResp      `json:"transactions"`
	Message            string             `json:"message"`
}

RecrDetailResp response body for recurring detail data

type RecrResp

type RecrResp struct {
	Error   bool           `json:"error"`
	Message string         `json:"message"`
	Data    RecrDetailResp `json:"data"`
}

RecrResp response body for recurring

type RecrSchCreateReq

type RecrSchCreateReq struct {
	Interval     int    `json:"interval" valid:"range(1|365)"`
	IntervalUnit string `json:"interval_unit" valid:"in(day|week|month)"`
	StartTime    string `json:"start_time" valid:"rfc3339"`
}

RecrSchCreateReq body request detail for create recurring schedule

type RecrSchUpdateReq

type RecrSchUpdateReq struct {
	Interval     int    `json:"interval" valid:"range(1|365)"`
	IntervalUnit string `json:"interval_unit" valid:"in(day|week|month)"`
}

RecrSchUpdateReq body request detail for update recurring schedule

type RecrSchdDetailResp

type RecrSchdDetailResp struct {
	Interval     int    `json:"interval"`
	IntervalUnit string `json:"interval_unit"`
	StartTime    string `json:"start_time"`
	Previous     string `json:"previous"`
	Next         string `json:"next"`
}

RecrSchdDetailResp response body for recurring schedule detail data

type RecrTrxResp

type RecrTrxResp struct {
	ID        string  `json:"id"`
	Amount    float64 `json:"amount"`
	RecurNo   int     `json:"recur_no"`
	Status    string  `json:"status"`
	ChargedAt string  `json:"charged_at"`
}

RecrTrxResp response body for recurring transactions data

type RecrUpdateReq

type RecrUpdateReq struct {
	Name               string           `json:"name" valid:"required,length(1|100)"`
	Amount             float64          `json:"amount" valid:"required,range(1|999999999999999)"`
	Token              string           `json:"token" valid:"required,length(1|500)"`
	CallbackURL        string           `json:"callback_url" valid:"required,url"`
	Schedule           RecrSchUpdateReq `json:"schedule" valid:"required"`
	MissedChargeAction *string          `json:"missed_charge_action" valid:"-,in(ignore|stop)"`
	TotalRecurrence    *int             `json:"total_recurrence" valid:"-"`
}

RecrUpdateReq body request for update recurring

type TokenizeCallbackReq

type TokenizeCallbackReq struct {
	Token          string  `json:"token"`
	RegisterID     string  `json:"register_id"`
	MaskedCardNo   string  `json:"masked_card_number"`
	CardHolderName string  `json:"card_holder_name"`
	CardExpDate    string  `json:"card_exp_date"`
	CardBrand      string  `json:"card_brand"`
	Status         string  `json:"status"`
	BankIssuer     string  `json:"bank_issuer"`
	Amount         float64 `json:"amount"`
	SignatureKey   string  `json:"signature_key"`
	ErrorCode      string  `json:"error_code"`
	Message        string  `json:"message"`
}

TokenizeCallbackReq body request on callback tokenization

type TokenizeDelReq

type TokenizeDelReq struct {
	RegisterID string `json:"register_id" valid:"required"`
}

TokenizeDelReq param for delete tokenize

type TokenizeDetail

type TokenizeDetail struct {
	Token          string  `json:"token"`
	RegisterID     string  `json:"register_id"`
	MaskedCardNo   string  `json:"masked_card_number"`
	CardHolderName string  `json:"card_holder_name"`
	CardExpDate    string  `json:"card_exp_date"`
	CardBrand      string  `json:"card_brand"`
	Status         string  `json:"status"`
	BankIssuer     string  `json:"bank_issuer"`
	Amount         float64 `json:"amount"`
	TokenizeStatusResp
}

TokenizeDetail token detail data from get / callback

type TokenizeGetReq

type TokenizeGetReq struct {
	RegisterID string `json:"register_id" valid:"required"`
}

TokenizeGetReq param for get tokenize

type TokenizeRegDataResp

type TokenizeRegDataResp struct {
	SeamlessURL string `json:"seamless_url"`
	ExpiredDate string `json:"expired_date"`
	Message     string `json:"message"`
	ErrorCode   string `json:"error_code"`
}

TokenizeRegDataResp response inner data for register token

type TokenizeRegResp

type TokenizeRegResp struct {
	Error   bool                `json:"error"`
	Message string              `json:"message"`
	Data    TokenizeRegDataResp `json:"data"`
}

TokenizeRegResp response body for register token

type TokenizeRegisterReq

type TokenizeRegisterReq struct {
	RegisterID  string    `json:"register_id" valid:"required,length(1|100)"`
	CallbackURL string    `json:"callback_url" valid:"required,url"`
	ReturnURL   string    `json:"return_url" valid:"required,url"`
	IsTrx       bool      `json:"is_transaction,omitempty" valid:"-"`
	TrxDetail   TrxDetail `json:"transaction,omitempty" valid:"-"`
}

TokenizeRegisterReq body request for register token

type TokenizeStatusDataBodyResp

type TokenizeStatusDataBodyResp struct {
	Token string `json:"token"`
}

TokenizeStatusDataBodyResp body on status response inner data

type TokenizeStatusDataResp

type TokenizeStatusDataResp struct {
	ErrorCode string                     `json:"error_code"`
	Body      TokenizeStatusDataBodyResp `json:"body"`
}

TokenizeStatusDataResp status response inner data

type TokenizeStatusResp

type TokenizeStatusResp struct {
	Error   bool                   `json:"error"`
	Message string                 `json:"message"`
	Data    TokenizeStatusDataResp `json:"data"`
}

TokenizeStatusResp response body for error / default response on GET and DEL request

type TrxDetail

type TrxDetail struct {
	Amount float64 `json:"amount" valid:"-"`
	Desc   string  `json:"description" valid:"-"`
}

TrxDetail body request for transactiond detail

Jump to

Keyboard shortcuts

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