modulepackage
0.0.6
Repository: https://github.com/ndolestudio/smobilpay-go.git
Documentation: pkg.go.dev
# README
Smobilpay Go SDK
This package provides an unofficial go
client for the Smobilpay API
Installation
smobilpay-go
is compatible with modern Go releases in module mode, with Go installed:
go get github.com/NdoleStudio/smobilpay-go
Alternatively the same can be achieved if you use import
in a package:
import "github.com/NdoleStudio/smobilpay-go"
Implemented
- Client
GET /ping
: API Healthcheck endpointGET /verifytx
: Get the current collection statusGET /historystd
: Get the transaction historyPOST /quotestd
: Initializes a transactionPOST /collectstd
: Confirms a transaction
- Bill
GET /bill
: Get details of a bill
- Topup
GET /topup
: Get available topup packages.
- Cashin
GET /cashin
: Get cashin pay item.
- Cashout
GET /cashout
: Get Cashout pay item.
- Product
GET /product
: Get product pay items.
Usage
Initializing the Client
An instance of the client can be created using New()
.
package main
import (
"github.com/NdoleStudio/smobilpay-go"
)
func main() {
client := smobilpay.New(
smobilpay.WithAccessToken(accessToken),
smobilpay.WithAccessSecret(accessSecret),
)
}
Error handling
All API calls return an error
as the last return object. All successful calls will return a nil
error.
status, response, err := client.Ping(context.Background())
if err != nil {
//handle error
}
Testing
You can run the unit tests for this client from the root directory using the command below:
go test -v
License
This project is licensed under the MIT License - see the LICENSE file for details
# Functions
New creates and returns a new *Client from a slice of Option.
WithAccessSecret sets the access secret for the smobilpay api.
WithAccessToken sets the access token for the smobilpay api.
WithBaseURL set's the base url for the smobilpay API.
WithCollectSyncVerifyInterval sets the interval for calling the `/verifytx` endpoint to check the status of pending transactions.
WithCollectSyncVerifyRetryCount sets the number of retries for calling the `/verifytx` endpoint to check the status of pending transactions.
WithHTTPClient sets the underlying HTTP client used for API requests.
WithRequestNonce sets the nonce in the s3pAuth_nonce header.
WithRequestTimestamp sets the timestamp in the s3pAuth_timestamp header.
# Constants
BillMerchantCamwater is the merchant name for camwater.
BillMerchantENEO is the merchant name for ENEO.
# Structs
Bill is the details for a bill payment.
BillGetParams are the parameters for getting a bill.
Client is the smobilpay API client.
CollectParams is the input needed to confirm a transaction.
PayItem represents a payment item.
PingStatus is the response when pinging the smobilpay API.
Quote represents an initialized transaction.
QuoteParams is the input needed to initialize a transaction.
Response captures the http response.
Transaction represents a transaction.
# Interfaces
Option is options for constructing a client.
RequestOption is options for constructing an API request.