monpay

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2026 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// MonpayGenerateQr [QR төлбөр үүсгэх]
	// See: POST {endpoint}/rest/branch/qrpurchase/generate
	MonpayGenerateQr = utils.API{
		Url:    "/rest/branch/qrpurchase/generate",
		Method: http.MethodPost,
	}
	// MonpayCheckQr [QR төлбөр шалгах]
	// See: GET {endpoint}/rest/branch/qrpurchase/check?uuid={uuid}
	MonpayCheckQr = utils.API{
		Url:    "/rest/branch/qrpurchase/check?uuid=",
		Method: http.MethodGet,
	}
	// MonpayPushNotification [Хэрэглэгч рүү push notification илгээх]
	// See: GET {endpoint}/rest/admin/notification/push
	MonpayPushNotification = utils.API{
		Url:    "/rest/admin/notification/push",
		Method: http.MethodGet,
	}

	// MonpayMiniAppAuthToken [Mini App access token авах]
	// See: POST {endpoint}/oauth/token
	MonpayMiniAppAuthToken = utils.API{
		Url:    "/oauth/token",
		Method: http.MethodPost,
	}
	// MonpayMiniAppUserInfo [Mini App хэрэглэгчийн мэдээлэл авах]
	// See: GET {endpoint}/api/oauth/userinfo
	MonpayMiniAppUserInfo = utils.API{
		Url:    "/api/oauth/userinfo",
		Method: http.MethodGet,
	}
	// MonpayMiniAppInvoiceCreate [Mini App нэхэмжлэх үүсгэх]
	// See: POST {endpoint}/api/oauth/invoice
	MonpayMiniAppInvoiceCreate = utils.API{
		Url:    "/api/oauth/invoice",
		Method: http.MethodPost,
	}
	// MonpayMiniAppInvoiceCheck [Mini App нэхэмжлэх шалгах]
	// See: GET {endpoint}/api/oauth/invoice/{invoiceId}
	MonpayMiniAppInvoiceCheck = utils.API{
		Url:    "/api/oauth/invoice/",
		Method: http.MethodGet,
	}
	// MonpayMiniAppInvoiceCancel [Mini App нэхэмжлэх цуцлах]
	// See: GET {endpoint}/api/oauth/invoice/cancel?invoiceId={invoiceId}
	MonpayMiniAppInvoiceCancel = utils.API{
		Url:    "/api/oauth/invoice/cancel",
		Method: http.MethodGet,
	}
	// MonpayMiniAppRefund [Mini App transaction refund хийх]
	// See: POST {endpoint}/api/oauth/refund
	MonpayMiniAppRefund = utils.API{
		Url:    "/api/oauth/refund",
		Method: http.MethodPost,
	}
	// MonpayMiniAppInvoiceRefund [Deprecated: use MonpayMiniAppRefund]
	// See: GET {endpoint}/api/oauth/invoice/refund?invoiceId={invoiceId}
	MonpayMiniAppInvoiceRefund = utils.API{
		Url:    "/api/oauth/invoice/refund",
		Method: http.MethodGet,
	}

	// MonpayDebtInvoiceCreate [Debt/penalty нэхэмжлэх үүсгэх]
	// See: POST {endpoint}/api/monpay/invoice
	MonpayDebtInvoiceCreate = utils.API{
		Url:    "/api/monpay/invoice",
		Method: http.MethodPost,
	}
	// MonpayDebtInvoiceGet [Debt нэхэмжлэхийн мэдээлэл авах]
	// See: GET {endpoint}/api/monpay/invoice/{invoiceId}
	MonpayDebtInvoiceGet = utils.API{
		Url:    "/api/monpay/invoice/",
		Method: http.MethodGet,
	}
	// MonpayDebtInvoiceCancel [Debt нэхэмжлэх цуцлах]
	// See: PUT {endpoint}/api/monpay/invoice/{invoiceId}
	MonpayDebtInvoiceCancel = utils.API{
		Url:    "/api/monpay/invoice/",
		Method: http.MethodPut,
	}
	// MonpayRedirect [Monpay app дээр invoice төлбөрийн хэрэгсэл харуулах]
	// See: GET {endpoint}/invoice/{invoiceId}
	MonpayRedirect = utils.API{
		Url:    "/invoice/",
		Method: http.MethodGet,
	}

	MonpayDeeplinkCreate = MonpayMiniAppInvoiceCreate
	MonpayDeeplinkCheck  = MonpayMiniAppInvoiceCheck
)
View Source
var ErrUnauthorized = errors.New("monpay: external access token rejected")

ErrUnauthorized is returned when Monpay rejects an installed ExternalToken with 401 or 403. The caller should discard the token, obtain a new one and retry — the rejected request was never processed, so retrying cannot double-create an invoice.

The managed path does not return this: there the SDK owns the token and refreshes it itself.

Functions

This section is empty.

Types

type APIError added in v1.1.0

type APIError struct {
	Message    string `json:"-"`
	StatusCode int    `json:"-"`
	Code       string `json:"code,omitempty"`
	IntCode    int    `json:"intCode,omitempty"`
	Info       string `json:"info,omitempty"`
	Body       string `json:"-"`
}

func (*APIError) Error added in v1.1.0

func (e *APIError) Error() string

type AccessToken

type AccessToken struct {
	AccessToken  string `json:"access_token"`
	TokenType    string `json:"token_type"`
	RefreshToken string `json:"refresh_token,omitempty"`
	ExpiresIn    int64  `json:"expires_in,omitempty"`
	Scope        string `json:"scope,omitempty"`
	// contains filtered or unexported fields
}

type Bank

type Bank string
const (
	BankKhan        Bank = "KHAN"
	BankTDB         Bank = "TDB"
	BankGolomt      Bank = "GOLOMT"
	BankState       Bank = "STATE"
	BankUlaanbaatar Bank = "ULAANBAATAR"
	BankXac         Bank = "XAC"
	BankCapitron    Bank = "CAPITRON"
	BankArig        Bank = "ARIG"
	BankChinggis    Bank = "CHINGGIS"
	BankBogd        Bank = "BOGD"
	BankCredit      Bank = "CREDIT"
	BankHugjil      Bank = "HUGJIL"
	BankTuriinsan   Bank = "TURIIN_SAN"
)

type CancelDebtInvoiceInput added in v1.1.4

type CancelDebtInvoiceInput struct {
	ReasonCode string // Цуцлах шалтгааны код (ж: "Cancel Request")
	ReasonText string // Цуцлах шалтгааны тайлбар
}

CancelDebtInvoiceInput is the input for CancelDebtInvoice.

type CancelDebtInvoiceRequest added in v1.1.4

type CancelDebtInvoiceRequest struct {
	ReasonCode string `json:"reasonCode"`
	ReasonText string `json:"reasonText"`
}

CancelDebtInvoiceRequest is the wire body for PUT /api/monpay/invoice/{id}.

type CreateDebtInvoiceInput added in v1.1.4

type CreateDebtInvoiceInput struct {
	MiniAppInvoiceID  int                    // Miniapp invoice-ийн давтагдашгүй id
	ExternalInvoiceID string                 // Tino талаас үүсгэсэн гадаад id
	Items             []DebtInvoiceItemInput // Нэхэмжлэхийн зүйлс
	Category          InvoiceCategory        // PENALTY | INVOICE
	AccessToken       string                 // Заавал биш: тодорхой token ашиглах
}

CreateDebtInvoiceInput is the input for CreateDebtInvoice.

type CreateDebtInvoiceRequest added in v1.1.4

type CreateDebtInvoiceRequest struct {
	MiniAppInvoiceID  int                      `json:"miniappInvoiceId"`
	ExternalInvoiceID string                   `json:"externalInvoiceId"`
	InvoiceItem       []debtInvoiceItemRequest `json:"invoiceItem"`
	InvoiceCategory   InvoiceCategory          `json:"invoiceCategory"`
}

CreateDebtInvoiceRequest is the wire body for POST /api/monpay/invoice.

type CreateDebtInvoiceResponse added in v1.1.4

type CreateDebtInvoiceResponse struct {
	Code    string                  `json:"code"`
	IntCode int                     `json:"intCode"`
	Info    string                  `json:"info"`
	Result  CreateDebtInvoiceResult `json:"result"`
}

CreateDebtInvoiceResponse is the batch response for POST /api/monpay/invoice.

type CreateDebtInvoiceResult added in v1.1.4

type CreateDebtInvoiceResult struct {
	Reference      string                        `json:"reference"`
	RequestedCount int                           `json:"requestedCount"`
	SuccessCount   int                           `json:"successCount"`
	FailureCount   int                           `json:"failureCount"`
	Results        []CreateDebtInvoiceResultItem `json:"results"`
}

type CreateDebtInvoiceResultItem added in v1.1.4

type CreateDebtInvoiceResultItem struct {
	RecipientType       string      `json:"recipientType"`
	RecipientIdentifier string      `json:"recipientIdentifier"`
	Result              string      `json:"result"`
	Invoice             DebtInvoice `json:"invoice"`
}

type DebtInvoice added in v1.1.4

type DebtInvoice struct {
	ID                int                     `json:"id"`
	InvoiceNumber     string                  `json:"invoiceNumber"`
	ExternalInvoiceID string                  `json:"externalInvoiceId"`
	SourceInvoiceID   string                  `json:"sourceInvoiceId"` // Miniapp invoice ID (create хариунд)
	IssuerType        string                  `json:"issuerType"`
	IssuerID          string                  `json:"issuerId"`
	Category          string                  `json:"category"`
	Type              string                  `json:"type"` // get/cancel хариунд
	Status            string                  `json:"status"`
	TotalAmount       float64                 `json:"totalAmount"`
	CollectedAmount   float64                 `json:"collectedAmount"`
	Items             []DebtInvoiceItem       `json:"items"`
	Obligations       []DebtInvoiceObligation `json:"obligations"`
}

DebtInvoice is a debt invoice as returned by create/get/cancel.

type DebtInvoiceItem added in v1.1.4

type DebtInvoiceItem struct {
	ID          int     `json:"id"`
	ItemCode    string  `json:"itemCode"`
	Description string  `json:"description"`
	Quantity    float64 `json:"quantity"`
	UnitPrice   float64 `json:"unitPrice"`
	LineAmount  float64 `json:"lineAmount"`
}

type DebtInvoiceItemInput added in v1.1.4

type DebtInvoiceItemInput struct {
	ItemCode    string  // Барааны код (ж: powerbank-ийн unique id)
	Description string  // Тайлбар
	UnitPrice   float64 // Нэгжийн үнэ
}

DebtInvoiceItemInput is a single line item of a debt invoice to create.

type DebtInvoiceObligation added in v1.1.4

type DebtInvoiceObligation struct {
	ID                  int     `json:"id"`
	RecipientType       string  `json:"recipientType"`
	RecipientIdentifier string  `json:"recipientIdentifier"`
	Amount              float64 `json:"amount"`
	PaidAmount          float64 `json:"paidAmount"`
	Status              string  `json:"status"`
}

type DebtInvoiceResponse added in v1.1.4

type DebtInvoiceResponse struct {
	Code    string      `json:"code"`
	IntCode int         `json:"intCode"`
	Info    string      `json:"info"`
	Result  DebtInvoice `json:"result"`
}

DebtInvoiceResponse is the single-invoice response for GET/PUT /api/monpay/invoice/{id}.

type Deeplink interface {
	// FetchToken [Merchant token-ийг гараар авах] — one request, no caching.
	//
	// Opt-in: the SDK manages its own token unless one is installed with
	// UseExternalToken. See [ExternalToken].
	FetchToken(ctx context.Context) (ExternalToken, error)

	// UseExternalToken installs a caller-owned token; the zero value clears it
	// and returns the client to managed mode.
	UseExternalToken(token ExternalToken)

	// InstalledToken returns the caller-owned token, or the zero value in
	// managed mode.
	InstalledToken() ExternalToken

	// Auth [Authorization code ашиглан хэрэглэгчийн access token авах]
	// See: POST https://z-wallet.monpay.mn/v2/oauth/token
	Auth(input MiniAppAuthInput) (AccessToken, error)

	// UserInfo [OAuth-оор нэвтэрсэн хэрэглэгчийн мэдээлэл авах]
	// See: GET https://z-wallet.monpay.mn/v2/api/oauth/userinfo
	UserInfo(accessToken string) (response MiniAppUserInfoResponse, err error)

	// CreateInvoice [Mini App нэхэмжлэх үүсгэх]
	// See: POST https://z-wallet.monpay.mn/v2/api/oauth/invoice
	CreateInvoice(input MiniAppCreateInvoiceInput) (response MiniAppInvoiceResponse, err error)

	// CancelInvoice [Mini App нэхэмжлэх цуцлах]
	// See: GET https://z-wallet.monpay.mn/v2/api/oauth/invoice/cancel?invoiceId={invoiceId}
	CancelInvoice(invoiceID int) (response MiniAppInvoiceResponse, err error)

	// Refund [Mini App нэхэмжлэх буцаах]
	// See: GET https://z-wallet.monpay.mn/v2/api/oauth/invoice/refund?invoiceId={invoiceId}
	//
	// Deprecated: use RefundTransaction.
	Refund(invoiceID int) (response MiniAppInvoiceResponse, err error)

	// RefundTransaction [Mini App-аар хийгдсэн transaction refund хийх]
	// See: POST https://z-wallet.monpay.mn/v2/api/oauth/refund
	RefundTransaction(input MiniAppRefundInput) (response MiniAppRefundResponse, err error)

	// CreateDeeplink [Mini App deeplink нэхэмжлэх үүсгэх]
	// See: POST https://z-wallet.monpay.mn/v2/api/oauth/invoice
	CreateDeeplink(amount float64, invoiceType InvoiceType, branchUsername, desc, invoiceId string) (response DeeplinkCreateResponse, err error)

	// RedirectInvoice [Monpay app дээр invoice төлбөрийн хэрэгсэл харуулах]
	// See: GET https://z-wallet.monpay.mn/v2/invoice/{invoiceId}
	RedirectInvoice(invoiceID int) error

	// CheckInvoice [Mini App нэхэмжлэх шалгах]
	// See: GET https://z-wallet.monpay.mn/v2/api/oauth/invoice/{invoiceId}
	CheckInvoice(invoiceID int) (response MiniAppInvoiceResponse, err error)

	// CreateDebtInvoice [Debt/penalty нэхэмжлэх үүсгэх]
	// See: POST https://z-wallet.monpay.mn/v2/api/monpay/invoice
	CreateDebtInvoice(input CreateDebtInvoiceInput) (response CreateDebtInvoiceResponse, err error)

	// GetDebtInvoice [Debt нэхэмжлэхийн мэдээлэл авах]
	// See: GET https://z-wallet.monpay.mn/v2/api/monpay/invoice/{invoiceId}
	GetDebtInvoice(invoiceID int) (response DebtInvoiceResponse, err error)

	// CancelDebtInvoice [Debt нэхэмжлэх цуцлах]
	// See: PUT https://z-wallet.monpay.mn/v2/api/monpay/invoice/{invoiceId}
	CancelDebtInvoice(invoiceID int, input CancelDebtInvoiceInput) (response DebtInvoiceResponse, err error)

	CallbackParser(url *url.URL) (response DeeplinkCallback)
}
func NewDeeplink(endpoint, id, secret, grantType, webhookUrl, redirectUrl string, options ...Option) Deeplink

NewDeeplink [Monpay Mini App SDK-ийг шинээр үүсгэх]

type DeeplinkCallback

type DeeplinkCallback struct {
	Amount    float64 `schema:"amount"`    // Нэхэмжилсэн дүн
	InvoiceId string  `schema:"invoiceId"` // Төлсөн нэхэмжлэхийн id
	Status    string  `schema:"status"`    // PAID, FAILED
	TnxId     string  `schema:"tnxId"`     // Гүйлгээ амжилттай болсон бол гүйлгээний дугаар
	Info      string  `schema:"info"`      // Хүнд уншигдахуйц гүйлгээний үр дүн
}

type DeeplinkCheckResponse

type DeeplinkCheckResponse = MiniAppInvoiceResponse

type DeeplinkCheckResult

type DeeplinkCheckResult = MiniAppInvoiceResult

type DeeplinkCreateRequest

type DeeplinkCreateRequest = MiniAppCreateInvoiceRequest

type DeeplinkCreateResponse

type DeeplinkCreateResponse = MiniAppInvoiceResponse

type DeeplinkCreateResult

type DeeplinkCreateResult = MiniAppInvoiceResult

type ExternalToken added in v1.2.0

type ExternalToken struct {
	// AccessToken is the bearer sent as Authorization on merchant calls.
	AccessToken string

	// RefreshToken is returned by Monpay. There is no refresh endpoint on the
	// merchant flow, so it is carried for completeness only: renew with
	// [Deeplink.FetchToken].
	RefreshToken string

	// TokenType is Monpay's token_type, normally "Bearer".
	TokenType string

	// ExpiresAt is when AccessToken stops being accepted.
	//
	// Monpay's client-credentials token often carries no expires_in at all, in
	// which case this is the ZERO time: the gateway told us nothing, so the SDK
	// guesses nothing. A caller holding a zero ExpiresAt should apply its own
	// renewal interval — the managed path uses defaultTokenTTL for exactly this
	// case, and is a reasonable thing to mirror.
	ExpiresAt time.Time

	// Scope is returned verbatim for diagnostics.
	Scope string
}

ExternalToken is a merchant token whose lifetime the CALLER owns.

It is the opt-in alternative to this SDK's built-in token management. By default the client still mints, caches and refreshes the client-credentials token itself (see Deeplink.Auth and the managed path in httpRequestDeeplink); nothing about that changes unless an ExternalToken is installed with Deeplink.UseExternalToken or WithExternalToken.

Install one when the token lives outside this process — in a shared cache, or minted by another service — and the SDK must not mint a second one behind your back. While one is installed the client sends it verbatim and never re-mints or refreshes it: a token it does not own is not its to replace, and doing so would be invisible to whoever does own it. A rejected token surfaces as ErrUnauthorized for the caller to act on.

func (ExternalToken) IsZero added in v1.2.0

func (t ExternalToken) IsZero() bool

IsZero reports whether the token carries no credential at all.

type FlexibleString added in v1.1.0

type FlexibleString string

func (FlexibleString) String added in v1.1.0

func (s FlexibleString) String() string

func (*FlexibleString) UnmarshalJSON added in v1.1.0

func (s *FlexibleString) UnmarshalJSON(data []byte) error

type InvoiceCategory added in v1.1.4

type InvoiceCategory string

InvoiceCategory is the category of a debt invoice (POST /api/monpay/invoice).

const (
	InvoiceCategoryPenalty InvoiceCategory = "PENALTY"
	InvoiceCategoryInvoice InvoiceCategory = "INVOICE"
)

type InvoiceType

type InvoiceType string
const (
	P2P InvoiceType = "P2P" // Хэрэглэгчээс хэрэглэгч
	P2B InvoiceType = "P2B" // Хэрэглэгчээс мерчант
	B2B InvoiceType = "B2B" // person to MF & MF to organization
)

type MiniAppAuthInput added in v1.1.0

type MiniAppAuthInput struct {
	RedirectURI string
	Code        string
	GrantType   string
}

type MiniAppCreateInvoiceInput added in v1.1.0

type MiniAppCreateInvoiceInput struct {
	RedirectUri      string
	Amount           float64
	ClientServiceUrl string
	Receiver         string
	InvoiceType      InvoiceType
	Description      string
	AccessToken      string
}

type MiniAppCreateInvoiceRequest added in v1.1.0

type MiniAppCreateInvoiceRequest struct {
	RedirectUri      string      `json:"redirectUri"`                // Webhook буюу гүйлгээний үр дүн илгээгдэх буцах хаяг
	Amount           float64     `json:"amount"`                     // Дүн
	ClientServiceUrl string      `json:"clientServiceUrl,omitempty"` // Амжилттай гүйлгээний дараа backend-ээс дуудах webhook url.
	Receiver         string      `json:"receiver"`                   // Нэхэмжлэхийн төрлөөс хамаарч утга нь өөр өөр байна.
	InvoiceType      InvoiceType `json:"invoiceType"`                // P2B, P2P, B2B
	Description      string      `json:"description"`                // Тайлбар
}

type MiniAppInvoiceResponse added in v1.1.0

type MiniAppInvoiceResponse struct {
	Code    string               `json:"code"`    // Төлөвийн тайлбар код
	IntCode int                  `json:"intCode"` // Төлөвийн код
	Info    string               `json:"info"`    // Төлөвийн мэдээлэл
	Result  MiniAppInvoiceResult `json:"result"`
}

type MiniAppInvoiceResult added in v1.1.0

type MiniAppInvoiceResult struct {
	ID              int         `json:"id"`          // Нэхэмжлэхийн давтагдашгүй id
	Receiver        string      `json:"receiver"`    // P2B салбар, P2P данс, B2B байгууллага
	Amount          float64     `json:"amount"`      // Дүн
	UserID          int         `json:"userId"`      // Төлөгч хэрэглэгчийн id
	MiniAppID       int         `json:"miniAppId"`   // Мини апп id
	CreateDate      time.Time   `json:"createDate"`  // Нэхэмжлэх үүссэн огноо
	UpdateDate      time.Time   `json:"updateDate"`  // Нэхэмжлэх засагдсан огноо
	Status          string      `json:"status"`      // NEW, PAID, FAILED
	Description     string      `json:"description"` // Нэхэмжлэхийн тайлбар
	TxnID           string      `json:"txnId"`       // Гүйлгээний дугаар
	StatusInfo      string      `json:"statusInfo"`  // Хэвлэж болохуйц мэдээлэл
	RedirectUri     string      `json:"redirectUri"` // Буцах url хаяг
	InvoiceType     InvoiceType `json:"invoiceType"`
	BankName        Bank        `json:"bankName"`        // Банк нэр (Only B2B connections)
	BankAccount     string      `json:"bankAccount"`     // Банкны дансны дугаар (Only B2B connections)
	BankAccountName string      `json:"bankAccountName"` // Данс эзэмшигчийн нэр (Only B2B connections)
}

type MiniAppRefundInput added in v1.1.1

type MiniAppRefundInput struct {
	InvoiceID   int
	Description string
	AccessToken string
}

type MiniAppRefundRequest added in v1.1.1

type MiniAppRefundRequest struct {
	InvoiceID   int    `json:"invoiceId"`   // Refund хийх invoice ID (miniapp invoiceID)
	Description string `json:"description"` // Refund тайлбар
}

type MiniAppRefundResponse added in v1.1.1

type MiniAppRefundResponse struct {
	Code    string              `json:"code"`
	Info    string              `json:"info"`
	IntCode int                 `json:"intCode"`
	Result  MiniAppRefundResult `json:"result"`
}

type MiniAppRefundResult added in v1.1.1

type MiniAppRefundResult struct {
	ID          int            `json:"id"`          // Invoice-ийн ID
	TxnID       string         `json:"txnId"`       // Анхны transaction ID
	RefundTxnID string         `json:"refundTxnId"` // Refund transaction ID
	Amount      float64        `json:"amount"`      // Буцаасан дүн
	Receiver    string         `json:"receiver"`    // Merchant branch username
	Phone       FlexibleString `json:"phone"`       // Хэрэглэгчийн утас
	MiniAppID   int            `json:"miniAppId"`   // Mini App ID
	Status      string         `json:"status"`      // REFUNDED, REFUNDFAILED
	StatusCode  int            `json:"statusCode"`  // Алдааны код
	StatusInfo  string         `json:"statusInfo"`  // Refund төлөвийн мэдээлэл
	Description string         `json:"description"` // Transaction тайлбар
	CreateDate  string         `json:"createDate"`  // Invoice үүссэн огноо
	UpdateDate  string         `json:"updateDate"`  // Refund шинэчлэгдсэн огноо
}

type MiniAppUserInfoResponse added in v1.1.0

type MiniAppUserInfoResponse struct {
	Code    string                `json:"code"`
	IntCode int                   `json:"intCode"`
	Info    string                `json:"info"`
	Result  MiniAppUserInfoResult `json:"result"`
}

type MiniAppUserInfoResult added in v1.1.0

type MiniAppUserInfoResult struct {
	UserID        int            `json:"userId"`
	UserPhone     FlexibleString `json:"userPhone"`
	UserEmail     string         `json:"userEmail"`
	UserFirstname string         `json:"userFirstname"`
	UserLastname  string         `json:"userLastname"`
}

type Monpay

type Monpay interface {
	// GenerateQr [QR төлбөр үүсгэх]
	// See: POST https://z-wallet.monpay.mn/rest/branch/qrpurchase/generate
	GenerateQr(input MonpayQrInput) (MonpayQrResponse, error)

	// CheckQr [QR төлбөр шалгах]
	// See: GET https://z-wallet.monpay.mn/rest/branch/qrpurchase/check?uuid={uuid}
	CheckQr(uuid string) (MonpayCheckResponse, error)

	// SendPushNotification [Хэрэглэгч рүү push notification илгээх]
	// See: GET https://z-wallet.monpay.mn/rest/admin/notification/push
	SendPushNotification(input MonpayPushNotificationInput) (MonpayPushNotificationResponse, error)

	CallbackParser(url *url.URL) MonpayCallback
}

func New

func New(endpoint, username, accountId, callback string) Monpay

type MonpayCallback

type MonpayCallback struct {
	Amount float64 `schema:"amount"`
	UUID   string  `schema:"uuid"`
	Status string  `schema:"status"`
	TnxId  string  `schema:"tnxId"`
}

type MonpayCheckResponse

type MonpayCheckResponse struct {
	Code   int               `json:"code"`
	Info   string            `json:"info"`
	Result MonpayResultCheck `json:"result"`
}

type MonpayPushNotificationInput added in v1.1.1

type MonpayPushNotificationInput struct {
	UserPhone string
	Title     string
	Text      string
	ActionKey string
	Action    string
}

type MonpayPushNotificationResponse added in v1.1.1

type MonpayPushNotificationResponse struct {
	Code    string                       `json:"code"`
	Info    string                       `json:"info"`
	IntCode int                          `json:"intCode"`
	Result  MonpayPushNotificationResult `json:"result"`
}

type MonpayPushNotificationResult added in v1.1.1

type MonpayPushNotificationResult struct {
	UserPhone string `json:"userPhone"`
	Title     string `json:"title"`
	Text      string `json:"text"`
	ActionKey string `json:"actionKey"`
	Action    string `json:"action"`
	Status    string `json:"status"`
}

type MonpayQrInput

type MonpayQrInput struct {
	Amount float64
}

type MonpayQrRequest

type MonpayQrRequest struct {
	Amount       float64 `json:"amount"`
	DisplayName  string  `json:"string"`
	GenerateUUID bool    `json:"generateUuid"`
	CallbackUrl  string  `json:"callbackUrl"`
}

type MonpayQrResponse

type MonpayQrResponse struct {
	Code   int            `json:"code"`
	Info   string         `json:"info"`
	Result MonpayResultQr `json:"result"`
}

type MonpayResultCheck

type MonpayResultCheck struct {
	UUID          string `json:"uuid"`
	UsedAt        int64  `json:"usedAt"`
	UsedByUd      int64  `json:"usedById"`
	TransactionId string `json:"transactionId"`
	Amount        int64  `json:"amount"`
	CreatedAt     int64  `json:"createdAt"`
	UserPhone     string `json:"userPhone"`
	UserAccountNo string `json:"userAccountNo"`
	UserVatId     string `json:"userVatId"`
	UsedAtUI      string `json:"usedAtUI"`
	CreatedAtUI   string `json:"createdAtUI"`
	AmountUI      string `json:"amountUI"`
}

type MonpayResultQr

type MonpayResultQr struct {
	Qrcode string `json:"qrcode"`
	UUID   string `json:"uuid"`
}

type Option added in v1.1.0

type Option func(*deeplink)

Option defines an option for Mini App initialization.

func WithAccessToken added in v1.1.0

func WithAccessToken(token AccessToken) Option

WithAccessToken [Client credentials token-ийг гаднаас өгөх]

func WithClient added in v1.1.0

func WithClient(client *resty.Client) Option

WithClient [Custom resty.Client ашиглах]

func WithExternalToken added in v1.2.0

func WithExternalToken(token ExternalToken) Option

WithExternalToken [Caller-owned merchant token-ийг эхлүүлэхдээ шингээх]

Installs a token the caller owns, putting the client in external mode from the first call: it sends this token as-is and never mints or refreshes one. Contrast WithAccessToken, which seeds the SDK's own managed cache and leaves refreshing to the SDK. See ExternalToken.

func WithSyncAuth added in v1.1.0

func WithSyncAuth() Option

WithSyncAuth [Эхлүүлэхдээ client credentials auth дуустал хүлээх]

Jump to

Keyboard shortcuts

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