samanpayment

package module
v0.0.0-...-f7f0306 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2020 License: MIT Imports: 5 Imported by: 0

README

Saman payment library

Saman payment library for Go Language. Which includes saman web api methods for connect to bank and verify transaction and reverse transaction.

Installation

Installation is done using go get.

go get -u github.com/aliworkshop/samanpayment
These are following bank methods which is supported by this package
  • GetTokenRequest
  • VerifyTransactionRequest
  • ReverseTransactionRequest

GetTokenRequest

this method use for get token from bank webservice for connect to the bank payment gateway

this method receives 5 following parameter for get token

Parameter Type
resnum String
amount Integer
payer_phone String
callback_url String
transaction_key Integer
saman := samanpayment.SamanConfig{
    TerminalId: 123456789,
}
result, err := saman.GetTokenRequest(resnum, transaction_key, amount, callback_url, mobile)

VerifyTransactionRequest

this method use for verify transaction and update database if payment was successful

this method receive 2 parameters included transaction_key that you set it before and refnum that you get it from bank response in callback

saman := samanpayment.SamanConfig{
    TerminalId: 123456789,
}
res, err := saman.VerifyTransactionRequest(transaction_key, resp.RefNum)

ReverseTransactionRequest

this method use for reverse transaction that was unsuccessful

this method receive 2 parameters included transaction_key that you set it before and refnum that you get it from bank response in callback

saman := samanpayment.SamanConfig{
    TerminalId: 123456789,
}
res, err := saman.VerifyTransactionRequest(transaction_key, resp.RefNum)

Contributor

Ali Torabi If this library helps you in anyway, show your love ❤ by putting a ⭐ on this project ✌

More details and learn how to work visit MiLearn

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetValue

func SetValue(statuscode int) string

Types

type CallbackResponse

type CallbackResponse struct {
	MID        string `json:"MID"`
	State      string `json:"State"`
	Status     int    `json:"Status"`
	RRN        string `json:"RRN"`
	RefNum     string `json:"RefNum"`
	ResNum     string `json:"ResNum"`
	TerminalId int    `json:"TerminalId"`
	TraceNo    string `json:"TraceNo"`
	Amount     int    `json:"Amount"`
	Wage       string `json:"Wage"`
	SecurePan  string `json:"SecurePan"`
}

type RequestToken

type RequestToken struct {
	Action              string `json:"action"`
	TerminalId          int    `json:"TerminalId"`
	RedirectUrl         string `json:"RedirectUrl"`
	TxnRandomSessionKey int    `json:"TxnRandomSessionKey"`
	ResNum              string `json:"ResNum"`
	Amount              int    `json:"Amount"`
	CellNumber          string `json:"CellNumber"`
}

type RequestTokenResponse

type RequestTokenResponse struct {
	Status           int    `json:"status"`
	ErrorCode        string `json:"errorCode"`
	ErrorDescription string `json:"errorDesc"`
	Token            string `json:"token"`
}

type ReverseTransaction

type ReverseTransaction struct {
	RefNum              string `json:"RefNum"`
	TerminalId          int    `json:"TerminalNumber"`
	TxnRandomSessionKey int    `json:"TxnRandomSessionKey"`
	IgnoreNationalcode  bool   `json:"IgnoreNationalcode"`
}

type ReverseTransactionResponse

type ReverseTransactionResponse struct {
	VerifyInfo        VerifyInfo `json:"TransactionDetail"`
	ResultCode        int        `json:"ResultCode"`
	ResultDescription string     `json:"ResultDescription"`
	Success           bool       `json:"Success"`
}

type SamanConfig

type SamanConfig struct {
	TerminalId int `json:"TerminalId"`
}

func (*SamanConfig) GetTokenRequest

func (config *SamanConfig) GetTokenRequest(resnum string, transaction_key int, amount int, callback_url string, payer_phone string) (*RequestTokenResponse, error)

func (*SamanConfig) ReverseTransactionRequest

func (config *SamanConfig) ReverseTransactionRequest(transaction_key int, refnum string) (*ReverseTransactionResponse, error)

func (*SamanConfig) VerifyTransactionRequest

func (config *SamanConfig) VerifyTransactionRequest(transaction_key int, refnum string) (*VerifyTransactionResponse, error)

type VerifyInfo

type VerifyInfo struct {
	ReferenceNumber string `json:"RRN"`
	RefNum          string `json:"RefNum"`
	MaskedPan       string `json:"MaskedPan"`
	HashedPan       string `json:"HashedPan"`
	TerminalId      int    `json:"TerminalNumber"`
	Amount          int    `json:"OrginalAmount"`
	AffectiveAmount int    `json:"AffectiveAmount"`
	StraceDate      string `json:"StraceDate"`
	TraceNo         string `json:"StraceNo"`
}

type VerifyTransaction

type VerifyTransaction struct {
	RefNum              string `json:"RefNum"`
	TerminalId          int    `json:"TerminalNumber"`
	TxnRandomSessionKey int    `json:"TxnRandomSessionKey"`
	IgnoreNationalcode  bool   `json:"IgnoreNationalcode"`
}

type VerifyTransactionResponse

type VerifyTransactionResponse struct {
	VerifyInfo        VerifyInfo `json:"TransactionDetail"`
	ResultCode        int        `json:"ResultCode"`
	ResultDescription string     `json:"ResultDescription"`
	Success           bool       `json:"Success"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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