go get -u github.com/vannleonheart/doku-api-go
dokuConfig := doku.Config{
BaseUrl: "{doku_base_url}",
ClientID: "{your_client_id}",
SecretKey: "{your_secret_key}",
PublicKeyPath: "{your_doku_public_key_file_path}",
}
Sandbox Base URL
https://api-sandbox.doku.com
dokuClient := doku.New(&dokuConfig)
Set Request Id manually
requestId := "{your_request_id}"
dokuClient := dokuClient.WithRequestId(requestId)
Auto Generated Request Id
dokuClient := dokuClient.WithAutoGeneratedRequestId()
requestId := doku.RandomString(10)
result, err := dokuClient.WithRequestId(requestId).Checkout(doku.Request{
Order: doku.Order{
InvoiceNumber: "{your_invoice_number}",
Amount: "{amount}",
},
Payment: &doku.Payment{
PaymentDueDate: 60, // in minutes
},
})
if err != nil {
// handle error
}
fmt.Println(result.Response.Payment.Url)
requestId := doku.RandomString(10)
result, err := dokuClient.WithRequestId(requestId).CheckStatus("{your_invoice_number}")
if err != nil {
// handle error
}
fmt.Println(result.Transaction.Status)
requestId := doku.RandomString(10)
result, err := dokuClient.WithRequestId(requestId).CreateVirtualAccount(doku.VirtualAccountBCA, doku.Request{
Order: doku.Order{
InvoiceNumber: "{your_invoice_number}",
Amount: "{amount}",
},
VirtualAccountInfo: &doku.VirtualAccountInfo{
BillingType: doku.BillingTypeFixBill,
ExpiredTime: 60,
ReusableStatus: false,
Info1: "",
Info2: "",
Info3: "",
},
Customer: &doku.Customer{
Name: "John Doe",
Email: "johndoe@email.com",
},
})
if err != nil {
// handle error
}
fmt.Println(result.VirtualAccountInfo.VirtualAccountNumber)