neero

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 9 Imported by: 0

README

neero-go

Build codecov Scrutinizer Code Quality Go Report Card GitHub contributors GitHub license PkgGoDev

This package provides a go API client for the Neero Payment Gateway API

Installation

neero-go is compatible with modern Go releases in module mode, with Go installed:

go get github.com/NdoleStudio/neero-go

Alternatively the same can be achieved if you use import in a package:

import "github.com/NdoleStudio/neero-go"

Implemented

  • Payment Methods
    • POST /api/v1/payment-methods: Create Payment Method
    • POST /api/v1/payment-methods/resolve-details: Resolve Payment Method Details
  • Balances
    • GET /api/v1/balances/payment-method/{paymentMethodId}: Get Balance for a Payment Method
  • Transaction Intents
    • POST /api/v1/transaction-intents/cash-in: Create Cash In Payment Intent
    • POST /api/v1/transaction-intents/cash-out: Create Cash Out Payment Intent
    • GET /api/v1/transaction-intents/{transactionId}: Find Transaction Intent By Id

Usage

Initializing the Client

An instance of the client can be created using New().

package main

import (
	"github.com/NdoleStudio/neero-go"
)

func main()  {
	client := neero.New(neero.WithSecretKey("" /*Your Neero merchant account secret key*/))
}
Error handling

All API calls return an error as the last return object. All successful calls will return a nil error.

status, response, err := statusClient.Status.Ok(context.Background())
if err != nil {
    //handle error
}

Testing

You can run the unit tests for this client from the root directory using the command below:

go test -v

License

This project is licensed under the MIT License - see the LICENSE file for details

Documentation

Index

Constants

View Source
const (
	// PaymentMethodTypeMobileMoney represents the mobile money payment method type.
	PaymentMethodTypeMobileMoney = PaymentMethodType("MOBILE_MONEY")

	// PaymentMethodTypeNeroMerchant represents the neero merchant payment method type.
	PaymentMethodTypeNeroMerchant = PaymentMethodType("NEERO_MERCHANT")
)
View Source
const (
	// MobileMoneyProviderMTNMoney represents the MTN mobile money provider.
	MobileMoneyProviderMTNMoney = MobileMoneyProvider("MTN_MONEY")

	// MobileMoneyProviderOrangeMoney represents the orange money provider.
	MobileMoneyProviderOrangeMoney = MobileMoneyProvider("ORANGE_MONEY")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BalanceResponse

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

BalanceResponse represents the account balance information.

type Client

type Client struct {
	PaymentMethod     *paymentMethodService
	Balance           *balanceService
	TransactionIntent *transactionIntentService
	// contains filtered or unexported fields
}

Client is the neero API client. Do not instantiate this client with Client{}. Use the New method instead.

func New

func New(options ...Option) *Client

New creates and returns a new neero.Client from a slice of neero.ClientOption.

type CreatePaymentMethodRequest

type CreatePaymentMethodRequest interface {
	// Type returns the payment method type.
	Type() PaymentMethodType

	// Attribute returns the payment method attribute.
	Attribute() PaymentMethodAttribute
}

CreatePaymentMethodRequest represents a request to create a payment method.

type CreatePaymentMethodRequestMobileMoneyDetails

type CreatePaymentMethodRequestMobileMoneyDetails struct {
	PhoneNumber         string              `json:"phoneNumber"`
	CountryIso          string              `json:"countryIso"`
	MobileMoneyProvider MobileMoneyProvider `json:"mobileMoneyProvider"`
}

CreatePaymentMethodRequestMobileMoneyDetails represents the details for creating a mobile money payment method.

func (*CreatePaymentMethodRequestMobileMoneyDetails) Attribute

Attribute returns the payment method attribute.

func (*CreatePaymentMethodRequestMobileMoneyDetails) Type

Type returns the payment method type.

type CreatePaymentMethodRequestNeroMerchantDetails

type CreatePaymentMethodRequestNeroMerchantDetails struct {
	MerchantKey string `json:"merchantKey"`
	StoreID     string `json:"storeId"`
	BalanceID   string `json:"balanceId"`
	OperatorID  string `json:"operatorId"`
}

CreatePaymentMethodRequestNeroMerchantDetails represents the details for creating a neero merchant payment method.

func (*CreatePaymentMethodRequestNeroMerchantDetails) Attribute

Attribute returns the payment method attribute.

func (*CreatePaymentMethodRequestNeroMerchantDetails) Type

Type returns the payment method type.

type CreatePaymentMethodResponse

type CreatePaymentMethodResponse struct {
	CreatedAt             string                                           `json:"createdAt"`
	UpdatedAt             string                                           `json:"updatedAt"`
	ID                    string                                           `json:"id"`
	Metadata              any                                              `json:"metadata"`
	OperatorDetails       *CreatePaymentMethodResponseOperatorDetails      `json:"operatorDetails"`
	Active                bool                                             `json:"active"`
	Type                  string                                           `json:"type"`
	WalletTypeProductName string                                           `json:"walletTypeProductName"`
	MobileMoneyDetails    *CreatePaymentMethodResponseMobileMoneyDetails   `json:"mobileMoneyDetails"`
	NeeroPersonDetails    *CreatePaymentMethodResponseNeeroPersonDetails   `json:"neeroPersonDetails"`
	NeeroMerchantDetails  *CreatePaymentMethodResponseNeeroMerchantDetails `json:"neeroMerchantDetails"`
	PaypalDetails         *CreatePaymentMethodResponsePaypalDetails        `json:"paypalDetails"`
	ShortInfo             string                                           `json:"shortInfo"`
	WalletID              any                                              `json:"walletId"`
}

CreatePaymentMethodResponse represents the response from creating a payment method.

type CreatePaymentMethodResponseMobileMoneyDetails

type CreatePaymentMethodResponseMobileMoneyDetails struct {
	CountryCode string `json:"countryCode"`
}

CreatePaymentMethodResponseMobileMoneyDetails represents the mobile money details in the payment method response.

type CreatePaymentMethodResponseNeeroMerchantDetails

type CreatePaymentMethodResponseNeeroMerchantDetails struct {
	MerchantKey string `json:"merchantKey"`
	StoreID     string `json:"storeId"`
	BalanceID   string `json:"balanceId"`
	OperatorID  any    `json:"operatorId"`
	Country     string `json:"country"`
}

CreatePaymentMethodResponseNeeroMerchantDetails represents the neero merchant details in the payment method response.

type CreatePaymentMethodResponseNeeroPersonDetails

type CreatePaymentMethodResponseNeeroPersonDetails struct {
	PersonID         any    `json:"personId"`
	AccountID        string `json:"accountId"`
	Country          string `json:"country"`
	PaymentRequestID any    `json:"paymentRequestId"`
}

CreatePaymentMethodResponseNeeroPersonDetails represents the neero person details in the payment method response.

type CreatePaymentMethodResponseOperatorDetails

type CreatePaymentMethodResponseOperatorDetails struct {
	OperatorID  any    `json:"operatorId"`
	MerchantKey string `json:"merchantKey"`
}

CreatePaymentMethodResponseOperatorDetails represents the operator details in the payment method response.

type CreatePaymentMethodResponsePaypalDetails

type CreatePaymentMethodResponsePaypalDetails struct {
	Email       string `json:"email"`
	CountryCode string `json:"countryCode"`
}

CreatePaymentMethodResponsePaypalDetails represents the PayPal details in the payment method response.

type MobileMoneyProvider

type MobileMoneyProvider string

MobileMoneyProvider represents the mobile money provider.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is options for constructing a client

func WithBaseURL

func WithBaseURL(baseURL string) Option

WithBaseURL set's the base url for the flutterwave API

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

WithHTTPClient sets the underlying HTTP client used for API requests. By default, http.DefaultClient is used.

func WithSecretKey

func WithSecretKey(secretKey string) Option

WithSecretKey sets the secret key to be used for API requests.

type PaymentMethodAttribute

type PaymentMethodAttribute string

PaymentMethodAttribute represents the attribute of the payment method.

type PaymentMethodType

type PaymentMethodType string

PaymentMethodType represents the type of payment method.

type ResolvePaymentMethodDetailsResponse

type ResolvePaymentMethodDetailsResponse struct {
	Name string `json:"name"`
}

ResolvePaymentMethodDetailsResponse represents the response from resolving payment method details.

type Response

type Response struct {
	HTTPResponse *http.Response
	Body         *[]byte
}

Response captures the http response

func (*Response) Error

func (r *Response) Error() error

Error ensures that the response can be decoded into a string inc ase it's an error response

type TransactionIntentCreateRequest

type TransactionIntentCreateRequest struct {
	Amount                     int                          `json:"amount"`
	CurrencyCode               string                       `json:"currencyCode"`
	PaymentType                TransactionIntentPaymentType `json:"paymentType"`
	SourcePaymentMethodID      *string                      `json:"sourcePaymentMethodId,omitempty"`
	DestinationPaymentMethodID *string                      `json:"destinationPaymentMethodId,omitempty"`
	Confirm                    bool                         `json:"confirm"`
	MetaData                   map[string]any               `json:"metadata"`
}

TransactionIntentCreateRequest represents a request to create a transaction intent.

type TransactionIntentPaymentType

type TransactionIntentPaymentType string

TransactionIntentPaymentType represents the type of payment for a transaction intent.

const (
	// TransactionIntentPaymentTypeMerchantCollection represents a merchant collection payment type.
	TransactionIntentPaymentTypeMerchantCollection TransactionIntentPaymentType = "MERCHANT_COLLECTION"
	// TransactionIntentPaymentTypeOrangeMoneyTransfer represents an orange money transfer payment type.
	TransactionIntentPaymentTypeOrangeMoneyTransfer TransactionIntentPaymentType = "ORANGE_MONEY_TRANSFER"
	// TransactionIntentPaymentTypeMTNMobileMoneyTransfer represents an MTN mobile money transfer payment type.
	TransactionIntentPaymentTypeMTNMobileMoneyTransfer TransactionIntentPaymentType = "MTN_MONEY_TRANSFER"
)

type TransactionIntentTransaction

type TransactionIntentTransaction struct {
	CreatedAt       string         `json:"createdAt"`
	UpdatedAt       string         `json:"updatedAt"`
	ID              string         `json:"id"`
	Metadata        map[string]any `json:"metadata"`
	OperatorDetails struct {
		OperatorID  any    `json:"operatorId"`
		MerchantKey string `json:"merchantKey"`
	} `json:"operatorDetails"`
	StatusUpdates []struct {
		Status    string `json:"status"`
		UpdatedAt string `json:"updatedAt"`
	} `json:"statusUpdates"`
	SourcePaymentMethodID      string `json:"sourcePaymentMethodId"`
	SourcePaymentMethodDetails struct {
		ID                    string `json:"id"`
		Type                  string `json:"type"`
		WalletTypeProductName string `json:"walletTypeProductName"`
		ShortInfo             string `json:"shortInfo"`
		WalletID              any    `json:"walletId"`
		MerchantDetails       struct {
			MerchantKey string `json:"merchantKey"`
			StoreID     string `json:"storeId"`
			BalanceID   string `json:"balanceId"`
			OperatorID  any    `json:"operatorId"`
			Country     string `json:"country"`
		} `json:"merchantDetails"`
	} `json:"sourcePaymentMethodDetails"`
	DestinationPaymentMethodID      string `json:"destinationPaymentMethodId"`
	DestinationPaymentMethodDetails struct {
		ID                    string `json:"id"`
		Type                  string `json:"type"`
		WalletTypeProductName string `json:"walletTypeProductName"`
		ShortInfo             string `json:"shortInfo"`
		WalletID              any    `json:"walletId"`
		MerchantDetails       struct {
			MerchantKey string `json:"merchantKey"`
			StoreID     string `json:"storeId"`
			BalanceID   string `json:"balanceId"`
			OperatorID  any    `json:"operatorId"`
			Country     string `json:"country"`
		} `json:"merchantDetails"`
	} `json:"destinationPaymentMethodDetails"`
	Type               string `json:"type"`
	Amount             any    `json:"amount"`
	Currency           string `json:"currency"`
	PaymentType        string `json:"paymentType"`
	ExpirationDateTime string `json:"expirationDateTime"`
	PaymentToken       string `json:"paymentToken"`
	SuccessURL         string `json:"successUrl"`
	FailureURL         string `json:"failureUrl"`
	CancelURL          string `json:"cancelUrl"`
	Customer           struct {
		Name  string `json:"name"`
		Email string `json:"email"`
		Phone string `json:"phone"`
	} `json:"customer"`
	ConfirmationSessionID string `json:"confirmationSessionId"`
	NextAction            struct {
		Type                  string `json:"type"`
		CreatedDateTime       string `json:"createdDateTime"`
		NeeroPersonWithdrawal struct {
			WithdrawalRequestID string `json:"withdrawalRequestId"`
		} `json:"neeroPersonWithdrawal"`
		URLRedirect struct {
			URLToRedirect string `json:"urlToRedirect"`
		} `json:"urlRedirect"`
	} `json:"nextAction"`
	CollectCustomerDetails        bool   `json:"collectCustomerDetails"`
	Status                        string `json:"status"`
	CreateFlowTransactionRequests []struct {
		Amount                     int    `json:"amount"`
		CurrencyCode               string `json:"currencyCode"`
		PaymentType                string `json:"paymentType"`
		SourcePaymentMethodID      string `json:"sourcePaymentMethodId"`
		DestinationPaymentMethodID string `json:"destinationPaymentMethodId"`
		TransactionType            string `json:"transactionType"`
	} `json:"createFlowTransactionRequests"`
	Fees struct {
		SourceFee struct {
			Owner struct {
				PersonID           any            `json:"personId"`
				WalletID           any            `json:"walletId"`
				MerchantKey        string         `json:"merchantKey"`
				StoreID            string         `json:"storeId"`
				BalanceID          string         `json:"balanceId"`
				ServiceNumber      string         `json:"serviceNumber"`
				CountryCode        string         `json:"countryCode"`
				Type               string         `json:"type"`
				GatewayCode        string         `json:"gatewayCode"`
				AdditionalData     map[string]any `json:"additionalData"`
				MaxPositiveBalance any            `json:"maxPositiveBalance"`
				Balance            any            `json:"balance"`
				Plan               string         `json:"plan"`
				PlanOrder          any            `json:"planOrder"`
			} `json:"owner"`
			Amount                       any `json:"amount"`
			Margin                       any `json:"margin"`
			OnAmountVoucherAmount        any `json:"onAmountVoucherAmount"`
			FreeLimitAmount              any `json:"freeLimitAmount"`
			OnFeeAmountVoucherAmount     any `json:"onFeeAmountVoucherAmount"`
			VoucherAmount                any `json:"voucherAmount"`
			ProductFeeAmount             any `json:"productFeeAmount"`
			WalletFeeAmount              any `json:"walletFeeAmount"`
			GovernmentFeeAmount          any `json:"governmentFeeAmount"`
			DenominationAdjustmentAmount any `json:"denominationAjustementAmount"`
			FeeVATAmount                 any `json:"feeVATAmount"`
			Vat                          any `json:"vat"`
			Rate                         any `json:"rate"`
			MarginRate                   any `json:"marginRate"`
			Voucher                      struct {
				Code  string `json:"code"`
				Value any    `json:"value"`
				Type  string `json:"type"`
			} `json:"voucher"`
			GovernmentFee struct {
				FeeCategory string `json:"feeCategory"`
				Fee         any    `json:"fee"`
				FeeType     string `json:"feeType"`
			} `json:"governmentFee"`
			ProductFee struct {
				FeeCategory string `json:"feeCategory"`
				Fee         any    `json:"fee"`
				FeeType     string `json:"feeType"`
			} `json:"productFee"`
			WalletTypefee struct {
				FeeCategory string `json:"feeCategory"`
				Fee         any    `json:"fee"`
				FeeType     string `json:"feeType"`
			} `json:"walletTypefee"`
			OtherPlansFees []string `json:"otherPlansFees"`
			Target         string   `json:"target"`
			Currency       string   `json:"currency"`
			MargedAmount   any      `json:"margedAmount"`
			TotalFeeAmount any      `json:"totalFeeAmount"`
			TotalAmount    any      `json:"totalAmount"`
			BillableAmount any      `json:"billableAmount"`
			Conversion     struct {
				MargedAmount        any    `json:"margedAmount"`
				TotalFeeAmount      any    `json:"totalFeeAmount"`
				TotalAmount         any    `json:"totalAmount"`
				BillableAmount      any    `json:"billableAmount"`
				ProductFeeAmount    any    `json:"productFeeAmount"`
				WalletFeeAmount     any    `json:"walletFeeAmount"`
				GovernmentFeeAmount any    `json:"governmentFeeAmount"`
				Rate                any    `json:"rate"`
				Currency            string `json:"currency"`
			} `json:"conversion"`
		} `json:"sourceFee"`
		DestinationFee struct {
			Owner struct {
				PersonID           any            `json:"personId"`
				WalletID           any            `json:"walletId"`
				MerchantKey        string         `json:"merchantKey"`
				StoreID            string         `json:"storeId"`
				BalanceID          string         `json:"balanceId"`
				ServiceNumber      string         `json:"serviceNumber"`
				CountryCode        string         `json:"countryCode"`
				Type               string         `json:"type"`
				GatewayCode        string         `json:"gatewayCode"`
				AdditionalData     map[string]any `json:"additionalData"`
				MaxPositiveBalance any            `json:"maxPositiveBalance"`
				Balance            any            `json:"balance"`
				Plan               string         `json:"plan"`
				PlanOrder          any            `json:"planOrder"`
			} `json:"owner"`
			Amount                       any `json:"amount"`
			Margin                       any `json:"margin"`
			OnAmountVoucherAmount        any `json:"onAmountVoucherAmount"`
			FreeLimitAmount              any `json:"freeLimitAmount"`
			OnFeeAmountVoucherAmount     any `json:"onFeeAmountVoucherAmount"`
			VoucherAmount                any `json:"voucherAmount"`
			ProductFeeAmount             any `json:"productFeeAmount"`
			WalletFeeAmount              any `json:"walletFeeAmount"`
			GovernmentFeeAmount          any `json:"governmentFeeAmount"`
			DenominationAjustementAmount any `json:"denominationAjustementAmount"`
			FeeVATAmount                 any `json:"feeVATAmount"`
			Vat                          any `json:"vat"`
			Rate                         any `json:"rate"`
			MarginRate                   any `json:"marginRate"`
			Voucher                      struct {
				Code  string `json:"code"`
				Value any    `json:"value"`
				Type  string `json:"type"`
			} `json:"voucher"`
			GovernmentFee struct {
				FeeCategory string `json:"feeCategory"`
				Fee         any    `json:"fee"`
				FeeType     string `json:"feeType"`
			} `json:"governmentFee"`
			ProductFee struct {
				FeeCategory string `json:"feeCategory"`
				Fee         any    `json:"fee"`
				FeeType     string `json:"feeType"`
			} `json:"productFee"`
			WalletTypefee struct {
				FeeCategory string `json:"feeCategory"`
				Fee         any    `json:"fee"`
				FeeType     string `json:"feeType"`
			} `json:"walletTypefee"`
			OtherPlansFees []string `json:"otherPlansFees"`
			Target         string   `json:"target"`
			Currency       string   `json:"currency"`
			MargedAmount   any      `json:"margedAmount"`
			TotalFeeAmount any      `json:"totalFeeAmount"`
			TotalAmount    any      `json:"totalAmount"`
			BillableAmount any      `json:"billableAmount"`
			Conversion     struct {
				MargedAmount        any    `json:"margedAmount"`
				TotalFeeAmount      any    `json:"totalFeeAmount"`
				TotalAmount         any    `json:"totalAmount"`
				BillableAmount      any    `json:"billableAmount"`
				ProductFeeAmount    any    `json:"productFeeAmount"`
				WalletFeeAmount     any    `json:"walletFeeAmount"`
				GovernmentFeeAmount any    `json:"governmentFeeAmount"`
				Rate                any    `json:"rate"`
				Currency            string `json:"currency"`
			} `json:"conversion"`
		} `json:"destinationFee"`
	} `json:"fees"`
}

TransactionIntentTransaction represents the transaction intent details.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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