toyyibpayapi

package module
v0.0.0-...-2a3721e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2025 License: MIT Imports: 5 Imported by: 0

README

toyyibpayapi

Simple Go client for ToyyibPay API.

Installation

go get github.com/saiaapiz/toyyibpayapi

Usage

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 */ }

Notes

  • 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.

Tests

See example tests in repository. Provide your real secret and category code to run integration tests.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(secret string, debug ...bool) *client

func WithPayerInfo

func WithPayerInfo(Name, Phone, Email string) billOptions

func WithWebhook

func WithWebhook(Reference, URL string, ReturnUrl ...string) billOptions

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL