Simple Go client for ToyyibPay API.
go get github.com/saiaapiz/toyyibpayapi
Import and create a client with your secret key:
import "github.com/saiaapiz/toyyibpayapi"
api := toyyibpayapi.New("YOUR_SECRET_KEY", true) // debug = true (optional)Get category details:
cat, err := api.Category("CATEGORY_CODE")
if err != nil { /* handle error */ }
fmt.Println(cat.Name, cat.Active())Create a bill (amount in sen — 1000 = RM10.00):
billcode, err := api.Create(
"CATEGORY_CODE",
"Title",
"Description",
1000,
toyyibpayapi.WithWebhook("ref-001", "https://example.com/webhook", "https://example.com/return"),
toyyibpayapi.WithPayerInfo("Name", "0123456789", "user@example.com"),
)
if err != nil { /* handle error */ }
fmt.Println("https://toyyibpay.com/" + billcode)Deactivate a bill:
if err := api.Deactive(billcode); err != nil { /* handle error */ }- Amounts are provided in sen (1 MYR = 100 sen).
- The client normalizes some non-standard ToyyibPay responses; check errors for backend messages.
- Use debug mode to print raw responses.
See example tests in repository. Provide your real secret and category code to run integration tests.
MIT