idpay

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 (
	IDPAY_HOST = "https://api.idpay.ir"

	PAYMENT_ENDPOINT      = "/v1.1/payment"
	VERIFY_ENDPOINT       = "/v1.1/payment/verify"
	INQUIRY_ENDPOINT      = "/v1.1/payment/inquiry"
	TRANSACTIONS_ENDPOINT = "/v1.1/payment/transactions"
)
View Source
const API_VERSION = "1.1"

Variables

This section is empty.

Functions

This section is empty.

Types

type CallBackGetFunc added in v1.1.3

type CallBackGetFunc func(ctx context.Context, status int, trackId int, id string, orderId string) error

type CallBackPostFunc added in v1.1.3

type CallBackPostFunc func(ctx context.Context, status int, trackId int, id string, orderId string, amount int, cardNo string, hashedCardNo string, date uint) error

type ErrorResponse

type ErrorResponse struct {
	ErrorCode    any    `json:"error_code"`
	ErrorMessage string `json:"error_message"`
}

type IdPay

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

func New

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

New create idpay object for create new request

func (*IdPay) CreateTransaction

func (i *IdPay) CreateTransaction(ctx context.Context, req *PaymentRequest) (*PaymentResponse, error)

CreateTransaction create a new transaction and return id and link

func (*IdPay) TransactionList

func (i *IdPay) TransactionList(ctx context.Context, req *TransactionListRequest) (*TransactionListResponse, error)

TransactionList get list of transaction with set page size and page

func (*IdPay) TransactionStatus

func (i *IdPay) TransactionStatus(ctx context.Context, req *TransactionStatusRequest) (*TransactionStatusResponse, error)

TransactionStatus check transaction status and return transaction details

func (*IdPay) VerifyTransaction

func (i *IdPay) VerifyTransaction(ctx context.Context, req *VerifyRequest) (*VerifyResponse, error)

VerifyTransaction verify an transaction base on id and order id

type PaymentRequest

type PaymentRequest struct {
	OrderId  string `validate:"required,max=50" json:"order_id"`
	Amount   uint   `validate:"required,min=1000,max=5000000000" json:"amount"`
	Name     string `validate:"omitempty,max=255" json:"name"`
	Phone    string `validate:"omitempty,max=11" json:"phone"`
	Mail     string `validate:"email,max=255" json:"mail"`
	Desc     string `validate:"omitempty,max=255" json:"desc"`
	Callback string `validate:"required,max=2048,url" json:"callback"`
}

type PaymentResponse

type PaymentResponse struct {
	Id   string `json:"id"`
	Link string `json:"link"`
}

type TransactionListRequest

type TransactionListRequest struct {
	Page     int `json:"-"`
	PageSize int `json:"-"`

	Id                  string   `json:"id"`
	OrderId             string   `validate:"omitempty,max=50" json:"order_id"`
	Amount              uint     `validate:"omitempty,max=5000000000,min=1000" json:"amount"`
	Status              []string `json:"status"`
	TrackId             string   `json:"track_id"`
	PaymentCardNo       string   `validate:"omitempty,max=16" json:"payment_card_no"`
	PaymentHashedCardNo string   `json:"payment_hashed_card_no"`
	PaymentDate         struct {
		Min uint `json:"min"`
		Max uint `json:"max"`
	} `json:"payment_date"`
	SettlementDate struct {
		Min uint `json:"min"`
		Max uint `json:"max"`
	} `json:"settlement_date"`
}

type TransactionListResponse

type TransactionListResponse struct {
	Attachment struct {
		Timestamp   int    `json:"timestamp"`
		TotalCount  int    `json:"total_count"`
		PageCount   int    `json:"page_count"`
		CurrentPage int    `json:"current_page"`
		TotalAmount string `json:"total_amount"`
		PageAmount  int    `json:"page_amount"`
	} `json:"attachment"`
	Records []*struct {
		Id      string `json:"id"`
		Status  string `json:"status"`
		TrackId string `json:"track_id"`
		OrderId string `json:"order_id"`
		Amount  string `json:"amount"`
		Wage    struct {
			By     string `json:"by"`
			Type   string `json:"type"`
			Amount string `json:"amount"`
		} `json:"wage"`
		Date  int `json:"date"`
		Payer struct {
			Name  string `json:"name"`
			Phone string `json:"phone"`
			Mail  string `json:"mail"`
			Desc  string `json:"desc"`
		} `json:"payer"`
		Payment struct {
			TrackId      string `json:"track_id"`
			Amount       string `json:"amount"`
			CardNo       string `json:"card_no"`
			HashedCardNo string `json:"hashed_card_no"`
			Date         string `json:"date"`
		} `json:"payment"`
		Verify struct {
			Date string `json:"date"`
		} `json:"verify"`
		Settlement struct {
			Account struct {
				Id     string `json:"id"`
				Iban   string `json:"iban"`
				Number string `json:"number"`
				Bank   struct {
					Id    string `json:"id"`
					Title string `json:"title"`
				} `json:"bank"`
			} `json:"account"`
			TrackId string `json:"track_id"`
			Amount  string `json:"amount"`
			Date    string `json:"date"`
		} `json:"settlement"`
	} `json:"records"`
}

type TransactionStatusRequest

type TransactionStatusRequest struct {
	Id      string `validate:"required" json:"id"`
	OrderId string `validate:"required,max=50" json:"order_id"`
}

type TransactionStatusResponse

type TransactionStatusResponse struct {
	Id      string `json:"id"`
	Status  string `json:"status"`
	TrackId string `json:"track_id"`
	OrderId string `json:"order_id"`
	Amount  string `json:"amount"`
	Wage    struct {
		By     string `json:"by"`
		Type   string `json:"type"`
		Amount string `json:"amount"`
	} `json:"wage"`
	Date  int `json:"date"`
	Payer struct {
		Name  string `json:"name"`
		Phone string `json:"phone"`
		Mail  string `json:"mail"`
		Desc  string `json:"desc"`
	} `json:"payer"`
	Payment struct {
		TrackId      string `json:"track_id"`
		Amount       string `json:"amount"`
		CardNo       string `json:"card_no"`
		HashedCardNo string `json:"hashed_card_no"`
		Date         string `json:"date"`
	} `json:"payment"`
	Verify struct {
		Date string `json:"date"`
	} `json:"verify"`
	Settlement struct {
		TrackId string `json:"track_id"`
		Amount  string `json:"amount"`
		Date    string `json:"date"`
	} `json:"settlement"`
}

type VerifyRequest

type VerifyRequest struct {
	Id      string `validate:"required" json:"id"`
	OrderId string `validate:"required,max=50" json:"order_id"`
}

type VerifyResponse

type VerifyResponse struct {
	Id      string `json:"id"`
	Status  string `json:"status"`
	TrackId string `json:"track_id"`
	OrderId string `json:"order_id"`
	Amount  string `json:"amount"`
	Date    string `json:"date"`
	Payment struct {
		TrackId      string `json:"track_id"`
		Amount       string `json:"amount"`
		CardNo       string `json:"card_no"`
		HashedCardNo string `json:"hashed_card_no"`
		Date         string `json:"date"`
	} `json:"payment"`
	Verify struct {
		Date int `json:"date"`
	} `json:"verify"`
}

Jump to

Keyboard shortcuts

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