oygo

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 11 Imported by: 0

README

OY! Indonesia API Go Client

go.dev reference Go Report Card

This library is the abstraction of OY! Indonesia API for access from applications written with Go.

Documentation

For the API documentation, check OY! API Reference.

For the details of this library, see the GoDoc.

Installation

Install oy-go with:

go get -u github.com/nadhirfr/oy-go

Then, import it using:

import (
    oygo "github.com/nadhirfr/oy-go"
    "github.com/nadhirfr/oy-go/$product$"
)

with $product$ is the product of OY! such as checkout and balance.

Go Module Support

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

module github.com/my/package

go 1.17

require (
  github.com/nadhirfr/oy-go v1.0.0
)

And use the same style of import paths as above:

import (
    oygo "github.com/nadhirfr/oy-go"
    "github.com/nadhirfr/oy-go/$product$"
)

with $product$ is the product of OY! such as checkout and balance.

Usage

It is recommended you use With Client method. 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 (
    oygo "github.com/nadhirfr/oy-go"
    "github.com/nadhirfr/oy-go/$product$"
)

// Setup
oygo.Opt.Username = "exampleusername"
oygo.Opt.SecretKey = "examplesecretkey"


// 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 (
    oygo "github.com/nadhirfr/oy-go"
    "github.com/nadhirfr/oy-go/client"
)

// Basic setup
oyClient := client.New("examplesecretkey", "exampleusername")

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

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

// GetAll
resp, err := oyClient.$product$.GetAll($product$.GetAllParams)
Sub-Packages Documentations

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

Contribute

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

License

MIT © LICENSE

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AllBankCode = map[BankCode]string{}/* 104 elements not displayed */

AllBankCode : Get All available PaymentType

Functions

func SetAPIRequester

func SetAPIRequester(apiRequester APIRequester)

SetAPIRequester sets the APIRequester for API call

func SetHTTPClient

func SetHTTPClient(newHTTPClient *http.Client)

SetHTTPClient sets the httpClient for API call

Types

type APIRequester

type APIRequester interface {
	Call(ctx context.Context, method string, url string, header *http.Header, body interface{}, result interface{}) *Error
}

APIRequester abstraction of HTTP Client that will make API calls to OY backend. `body` is POST-requests' bodies if applicable. `result` pointer to value which response string will be unmarshalled to.

func GetAPIRequester

func GetAPIRequester() APIRequester

GetAPIRequester returns the oy APIRequester. If it is already created, it will return the created one. Else, it will create a default implementation.

type APIRequesterImplementation

type APIRequesterImplementation struct {
	HTTPClient *http.Client
}

APIRequesterImplementation is the default implementation of APIRequester

func (*APIRequesterImplementation) Call

func (a *APIRequesterImplementation) Call(ctx context.Context, method string, url string, header *http.Header, body interface{}, result interface{}) *Error

Call makes HTTP requests with JSON-format body. `body` is POST-requests' bodies if applicable. `result` pointer to value which response string will be unmarshalled to.

type APIRequesterWrapper

type APIRequesterWrapper struct {
	// contains filtered or unexported fields
}

APIRequesterWrapper is the APIRequester with locker for setting the APIRequester

type AccountInquiryGet

type AccountInquiryGet struct {
	Status        AccountInquiryStatus `json:"status"`         //Status of inquiry {code: <status_code>, message: <status_message>}
	BankCode      BankCode             `json:"bank_code"`      //Bank Code of the Beneficiary account, see Disbursement Bank Codes
	AccountNumber string               `json:"account_number"` //Account Number of the Beneficiary Account
	AccountName   string               `json:"account_name"`   //Account Name of the Beneficiary Account
	Id            string               `json:"id"`             //Unique ID of the inquiry. ID will be provided only for 000 or 209 status. Otherwise, the ID will be null.
	InvoiceId     string               `json:"invoice_id"`     //ID of the invoice related to the inquiry result.
	Timestamp     date.YYYYMMDDHHMMSS  `json:"timestamp"`      //UTC Timestamp api hit (Format: yyyy-MM-ddTHH:mm:ss)
}

type AccountInquiryStatus

type AccountInquiryStatus struct {
	Code    *string `json:"code"`
	Message *string `json:"message"`
}

type BalanceGet

type BalanceGet struct {
	Status             BalanceStatus `json:"status"`             //Status of Payout in Object {code: <status_code>, message: <status_message>}
	Balance            *float64      `json:"balance"`            //Remaining balance (Accept non fraction number)
	OverdraftBalance   *float64      `json:"overdraftBalance"`   //Remaining overdraft balance (Accept non fraction number)
	OverbookingBalance *float64      `json:"overbookingBalance"` //Remaining overbooking balance (Accept non fraction number)
	PendingBalance     *float64      `json:"pendingBalance"`     //The cumulative balance of your pending transactions.
	AvailableBalance   *float64      `json:"availableBalance"`   //The total cumulative money of Balance + Available Overdraft - Pending Balance that you can use for disbursement.
	Timestamp          *string       `json:"timestamp"`          //Execution time of Disbursement in OY! system ("dd-MM-yyyy HH:mm:ss").
}

type BalanceStatus

type BalanceStatus struct {
	Code    *string `json:"code"`
	Message *string `json:"message"`
}

type BankCode

type BankCode string

BankCode value

const (
	BankBRI                        BankCode = "002"
	BankMandiri                    BankCode = "008"
	BankBNI                        BankCode = "009"
	BankDanamon                    BankCode = "011"
	BankPermata                    BankCode = "013"
	BankBCA                        BankCode = "014"
	BIIMaybank                     BankCode = "016"
	BankPanin                      BankCode = "019"
	CIMBNiaga                      BankCode = "022"
	BankUOBINDONESIA               BankCode = "023"
	BankOCBCNISP                   BankCode = "028"
	CITIBANK                       BankCode = "031"
	BankWinduKentjanaInternational BankCode = "036"
	BankARTHAGRAHA                 BankCode = "037"
	BankTOKYOMITSUBISHIUFJ         BankCode = "042"
	BankDBS                        BankCode = "046"
	Standard                       BankCode = "050"
	BankCAPITAL                    BankCode = "054"
	ANZIndonesia                   BankCode = "061"
	BankOFCHINA                    BankCode = "069"
	BankBumiArta                   BankCode = "076"
	BankHSBC                       BankCode = "087"
	BankAntardaerah                BankCode = "088"
	BankRabobank                   BankCode = "089"
	BankJTRUSTINDONESIA            BankCode = "095"
	BankMAYAPADA                   BankCode = "097"
	BankJawaBarat                  BankCode = "110"
	BankDKI                        BankCode = "111"
	BankBPDDIY                     BankCode = "112"
	BankJATENG                     BankCode = "113"
	BankJatim                      BankCode = "114"
	BankJambi                      BankCode = "115"
	BankAceh                       BankCode = "116"
	BankSUMUT                      BankCode = "117"
	BankNAGARI                     BankCode = "118"
	BankRiau                       BankCode = "119"
	BankSUMSELBABEL                BankCode = "120"
	BankLampung                    BankCode = "121"
	BankKALSEL                     BankCode = "122"
	BankKALBAR                     BankCode = "123"
	BankBPDKaltim                  BankCode = "124"
	BankBPDKalteng                 BankCode = "125"
	BankSULSELBAR                  BankCode = "126"
	BankSulut                      BankCode = "127"
	BankNTB                        BankCode = "128"
	BankBPDBali                    BankCode = "129"
	BankNTT                        BankCode = "130"
	BankMaluku                     BankCode = "131"
	BankBPDPapua                   BankCode = "132"
	BankSULTENG                    BankCode = "134"
	BankSultra                     BankCode = "135"
	BankBANTEN                     BankCode = "137"
	BankNusantaraParahyangan       BankCode = "145"
	BankOfIndiaIndonesia           BankCode = "146"
	BankMuamalat                   BankCode = "147"
	BankMestika                    BankCode = "151"
	BankSHINHAN                    BankCode = "152"
	BankSinarmas                   BankCode = "153"
	BankMaspion                    BankCode = "157"
	BankGanesha                    BankCode = "161"
	BankICBC                       BankCode = "164"
	BankQNBIndonesia               BankCode = "167"
	BankBTN                        BankCode = "200"
	BankWooriSaudara               BankCode = "212"
	BankBTPN                       BankCode = "213"
	BankVictoriaSyariah            BankCode = "405"
	BankJabarBantenSyariah         BankCode = "425"
	BankMega                       BankCode = "426"
	BankBukopin                    BankCode = "441"
	BankSyariahIndonesia           BankCode = "451"
	BankJasaJakarta                BankCode = "472"
	BankKEBHANA                    BankCode = "484"
	BankMNCINTERNATIONAL           BankCode = "485"
	BankNeoCommerce                BankCode = "490"
	BankRakyatIndonesiaAGRONIAGA   BankCode = "494"
	BankSBIIndonesia               BankCode = "498"
	BankRoyal                      BankCode = "501"
	BankNationalNobu               BankCode = "503"
	BankMEGASYARIAH                BankCode = "506"
	BankINA                        BankCode = "513"
	BankPANINSYARIAH               BankCode = "517"
	PRIMAMASTERBANK                BankCode = "520"
	BankSYARIAHBUKOPIN             BankCode = "521"
	BankSahabatSampoerna           BankCode = "523"
	BankDINAR                      BankCode = "526"
	BankKESEJAHTERAANEKONOMI       BankCode = "535"
	BankBCASYARIAH                 BankCode = "536"
	BankJago                       BankCode = "542"
	BankBTPNSYARIAH                BankCode = "547"
	BankMULTIARTASENTOSA           BankCode = "548"
	BankMayora                     BankCode = "553"
	BankINDEX                      BankCode = "555"
	CNB                            BankCode = "559"
	BankMANTAP                     BankCode = "564"
	BankVICTORIAINTL               BankCode = "566"
	HARDA                          BankCode = "567"
	BPRKS                          BankCode = "688"
	IBK                            BankCode = "945"
	BankCTBCIndonesia              BankCode = "949"
	BankCOMMONWEALTH               BankCode = "950"
	OVO                            BankCode = "ovo"
	LinkAja                        BankCode = "linkaja"
	Dana                           BankCode = "dana"
	Gopay                          BankCode = "gopay"
	ShopeePayEwallet               BankCode = "shopeepay_ewallet"
	LinkAjaEwallet                 BankCode = "linkaja_ewallet"
)

type Checkout

type Checkout struct {
	PartnerTxId       string               `json:"partner_tx_id"`
	Amount            int                  `json:"amount"`
	PaidAmount        *int                 `json:"paid_amount"`
	SenderName        *string              `json:"sender_name"`
	SenderPhoneNumber *string              `json:"sender_phone"`
	SenderNote        *string              `json:"sender_note"`
	SenderBank        *string              `json:"sender_bank"`
	SettlementStatus  *string              `json:"settlement_status"`
	SettlementType    *string              `json:"settlement_type"`
	SettlementTime    *date.YYYYMMDDHHMMSS `json:"settlement_time"`
	PaymentMethod     *string              `json:"payment_method"`
	Status            string               `json:"status"`
	IsInvoice         bool                 `json:"is_invoice"`
	TxRefNumber       *string              `json:"tx_ref_number"`
	Description       string               `json:"description"`
	Email             string               `json:"email"`
	Expiration        *date.YYYYMMDDHHMMSS `json:"expiration"`
	Created           date.YYYYMMDDHHMMSS  `json:"created"`
	Updated           date.YYYYMMDDHHMMSS  `json:"updated"`
}

type CheckoutGet

type CheckoutGet struct {
	Success    bool      `json:"success"`
	StatusCode int       `json:"status_code"`
	Reason     *string   `json:"reason"`
	Error      *string   `json:"error"`
	Data       *Checkout `json:"data"`
}

type CheckoutResult

type CheckoutResult struct {
	PaymentLinkId string `json:"payment_link_id"`
	Message       string `json:"message"`
	EmailStatus   string `json:"email_status"`
	Url           string `json:"url"`
	Status        bool   `json:"status"`
}

type DisbursementCallback

type DisbursementCallback struct {
	Status              DisbursementStatus `json:"status" form:"status"`                               //Status of Payout in Object {code: <status_code>, message: <status_message>}
	TxStatusDescription string             `json:"tx_status_description" form:"tx_status_description"` //additional information of status code (e.g. FORCE CREDIT)
	Amount              float64            `json:"amount" form:"amount"`                               //Amount of disbursement (Accept Non-Decimal Number)
	RecipientName       string             `json:"recipient_name" form:"recipient_name"`               //Account holder name of Beneficiary account number
	RecipientBank       BankCode           `json:"recipient_bank" form:"recipient_bank"`               //Bank Code of the Beneficiary account, see Disbursement Bank Codes
	RecipientAccount    string             `json:"recipient_account" form:"recipient_account"`         //Beneficiary account number
	TrxId               string             `json:"trx_id" form:"trx_id"`                               //Unique Payout ID from OY!. Partner can use this ID for settlement
	PartnerTrxId        string             `json:"partner_trx_id" form:"partner_trx_id"`               //Unique Payout ID which partner put on the Request, generated by partner
	Timestamp           string             `json:"timestamp" form:"timestamp"`                         //Execution time of API remit status in OY! system ("dd-MM-yyyy HH:mm:ss")
	CreatedDate         string             `json:"created_date" form:"created_date"`                   //Executionn time of Disbures in OY! system ("dd-MM-yyyy HH:mm:ss")
	LastUpdatedDate     string             `json:"last_updated_date" form:"last_updated_date"`         //Latest status change of a disbursement. Example from 'Pending' to 'Success' ("dd-MM-yyyy HH:mm:ss")
}

type DisbursementGet

type DisbursementGet struct {
	Status              DisbursementStatus `json:"status"`                //Status of Payout in Object {code: <status_code>, message: <status_message>}
	TxStatusDescription string             `json:"tx_status_description"` //additional information of status code (e.g. FORCE CREDIT)
	Amount              float64            `json:"amount"`                //Amount of disbursement (Accept Non-Decimal Number)
	RecipientName       string             `json:"recipient_name"`        //Account holder name of Beneficiary account number
	RecipientBank       BankCode           `json:"recipient_bank"`        //Bank Code of the Beneficiary account, see Disbursement Bank Codes
	RecipientAccount    string             `json:"recipient_account"`     //Beneficiary account number
	TrxId               string             `json:"trx_id"`                //Unique Payout ID from OY!. Partner can use this ID for settlement
	PartnerTrxId        string             `json:"partner_trx_id"`        //Unique Payout ID which partner put on the Request, generated by partner
	Timestamp           string             `json:"timestamp"`             //Execution time of API remit status in OY! system ("dd-MM-yyyy HH:mm:ss")
	CreatedDate         string             `json:"created_date"`          //Executionn time of Disbures in OY! system ("dd-MM-yyyy HH:mm:ss")
	LastUpdatedDate     string             `json:"last_updated_date"`     //Latest status change of a disbursement. Example from 'Pending' to 'Success' ("dd-MM-yyyy HH:mm:ss")
}

type DisbursementResult

type DisbursementResult struct {
	Status           DisbursementStatus `json:"status"`            //Status of Payout in Object {code: <status_code>, message: <status_message>}
	Amount           *float64           `json:"amount"`            //Amount of disbursement (Accept Non-Decimal Number)
	RecipientBank    BankCode           `json:"recipient_bank"`    //Bank Code of the Beneficiary account, see Disbursement Bank Codes
	RecipientAccount string             `json:"recipient_account"` //Beneficiary account number
	TrxId            string             `json:"trx_id"`            //Unique Payout ID from OY!. Partner can use this ID for settlement
	PartnerTrxId     string             `json:"partner_trx_id"`    //Unique Payout ID which partner put on the Request
	Timestamp        *string            `json:"timestamp"`         //Execution time of Disbursement in OY! system ("dd-MM-yyyy HH:mm:ss").
}

type DisbursementStatus

type DisbursementStatus struct {
	Code    *string `json:"code"`
	Message *string `json:"message"`
}

type Error

type Error struct {
	Message string `json:"message,omitempty"`
	Url     string `json:"url,omitempty"`
	Status  int    `json:"status,omitempty"`
}

func FromGoErr

func FromGoErr(err error) *Error

FromGoErr generates oygo.Error from generic go errors

func FromHTTPErr

func FromHTTPErr(status int, respBody []byte) *Error

FromHTTPErr generates oygo.Error from http errors with non 2xx status

func (*Error) Error

func (e *Error) Error() string

Error returns error message. This enables oygo.Error to comply with Go error interface

func (*Error) GetStatus

func (e *Error) GetStatus() int

GetStatus returns http status code

type Option

type Option struct {
	SecretKey string // customer's secret API key
	Username  string // customer's username
	OyURL     string // should there be a need to override API base URL
}

Option is the wrap of the parameters needed for the API call

var Opt Option = Option{
	OyURL: "https://partner.oyindonesia.com",
}

Opt is the default Option for the API call without API client

type ScheduledDisbursementCallback

type ScheduledDisbursementCallback struct {
	Status              ScheduledDisbursementStatus `json:"status" form:"status"`                               //Status of Payout in Object {code: <status_code>, message: <status_message>}
	TxStatusDescription string                      `json:"tx_status_description" form:"tx_status_description"` //additional information of status code (e.g. FORCE CREDIT)
	Amount              float64                     `json:"amount" form:"amount"`                               //Amount of disbursement (Accept Non-Decimal Number)
	RecipientName       string                      `json:"recipient_name" form:"recipient_name"`               //Account holder name of Beneficiary account number
	RecipientBank       BankCode                    `json:"recipient_bank" form:"recipient_bank"`               //Bank Code of the Beneficiary account, see ScheduledDisbursement Bank Codes
	RecipientAccount    string                      `json:"recipient_account" form:"recipient_account"`         //Beneficiary account number
	TrxId               string                      `json:"trx_id" form:"trx_id"`                               //Unique Payout ID from OY!. Partner can use this ID for settlement
	PartnerTrxId        string                      `json:"partner_trx_id" form:"partner_trx_id"`               //Unique Payout ID which partner put on the Request, generated by partner
	ScheduledTrxStatus  string                      `json:"scheduled_trx_status" form:"scheduled_trx_status"`   //Status of scheduled disbursement
	ScheduleDate        string                      `json:"schedule_date" form:"schedule_date"`                 //Date for scheduled non-trigger-based disburse in "dd-mm-yyyy" format. Null if scheduled disbursement is trigger-based
	IsTriggerBased      bool                        `json:"is_trigger_based" form:"is_trigger_based"`           //Whether scheduled transfer is trigger-based
	TriggerDate         string                      `json:"trigger_date" form:"trigger_date"`                   //Date when the disburse can be claimed by Beneficiary in "dd-mm-yyyy" format. Null if scheduled disbursement is non-trigger-based
	TriggerEmail        string                      `json:"trigger_email" form:"trigger_email"`                 //Email which the fund acceptance email and URL will be sent to. Null if scheduled disbursement is non-trigger-based
	Timestamp           string                      `json:"timestamp" form:"timestamp"`                         //Execution time of API remit status in OY! system ("dd-MM-yyyy HH:mm:ss")
	CreatedDate         string                      `json:"created_date" form:"created_date"`                   //Executionn time of Disbures in OY! system ("dd-MM-yyyy HH:mm:ss")
	LastUpdatedDate     string                      `json:"last_updated_date" form:"last_updated_date"`         //Latest status change of a disbursement. Example from 'Pending' to 'Success' ("dd-MM-yyyy HH:mm:ss")
}

type ScheduledDisbursementGet

type ScheduledDisbursementGet struct {
	Status              ScheduledDisbursementStatus `json:"status"`                //Status of Payout in Object {code: <status_code>, message: <status_message>}
	TxStatusDescription string                      `json:"tx_status_description"` //additional information of status code (e.g. FORCE CREDIT)
	Amount              float64                     `json:"amount"`                //Amount of disbursement (Accept Non-Decimal Number)
	RecipientName       string                      `json:"recipient_name"`        //Account holder name of Beneficiary account number
	RecipientBank       BankCode                    `json:"recipient_bank"`        //Bank Code of the Beneficiary account, see ScheduledDisbursement Bank Codes
	RecipientAccount    string                      `json:"recipient_account"`     //Beneficiary account number
	TrxId               string                      `json:"trx_id"`                //Unique Payout ID from OY!. Partner can use this ID for settlement
	PartnerTrxId        string                      `json:"partner_trx_id"`        //Unique Payout ID which partner put on the Request, generated by partner
	ScheduledTrxStatus  string                      `json:"scheduled_trx_status"`  //Status of scheduled disbursement
	ScheduleDate        string                      `json:"schedule_date"`         //Date for scheduled non-trigger-based disburse in "dd-mm-yyyy" format. Null if scheduled disbursement is trigger-based
	IsTriggerBased      bool                        `json:"is_trigger_based"`      //Whether scheduled transfer is trigger-based
	TriggerDate         string                      `json:"trigger_date"`          //Date when the disburse can be claimed by Beneficiary in "dd-mm-yyyy" format. Null if scheduled disbursement is non-trigger-based
	TriggerEmail        string                      `json:"trigger_email"`         //Email which the fund acceptance email and URL will be sent to. Null if scheduled disbursement is non-trigger-based
	Timestamp           time.Time                   `json:"timestamp"`             //Execution time of API remit status in OY! system ("dd-MM-yyyy HH:mm:ss")
}

type ScheduledDisbursementResult

type ScheduledDisbursementResult struct {
	Status             ScheduledDisbursementStatus `json:"status"`               //Status of Payout in Object {code: <status_code>, message: <status_message>}
	Amount             *float64                    `json:"amount"`               //Amount of disbursement (Accept Non-Decimal Number)
	RecipientBank      BankCode                    `json:"recipient_bank"`       //Bank Code of the Beneficiary account, see Disbursement Bank Codes
	RecipientAccount   string                      `json:"recipient_account"`    //Beneficiary account number
	PartnerTrxId       string                      `json:"partner_trx_id"`       //Unique Payout ID which partner put on the Request
	ScheduledTrxStatus string                      `json:"scheduled_trx_status"` //Status of scheduled disbursement
	ScheduleDate       string                      `json:"schedule_date"`        //Date for scheduled non-trigger-based disburse in "dd-mm-yyyy" format. Null if scheduled disbursement is trigger-based
	IsTriggerBased     bool                        `json:"is_trigger_based"`     //Whether scheduled transfer is trigger-based
	TriggerDate        string                      `json:"trigger_date"`         //Date when the disburse can be claimed by Beneficiary in "dd-mm-yyyy" format. Null if scheduled disbursement is non-trigger-based
	TriggerEmail       string                      `json:"trigger_email"`        //Email which the fund acceptance email and URL will be sent to. Null if scheduled disbursement is non-trigger-based
	Timestamp          *string                     `json:"timestamp"`            //Execution time of Disbursement in OY! system ("dd-MM-yyyy HH:mm:ss").
}

type ScheduledDisbursementStatus

type ScheduledDisbursementStatus struct {
	Code    *string `json:"code"`
	Message *string `json:"message"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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