Skip to content
Xendit REST API Client for Go - Card, Virtual Account, Invoice, Disbursement, Recurring Payments, Payout, EWallet, Balance, Retail Outlets Services
Go Makefile
Branch: master
Clone or download

Latest commit

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows ci(actions) Add go get test deps Mar 9, 2020
balance Merge branch 'master' of github.com:slzhffktm/xendit-go into fix-all Feb 3, 2020
card
cardlesscredit Add readme Feb 24, 2020
client fix(client) Add missing disbursement cli Mar 3, 2020
disbursement style(gofmt) Fix pending style issues from goreport Mar 10, 2020
ewallet
example Add readme Feb 24, 2020
integration_test ci(actions) Enrich error from integration test Mar 5, 2020
invoice style(gofmt) Fix pending style issues from goreport Mar 10, 2020
payout Change (c Client) to (c *Client) Jan 29, 2020
recurringpayment ci(actions) Fix ci failures Mar 5, 2020
retailoutlet
utils
virtualaccount style(gofmt) Fix pending style issues from goreport Mar 10, 2020
.editorconfig Create Base Structure and Invoice (#2) Jan 15, 2020
.env.example Ignore .env and add .env.example Jan 29, 2020
.gitignore ci(actions) Add Github Actions for test, lint, & coverage Mar 5, 2020
.pre-commit-config.yaml ci(precommit) Add simplify opt to gofmt Mar 10, 2020
LICENSE feat(license) Add MIT License Feb 18, 2020
Makefile Add readme Feb 24, 2020
README.md docs(README) Add goreport badge Mar 10, 2020
apirequester.go
balance.go docs(godocs) Provide links to go.dev in documentations Mar 4, 2020
card.go
cardlesscredit.go docs(godocs) Provide links to go.dev in documentations Mar 4, 2020
disbursement.go docs(godocs) Provide links to go.dev in documentations Mar 4, 2020
error.go Create Base Structure and Invoice (#2) Jan 15, 2020
ewallet.go docs(godocs) Provide links to go.dev in documentations Mar 4, 2020
example_test.go docs(example) Add examples to root package Mar 3, 2020
go.mod ci(actions) Add go get test deps Mar 9, 2020
go.sum ci(actions) Add go get test deps Mar 9, 2020
invoice.go docs(godocs) Provide links to go.dev in documentations Mar 4, 2020
newhttprequest_113.go fix(apirequester) Add support for pre1.13 w/o NewRequestWithContext Mar 5, 2020
newhttprequest_pre113.go fix(apirequester) Add support for pre1.13 w/o NewRequestWithContext Mar 5, 2020
payout.go
recurringpayment.go ci(actions) Fix ci failures Mar 5, 2020
retailoutlet.go docs(godocs) Provide links to go.dev in documentations Mar 4, 2020
virtualaccount.go docs(godocs) Provide links to go.dev in documentations Mar 4, 2020
xendit.go Create Base Structure and Invoice (#2) Jan 15, 2020

README.md

Xendit API Go Client

go.dev reference Coverage Status Go Report Card

This library is the abstraction of Xendit API for access from applications written with Go.

Documentation

For the API documentation, check Xendit API Reference.

For the details of this library, see the GoDoc.

Installation

Install xendit-go with:

go get -u github.com/xendit/xendit-go

Then, import it using:

import (
    "github.com/xendit/xendit-go"
    "github.com/xendit/xendit-go/$product$"
)

with $product$ is the product of Xendit such as invoice and balance.

Go Module Support

This library supports Go modules by default. Simply require xendit-go in go.mod with a version like so:

module github.com/my/package

go 1.13

require (
  github.com/xendit/xendit-go v1.0.0
)

And use the same style of import paths as above:

import (
    "github.com/xendit/xendit-go"
    "github.com/xendit/xendit-go/$product$"
)

with $product$ is the product of Xendit such as invoice and balance.

Using xendit-go with $GOPATH

If you are still using $GOPATH and not planning to migrate to go mod, installing xendit-go would require installing its (only) dependency validator via

go get -u github.com/go-playground/validator

Please note that this means you are using master of validator and effectively miss out on its versioning that's gomod-based.

After installing validator, xendit-go can be installed normally.

Usage

The following pattern is applied throughout the library for a given $product$:

Without Client

If you're only dealing with a single secret key, you can simply import the packages required for the products you're interacting with without the need to create a client.

import (
    "github.com/xendit/xendit-go"
    "github.com/xendit/xendit-go/$product$"
)

// Setup
xendit.Opt.SecretKey = "examplesecretkey"

xendit.SetAPIRequester(apiRequester) // optional, useful for mocking

// Create
resp, err := $product$.Create($product$.CreateParams)

// Get
resp, err := $product$.Get($product$.GetParams)

// GetAll
resp, err := $product$.GetAll($product$.GetAllParams)

With Client

If you're dealing with multiple secret keys, it is recommended you use client.API. This allows you to create as many clients as needed, each with their own individual key.

import (
    "github.com/xendit/xendit-go"
    "github.com/xendit/xendit-go/client"
)

// Basic setup
xenCli := client.New("examplesecretkey")

// or with optional, useful-for-mocking `exampleAPIRequester`
xenCli := client.New("examplesecretkey").WithAPIRequester(exampleAPIRequester)

// Create
resp, err := xenCli.$product$.Create($product$.CreateParams)

// Get
resp, err := xenCli.$product$.Get($product$.GetParams)

// GetAll
resp, err := xenCli.$product$.GetAll($product$.GetAllParams)

Sub-Packages Documentations

The following is a list of pointers to documentations for sub-packages of xendit-go.

Contribute

For any requests, bugs, or comments, please open an issue or submit a pull request.

Test

After modifying the code, please make sure that the code passes all test cases.

Run all tests

go test ./...

Run tests for a package

go test ./invoice

Run a single test

go test ./invoice -run TestCreateInvoice

Run integration tests

SECRET_KEY=<your secret key> go run ./integration_test

Pre-commit

Before making any commits, please install pre-commit. To install pre-commit, follow the installation steps.

After installing the pre-commit, please install the needed dependencies:

make init

After the code passes everything, please submit a pull request.

You can’t perform that action at this time.