Documentation ¶
Index ¶
- Constants
- type Bill
- type BillGetParams
- type Client
- func (client *Client) Collect(ctx context.Context, params *CollectParams, options ...RequestOption) (*Transaction, *Response, error)
- func (client *Client) CollectSync(ctx context.Context, params *CollectParams, options ...RequestOption) (*Transaction, *Response, error)
- func (client *Client) Ping(ctx context.Context, options ...RequestOption) (*PingStatus, *Response, error)
- func (client *Client) Quote(ctx context.Context, params *QuoteParams, options ...RequestOption) (*Quote, *Response, error)
- func (client *Client) TransactionHistory(ctx context.Context, from time.Time, to time.Time, options ...RequestOption) ([]*Transaction, *Response, error)
- func (client *Client) Verify(ctx context.Context, paymentTransactionNumber string, options ...RequestOption) (*Transaction, *Response, error)
- type CollectParams
- type Option
- func WithAccessSecret(accessSecret string) Option
- func WithAccessToken(accessToken string) Option
- func WithBaseURL(baseURL string) Option
- func WithCollectSyncVerifyInterval(interval time.Duration) Option
- func WithCollectSyncVerifyRetryCount(retryCount uint) Option
- func WithHTTPClient(httpClient *http.Client) Option
- type PayItem
- type PingStatus
- type Quote
- type QuoteParams
- type RequestOption
- type Response
- type Transaction
Constants ¶
const ( // BillMerchantENEO is the merchant name for ENEO BillMerchantENEO = "ENEO" // BillMerchantCamwater is the merchant name for camwater BillMerchantCamwater = "CAMWATER" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bill ¶
type Bill struct { PayItemID string `json:"payItemId"` ServiceNumber string `json:"serviceNumber"` ServiceID string `json:"serviceid"` Merchant string `json:"merchant"` AmountType string `json:"amountType"` LocalCurrency string `json:"localCur"` AmountLocalCurrency string `json:"amountLocalCur"` BillNumber string `json:"billNumber"` CustomerNumber string `json:"customerNumber"` BillMonth string `json:"billMonth"` BillYear string `json:"billYear"` BillDate time.Time `json:"billDate"` BillDueDate time.Time `json:"billDueDate"` PayItemDescription string `json:"payItemDescr"` BillType string `json:"billType"` PenaltyAmount string `json:"penaltyAmount"` PayOrder int `json:"payOrder"` OptionalString interface{} `json:"optStrg"` OptionalNumber interface{} `json:"optNmb"` }
Bill is the details for a bill payment
type BillGetParams ¶
BillGetParams are the parameters for getting a bill
type Client ¶
type Client struct { Topup *topupService Bill *billService Cashout *cashoutService Cashin *cashinService Product *productService // contains filtered or unexported fields }
Client is the smobilpay API client. Do not instantiate this client with Client{}. Use the New method instead.
func (*Client) Collect ¶
func (client *Client) Collect(ctx context.Context, params *CollectParams, options ...RequestOption) (*Transaction, *Response, error)
Collect confirms a transaction
https://apidocs.smobilpay.com/s3papi/API-Reference.2066448558.html
func (*Client) CollectSync ¶ added in v0.0.2
func (client *Client) CollectSync(ctx context.Context, params *CollectParams, options ...RequestOption) (*Transaction, *Response, error)
CollectSync confirms a transaction in sync by retrying every 15 seconds for 5 minutes
https://apidocs.smobilpay.com/s3papi/API-Reference.2066448558.html
func (*Client) Ping ¶
func (client *Client) Ping(ctx context.Context, options ...RequestOption) (*PingStatus, *Response, error)
Ping checks if the API is available
https://apidocs.smobilpay.com/s3papi/API-Reference.2066448558.html
func (*Client) Quote ¶
func (client *Client) Quote(ctx context.Context, params *QuoteParams, options ...RequestOption) (*Quote, *Response, error)
Quote initializes a transaction
https://apidocs.smobilpay.com/s3papi/API-Reference.2066448558.html
func (*Client) TransactionHistory ¶
func (client *Client) TransactionHistory(ctx context.Context, from time.Time, to time.Time, options ...RequestOption) ([]*Transaction, *Response, error)
TransactionHistory gets the history of transactions
https://apidocs.smobilpay.com/s3papi/API-Reference.2066448558.html
func (*Client) Verify ¶
func (client *Client) Verify(ctx context.Context, paymentTransactionNumber string, options ...RequestOption) (*Transaction, *Response, error)
Verify gets the current collection status
https://apidocs.smobilpay.com/s3papi/API-Reference.2066448558.html
type CollectParams ¶
type CollectParams struct { QuoteID string `json:"quoteId"` CustomerPhoneNumber string `json:"customerPhonenumber"` CustomerEmailAddress string `json:"customerEmailaddress"` CustomerName string `json:"customerName"` CustomerAddress string `json:"customerAddress"` CustomerNumber string `json:"customerNumber"` ServiceNumber string `json:"serviceNumber"` ExternalTransactionID string `json:"trid"` }
CollectParams is the input needed to confirm a transaction
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option is options for constructing a client
func WithAccessSecret ¶
WithAccessSecret sets the access secret for the smobilpay api
func WithAccessToken ¶
WithAccessToken sets the access token for the smobilpay api
func WithBaseURL ¶
WithBaseURL set's the base url for the smobilpay API
func WithCollectSyncVerifyInterval ¶ added in v0.0.3
WithCollectSyncVerifyInterval sets the interval for calling the `/verifytx` endpoint to check the status of pending transactions
func WithCollectSyncVerifyRetryCount ¶ added in v0.0.3
WithCollectSyncVerifyRetryCount sets the number of retries for calling the `/verifytx` endpoint to check the status of pending transactions
func WithHTTPClient ¶
WithHTTPClient sets the underlying HTTP client used for API requests. By default, http.DefaultClient is used.
type PayItem ¶ added in v0.0.3
type PayItem struct { ServiceID string `json:"serviceid"` Merchant string `json:"merchant"` PayItemID string `json:"payItemId"` AmountType string `json:"amountType"` LocalCurrency string `json:"localCur"` Name string `json:"name"` AmountLocalCurrency interface{} `json:"amountLocalCur"` Description string `json:"description"` PayItemDescription interface{} `json:"payItemDescr"` OptionalString interface{} `json:"optStrg"` OptionalNumber interface{} `json:"optNmb"` }
PayItem represents a payment item
type PingStatus ¶
type PingStatus struct { Time time.Time `json:"time"` Version string `json:"version"` Nonce string `json:"nonce"` Key string `json:"key"` }
PingStatus is the response when pinging the smobilpay API
type Quote ¶
type Quote struct { QuoteID string `json:"quoteId"` ExpiresAt time.Time `json:"expiresAt"` PayItemID string `json:"payItemId"` AmountLocalCurrency string `json:"amountLocalCur"` PriceLocalCurrency string `json:"priceLocalCur"` PriceSystemCurrency string `json:"priceSystemCur"` LocalCurrency string `json:"localCur"` SystemCurrency string `json:"systemCur"` Promotion interface{} `json:"promotion"` }
Quote represents an initialized transaction
type QuoteParams ¶
QuoteParams is the input needed to initialize a transaction
type RequestOption ¶
type RequestOption interface {
// contains filtered or unexported methods
}
RequestOption is options for constructing an API request
func WithRequestNonce ¶
func WithRequestNonce(nonce string) RequestOption
WithRequestNonce sets the nonce in the s3pAuth_nonce header
func WithRequestTimestamp ¶
func WithRequestTimestamp(timestamp time.Time) RequestOption
WithRequestTimestamp sets the timestamp in the s3pAuth_timestamp header
type Transaction ¶
type Transaction struct { PaymentTransactionNumber string `json:"ptn"` Timestamp time.Time `json:"timestamp"` AgentBalance string `json:"agentBalance"` ReceiptNumber string `json:"receiptNumber"` VerificationCode string `json:"veriCode"` ClearingDate string `json:"clearingDate"` PriceLocalCurrency string `json:"priceLocalCur"` PriceSystemCurrency string `json:"priceSystemCur"` LocalCurrency string `json:"localCur"` SystemCurrency string `json:"systemCur"` ExternalTransactionID *string `json:"trid"` Pin interface{} `json:"pin"` Status string `json:"status"` PayItemDescription *string `json:"payItemDescr"` PayItemID string `json:"payItemId"` }
Transaction represents a transaction
func (*Transaction) IsFailed ¶
func (transaction *Transaction) IsFailed() bool
IsFailed checks if a transaction failed
func (*Transaction) IsPending ¶ added in v0.0.2
func (transaction *Transaction) IsPending() bool
IsPending checks if a transaction is pending