Unofficial iPaymu API wrapper written in Golang for access from applications.
For the API documentation, please check iPaymu API Documentation.
- Redirect Payment
- Direct Payment
- Get Balance Account
- Detail Transaction
- Clean Code
- Testing
- COD Feature in Direct and Redirect Payment
go get -u github.com/ferdhika31/iPaymu-go
By default the environment set the production
. You can set manually if you need.
import (
ipaymu "github.com/ferdhika31/iPaymu-go"
cnstipay "github.com/ferdhika31/iPaymu-go/consts"
)
var cfg = ipaymu.NewConfig()
cfg.Env = cnstipay.Sandbox
// or
cfg.Env = cnstipay.Production
cfg.ApiSecret = "API_SECRET_KEY_HERE"
cfg.VirtualAccount = "VA_KEY_HERE"
By default the notifyUrl
is mandatory for redirect payment
or direct payment
. You can set url manually if you need. returnUrl
and cancelUrl
can only be used when redirect payment
.
cfg.NotifyUrl = "http://localhost:8000/notify"
cfg.ReturnUrl = "http://localhost:8000/return"
cfg.CancelUrl = "http://localhost:8000/cancel"
var payment = ipaymu.Payment{Config: cfg}
// optional
var c = ipaymu.NewCustomer("Ferdhika", "08313213131", "fer@dika.web.id")
payment.SetCustomer(c)
// mandatory
payment.AddProduct(ipaymu.Product{Name: "Pot Kayu", Qty: 1, Price: 18000})
payment.AddProduct(ipaymu.Product{Name: "Kaos", Qty: 2, Price: 60000})
res, _ := payment.RedirectPayment(&ipaymu.RedirectRequest{
// optional
ReferenceID: "TRX0031",
PaymentMethod: cnstipay.VA,
})
b := ipaymu.Balance{Config: cfg}
res, _ := b.GetBalance()
trx := ipaymu.Transaction{Config: cfg}
res, _ := trx.GetTransaction(id)
For any requests, bugs, or comments, please open an issue or submit a pull request.