Skip to content

vannleonheart/doku-api-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DOKU API

Installation

go get -u github.com/vannleonheart/doku-api-go

Config

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

Client

dokuClient := doku.New(&dokuConfig)

Set Request Id manually

requestId := "{your_request_id}"

dokuClient := dokuClient.WithRequestId(requestId)

Auto Generated Request Id

dokuClient := dokuClient.WithAutoGeneratedRequestId()

Checkout Payment URL (Back-End Integration)

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)

Check Status using Invoice Number

requestId := doku.RandomString(10)

result, err := dokuClient.WithRequestId(requestId).CheckStatus("{your_invoice_number}")

if err != nil {
    // handle error
}

fmt.Println(result.Transaction.Status)

Create Virtual Account (Non-SNAP)

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)

About

Go library for Doku

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages