A client library written in Go (golang) for the PayFast payment gateway which uses no external dependencies.
This client has parity with the existing API functionality provided by PayFast.
go get -u github.com/huysamen/payfast-go
Create a new client default client to start accessing your PayFast account.
import payfast "github.com/huysamen/payfast-go"
pf, err := payfast.Default()
This will create a client with the default settings. It also expects the following environment variables to be set:
PAYFAST_MERCHANT_ID=[your payfast merchant id]
PAYFAST_MERCHANT_PASSPHRASE=[your payfast merchant passphrase]
You can also create a more configurable client which accepts an *http.Client
as well as the merchant ID and passphrase.
pf, err := payfast.New(123, "passphrase", httpClient)
ok, err := pf.Health.Ping()
sub, err := pf.Subscriptions.Fetch("subscription-token")
An example of how to use the nullable types:
sub, err := pf.Subscriptions.Update(
"subscription-token",
subscriptions.UpdateSubscriptionReq{
Cycles: types.Numeric{}, // default instance treated as nil and ignored
Frequency: types.NewNumeric(types.Annual),
//RunDate: types.Time{}, // excluded field treated as nil and ignored
Amount: types.NewNumeric(123),
},
)