dusupay

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2022 License: MIT Imports: 16 Imported by: 0

README

Dusupay API SDK GO (Unofficial)

Build Status Codecov Go Report Card Version Release License GoDoc Mentioned in Awesome Go

Description

Unofficial Dusupay payment gateway API Client for Go

API documentation

https://docs.dusupay.com

Installation

go get -u github.com/kachit/dusupay-sdk-go

Usage

package main

import (
    "fmt"
    "context"
    dusupay "github.com/kachit/dusupay-sdk-go"
)

func main(){
    // Create a client instance
    cfg := dusupay.NewConfig("Your public key", "Your secret key")
    client, err := dusupay.NewClientFromConfig(cfg, nil)
    if err != nil {
        fmt.Printf("config parameter error " + err.Error())
        panic(err)
    }
}
Get balances list
ctx := context.Background()
balances, response, err := client.Merchants().GetBalances(ctx)

if err != nil {
    fmt.Printf("Wrong API request " + err.Error())
    panic(err)
}

//Dump raw response
fmt.Println(response)

//Dump result
fmt.Println(balances.Status)
fmt.Println(balances.Code)
fmt.Println(balances.Message)
fmt.Println((*balances.Data)[0].Currency)
fmt.Println((*balances.Data)[0].Balance)
Get banks list
ctx := context.Background()
filter := &dusupay.BanksFilter{TransactionType: dusupay.TransactionTypePayout, Country: dusupay.CountryCodeGhana}
banks, response, err := client.Banks().GetList(ctx, filter)

if err != nil {
    fmt.Printf("Wrong API request " + err.Error())
    panic(err)
}

//Dump raw response
fmt.Println(response)

//Dump result
fmt.Println(banks.Status)
fmt.Println(banks.Code)
fmt.Println(banks.Message)
fmt.Println((*banks.Data)[0].Id)
fmt.Println((*banks.Data)[0].Name)
fmt.Println((*banks.Data)[0].BankCode)
Get banks branches list
ctx := context.Background()
filter := &dusupay.BanksBranchesFilter{Country: dusupay.CountryCodeGhana, Bank: "BankCode"}
branches, response, err := client.Banks().GetBranchesList(ctx, filter)

if err != nil {
    fmt.Printf("Wrong API request " + err.Error())
    panic(err)
}

//Dump raw response
fmt.Println(response)

//Dump result
fmt.Println(branches.Status)
fmt.Println(branches.Code)
fmt.Println(branches.Message)
fmt.Println((*branches.Data)[0].Name)
fmt.Println((*branches.Data)[0].Code)
Get providers list
ctx := context.Background()
filter := &dusupay.ProvidersFilter{Country: dusupay.CountryCodeUganda, Method: dusupay.TransactionMethodMobileMoney, TransactionType: dusupay.TransactionTypeCollection}
providers, response, err := client.Providers().GetList(ctx, filter)

if err != nil {
    fmt.Printf("Wrong API request " + err.Error())
    panic(err)
}

//Dump raw response
fmt.Println(response)

//Dump result
fmt.Println(providers.Status)
fmt.Println(providers.Code)
fmt.Println(providers.Message)
fmt.Println((*providers.Data)[0].ID)
fmt.Println((*providers.Data)[0].Name)
Create collection request
ctx := context.Background()
request := &dusupay.CollectionRequest{
    Currency:          dusupay.CurrencyCodeUGX,
    Amount:            10000,
    Method:            dusupay.TransactionMethodMobileMoney,
    ProviderId:        "airtel_ug",
    MerchantReference: "1234567891",
    RedirectUrl:       "http://foo.bar",
    Narration:         "narration",
    AccountNumber:         "256752000123",
    MobileMoneyHpp:         true,
}
result, response, err := client.Collections().Create(ctx, request)

if err != nil {
    fmt.Printf("Wrong API request " + err.Error())
    panic(err)
}

//Dump raw response
fmt.Println(response)

//Dump result
fmt.Println(result.Status)
fmt.Println(result.Code)
fmt.Println(result.Message)
fmt.Println((*result.Data).ID)
fmt.Println((*result.Data).PaymentURL)
Create payout request
ctx := context.Background()
request := &dusupay.PayoutRequest{
    Currency:          dusupay.CurrencyCodeUGX,
    Amount:            10000,
    Method:            dusupay.TransactionMethodMobileMoney,
    ProviderId:        "airtel_ug",
    MerchantReference: "1234567892",
    Narration:         "narration",
    AccountNumber:         "256752000123",
    AccountName:         "Foo Bar",
}
result, response, err := client.Payouts().Create(ctx, request)

if err != nil {
    fmt.Printf("Wrong API request " + err.Error())
    panic(err)
}

//Dump raw response
fmt.Println(response)

//Dump result
fmt.Println(result.Status)
fmt.Println(result.Code)
fmt.Println(result.Message)
fmt.Println((*result.Data).ID)
Create refund request
ctx := context.Background()
request := &dusupay.RefundRequest{
    Amount:            100,
    InternalReference:            "DUSUPAY5FNZCVUKZ8C0KZE",
}
result, response, err := client.Refunds().Create(ctx, request)

if err != nil {
    fmt.Printf("Wrong API request " + err.Error())
    panic(err)
}

//Dump raw response
fmt.Println(response)

//Dump result
fmt.Println(result.Status)
fmt.Println(result.Code)
fmt.Println(result.Message)
fmt.Println((*result.Data).ID)
Verify webhook signature
requestPayload := `
{
    "id": 226,
    "request_amount": 10,
    "request_currency": "USD",
    "account_amount": 737.9934,
    "account_currency": "UGX",
    "transaction_fee": 21.4018,
    "total_credit": 716.5916,
    "customer_charged": false,
    "provider_id": "mtn_ug",
    "merchant_reference": "76859aae-f148-48c5-9901-2e474cf19b71",
    "internal_reference": "DUSUPAY405GZM1G5JXGA71IK",
    "transaction_status": "COMPLETED",
    "transaction_type": "collection",
    "message": "Transaction Completed Successfully"
}
`
requestUri := "https://www.sample-url.com/callback"
signature := "value from 'dusupay-signature' http header"

var webhook dusupay.CollectionWebhook
_ = json.Unmarshal(requestPayload, &webhook)

rawBytes, _ := ioutil.ReadFile("path/to/dusupay-public-key.pem")

validator, _ := dusupay.NewSignatureValidator(rawBytes)
err := validator.ValidateSignature(webhook, requestUri, signature)

Documentation

Index

Constants

View Source
const ProdAPIUrl = "https://api.dusupay.com"

ProdAPIUrl production ENV API url

View Source
const SandboxAPIUrl = "https://sandbox.dusupay.com"

SandboxAPIUrl sandbox ENV API url

Variables

This section is empty.

Functions

This section is empty.

Types

type BalancesResponse

type BalancesResponse struct {
	ResponseBody
	Data *BalancesResponseData `json:"data,omitempty"`
}

BalancesResponse struct

type BalancesResponseData

type BalancesResponseData []*BalancesResponseDataItem

BalancesResponseData struct

func (*BalancesResponseData) UnmarshalJSON

func (brd *BalancesResponseData) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal json data

type BalancesResponseDataItem

type BalancesResponseDataItem struct {
	Currency string  `json:"currency"`
	Balance  float64 `json:"balance"`
}

BalancesResponseDataItem struct

type BanksBranchesFilter

type BanksBranchesFilter struct {
	//ISO-2 country code from those supported
	Country CountryCode `json:"country_code"`
	Bank    string      `json:"bank_code"`
}

BanksBranchesFilter branches list filter (see https://docs.dusupay.com/sending-money/payouts/bank-branches)

type BanksBranchesResponse

type BanksBranchesResponse struct {
	ResponseBody
	Data *BanksBranchesResponseData `json:"data,omitempty"`
}

BanksBranchesResponse struct

type BanksBranchesResponseData

type BanksBranchesResponseData []*BanksBranchesResponseDataItem

BanksBranchesResponseData struct

func (*BanksBranchesResponseData) UnmarshalJSON

func (rsp *BanksBranchesResponseData) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal json data

type BanksBranchesResponseDataItem

type BanksBranchesResponseDataItem struct {
	Code string `json:"code"`
	Name string `json:"name"`
}

BanksBranchesResponseDataItem struct

type BanksFilter

type BanksFilter struct {
	TransactionType TransactionTypeCode `json:"transaction_type"`
	//ISO-2 country code from those supported
	Country CountryCode `json:"country_code"`
}

BanksFilter (see https://docs.dusupay.com/sending-money/payouts/bank-codes)

type BanksResource

type BanksResource struct {
	ResourceAbstract
}

BanksResource wrapper

func (*BanksResource) GetBranchesList

GetBranchesList get banks branches list (see https://docs.dusupay.com/sending-money/payouts/bank-branches)

func (*BanksResource) GetList

func (r *BanksResource) GetList(ctx context.Context, filter *BanksFilter) (*BanksResponse, *http.Response, error)

GetList get banks list (see https://docs.dusupay.com/sending-money/payouts/bank-codes)

type BanksResponse

type BanksResponse struct {
	ResponseBody
	Data *BanksResponseData `json:"data,omitempty"`
}

BanksResponse struct

type BanksResponseData

type BanksResponseData []*BanksResponseDataItem

BanksResponseData struct

func (*BanksResponseData) UnmarshalJSON

func (rsp *BanksResponseData) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshal json data

type BanksResponseDataItem

type BanksResponseDataItem struct {
	Id                  string  `json:"id"`
	Name                string  `json:"name"`
	TransactionCurrency string  `json:"transaction_currency"`
	MinAmount           float64 `json:"min_amount"`
	MaxAmount           float64 `json:"max_amount"`
	BankCode            string  `json:"bank_code"`
	Available           bool    `json:"available"`
	SandboxTestAccounts struct {
		Success string `json:"success"`
		Failure string `json:"failure"`
	} `json:"sandbox_test_accounts,omitempty"`
}

BanksResponseDataItem struct

type Client

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

Client struct

func NewClientFromConfig

func NewClientFromConfig(config *Config, cl *http.Client) (*Client, error)

NewClientFromConfig Create new client from config

func (*Client) Banks

func (c *Client) Banks() *BanksResource

Banks resource

func (*Client) Collections

func (c *Client) Collections() *CollectionsResource

Collections resource

func (*Client) Merchants

func (c *Client) Merchants() *MerchantsResource

Merchants resource

func (*Client) Payouts

func (c *Client) Payouts() *PayoutsResource

Payouts resource

func (*Client) Providers

func (c *Client) Providers() *ProvidersResource

Providers resource

func (*Client) Refunds

func (c *Client) Refunds() *RefundsResource

Refunds resource

func (*Client) Webhooks

func (c *Client) Webhooks() *WebhooksResource

Webhooks resource

type CollectionRequest

type CollectionRequest struct {
	Currency          CurrencyCode          `json:"currency"`
	Amount            float64               `json:"amount"`
	Method            TransactionMethodCode `json:"method"`
	ProviderId        string                `json:"provider_id"`
	AccountNumber     string                `json:"account_number"`
	MerchantReference string                `json:"merchant_reference"`
	Narration         string                `json:"narration"`
	MobileMoneyHpp    bool                  `json:"mobile_money_hpp"`
	RedirectUrl       string                `json:"redirect_url"`
	AccountName       string                `json:"account_name"`
	AccountEmail      string                `json:"account_email"`
	Voucher           string                `json:"voucher"`
}

CollectionRequest struct

type CollectionResponse

type CollectionResponse struct {
	ResponseBody
	Data *CollectionResponseData `json:"data,omitempty"`
}

CollectionResponse struct

type CollectionResponseData

type CollectionResponseData struct {
	ID                int64   `json:"id"`
	RequestAmount     float64 `json:"request_amount"`
	RequestCurrency   string  `json:"request_currency"`
	AccountAmount     float64 `json:"account_amount"`
	AccountCurrency   string  `json:"account_currency"`
	TransactionFee    float64 `json:"transaction_fee"`
	TotalCredit       float64 `json:"total_credit"`
	ProviderID        string  `json:"provider_id"`
	MerchantReference string  `json:"merchant_reference"`
	InternalReference string  `json:"internal_reference"`
	TransactionStatus string  `json:"transaction_status"`
	TransactionType   string  `json:"transaction_type"`
	Message           string  `json:"message"`
	CustomerCharged   bool    `json:"customer_charged"`
	PaymentURL        string  `json:"payment_url"`
	Instructions      []struct {
		StepNo      string `json:"step_no"`
		Description string `json:"description"`
	} `json:"instructions"`
}

CollectionResponseData struct

type CollectionWebhook

type CollectionWebhook struct {
	ID                int64   `json:"id"`
	RequestAmount     float64 `json:"request_amount"`
	RequestCurrency   string  `json:"request_currency"`
	AccountAmount     float64 `json:"account_amount"`
	AccountCurrency   string  `json:"account_currency"`
	TransactionFee    float64 `json:"transaction_fee"`
	TotalCredit       float64 `json:"total_credit"`
	CustomerCharged   bool    `json:"customer_charged"`
	ProviderID        string  `json:"provider_id"`
	MerchantReference string  `json:"merchant_reference"`
	InternalReference string  `json:"internal_reference"`
	TransactionStatus string  `json:"transaction_status"`
	TransactionType   string  `json:"transaction_type"`
	Message           string  `json:"message"`
	AccountNumber     string  `json:"account_number"`
	AccountName       string  `json:"account_name"`
	InstitutionName   string  `json:"institution_name"`
}

CollectionWebhook struct

func (*CollectionWebhook) BuildPayloadString added in v0.0.8

func (cw *CollectionWebhook) BuildPayloadString(url string) string

type CollectionsResource

type CollectionsResource struct {
	ResourceAbstract
}

CollectionsResource wrapper

type Config

type Config struct {
	Uri         string `json:"uri"`
	PublicKey   string `json:"public_key"`
	SecretKey   string `json:"secret_key"`
	WebhookHash string `json:"webhook_hash"`
}

Config structure

func NewConfig

func NewConfig(publicKey string, secretKey string) *Config

NewConfig Create new config from credentials (Prod version)

func NewConfigSandbox

func NewConfigSandbox(publicKey string, secretKey string) *Config

NewConfigSandbox Create new config from credentials (Sandbox version)

func (*Config) IsSandbox

func (c *Config) IsSandbox() bool

IsSandbox check is sandbox environment

func (*Config) IsValid

func (c *Config) IsValid() error

IsValid check is valid config parameters

type CountryCode

type CountryCode string

CountryCode type

const CountryCodeBurundi CountryCode = "BI"

CountryCodeBurundi type

const CountryCodeCameroon CountryCode = "CM"

CountryCodeCameroon type

const CountryCodeEurope CountryCode = "EU"

CountryCodeEurope type

const CountryCodeGhana CountryCode = "GH"

CountryCodeGhana type

const CountryCodeKenya CountryCode = "KE"

CountryCodeKenya type

const CountryCodeNigeria CountryCode = "NG"

CountryCodeNigeria type

const CountryCodeRwanda CountryCode = "RW"

CountryCodeRwanda type

const CountryCodeSouthAfrica CountryCode = "ZA"

CountryCodeSouthAfrica type

const CountryCodeTanzania CountryCode = "TZ"

CountryCodeTanzania type

const CountryCodeUSA CountryCode = "US"

CountryCodeUSA type

const CountryCodeUganda CountryCode = "UG"

CountryCodeUganda type

const CountryCodeUnitedKingdom CountryCode = "GB"

CountryCodeUnitedKingdom type

const CountryCodeZambia CountryCode = "ZM"

CountryCodeZambia type

type CurrencyCode

type CurrencyCode string

CurrencyCode type

const CurrencyCodeBIF CurrencyCode = "BIF"

CurrencyCodeBIF type

const CurrencyCodeEUR CurrencyCode = "EUR"

CurrencyCodeEUR type

const CurrencyCodeGBP CurrencyCode = "GBP"

CurrencyCodeGBP type

const CurrencyCodeGHS CurrencyCode = "GHS"

CurrencyCodeGHS type

const CurrencyCodeKES CurrencyCode = "KES"

CurrencyCodeKES type

const CurrencyCodeNGN CurrencyCode = "NGN"

CurrencyCodeNGN type

const CurrencyCodeRWF CurrencyCode = "RWF"

CurrencyCodeRWF type

const CurrencyCodeTZS CurrencyCode = "TZS"

CurrencyCodeTZS type

const CurrencyCodeUGX CurrencyCode = "UGX"

CurrencyCodeUGX type

const CurrencyCodeUSD CurrencyCode = "USD"

CurrencyCodeUSD type

const CurrencyCodeXAF CurrencyCode = "XAF"

CurrencyCodeXAF type

const CurrencyCodeZAR CurrencyCode = "ZAR"

CurrencyCodeZAR type

const CurrencyCodeZMW CurrencyCode = "ZMW"

CurrencyCodeZMW type

type IncomingWebhookInterface added in v0.0.8

type IncomingWebhookInterface interface {
	BuildPayloadString(url string) string
}

IncomingWebhookInterface interface

type MerchantsResource

type MerchantsResource struct {
	ResourceAbstract
}

MerchantsResource wrapper

func (*MerchantsResource) GetBalances

GetBalances get balances list (see https://docs.dusupay.com/appendix/account-balance)

type PayoutRequest

type PayoutRequest struct {
	Currency          CurrencyCode          `json:"currency"`
	Amount            float64               `json:"amount"`
	Method            TransactionMethodCode `json:"method"`
	ProviderId        string                `json:"provider_id"`
	AccountNumber     string                `json:"account_number"`
	AccountName       string                `json:"account_name"`
	AccountEmail      string                `json:"account_email"`
	MerchantReference string                `json:"merchant_reference"`
	Narration         string                `json:"narration"`
	ExtraParams       struct {
		BankCode       string `json:"bank_code"`
		BankBranchCode string `json:"branch_code"`
	} `json:"extra_params"`
}

PayoutRequest struct

type PayoutResponse

type PayoutResponse struct {
	ResponseBody
	Data *PayoutResponseData `json:"data,omitempty"`
}

PayoutResponse struct

type PayoutResponseData

type PayoutResponseData struct {
	ID                int64   `json:"id"`
	RequestAmount     float64 `json:"request_amount"`
	RequestCurrency   string  `json:"request_currency"`
	AccountAmount     float64 `json:"account_amount"`
	AccountCurrency   string  `json:"account_currency"`
	TransactionFee    float64 `json:"transaction_fee"`
	TotalDebit        float64 `json:"total_debit"`
	ProviderID        string  `json:"provider_id"`
	MerchantReference string  `json:"merchant_reference"`
	InternalReference string  `json:"internal_reference"`
	TransactionStatus string  `json:"transaction_status"`
	TransactionType   string  `json:"transaction_type"`
	Message           string  `json:"message"`
}

PayoutResponseData struct

type PayoutWebhook

type PayoutWebhook struct {
	ID                int64   `json:"id"`
	RequestAmount     float64 `json:"request_amount"`
	RequestCurrency   string  `json:"request_currency"`
	AccountAmount     float64 `json:"account_amount"`
	AccountCurrency   string  `json:"account_currency"`
	TransactionFee    float64 `json:"transaction_fee"`
	TotalDebit        float64 `json:"total_debit"`
	ProviderID        string  `json:"provider_id"`
	MerchantReference string  `json:"merchant_reference"`
	InternalReference string  `json:"internal_reference"`
	TransactionStatus string  `json:"transaction_status"`
	TransactionType   string  `json:"transaction_type"`
	Message           string  `json:"message"`
	AccountNumber     string  `json:"account_number"`
	AccountName       string  `json:"account_name"`
	InstitutionName   string  `json:"institution_name"`
}

PayoutWebhook struct

func (*PayoutWebhook) BuildPayloadString added in v0.0.8

func (pw *PayoutWebhook) BuildPayloadString(url string) string

type PayoutsResource

type PayoutsResource struct {
	ResourceAbstract
}

PayoutsResource wrapper

func (*PayoutsResource) Create

Create payout request (see https://docs.dusupay.com/sending-money/payouts/post-payout-request)

type ProvidersFilter

type ProvidersFilter struct {
	TransactionType TransactionTypeCode   `json:"transaction_type"`
	Method          TransactionMethodCode `json:"method"`
	Country         CountryCode           `json:"country"`
}

ProvidersFilter list of providers filter

type ProvidersResource

type ProvidersResource struct {
	ResourceAbstract
}

ProvidersResource wrapper

func (*ProvidersResource) GetList

GetList Get providers list (see https://docs.dusupay.com/appendix/payment-options/payment-providers)

type ProvidersResponse

type ProvidersResponse struct {
	ResponseBody
	Data *ProvidersResponseData `json:"data,omitempty"`
}

ProvidersResponse struct

type ProvidersResponseData

type ProvidersResponseData []*ProvidersResponseDataItem

ProvidersResponseData struct

func (*ProvidersResponseData) UnmarshalJSON

func (rsp *ProvidersResponseData) UnmarshalJSON(data []byte) error

UnmarshalJSON method

type ProvidersResponseDataItem

type ProvidersResponseDataItem struct {
	ID                  string  `json:"id"`
	Name                string  `json:"name"`
	TransactionCurrency string  `json:"transaction_currency"`
	MinAmount           float64 `json:"min_amount"`
	MaxAmount           float64 `json:"max_amount"`
	Available           bool    `json:"available"`
	SandboxTestAccounts struct {
		Success string `json:"success"`
		Failure string `json:"failure"`
	} `json:"sandbox_test_accounts,omitempty"`
}

ProvidersResponseDataItem struct

type RefundRequest

type RefundRequest struct {
	Amount            float64 `json:"amount"`
	InternalReference string  `json:"internal_reference"`
}

RefundRequest struct

type RefundResponse

type RefundResponse struct {
	ResponseBody
	Data *RefundResponseData `json:"data,omitempty"`
}

RefundResponse struct

type RefundResponseData

type RefundResponseData struct {
	ID                  int64   `json:"id"`
	RefundAmount        float64 `json:"refund_amount"`
	RefundCurrency      string  `json:"refund_currency"`
	TransactionFee      float64 `json:"transaction_fee"`
	TotalDebit          float64 `json:"total_debit"`
	ProviderID          string  `json:"provider_id"`
	MerchantReference   string  `json:"merchant_reference"`
	CollectionReference string  `json:"collection_reference"`
	InternalReference   string  `json:"internal_reference"`
	TransactionType     string  `json:"transaction_type"`
	TransactionStatus   string  `json:"transaction_status"`
	AccountNumber       string  `json:"account_number"`
	Message             string  `json:"message"`
}

RefundResponseData struct

type RefundWebhook

type RefundWebhook struct {
	ID                  int64   `json:"id"`
	RefundAmount        float64 `json:"refund_amount"`
	RefundCurrency      string  `json:"refund_currency"`
	TransactionFee      float64 `json:"transaction_fee"`
	TotalDebit          float64 `json:"total_debit"`
	ProviderID          string  `json:"provider_id"`
	CollectionReference string  `json:"collection_reference"`
	InternalReference   string  `json:"internal_reference"`
	TransactionType     string  `json:"transaction_type"`
	TransactionStatus   string  `json:"transaction_status"`
	AccountNumber       string  `json:"account_number"`
	Message             string  `json:"message"`
}

RefundWebhook struct

func (*RefundWebhook) BuildPayloadString added in v0.0.8

func (rw *RefundWebhook) BuildPayloadString(url string) string

type RefundsResource

type RefundsResource struct {
	ResourceAbstract
}

RefundsResource wrapper

func (*RefundsResource) Create

Create refund request (see https://docs.dusupay.com/appendix/refunds)

type RequestBuilder

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

RequestBuilder handler

func (*RequestBuilder) BuildRequest

func (rb *RequestBuilder) BuildRequest(ctx context.Context, method string, path string, query map[string]interface{}, body map[string]interface{}) (req *http.Request, err error)

BuildRequest method

type ResourceAbstract

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

ResourceAbstract base resource

func NewResourceAbstract

func NewResourceAbstract(transport *Transport, config *Config) ResourceAbstract

NewResourceAbstract Create new resource abstract

type ResponseBody

type ResponseBody struct {
	Code    int    `json:"code"`
	Status  string `json:"status"`
	Message string `json:"message"`
}

ResponseBody struct

func (*ResponseBody) IsSuccess

func (r *ResponseBody) IsSuccess() bool

IsSuccess method

type SignatureValidator added in v0.0.8

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

SignatureValidator struct

func NewSignatureValidator added in v0.0.8

func NewSignatureValidator(publicKeyBytes []byte) (*SignatureValidator, error)

NewSignatureValidator method

func (*SignatureValidator) ValidateSignature added in v0.0.8

func (sv *SignatureValidator) ValidateSignature(webhook IncomingWebhookInterface, webhookUrl string, signature string) error

ValidateSignature method (see https://docs.dusupay.com/webhooks-and-redirects/webhooks/signature-verification)

type TransactionMethodCode

type TransactionMethodCode string

TransactionMethodCode type

const TransactionMethodBank TransactionMethodCode = "BANK"

TransactionMethodBank type

const TransactionMethodCard TransactionMethodCode = "CARD"

TransactionMethodCard type

const TransactionMethodCrypto TransactionMethodCode = "CRYPTO"

TransactionMethodCrypto type

const TransactionMethodMobileMoney TransactionMethodCode = "MOBILE_MONEY"

TransactionMethodMobileMoney type

type TransactionStatusCode

type TransactionStatusCode string

TransactionStatusCode type

const TransactionStatusCancelled TransactionStatusCode = "CANCELLED"

TransactionStatusCancelled const

const TransactionStatusCompleted TransactionStatusCode = "COMPLETED"

TransactionStatusCompleted const

const TransactionStatusFailed TransactionStatusCode = "FAILED"

TransactionStatusFailed const

const TransactionStatusPending TransactionStatusCode = "PENDING"

TransactionStatusPending const

type TransactionTypeCode

type TransactionTypeCode string

TransactionTypeCode type

const TransactionTypeCollection TransactionTypeCode = "COLLECTION"

TransactionTypeCollection const

const TransactionTypePayout TransactionTypeCode = "PAYOUT"

TransactionTypePayout const

const TransactionTypeRefund TransactionTypeCode = "REFUND"

TransactionTypeRefund const

type Transport

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

Transport wrapper

func NewHttpTransport

func NewHttpTransport(config *Config, h *http.Client) *Transport

NewHttpTransport create new http transport

func (*Transport) Get

func (tr *Transport) Get(ctx context.Context, path string, query map[string]interface{}) (resp *http.Response, err error)

Get method

func (*Transport) Post

func (tr *Transport) Post(ctx context.Context, path string, body map[string]interface{}, query map[string]interface{}) (resp *http.Response, err error)

Post method

func (*Transport) SendRequest

func (tr *Transport) SendRequest(ctx context.Context, method string, path string, query map[string]interface{}, body map[string]interface{}) (resp *http.Response, err error)

SendRequest Send request method

type WebhookResponse

type WebhookResponse struct {
	ResponseBody
	Data *WebhookResponseData `json:"data,omitempty"`
}

WebhookResponse struct

type WebhookResponseData

type WebhookResponseData struct {
	Payload *WebhookResponsePayload `json:"payload,omitempty"`
}

WebhookResponseData struct

type WebhookResponsePayload

type WebhookResponsePayload struct {
	ID                int64   `json:"id"`
	RequestAmount     float64 `json:"request_amount"`
	RequestCurrency   string  `json:"request_currency"`
	AccountAmount     float64 `json:"account_amount"`
	AccountCurrency   string  `json:"account_currency"`
	TransactionFee    float64 `json:"transaction_fee"`
	ProviderID        string  `json:"provider_id"`
	MerchantReference string  `json:"merchant_reference"`
	InternalReference string  `json:"internal_reference"`
	TransactionStatus string  `json:"transaction_status"`
	TransactionType   string  `json:"transaction_type"`
	Message           string  `json:"message"`
}

WebhookResponsePayload struct

type WebhooksResource

type WebhooksResource struct {
	ResourceAbstract
}

WebhooksResource wrapper

func (*WebhooksResource) SendCallback

func (r *WebhooksResource) SendCallback(ctx context.Context, internalReference string) (*WebhookResponse, *http.Response, error)

SendCallback (see https://docs.dusupay.com/appendix/webhooks/webhook-trigger)

Jump to

Keyboard shortcuts

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