Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) CreatePaymentCheckout(ctx context.Context, req CreatePaymentCheckoutRequest) (*CreatePaymentCheckoutResponse, error)
- func (c *Client) CreateTransactionQR(ctx context.Context, req CreateTransactionQRRequest) (*CreateTransactionQRResponse, error)
- func (c *Client) GetPaymentByCheckoutID(ctx context.Context, checkoutID string) (*GetPaymentByCheckoutIDResponse, error)
- func (c *Client) GetPaymentByOrderID(ctx context.Context, orderID string) (*GetPaymentByOrderIDResponse, error)
- func (c *Client) GetPaymentByTransactionID(ctx context.Context, transactionID string) (*GetPaymentByTransactionIDResponse, error)
- func (c *Client) GetStores(ctx context.Context) (*GetStoresResponse, error)
- func (c *Client) RefundPayment(ctx context.Context, req RefundPaymentRequest) (*RefundPaymentResponse, error)
- func (c *Client) RequestAccessToken() (*GetAccessTokenResponse, error)
- func (c *Client) SetTokenSource(src oauth2.TokenSource)
- func (c *Client) Token() (*oauth2.Token, error)
- func (c *Client) VerifyWebhook(ctx context.Context, body io.Reader) (*Webhook, error)
- type Config
- type CreatePaymentCheckoutRequest
- type CreatePaymentCheckoutResponse
- type CreateTransactionQRRequest
- type CreateTransactionQRResponse
- type CreateTransactionQRType
- type Error
- type ErrorCode
- type GetAccessTokenRequest
- type GetAccessTokenResponse
- type GetPaymentByCheckoutIDResponse
- type GetPaymentByOrderIDResponse
- type GetPaymentByTransactionIDResponse
- type GetStoresResponse
- type PaymentMethod
- type PaymentStatus
- type PaymentType
- type RefundPaymentRequest
- type RefundPaymentResponse
- type Store
- type Webhook
Constants ¶
View Source
const ( ErrorCodePaymentAlreadyRefunded = "PAYMENT_FULLY_REFUNDED" ErrorCodeTransactionNotFound = "TRANSACTION_NOT_FOUND" ErrorCodeStoreNotFound = "STORE_NOT_FOUND" ErrorCodeValidationError = "VALIDATION_ERROR" ErrorCodeRefundAmountExceedPerDay = "PAYMENT_REFUND_AMOUNT_EXCEED_PER_DAY" ErrorCodeMerchantSettlementAccNotVerified = "MERCHANT_SETTLEMENT_ACCOUNT_NOT_VERIFIED" )
error codes :
View Source
const ( LayoutV1 layout = "v1" LayoutV2 layout = "v2" LayoutV3 layout = "v3" LayoutV4 layout = "v4" )
layout versions :
View Source
const ( // payment types : PaymentTypeWeb PaymentType = "WEB_PAYMENT" PaymentTypeMobile PaymentType = "MOBILE_PAYMENT" // payment methods : PaymentMethodWeChatMalaysia PaymentMethod = "WECHAT_MY" PaymentMethodWeChatChina PaymentMethod = "WECHAT_CN" PaymentMethodBoostMalaysia PaymentMethod = "BOOST_MY" PaymentMethodPrestoMalaysia PaymentMethod = "PRESTO_MY" PaymentMethodAlipayChina PaymentMethod = "ALIPAY_CN" PaymentMethodTnGMalaysia PaymentMethod = "TNG_MY" PaymentMethodGrabMalaysia PaymentMethod = "GRABPAY_MY" PaymentMethodMaybankMalaysia PaymentMethod = "MAYBANK_MY" PaymentMethodRazerPayMalaysia PaymentMethod = "RAZERPAY_MY" PaymentMethodMCashMalaysia PaymentMethod = "MCASH_MY" PaymentMethodShopeePayMalaysia PaymentMethod = "SHOPEEPAY_MY" PaymentMethodFpxMalaysia PaymentMethod = "FPX_MY" PaymentMethodGoBizMalaysia PaymentMethod = "GOBIZ_MY" // payment status : PaymentStatusInProcess PaymentStatus = "IN_PROCESS" PaymentStatusSuccess PaymentStatus = "SUCCESS" PaymentStatusFailed PaymentStatus = "FAILED" PaymentStatusFullyRefunded PaymentStatus = "FULL_REFUNDED" PaymentStatusReserved PaymentStatus = "REVERSED" PaymentStatusCancelled PaymentStatus = "CANCELLED" )
View Source
const (
EventTypeWebPayment eventType = "PAYMENT_WEB_ONLINE"
)
View Source
const (
ResponseSuccess = "SUCCESS"
)
Variables ¶
View Source
var ( ErrPaymentAlreadyRefunded = newErrorCode(ErrorCodePaymentAlreadyRefunded) ErrTransactionNotFound = newErrorCode(ErrorCodeTransactionNotFound) ErrStoreNotFound = newErrorCode(ErrorCodeStoreNotFound) ErrRefundExceedLimitPerDay = newErrorCode(ErrorCodeRefundAmountExceedPerDay) ErrValidation = newErrorCode(ErrorCodeValidationError) )
error to compare, you may compare using errors.Is(err, rm.ErrPaymentAlreadyRefunded)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client :
func (*Client) CreatePaymentCheckout ¶
func (c *Client) CreatePaymentCheckout( ctx context.Context, req CreatePaymentCheckoutRequest, ) (*CreatePaymentCheckoutResponse, error)
CreatePaymentCheckout :
func (*Client) CreateTransactionQR ¶
func (c *Client) CreateTransactionQR( ctx context.Context, req CreateTransactionQRRequest, ) (*CreateTransactionQRResponse, error)
CreateTransactionQR :
func (*Client) GetPaymentByCheckoutID ¶
func (c *Client) GetPaymentByCheckoutID( ctx context.Context, checkoutID string, ) (*GetPaymentByCheckoutIDResponse, error)
GetPaymentByCheckoutID :
func (*Client) GetPaymentByOrderID ¶
func (c *Client) GetPaymentByOrderID( ctx context.Context, orderID string, ) (*GetPaymentByOrderIDResponse, error)
GetPaymentByOrderID :
func (*Client) GetPaymentByTransactionID ¶
func (c *Client) GetPaymentByTransactionID( ctx context.Context, transactionID string, ) (*GetPaymentByTransactionIDResponse, error)
GetPaymentByTransactionID :
func (*Client) GetStores ¶
func (c *Client) GetStores(ctx context.Context) (*GetStoresResponse, error)
GetStores :
func (*Client) RefundPayment ¶
func (c *Client) RefundPayment( ctx context.Context, req RefundPaymentRequest, ) (*RefundPaymentResponse, error)
RefundPayment :
func (*Client) RequestAccessToken ¶
func (c *Client) RequestAccessToken() (*GetAccessTokenResponse, error)
RequestAccessToken :
func (*Client) SetTokenSource ¶
func (c *Client) SetTokenSource(src oauth2.TokenSource)
type Config ¶
type Config struct {
ClientID string
ClientSecret string
PrivateKey []byte
PublicKey []byte
StoreID string
Sandbox bool
TokenSource oauth2.TokenSource
Tracer opentracing.Tracer
}
type CreatePaymentCheckoutRequest ¶
type CreatePaymentCheckoutRequest struct {
Order struct {
ID string `json:"id"`
Title string `json:"title"`
Detail string `json:"detail"`
AdditionalData string `json:"additionalData"`
Amount uint `json:"amount"`
Currency string `json:"currencyType"`
} `json:"order"`
Customer struct {
UserID string `json:"userId"`
Email string `json:"email,omitempty"`
CountryCode string `json:"countryCode,omitempty"`
PhoneNumber string `json:"phoneNumber,omitempty"`
} `json:"customer"`
Type PaymentType `json:"type"`
Method []PaymentMethod `json:"method"`
ExcludeMethod []string `json:"excludeMethod"`
StoreID string `json:"storeId"`
RedirectURL string `json:"redirectUrl"`
NotifyURL string `json:"notifyUrl"`
LayoutVersion layout `json:"layoutVersion"`
ExpiresInSeconds int64 `json:"expiresInSeconds"`
}
CreatePaymentCheckoutRequest :
type CreatePaymentCheckoutResponse ¶
type CreatePaymentCheckoutResponse struct {
Item struct {
CheckoutID string `json:"checkoutId"`
URL string `json:"url"`
} `json:"item"`
Code string `json:"code"`
}
CreatePaymentCheckoutResponse :
type CreateTransactionQRRequest ¶
type CreateTransactionQRRequest struct {
Type CreateTransactionQRType `json:"type"`
CurrencyType string `json:"currencyType"`
Amount int `json:"amount"`
IsPreFillAmount bool `json:"isPreFillAmount"`
Method []string `json:"method"`
Order struct {
AdditionalData string `json:"additionalData"`
Details string `json:"details"`
Title string `json:"title"`
} `json:"order"`
Expiry struct {
Type string `json:"type"`
} `json:"expiry"`
RedirectURL string `json:"redirectUrl"`
StoreID string `json:"storeId"`
}
CreateTransactionQRRequest :
type CreateTransactionQRResponse ¶
type CreateTransactionQRResponse struct {
Item struct {
Store struct {
ID string `json:"id"`
Name string `json:"name"`
ImageURL string `json:"imageUrl"`
AddressLine1 string `json:"addressLine1"`
AddressLine2 string `json:"addressLine2"`
PostCode string `json:"postCode"`
City string `json:"city"`
State string `json:"state"`
Country string `json:"country"`
CountryCode string `json:"countryCode"`
PhoneNumber string `json:"phoneNumber"`
GeoLocation struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
} `json:"geoLocation"`
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"store"`
Type string `json:"type"`
IsPreFillAmount bool `json:"isPreFillAmount"`
CurrencyType string `json:"currencyType"`
Amount int `json:"amount"`
Platform string `json:"platform"`
Method interface{} `json:"method"`
Expiry struct {
Type string `json:"type"`
Day int `json:"day"`
ExpiredAt time.Time `json:"expiredAt"`
} `json:"expiry"`
Code string `json:"code"`
Status string `json:"status"`
QrCodeURL string `json:"qrCodeUrl"`
RedirectURL string `json:"redirectUrl"`
Order struct {
Title string `json:"title"`
Detail string `json:"detail"`
AdditionalData string `json:"additionalData"`
} `json:"order"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"item"`
Code string `json:"code"`
}
CreateTransactionQRResponse :
type CreateTransactionQRType ¶
type CreateTransactionQRType string
CreateTransactionQRType :
const (
CreateTransactionQRTypeStatic CreateTransactionQRType = "STATIC"
)
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error :
func (Error) ResponseBytes ¶
type GetAccessTokenRequest ¶
type GetAccessTokenRequest struct {
GrantType string `json:"grantType"`
}
GetAccessTokenRequest :
type GetAccessTokenResponse ¶
type GetAccessTokenResponse struct {
AccessToken string `json:"accessToken"`
TokenType string `json:"tokenType"`
ExpiresIn int `json:"expiresIn"`
RefreshToken string `json:"refreshToken"`
RefreshTokenExpiresIn int `json:"refreshTokenExpiresIn"`
}
GetAccessTokenResponse :
type GetPaymentByCheckoutIDResponse ¶
type GetPaymentByCheckoutIDResponse struct {
Item struct {
ID string `json:"id"`
Order struct {
ID string `json:"id"`
Title string `json:"title"`
Detail string `json:"detail"`
AdditionalData string `json:"additionalData"`
CurrencyType string `json:"currencyType"`
Amount uint `json:"amount"`
} `json:"order"`
Type string `json:"type"`
TransactionID string `json:"transactionId"`
Platform string `json:"platform"`
Method []string `json:"method"`
RedirectURL string `json:"redirectUrl"`
NotifyURL string `json:"notifyUrl"`
StartAt time.Time `json:"startAt"`
EndAt time.Time `json:"endAt"`
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"item"`
Code string `json:"code"`
}
type GetPaymentByOrderIDResponse ¶
type GetPaymentByOrderIDResponse struct {
Item struct {
Store struct {
ID string `json:"id"`
Name string `json:"name"`
ImageURL string `json:"imageUrl"`
AddressLine1 string `json:"addressLine1"`
AddressLine2 string `json:"addressLine2"`
PostCode string `json:"postCode"`
City string `json:"city"`
State string `json:"state"`
Country string `json:"country"`
CountryCode string `json:"countryCode"`
PhoneNumber string `json:"phoneNumber"`
GeoLocation struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
} `json:"geoLocation"`
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"store"`
ReferenceID string `json:"referenceId"`
TransactionID string `json:"transactionId"`
Order struct {
ID string `json:"id"`
Title string `json:"title"`
Detail string `json:"detail"`
Amount uint `json:"amount"`
} `json:"order"`
TerminalID string `json:"terminalId"`
Payee struct {
} `json:"payee"`
CurrencyType string `json:"currencyType"`
BalanceAmount uint `json:"balanceAmount"`
Platform string `json:"platform"`
Method string `json:"method"`
TransactionAt time.Time `json:"transactionAt"`
Type PaymentType `json:"type"`
Status PaymentStatus `json:"status"`
Region string `json:"region"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"item"`
Code string `json:"code"`
}
GetPaymentByOrderIDResponse :
type GetPaymentByTransactionIDResponse ¶
type GetPaymentByTransactionIDResponse struct {
Item struct {
Store struct {
ID string `json:"id"`
Name string `json:"name"`
ImageURL string `json:"imageUrl"`
AddressLine1 string `json:"addressLine1"`
AddressLine2 string `json:"addressLine2"`
PostCode string `json:"postCode"`
City string `json:"city"`
State string `json:"state"`
Country string `json:"country"`
CountryCode string `json:"countryCode"`
PhoneNumber string `json:"phoneNumber"`
GeoLocation struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
} `json:"geoLocation"`
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"store"`
ReferenceID string `json:"referenceId"`
TransactionID string `json:"transactionId"`
Order struct {
ID string `json:"id"`
Title string `json:"title"`
Detail string `json:"detail"`
Amount uint `json:"amount"`
} `json:"order"`
TerminalID string `json:"terminalId"`
Payee struct {
} `json:"payee"`
CurrencyType string `json:"currencyType"`
BalanceAmount int `json:"balanceAmount"`
Voucher interface{} `json:"voucher"`
Platform string `json:"platform"`
Method string `json:"method"`
TransactionAt time.Time `json:"transactionAt"`
Type string `json:"type"`
Status PaymentStatus `json:"status"`
Region string `json:"region"`
Source string `json:"source"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"item"`
Code string `json:"code"`
}
GetPaymentByTransactionIDResponse :
type GetStoresResponse ¶
type GetStoresResponse struct {
Items []Store `json:"items"`
Code string `json:"code"`
Meta struct {
Count int `json:"count"`
Total int `json:"total"`
} `json:"meta"`
}
GetStoresResponse :
type RefundPaymentRequest ¶
type RefundPaymentRequest struct {
TransactionID string `json:"transactionId"`
Refund struct {
Type string `json:"type"`
CurrencyType string `json:"currencyType"`
Amount uint `json:"amount"`
} `json:"refund"`
Reason string `json:"reason"`
}
RefundPaymentRequest :
type RefundPaymentResponse ¶
type RefundPaymentResponse struct {
Item struct {
Store struct {
ID string `json:"id"`
Name string `json:"name"`
ImageURL string `json:"imageUrl"`
AddressLine1 string `json:"addressLine1"`
AddressLine2 string `json:"addressLine2"`
PostCode string `json:"postCode"`
City string `json:"city"`
State string `json:"state"`
Country string `json:"country"`
CountryCode string `json:"countryCode"`
PhoneNumber string `json:"phoneNumber"`
GeoLocation struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
} `json:"geoLocation"`
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"store"`
ReferenceID string `json:"referenceId"`
TransactionID string `json:"transactionId"`
Order struct {
ID string `json:"id"`
Title string `json:"title"`
Detail string `json:"detail"`
Amount int `json:"amount"`
} `json:"order"`
TerminalID string `json:"terminalId"`
Payee struct {
UserID string `json:"userId"`
} `json:"payee"`
CurrencyType string `json:"currencyType"`
BalanceAmount int `json:"balanceAmount"`
Voucher interface{} `json:"voucher"`
Platform string `json:"platform"`
Method string `json:"method"`
TransactionAt time.Time `json:"transactionAt"`
Type string `json:"type"`
Status string `json:"status"`
Region string `json:"region"`
ExtraInfo struct {
Card struct {
} `json:"card"`
} `json:"extraInfo"`
Source string `json:"source"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"item"`
Code string `json:"code"`
}
RefundPaymentResponse :
type Store ¶
type Store struct {
ID string `json:"id"`
Name string `json:"name"`
AddressLine1 string `json:"addressLine1"`
AddressLine2 string `json:"addressLine2"`
PostCode string `json:"postCode"`
City string `json:"city"`
State string `json:"state"`
Country string `json:"country"`
CountryCode string `json:"countryCode"`
PhoneNumber string `json:"phoneNumber"`
GeoLocation struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
} `json:"geoLocation"`
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
Store :
type Webhook ¶
type Webhook struct {
Data struct {
BalanceAmount int `json:"balanceAmount"`
CreatedAt time.Time `json:"createdAt"`
CurrencyType string `json:"currencyType"`
Method string `json:"method"`
Order struct {
Amount int `json:"amount"`
Detail string `json:"detail"`
ID string `json:"id"`
Title string `json:"title"`
} `json:"order"`
Payee struct {
} `json:"payee"`
Platform string `json:"platform"`
ReferenceID string `json:"referenceId"`
Region string `json:"region"`
Status string `json:"status"`
Store struct {
AddressLine1 string `json:"addressLine1"`
AddressLine2 string `json:"addressLine2"`
City string `json:"city"`
Country string `json:"country"`
CountryCode string `json:"countryCode"`
CreatedAt time.Time `json:"createdAt"`
GeoLocation struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
} `json:"geoLocation"`
ID string `json:"id"`
ImageURL string `json:"imageUrl"`
Name string `json:"name"`
PhoneNumber string `json:"phoneNumber"`
PostCode string `json:"postCode"`
State string `json:"state"`
Status string `json:"status"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"store"`
TerminalID string `json:"terminalId"`
TransactionAt time.Time `json:"transactionAt"`
TransactionID string `json:"transactionId"`
Type PaymentType `json:"type"`
UpdatedAt time.Time `json:"updatedAt"`
Voucher interface{} `json:"voucher"`
} `json:"data"`
EventType eventType `json:"eventType"`
}
Click to show internal directories.
Click to hide internal directories.