idpay

package
v0.0.0-...-991c3fc Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CREATE_TRANSACTION_URL = "https://api.idpay.ir/v1.1/payment"
	VERIFY_TRANSACTION_URL = "https://api.idpay.ir/v1.1/payment/verify"
)

Variables

View Source
var (
	// TransactionStatusNotDone Payment has not been done
	// پرداخت انجام نشده است 1
	TransactionStatusNotDone = newTransactionStatus(1, "Payment has not been done", "پرداخت انجام نشده است")
	// TransactionStatusFailed Payment failed
	// پرداخت ناموفق بوده است 2
	TransactionStatusFailed = newTransactionStatus(2, "Payment failed", "پرداخت ناموفق بوده است")
	// TransactionStatusError Error occurred
	// خطا رخ داده است 3
	TransactionStatusError = newTransactionStatus(3, "Error occurred", "خطا رخ داده است")
	// TransactionStatusBlocked Blocked
	// بلوکه شده 4
	TransactionStatusBlocked = newTransactionStatus(4, "Blocked", "بلوکه شده")
	// TransactionStatusRefundedToPayer Refunded to the payer
	// برگشت به پرداخت کننده 5
	TransactionStatusRefundedToPayer = newTransactionStatus(5, "Refunded to the payer", "برگشت به پرداخت کننده")
	// TransactionStatusSystematicallyRefunded Systematically refunded
	// برگشت خورده سیستمی 6
	TransactionStatusSystematicallyRefunded = newTransactionStatus(6, "Systematically refunded", "برگشت خورده سیستمی")
	// TransactionStatusCanceled Payment canceled
	// انصراف از پرداخت 7
	TransactionStatusCanceled = newTransactionStatus(7, "Payment canceled", "انصراف از پرداخت")
	// TransactionStatusRedirectedToGateway Redirected to the payment gateway
	// به درگاه پرداخت منتقل شد 8
	TransactionStatusRedirectedToGateway = newTransactionStatus(8, "Redirected to the payment gateway", "به درگاه پرداخت منتقل شد")
	// TransactionStatusWaitingForConfirmation Waiting for payment confirmation
	// در انتظار تایید پرداخت 10
	TransactionStatusWaitingForConfirmation = newTransactionStatus(10, "Waiting for payment confirmation", "در انتظار تایید پرداخت")
	// TransactionStatusConfirmed Payment confirmed
	// پرداخت تایید شده است 100
	TransactionStatusConfirmed = newTransactionStatus(100, "Payment confirmed", "پرداخت تایید شده است")
	// TransactionStatusAlreadyConfirmed Payment has already been confirmed
	// پرداخت قبلا تایید شده است 101
	TransactionStatusAlreadyConfirmed = newTransactionStatus(101, "Payment has already been confirmed", "پرداخت قبلا تایید شده است")
	// TransactionStatusPaidToReceiver Paid to the receiver
	// به دریافت کننده واریز شد 200
	TransactionStatusPaidToReceiver = newTransactionStatus(200, "Paid to the receiver", "به دریافت کننده واریز شد")
)

وضعیت تراکنش TransactionStatus

Functions

func New

func New(
	identityData IdentityData,
) *idpay

Types

type ErrorResponse

type ErrorResponse struct {
	ErrorCode    int    `json:"error_code"`
	ErrorMessage string `json:"error_message"`
	RawResponse  []byte `json:"-"`
}

type IdentityData

type IdentityData interface {
	GetIdentityData() (string, bool, error)
}

type Payment

type Payment struct {
	TrackId    string      `json:"track_id"`
	Amount     string      `json:"amount"`
	CardNumber string      `json:"card_no"`
	CardHash   string      `json:"card_hash_no"`
	Date       interface{} `json:"date"`
}

type PaymentRequest

type PaymentRequest struct {
	OrderId     string  `json:"order_id"`
	Amount      uint64  `json:"amount"`
	Name        string  `json:"name"`
	Phone       *string `json:"phone"`
	Mail        *string `json:"mail"`
	Description *string `json:"desc"`
	Callback    string  `json:"callback"`
}

func NewPaymentRequest

func NewPaymentRequest(
	orderId string,
	amount uint64,
	name string,
	phone, mail, description *string,
	callback string,
) *PaymentRequest

type PaymentResponse

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

type TransactionStatus

type TransactionStatus struct {
	Status    int    `json:"status"`
	StatusStr string `json:"status_str"`
	English   string `json:"en"`
	Persian   string `json:"fa"`
}

func GetTransactionStatus

func GetTransactionStatus(status string) *TransactionStatus

type Verify

type Verify struct {
	Date interface{} `json:"date"`
}

type VerifyRequest

type VerifyRequest struct {
	Id      string `json:"id"`
	OrderId string `json:"order_id"`
}

func NewVerifyRequest

func NewVerifyRequest(
	id, orderId string,
) *VerifyRequest

type VerifyResponse

type VerifyResponse struct {
	Status  int    `json:"status"`
	TrackId string `json:"track_id"`
	Id      string `json:"id"`
	OrderId string `json:"order_id"`
	// TODO: check again the amount value when you are calling it
	Amount      string  `json:"amount"`
	Date        string  `json:"date"`
	Payment     Payment `json:"payment"`
	Verify      Verify  `json:"verify"`
	RawResponse []byte  `json:"-"`
}

func (*VerifyResponse) GetStatusString

func (vr *VerifyResponse) GetStatusString() string

func (*VerifyResponse) Raw

func (vr *VerifyResponse) Raw() ([]byte, error)

Jump to

Keyboard shortcuts

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