Documentation
¶
Index ¶
- type AccessTokenResponse
- type Client
- type Option
- func WithAPIURL(apiURL string) Option
- func WithClientID(clientID string) Option
- func WithClientSecret(clientSecret string) Option
- func WithCustomerKey(customerKey string) Option
- func WithCustomerSecret(customerSecret string) Option
- func WithHTTPClient(httpClient *http.Client) Option
- func WithTokenURL(tokenURL string) Option
- type RefundParams
- type RefundService
- type RefundTransaction
- type RefundTransactionStatus
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessTokenResponse ¶
type AccessTokenResponse struct { AccessToken string `json:"access_token"` Scope string `json:"scope"` TokenType string `json:"token_type"` ExpiresIn int64 `json:"expires_in"` }
AccessTokenResponse is the response when fetching the access token
type Client ¶
type Client struct { Refund *RefundService // contains filtered or unexported fields }
Client is the Y-Note API client. Do not instantiate this client with Client{}. Use the New method instead.
func (*Client) AccessToken ¶
AccessToken fetches the access token used to authenticate api requests.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is options for constructing a client
func WithAPIURL ¶
WithAPIURL set's the api URL for the Y-Note API
func WithClientID ¶
WithClientID sets the Y-Note API clientID used to fetch the access token
func WithClientSecret ¶
WithClientSecret sets the Y-Note API client secret used to fetch the access token
func WithCustomerKey ¶
WithCustomerKey sets the customer key used to make API requests
func WithCustomerSecret ¶
WithCustomerSecret sets the customer secret used to make API requests
func WithHTTPClient ¶
WithHTTPClient sets the underlying HTTP client used for API requests. By default, http.DefaultClient is used.
func WithTokenURL ¶
WithTokenURL set's the token URL for the Y-Note API
type RefundParams ¶
type RefundParams struct { ChannelUserMsisdn string `json:"channelUserMsisdn"` Pin string `json:"pin"` Webhook string `json:"webhook"` Amount string `json:"amount"` FinalCustomerPhone string `json:"final_customer_phone"` FinalCustomerName string `json:"final_customer_name"` RefundMethod string `json:"refund_method"` FeesIncluded bool `json:"fees_included"` MaximumRetries string `json:"maximum_retries"` FinalCustomerNameAccuracy string `json:"final_customer_name_accuracy"` }
RefundParams are the parameters for executing a refund transaction
type RefundService ¶
type RefundService service
RefundService is the API client for the `/prod/refund` endpoint
func (*RefundService) Refund ¶
func (service *RefundService) Refund(ctx context.Context, params *RefundParams) (*RefundTransaction, *Response, error)
Refund executes an initiated transaction
func (*RefundService) Status ¶
func (service *RefundService) Status(ctx context.Context, transactionID string) (*RefundTransactionStatus, *Response, error)
Status returns the status of an initiated transaction
type RefundTransaction ¶
type RefundTransaction struct { MD5OfMessageBody string `json:"MD5OfMessageBody"` MD5OfMessageAttributes string `json:"MD5OfMessageAttributes"` MessageID string `json:"MessageId"` ResponseMetadata struct { RequestID string `json:"RequestId"` HTTPStatusCode int `json:"HTTPStatusCode"` HTTPHeaders struct { XAmznRequestid string `json:"x-amzn-requestid"` Date string `json:"date"` ContentType string `json:"content-type"` ContentLength string `json:"content-length"` Connection string `json:"connection"` } `json:"HTTPHeaders"` RetryAttempts int `json:"RetryAttempts"` } `json:"ResponseMetadata"` }
RefundTransaction is the response from a refund transaction
type RefundTransactionStatus ¶
type RefundTransactionStatus struct { Status *string `json:"status"` ErrorCode *int `json:"ErrorCode"` ErrorMessage *string `json:"ErrorMessage"` Result *struct { Message string `json:"message"` Data struct { CreatedAt string `json:"createtime"` SubscriberMsisdn string `json:"subscriberMsisdn"` Amount any `json:"amount"` PayToken string `json:"payToken"` TransactionID string `json:"txnid"` TransactionMode string `json:"txnmode"` TransactionStatus string `json:"txnstatus"` OrderID string `json:"orderId"` Status string `json:"status"` ChannelUserMsisdn string `json:"channelUserMsisdn"` Description string `json:"description"` } `json:"data"` } `json:"result"` Parameters struct { Amount string `json:"amount"` Xauth string `json:"xauth"` ChannelUserMsisdn string `json:"channel_user_msisdn"` CustomerKey string `json:"customer_key"` CustomerSecret string `json:"customer_secret"` FinalCustomerName string `json:"final_customer_name"` FinalCustomerPhone string `json:"final_customer_phone"` FinalCustomerNameAccuracy any `json:"final_customer_name_accuracy"` } `json:"parameters"` CreatedAt string `json:"CreateAt"` MessageID string `json:"MessageId"` RefundStep string `json:"RefundStep"` }
RefundTransactionStatus is the response from a refund transaction status
func (*RefundTransactionStatus) IsFailed ¶ added in v0.0.2
func (status *RefundTransactionStatus) IsFailed() bool
IsFailed checks if the refund transaction is failed
func (*RefundTransactionStatus) IsPending ¶ added in v0.0.2
func (status *RefundTransactionStatus) IsPending() bool
IsPending checks if the refund transaction is pending
func (*RefundTransactionStatus) IsSuccessful ¶ added in v0.0.2
func (status *RefundTransactionStatus) IsSuccessful() bool
IsSuccessful checks if the refund transaction is successful