forpay-sdk-go

module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 14, 2020 License: Apache-2.0

README

Forpay SDK for Go

API Reference Apache V2 License Build Status Go Report Card Codacy Badge FOSSA Status

Installing

Use go get to retrive the SDK to add it to your GOPATH workspace, or project's go module dependencies.

go get github.com/hactrox/forpay-sdk-go/forpay

To update the SDK use go get -u to retrieve the latest version of the SDK.

go get -u github.com/hactrox/forpay-sdk-go/forpay

Quick Start

package main

import (
    "fmt"

    "github.com/hactrox/forpay-sdk-go/forpay"
    "github.com/hactrox/forpay-sdk-go/forpay/response"
)

var client *forpay.Client

func main() {
    var err error

    // Prepare required variables.
    appID := "00000000"
    keyID := "00000000000000000000000000000000"
    keyFile := "./priv.pem"

    // Create forpay sdk client instance.
    client, err = forpay.NewClientWithRSA(appID, keyID, keyFile)
    if err != nil {
        panic(err)
    }

    // Prepare required request parameters.
    currencyID := uint16(1)
    walletID := uint64(8888888888888888)
    // Create request using `CreateXXXRequest` funcs.
    req := forpay.CreateGetBalanceRequest(walletID, currencyID)

    // Send request and receive response.
    resp, err := client.GetBalance(req)
    if err != nil {
        // Check if the error is `*response.Error`.
        if e, ok := err.(*response.Error); ok {
            fmt.Println(e.Error())

            // You can handle specific errors according to the following info.
            // fmt.Println(e.HTTPStatus)
            // fmt.Println(e.IsBusinessFailed())
            // fmt.Println(e.Code)
            // fmt.Println(e.Msg)
            // fmt.Println(e.SubCode)
            // fmt.Println(e.SubMsg)
        } else {
            fmt.Println(err)
        }

        return
    }

    // Handle response.
    fmt.Println(resp.Data.CurrencyID)
    fmt.Println(resp.Data.Available)
    fmt.Println(resp.Data.Frozen)
    fmt.Println(resp.Data.Locked)
}

License

This SDK is distributed under the Apache License, Version 2.0.

FOSSA Status

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL