Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Kachit/fasapay-sdk-go
Fasapay payment gateway XML API Client for Go (Unofficial)
https://github.com/Kachit/fasapay-sdk-go
api api-client fasapay golang payment-gateway payment-integration sdk sdk-go unofficial
Last synced: 3 months ago
JSON representation
Fasapay payment gateway XML API Client for Go (Unofficial)
- Host: GitHub
- URL: https://github.com/Kachit/fasapay-sdk-go
- Owner: Kachit
- License: mit
- Created: 2022-03-26T19:28:26.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-16T19:15:37.000Z (over 2 years ago)
- Last Synced: 2024-07-30T20:44:38.435Z (6 months ago)
- Topics: api, api-client, fasapay, golang, payment-gateway, payment-integration, sdk, sdk-go, unofficial
- Language: Go
- Homepage: https://www.fasapay.com/en/apiguide/index
- Size: 112 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - fasapay-sdk-go - Unofficial Fasapay payment gateway XML API Client for Golang. (Third-party APIs / Utility/Miscellaneous)
- awesome-go-extra - fasapay-sdk-go - 03-26T19:28:26Z|2022-06-16T19:15:37Z| (Third-party APIs / Fail injection)
README
# Fasapay XML API SDK GO (Unofficial)
[![Build Status](https://app.travis-ci.com/Kachit/fasapay-sdk-go.svg?branch=master)](https://app.travis-ci.com/github/Kachit/fasapay-sdk-go)
[![Codecov](https://codecov.io/gh/Kachit/fasapay-sdk-go/branch/master/graph/badge.svg)](https://codecov.io/gh/Kachit/fasapay-sdk-go)
[![Go Report Card](https://goreportcard.com/badge/github.com/kachit/fasapay-sdk-go)](https://goreportcard.com/report/github.com/kachit/fasapay-sdk-go)
[![Version](https://img.shields.io/github/go-mod/go-version/Kachit/fasapay-sdk-go)](https://go.dev/doc/go1.14)
[![Release](https://img.shields.io/github/v/release/Kachit/fasapay-sdk-go.svg)](https://github.com/Kachit/fasapay-sdk-go/releases)
[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/kachit/fasapay-sdk-go/blob/master/LICENSE)
[![GoDoc](https://pkg.go.dev/badge/github.com/kachit/fasapay-sdk-go)](https://pkg.go.dev/github.com/kachit/fasapay-sdk-go)
[![Mentioned in Awesome Go](https://awesome.re/mentioned-badge.svg)](https://github.com/avelino/awesome-go#third-party-apis)## Description
Unofficial Fasapay payment gateway XML API Client for Go## API documentation
https://www.fasapay.com/en/apiguide/index## Installation
```shell
go get -u github.com/kachit/fasapay-sdk-go
```## Usage
```go
package mainimport (
"fmt"
"context"
fasapay "github.com/kachit/fasapay-sdk-go"
)func main(){
// Create a client instance
cfg := fasapay.NewConfig("Your API key", "Your API secret word")
client, err := fasapay.NewClientFromConfig(cfg, nil)
if err != nil {
fmt.Printf("config parameter error " + err.Error())
panic(err)
}
}
```
### Get balances list
```go
ctx := context.Background()
currencies := []fasapay.CurrencyCode{fasapay.CurrencyCodeIDR, fasapay.CurrencyCodeUSD}
result, resp, err := client.Accounts().GetBalances(currencies, ctx, nil)if err != nil {
fmt.Printf("Wrong API request " + err.Error())
panic(err)
}//Dump raw response
fmt.Println(response)//Dump result
fmt.Println(result.Balances.IDR)
fmt.Println(result.Balances.USD)
```
### Get accounts list
```go
ctx := context.Background()
accounts := []string{"FP0000001", "FP0000002"}
result, resp, err := client.Accounts().GetAccounts(accounts, ctx, nil)if err != nil {
fmt.Printf("Wrong API request " + err.Error())
panic(err)
}//Dump raw response
fmt.Println(response)//Dump result
fmt.Println(result.Accounts[0].FullName)
fmt.Println(result.Accounts[0].Account)
fmt.Println(result.Accounts[0].Status)
```### Create transfer
```go
ctx := context.Background()
transfer1 := &CreateTransferRequestParams{
Id: "123",
To: "FP89680",
Amount: 1000.0,
Currency: CurrencyCodeIDR,
Note: "standart operation",
}transfer2 := &CreateTransferRequestParams{
Id: "1234",
To: "FP89681",
Amount: 1001.0,
Currency: CurrencyCodeIDR,
Note: "standart operation",
}
result, resp, err := client.Transfers().CreateTransfer([]*CreateTransferRequestParams{transfer, transfer2}, ctx, nil)if err != nil {
fmt.Printf("Wrong API request " + err.Error())
panic(err)
}//Dump raw response
fmt.Println(response)//Dump result
fmt.Println(result.Transfers[0].BatchNumber)
fmt.Println(result.Transfers[0].Datetime)
fmt.Println(result.Transfers[0].From)
fmt.Println(result.Transfers[0].To)
fmt.Println(result.Transfers[0].Amount)
fmt.Println(result.Transfers[0].Note)fmt.Println(result.Transfers[1].BatchNumber)
fmt.Println(result.Transfers[1].Datetime)
fmt.Println(result.Transfers[1].From)
fmt.Println(result.Transfers[1].To)
fmt.Println(result.Transfers[1].Amount)
fmt.Println(result.Transfers[1].Note)
```### Get transfers history
```go
ctx := context.Background()
history := &fasapay.GetHistoryRequestParams{StartDate: "2022-03-01", EndDate: "2022-03-28"}
result, resp, err := client.Transfers().GetHistory(history, ctx, nil)if err != nil {
fmt.Printf("Wrong API request " + err.Error())
panic(err)
}//Dump raw response
fmt.Println(response)//Dump result
fmt.Println(result.History.Page.TotalItem)
fmt.Println(result.History.Page.PageCount)
fmt.Println(result.History.Page.CurrentPage)fmt.Println(result.History.Details[0].BatchNumber)
fmt.Println(result.History.Details[0].Datetime)
fmt.Println(result.History.Details[0].From)
fmt.Println(result.History.Details[0].To)
fmt.Println(result.History.Details[0].Amount)
fmt.Println(result.History.Details[0].Note)
```### Get transfers details
```go
ctx := context.Background()
var detail1 fasapay.GetDetailsRequestDetailParamsString = "TR0000000001"
var detail2 fasapay.GetDetailsRequestDetailParamsString = "TR0000000002"
details := []fasapay.GetDetailsDetailParamsInterface{&detail1, &detail2}
result, resp, err := client.Transfers().GetDetails(details, ctx, nil)if err != nil {
fmt.Printf("Wrong API request " + err.Error())
panic(err)
}//Dump raw response
fmt.Println(response)//Dump result
fmt.Println(result.Details[0].BatchNumber)
fmt.Println(result.Details[0].Datetime)
fmt.Println(result.Details[0].From)
fmt.Println(result.Details[0].To)
fmt.Println(result.Details[0].Amount)
fmt.Println(result.Details[0].Note)fmt.Println(result.Details[1].BatchNumber)
fmt.Println(result.Details[1].Datetime)
fmt.Println(result.Details[1].From)
fmt.Println(result.Details[1].To)
fmt.Println(result.Details[1].Amount)
fmt.Println(result.Details[1].Note)
```