Go package to use Billplz API.
Import this package
import (
billplz "github.com/billplz/billplz-go"
// models "github.com/billplz/billplz-go/models"
)
On the root folder, run dep ensure
On the root folder, run dep ensure -update
For POST requests, make sure to import the models from the package.
import (
"fmt"
billplz "github.com/billplz/billplz-go"
models "github.com/billplz/billplz-go/models"
)
There are 2 variables need for the init function, which is ENVIRONMENT
and APIKEY
.
You can get your key from your Billplz dashboard.
ENVIRONMENT = staging | production
. Setting the correct environment is crucial as Billplz uses different urls for each environment.
billplz.Init(ENVIRONMENT, APIKEY)
Reference: API V4 Get Collection
billplz.Init("staging", "69da23bf-da10-4fda-814d-3ad970035d38")
r, err := billplz.GetCollection("ei3a6mdl")
if len(err.Error.Type) > 0 {
fmt.Printf("%+v\n", err)
return
}
fmt.Printf("%+v\n", r)
Reference: API V4 Create Collection
Collection
struct:
Parameters | Data Type | Required |
---|---|---|
Title | string | true |
SplitHeader | string | false |
SplitPayments | array | false |
SplitPayment
struct:
Parameters | Type | Required |
---|---|---|
string | true | |
FixedCut | integer | false |
VariableCut | string | false |
StackOrder | integer | true |
billplz.Init("staging", "69da23bf-da10-4fda-814d-3ad970035d38")
data := models.Collection{
Title: "test 4",
SplitHeader: false,
SplitPayments: []models.SplitPayment{
{
Email: "abc@gmail.com",
FixedCut: 100,
StackOrder: 0,
},
{
Email: "abc@gmail.com",
FixedCut: 200,
StackOrder: 1,
},
},
}
r, err := billplz.CreateCollection(data)
if len(err.Error.Type) > 0 {
fmt.Printf("%+v\n", err)
return
}
fmt.Printf("%+v\n", r)
Reference: API V3 Create Bill
Bill
struct:
Parameters | Type | Required |
---|---|---|
CollectionId | string | true |
string | true | |
Mobile | string | true |
Name | string | true |
Amount | integer | true |
CallbackUrl | string | true |
Description | string | true |
DueAt | string | true |
RedirectUrl | integer | false |
Reference1Label | string | false |
Reference1 | string | false |
Reference2Label | string | false |
Reference2 | string | false |
billplz.Init("staging", "69da23bf-da10-4fda-814d-3ad970035d38")
data := models.Bill{
CollectionId: "gaem247h",
Email: "helmiruza@gmail.com",
Mobile: "60193102400",
Name: "Helmi Ruza",
Amount: 10000,
CallbackUrl: "https://billplz.com",
Description: "Test Bill 123",
DueAt: "2019-07-12",
}
resp, err := billplz.CreateBill(data)
if len(err.Error.Type) > 0 {
fmt.Printf("%+v\n", err)
return
}
fmt.Printf("%+v\n", resp)
Reference: API V3 Get Bill
billplz.Init("staging", "69da23bf-da10-4fda-814d-3ad970035d38")
resp, err := billplz.GetBill("0npozuf0")
if len(err.Error.Type) > 0 {
fmt.Printf("%+v\n", err)
return
}
fmt.Printf("%+v\n", resp)
Reference: API V4 Create Payout Collection
PayoutCollection
struct:
Parameters | Type | Required |
---|---|---|
Title | string | true |
billplz.Init("staging", "69da23bf-da10-4fda-814d-3ad970035d38")
data := models.PayoutCollection{
Title: "Collection for Payout",
}
fmt.Println(billplz.CreatePayoutCollection(data))
Reference: API V4 Get Payout Collection
billplz.Init("staging", "69da23bf-da10-4fda-814d-3ad970035d38")
fmt.Println(billplz.GetPayoutCollection(PAYOUT_COLLECTION_ID))
Reference: API V3 Get FPX Banks
This list can be used to bypass Billplz's bill page.
billplz.Init("staging", "69da23bf-da10-4fda-814d-3ad970035d38")
fmt.Println(billplz.GetFpxBanks())
Reference: API V3 Get Bank Account
billplz.Init("staging", "69da23bf-da10-4fda-814d-3ad970035d38")
fmt.Println(billplz.GetBankVerification(BANK_ACCOUNT_NO))
Reference: API V3 Create Bank Account
This process is required for Mass Payment Instructions (Payout). In order to create a successful payout instruction, each recipient's account should be verified.
Bank
struct:
Parameters | Type | Required |
---|---|---|
Name | string | true |
IdNo | string | true |
AccNo | string | true |
Code | string | true |
Organization | boolean | true |
billplz.Init("staging", "69da23bf-da10-4fda-814d-3ad970035d38")
data := models.Bank{
Name: "Insan Jaya",
IdNo: "91234567890",
AccNo: "999988887777",
Code: "MBBEMYKL",
Organization: true
}
fmt.Println(billplz.CreateBankVerfication(data))
Facebook: Billplz Dev Jam