Skip to content

duitkupg/duitku-go

Repository files navigation

Duitku Golang API Client Library

Go Reference Build Status Go Report Card License: MIT

Duitku API Library for Go

Supported Feature

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

Requirements

Documentation

Installation

Make sure your project is using go modules, if not initialize it:

go mod init

Get this library, add to your project

go get -u github.com/idoyudha/duitku-go

Example Usage

import (
	"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)

More Detailed Example

Support

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.

License

MIT license. For more information, see the LICENSE file.

Packages

No packages published

Languages