pay

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PAY_HOST = "https://pay.ir"

	PAYMENT_ENDPOINT = "/pg/send"
	VERIFY_ENDPOINT  = "/pg/verify"
)
View Source
const API_VERSION = "1"

Variables

This section is empty.

Functions

func DefaultCallback

func DefaultCallback(actionFunc CallBackFunc) http.HandlerFunc

DefaultCallback is default callback for http server handler, example :

        http.Handle("/callback", pay.DefaultCallback(callback))
	    http.ListenAndServe(":8080", nil)

Types

type CallBackFunc

type CallBackFunc func(ctx context.Context, status int, token string) error

CallBackFunc is a function for create call back action

type ErrorResponse

type ErrorResponse struct {
	Status       int    `json:"status"`
	ErrorCode    int    `json:"errorCode"`
	ErrorMessage string `json:"errorMessage"`
}

type Pay

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

func New

func New(client client.Transporter, apiKey string, sandbox bool) (*Pay, error)

New create pay object for create and verify transaction in pay.ir service

func (*Pay) CreateTransaction

func (p *Pay) CreateTransaction(ctx context.Context, req *PaymentRequest) (*PaymentResponse, error)

CreateTransaction create new transaction and return status and token

func (*Pay) VerifyTransaction

func (p *Pay) VerifyTransaction(ctx context.Context, req *VerifyRequest) (*VerifyResponse, error)

VerifyTransaction payment transaction via token

type PaymentRequest

type PaymentRequest struct {
	Amount          uint   `json:"amount" validate:"required,min=10000"`
	Redirect        string `json:"redirect" validate:"required,url"`
	Mobile          string `json:"mobile,omitempty" validate:"omitempty,min=11"`
	FactorNumber    string `json:"factorNumber,omitempty"`
	Description     string `json:"description,omitempty" validate:"omitempty,max=255"`
	ValidCardNumber string `json:"validCardNumber,omitempty" validate:"omitempty,max=16"`
}

type PaymentResponse

type PaymentResponse struct {
	Status int    `json:"status"`
	Token  string `json:"token"`
}

type Request

type Request struct {
	API string `json:"api"`
	*PaymentRequest
	*VerifyRequest
}

type VerifyRequest

type VerifyRequest struct {
	Token string `json:"token" validate:"required"`
}

type VerifyResponse

type VerifyResponse struct {
	Status       int    `json:"status"`
	Amount       string `json:"amount"`
	TransId      int    `json:"transId"`
	FactorNumber string `json:"factorNumber"`
	Mobile       string `json:"mobile"`
	Description  string `json:"description"`
	CardNumber   string `json:"cardNumber"`
	Message      string `json:"message"`
}

Jump to

Keyboard shortcuts

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