fazz

package module
v0.2.0-beta Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: MIT Imports: 1 Imported by: 0

README

Fazz / Xfers SDK for Go

GoDoc Test Status Go Report Card

Table of Contents

Overview

🚧 The SDK is currently undergoing heavy development with frequent changes, because of this please get the latest update of the SDK 🚧

Compatibility: The SDK has been developed using Indonesia Payment API version 4 and currently does not support Singapore Payments.

Fazz previously Xfers, is a company that provides financial services in Southeast Asia such as sending and receiving payments, grow their capital, and get funding.

Fazz provides SDKs in several programming languages but not in Go. Because of this the SDK was created.

For more information, visit the Fazz Payments API Official documentation.

Installation

Make sure you are using go version 1.18 or later

go get -u github.com/abmid/fazz-sdk-go

Documentation

package main

import (
	"context"
	"fmt"

	"github.com/abmid/fazz-sdk-go"
	"github.com/abmid/fazz-sdk-go/client"
)

func main() {
	c := client.New(client.Options{ApiKey: "test_apikey", SecretKey: "secretkey"})

	payload := fazz.ValidateBankAccountPayload{
		AccountNo:     "000501003219303",
		BankShortCode: "BRI",
	}

	res, err := c.ValidationService.BankAccount(context.Background(), payload)
	if err != nil {
		// Handle case error
	}

	fmt.Println(res)
}

Example Create Payment for Virtual Account

	// ========== Example Create VA ==========
	payload := fazz.PaymentCreateVAPayload{
		Payment: fazz.Payment{
			Amount:      15000,
			ReferenceId: "SDK_TEST_01",
			ExpiredAt:   time.Now().Add(70 * time.Minute).Format(time.RFC3339),
			Description: "SDK desc",
		},
		PaymentMethodOptions: fazz.PaymentVAOptions{
			BankShortCode: "BCA",
			DisplayName:   "GOOD Man",
			SuffixNo:      "123456",
		},
	}
	res, err := c.Payment.CreateVA(context.Background(), payload)
	if err != nil {
		// handle case error
		fmt.Println(err)
	}

	fmt.Println(res)

For more examples, please check directory example and Godoc

API Supports

  • PAYMENTS
    • Create a payment
    • Get a payment
    • Get a list of payments
    • Update a payment
  • PAYMENT METHODS
    • Create a payment method
    • Get a payment method
    • Get a list of payments for a payment method
    • Create a mock payment for a payment method
  • PAYMENT LINKS
    • Create a payment link
    • Get a payment link
    • Update a payment link
  • DISBURSEMENTS
    • Create a disbursement
    • Get a disbursement
    • Get a list of disbursements
    • Update a disbursement
    • Get a list of banks
  • ACCOUNTS
    • Get account balance
  • VALIDATIONS
    • validate a bank account

Contributing

We are open and grateful for any contribution. If you want to contribute please do PR and follow the code guide.

License

Copyright (c) 2023-present Abdul Hamid and Contributors. This SDK is free and open-source software licensed under the MIT License.

Documentation

Index

Constants

View Source
const (
	ErrorCodeSDK = "SDK_ERROR"
	// Generic Errors
	// ErrorCode000 is used for error Unknown error
	ErrorCode000 = "000"
	// ErrorCode001 is used for error Internal server error
	ErrorCode001 = "001"
	// ErrorCode002 is used for error Access denied
	ErrorCode002 = "002"
	// ErrorCode003 is used for error Feature not supported
	ErrorCode003 = "003"
	// ErrorCode004 is used for error Record not found
	ErrorCode004 = "004"
	// ErrorCode005 is used for error Invalid parameters
	ErrorCode005 = "005"
	// ErrorCode010 is used for error Service Temporarily Unavailable
	ErrorCode010 = "010"

	// Transaction Specific Errors
	// ErrorCodeTXN0001 is used for error Account has insufficient funds
	ErrorCodeTXN0001 = "TXN0001"
	// ErrorCodeTXN0002 is used for error Invalid transaction amount
	ErrorCodeTXN0002 = "TXN0002"
	// ErrorCodeTXN0003 is used for error Transaction exceeds account transaction limit
	ErrorCodeTXN0003 = "TXN0003"
	// ErrorCodeTXN0004 is used for error Transaction exceeds account balance limit
	ErrorCodeTXN0004 = "TXN0004"
	// ErrorCodeTXN0005 is used for error Failed to create virtual account number
	ErrorCodeTXN0005 = "TXN0005"
	// ErrorCodeTXN0006 is used for error suffixNo params is not supported for this bank
	ErrorCodeTXN0006 = "TXN0006"
	// ErrorCodeTXN0007 is used for error suffixNo params exceed maximum number limit
	ErrorCodeTXN0007 = "TXN0007"
)
View Source
const (
	SandboxURL    = "https://sandbox-id.xfers.com/api"
	ProductionURL = "https://id.xfers.com/api"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DisbursementCreatePayload

type DisbursementCreatePayload struct {
	Amount             uint32             `json:"amount"`      // Required
	ReferenceID        string             `json:"referenceId"` // Required
	Description        string             `json:"description"`
	DisbursementMethod DisbursementMethod `json:"disbursementMethod"` // Required
}

DisbursementCreatePayload is payload for create disbursement API

type DisbursementMethod

type DisbursementMethod struct {
	Type                  string `json:"type"`          // Required
	BankShortCode         string `json:"bankShortCode"` // Required
	BankAccountNo         string `json:"bankAccountNo"` // Required
	BankAccountHolderName string `json:"bankAccountHolderName"`
}

DisbursementMethod is part of payload create disbursement

type DisbursementUpdatePayload

type DisbursementUpdatePayload struct {
	Action string `json:"action"`
}

DisbursementUpdatePayload is payload for update disbursement API

type Error

type Error struct {
	HttpStatusCode int      // Response from http status code
	Errors         []Errors `json:"errors"`
}

Error is combined from standard error Fazz with response HTTP Status Code

func ErrFromAPI

func ErrFromAPI(httpStatusCode int, responseBody []byte) *Error

ErrFromAPI is used when get an error from response API

func ErrFromSDK

func ErrFromSDK(err error) *Error

ErrFromSDK is used when get an error from the SDK

type Errors

type Errors struct {
	Code   string `json:"code"`
	Title  string `json:"title"`
	Detail string `json:"detail"`
}

Errors is standard list response error from Fazz

type FazzParams

type FazzParams struct {
	PageNumber    uint32 `url:"page[number],omitempty"`
	PageSize      uint32 `url:"page[size],omitempty"`
	Sort          string `url:"sort,omitempty"`
	CreatedAfter  string `url:"filter[createdAfter],omitempty"`  // Time.iso8601
	CreatedBefore string `url:"filter[createdBefore],omitempty"` // Time.iso8601
	Status        string `url:"filter[status],omitempty"`
	ReferenceID   string `url:"filter[referenceId],omitempty"`
}

FazzParams represent default pagination, sorting & filtering from Fazz

type FazzPayload

type FazzPayload struct {
	Data struct {
		Attributes any `json:"attributes"`
	} `json:"data"`
}

FazzPayload represent default format body params from Fazz

type Payment

type Payment struct {
	PaymentMethodType string `json:"paymentMethodType"` // Required
	Amount            uint32 `json:"amount"`            // Required
	ReferenceId       string `json:"referenceId"`       // Required
	ExpiredAt         string `json:"expiredAt,omitempty"`
	Description       string `json:"description,omitempty"`
}

Payment is general payload for create a payment like retail outlet, va, qris and e-wallet.

type PaymentCreateEwalletPayload

type PaymentCreateEwalletPayload struct {
	Payment
	PaymentMethodOptions PaymentEwalletOptions `json:"paymentMethodOptions"`
}

PaymentCreateEwalletPayload represent for request payload Create a Payment (E-Wallet)

type PaymentCreateQRISPayload

type PaymentCreateQRISPayload struct {
	Payment
	PaymentMethodOptions PaymentQRISOptions `json:"paymentMethodOptions"`
}

PaymentCreateQRISPayload represent for request payload Create a Payment (QRIS)

type PaymentCreateRetailPayload

type PaymentCreateRetailPayload struct {
	Payment
	PaymentMethodOptions PaymentRetailOptions `json:"paymentMethodOptions"`
}

PaymentCreateRetailPayload represent for request payload Create a Payment (Retail Outlet)

type PaymentCreateVAPayload

type PaymentCreateVAPayload struct {
	Payment
	PaymentMethodOptions PaymentVAOptions `json:"paymentMethodOptions"`
}

PaymentCreateVAPayload represent for request payload Create a Payment (Virtual Account)

type PaymentEwalletOptions

type PaymentEwalletOptions struct {
	ProviderCode              string `json:"providerCode"`
	AfterSettlementReturnlUrl string `json:"afterSettlementReturnUrl"`
}

PaymentEwalletOptions is part of PaymentCreateEwalletPayload

type PaymentLinkCreatePayload

type PaymentLinkCreatePayload struct {
	Amount               uint32             `json:"amount"`              // Required
	ReferenceId          string             `json:"referenceId"`         // Required
	CustomerName         string             `json:"customerName"`        // Required
	CustomerEmail        string             `json:"customerEmail"`       // Required
	CustomerPhoneNumber  string             `json:"customerPhoneNumber"` // Required
	Description          string             `json:"description"`         // Required
	ExpiredAt            string             `json:"expiredAt,omitempty"` // ISO601
	PaymentMethodOptions PaymentLinkOptions `json:"paymentMethodOptions"`
}

PaymentLinkCreatePayload represent request payload for Create a Payment Link API.

type PaymentLinkOptions

type PaymentLinkOptions struct {
	DisplayName string `json:"displayName,omitempty"`
}

PaymentLinkOptions is part of PaymentLinkCreatePayload

type PaymentLinkUpdatePayload

type PaymentLinkUpdatePayload struct {
	// cancel, receive_payment, or settle. receive_payment & settle for sandbox purpose
	Action string `json:"action"`
}

PaymetLinkUpdatePayload represent request payload for Update a Payment Link API.

type PaymentMethodCreateQRISPayload

type PaymentMethodCreateQRISPayload struct {
	ReferenceID string `json:"referenceId"` // Required
	DisplayName string `json:"displayName"`
}

PaymentMethodCreateQRISPayload represent request payload for Create Payment Method type QRIS API.

type PaymentMethodCreateVAPayload

type PaymentMethodCreateVAPayload struct {
	ReferenceID   string `json:"referenceId"`   // Required
	BankShortCode string `json:"bankShortCode"` // Required
	DisplayName   string `json:"displayName"`   // Required
	SuffixNo      string `json:"suffixNo,omitempty"`
}

PaymentMethodCreateVAPayload represent request payload for Create Payment Method type Virtual Account API.

type PaymentMethodOptions

type PaymentMethodOptions struct {
	Amount float32 `json:"amount"`
}

PaymentMethodOptions is part of PaymentMethodSimulatePayload

type PaymentMethodSimulatePayload

type PaymentMethodSimulatePayload struct {
	Action  string               `json:"action"`
	Options PaymentMethodOptions `json:"options"`
}

PaymentMethodSimulatePayload represent request payload for Create a mock payment API.

type PaymentQRISOptions

type PaymentQRISOptions struct {
	DisplayName string `json:"displayName"`
}

PaymentQRISOptions is part of PaymentCreateQRISPayload

type PaymentRetailOptions

type PaymentRetailOptions struct {
	RetailOutletName string `json:"retailOutletName"`
	DisplayName      string `json:"displayName"`
}

PaymentRetailOptions is part of PaymentCreateRetailPayload

type PaymentUpdatePayload

type PaymentUpdatePayload struct {
	Action string `json:"action"`
}

PaymentUpdatePayload represent for request payload Update a Payment API.

type PaymentVAOptions

type PaymentVAOptions struct {
	BankShortCode string `json:"bankShortCode"`
	DisplayName   string `json:"displayName"`
	SuffixNo      string `json:"suffixNo,omitempty"`
}

PaymentVAOptions is part of PaymentCreateVAPayload

type ValidateBankAccountPayload

type ValidateBankAccountPayload struct {
	AccountNo     string `json:"accountNo"`
	BankShortCode string `json:"bankShortCode"`
}

ValidateBankAccount represent for payload request Validate a bank account API

Docs: https://docs.fazz.com/v4-ID/reference/validate-bank-account

Directories

Path Synopsis
internal
test/mock
Package mock_request is a generated GoMock package.
Package mock_request is a generated GoMock package.

Jump to

Keyboard shortcuts

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