Duitku API Library for Go
| Feature | Function | HTTP Request | Description |
|---|---|---|---|
| Get Payment Method | client.PaymentService.GetMethods | POST /merchant/paymentmethod/getpaymentmethod | Get list of available payment methods |
| Create New Transaction | client.TransactionService.Create | POST /merchant/v2/inquiry | Create Transaction via V2 API |
| Get Transaction | client.TransactionService.GetStatus | POST /merchant/transactionStatus | Get Transaction via V2 API |
| Craete New Invoice | client.InvoiceService.Create | POST /merchant/createInvoice | Create Transaction via POP API |
- Go 1.24 or later
- Duitku account, register here
- API Key
Make sure your project is using go modules, if not initialize it:
go mod initGet this library, add to your project
go get -u github.com/idoyudha/duitku-goimport (
"context"
"github.com/idoyudha/duitku-go"
"github.com/idoyudha/duitku-go/common"
"github.com/idoyudha/duitku-go/invoice"
)
client := duitku.NewClient(&common.Config{
MerchantCode: "YOUR MERCHANT CODE",
APIKey: "YOUR API KEY",
Environment: common.SandboxEnv,
})
invoiceRequest := invoice.CreateInvoiceRequest{
PaymentAmount: 10001,
MerchantOrderId: "YOUR UNIQUE ORDER ID",
ProductDetails: "YOUR PRODUCT DETAILS",
Email: "admin@yourcompany.com",
CallbackURL: "https://yourcompany.com/callback",
ReturnURL: "https://yourcompany.com",
}
res, httpResponse, err := client.InvoiceService.Create(context.Background(), invoiceRequest)
if err != nil {
log.Printf("Found error InvoiceService.Create => %v", err)
}
log.Printf("Full HTTP Response from InvoiceService.Create => %v", httpResponse)
log.Printf("Response body from InvoiceService.Create => %v", createInvoiceRes)- Invoice (Create Invoice - POP)
- Payment (Get Payment Method)
- Transaction (Create Transaction, Get Transaction Status)
If you have a feature request or spotted a bug or a techical problem, create an issue here. For other questions, please contact duitku through their live chat on your dashboard.
MIT license. For more information, see the LICENSE file.