payload

package
v1.2.8 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2022 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse struct {
	ConversationID           string `json:"ConversationID"`
	OriginatorConversationID string `json:"OriginatorConversationID"`
	ResponseCode             string `json:"ResponseCode"`
	ResponseDescription      string `json:"ResponseDescription"`
}

APIResponse is response returned after interacting with mpesa API

func (*APIResponse) Succeeded

func (apiRes *APIResponse) Succeeded() bool

Succeeded checks whether response was successful

type AccountBalanceRequest

type AccountBalanceRequest struct {
	CommandID          string `json:"CommandID,omitempty"`
	PartyA             int32  `json:"PartyA,omitempty"`
	IdentifierType     int32  `json:"IdentifierType,omitempty"`
	Remarks            string `json:"Remarks,omitempty"`
	Initiator          string `json:"Initiator,omitempty"`
	SecurityCredential string `json:"SecurityCredential,omitempty"`
	QueueTimeOutURL    string `json:"QueueTimeOutURL,omitempty"`
	ResultURL          string `json:"ResultURL,omitempty"`
}

AccountBalanceRequest is request to make balance inquiry

type B2CRequest

type B2CRequest struct {
	InitiatorName      string `json:"InitiatorName,omitempty"`
	SecurityCredential string `json:"SecurityCredential,omitempty"`
	CommandID          string `json:"CommandID,omitempty"`
	Amount             string `json:"Amount,omitempty"`
	PartyA             string `json:"PartyA,omitempty"`
	PartyB             int64  `json:"PartyB,omitempty"`
	Remarks            string `json:"Remarks,omitempty"`
	QueueTimeOutURL    string `json:"QueueTimeOutURL,omitempty"`
	ResultURL          string `json:"ResultURL,omitempty"`
	Occassion          string `json:"Occassion,omitempty"`
}

B2CRequest is request to transact between an M-Pesa short code to a phone number registered on M-Pesa.

type Body

type Body struct {
	STKCallback STKCallback `json:"stkCallback,omitempty"`
}

Body ...

type CallbackMeta

type CallbackMeta struct {
	Item []Item `json:"Item,omitempty"`
}

CallbackMeta is response body for successful response

func (*CallbackMeta) Balance added in v1.2.3

func (c *CallbackMeta) Balance() string

Balance returns the transaction balance

func (*CallbackMeta) GetAmount

func (c *CallbackMeta) GetAmount() float32

GetAmount returns the transaction amount

func (*CallbackMeta) GetTransTime

func (c *CallbackMeta) GetTransTime() time.Time

GetTransTime returns the transaction time

func (*CallbackMeta) MpesaReceiptNumber

func (c *CallbackMeta) MpesaReceiptNumber() string

MpesaReceiptNumber returns the receipt number

func (*CallbackMeta) PhoneNumber

func (c *CallbackMeta) PhoneNumber() string

PhoneNumber returns the phone number

type GenericAPIResponse

type GenericAPIResponse struct {
	Response map[string]string
}

GenericAPIResponse is generic API response

func (*GenericAPIResponse) ConversationID

func (gRes *GenericAPIResponse) ConversationID() string

ConversationID returns the conversation id

func (*GenericAPIResponse) Error

func (gRes *GenericAPIResponse) Error() string

Error returns the error

func (*GenericAPIResponse) ErrorCode

func (gRes *GenericAPIResponse) ErrorCode() string

ErrorCode returns the error code

func (*GenericAPIResponse) ErrorMessage

func (gRes *GenericAPIResponse) ErrorMessage() string

ErrorMessage returns the error message

func (*GenericAPIResponse) OriginatorConversationID

func (gRes *GenericAPIResponse) OriginatorConversationID() string

OriginatorConversationID returns the originator conversation id

func (*GenericAPIResponse) ResponseCode

func (gRes *GenericAPIResponse) ResponseCode() string

ResponseCode returns the response code

func (*GenericAPIResponse) ResponseDescription

func (gRes *GenericAPIResponse) ResponseDescription() string

ResponseDescription returns the response description

func (*GenericAPIResponse) Succeeded

func (gRes *GenericAPIResponse) Succeeded() bool

Succeeded checks whether the request succeeded

type IncomingTransactionOnfon

type IncomingTransactionOnfon struct {
	OriginatorConversationID         string `json:"originatorConversationID"`
	ResultType                       string `json:"resultType"`
	ResultCode                       string `json:"resultCode"`
	ResultDesc                       string `json:"resultDesc"`
	ConversationID                   string `json:"conversationID"`
	TransactionAmount                string `json:"transactionAmount"`
	TransactionID                    string `json:"transactionID"`
	TransactionReceipt               string `json:"transactionReceipt"`
	ReceiverPartyPublicName          string `json:"receiverPartyPublicName"`
	B2CUtilityAccountAvailableFunds  string `json:"b2CUtilityAccountAvailableFunds"`
	TransactionCompletedDateTime     string `json:"transactionCompletedDateTime"`
	B2CRecipientIsRegisteredCustomer string `json:"b2CRecipientIsRegisteredCustomer"`
}

IncomingTransactionOnfon is the payload for incoming transaction from onfon

func (*IncomingTransactionOnfon) Amount

func (tx *IncomingTransactionOnfon) Amount() float64

Amount retrievs transaction amount

func (*IncomingTransactionOnfon) B2CRecipientIsRegisteredCustomerV2

func (tx *IncomingTransactionOnfon) B2CRecipientIsRegisteredCustomerV2() bool

B2CRecipientIsRegisteredCustomerV2 checks whether the b2c recipient is a registred customer

func (*IncomingTransactionOnfon) B2CUtilityAccountAvailableFundsV2

func (tx *IncomingTransactionOnfon) B2CUtilityAccountAvailableFundsV2() float64

B2CUtilityAccountAvailableFundsV2 retrievs B2CUtilityAccountAvailableFunds as float64

func (*IncomingTransactionOnfon) CompletedDateTime

func (tx *IncomingTransactionOnfon) CompletedDateTime() time.Time

CompletedDateTime is time the transacction was completed

func (*IncomingTransactionOnfon) MSISDN

func (tx *IncomingTransactionOnfon) MSISDN() string

MSISDN retrieves phone number

func (*IncomingTransactionOnfon) Succeeded

func (tx *IncomingTransactionOnfon) Succeeded() bool

Succeeded checks whether transaction was successful

type Item

type Item struct {
	Name  string      `json:"Name,omitempty"`
	Value interface{} `json:"Value,omitempty"`
}

Item ...

type MpesaPayload

type MpesaPayload struct {
	TransactionType   string `json:"transaction_type,omitempty"`
	TransID           string `json:"trans_id,omitempty"`
	TransTime         string `json:"trans_time,omitempty"`
	TransAmount       string `json:"trans_amount,omitempty"`
	BusinessShortCode string `json:"business_short_code,omitempty"`
	BillRefNumber     string `json:"bill_ref_number,omitempty"`
	InvoiceNumber     string `json:"invoice_number,omitempty"`
	OrgAccountBalance string `json:"org_account_balance,omitempty"`
	ThirdPartyTransID string `json:"third_party_trans_id,omitempty"`
	MSISDN            string `json:"msisdn,omitempty"`
	FirstName         string `json:"first_name,omitempty"`
	MiddleName        string `json:"middle_name,omitempty"`
	LastName          string `json:"last_name,omitempty"`
}

MpesaPayload is incoming paybill transaction from mpesa

type MpesaPayloadV2 added in v1.2.8

type MpesaPayloadV2 struct {
	TransactionType   string `json:"TransactionType"`
	TransID           string `json:"TransID"`
	TransTime         string `json:"TransTime"`
	TransAmount       string `json:"TransAmount"`
	BusinessShortCode string `json:"BusinessShortCode"`
	BillRefNumber     string `json:"BillRefNumber"`
	InvoiceNumber     string `json:"InvoiceNumber"`
	OrgAccountBalance string `json:"OrgAccountBalance"`
	ThirdPartyTransID string `json:"ThirdPartyTransID"`
	MSISDN            string `json:"MSISDN"`
	FirstName         string `json:"FirstName"`
	MiddleName        string `json:"MiddleName"`
	LastName          string `json:"LastName"`
}

MpesaPayloadV2 is incoming paybill transaction from mpesa

type QueryStkRequest added in v1.2.8

type QueryStkRequest struct {
	BusinessShortCode string `json:"BusinessShortCode"`
	Password          string `json:"Password"`
	Timestamp         string `json:"Timestamp"`
	CheckoutRequestID string `json:"CheckoutRequestID"`
}

type QueryStkResponse added in v1.2.8

type QueryStkResponse struct {
	ResponseCode        string `json:"ResponseCode"`
	ResponseDescription string `json:"ResponseDescription"`
	MerchantRequestID   string `json:"MerchantRequestID"`
	CheckoutRequestID   string `json:"CheckoutRequestID"`
	ResultCode          string `json:"ResultCode"`
	ResultDesc          string `json:"ResultDesc"`
}

type ReversalRequest

type ReversalRequest struct {
	CommandID              string `json:"CommandID,omitempty"`
	ReceiverParty          int32  `json:"ReceiverParty,omitempty"`
	ReceiverIdentifierType int64  `json:"ReceiverIdentifierType,omitempty"`
	Remarks                string `json:"Remarks,omitempty"`
	Initiator              string `json:"Initiator,omitempty"`
	SecurityCredential     string `json:"SecurityCredential,omitempty"`
	QueueTimeOutURL        string `json:"QueueTimeOutURL,omitempty"`
	ResultURL              string `json:"ResultURL,omitempty"`
	TransactionID          string `json:"TransactionID,omitempty"`
	Occassion              string `json:"Occassion,omitempty"`
}

ReversalRequest is request to reverses a M-Pesa transaction.

type STKCallback

type STKCallback struct {
	MerchantRequestID string       `json:"MerchantRequestID,omitempty"`
	CheckoutRequestID string       `json:"CheckoutRequestID,omitempty"`
	ResultCode        int          `json:"ResultCode,omitempty"`
	ResultDesc        string       `json:"ResultDesc,omitempty"`
	CallbackMetadata  CallbackMeta `json:"CallbackMetadata,omitempty"`
}

STKCallback ...

type STKPayload

type STKPayload struct {
	Body Body `json:"Body,omitempty"`
}

STKPayload is incoming transaction payload for stk push

type Transaction

type Transaction struct {
	Result struct {
		ResultType               int    `json:"ResultType"`
		ResultCode               int    `json:"ResultCode"`
		ResultDesc               string `json:"ResultDesc"`
		OriginatorConversationID string `json:"OriginatorConversationID"`
		ConversationID           string `json:"ConversationID"`
		TransactionID            string `json:"TransactionID"`
		ResultParameters         struct {
			ResultParameter []struct {
				Key   string      `json:"Key"`
				Value interface{} `json:"Value"`
			} `json:"ResultParameter"`
		} `json:"ResultParameters"`
		ReferenceData struct {
			ReferenceItem struct {
				Key   string      `json:"Key"`
				Value interface{} `json:"Value"`
			} `json:"ReferenceItem"`
		} `json:"ReferenceData"`
	} `json:"Result"`
}

Transaction is response from mpesa

func (*Transaction) B2CChargesPaidAccountAvailableFunds

func (tx *Transaction) B2CChargesPaidAccountAvailableFunds() float64

B2CChargesPaidAccountAvailableFunds ...

func (*Transaction) B2CRecipientIsRegisteredCustomer

func (tx *Transaction) B2CRecipientIsRegisteredCustomer() bool

B2CRecipientIsRegisteredCustomer checks whether the b2c recipient is a registred customer

func (*Transaction) B2CUtilityAccountAvailableFunds

func (tx *Transaction) B2CUtilityAccountAvailableFunds() float64

B2CUtilityAccountAvailableFunds returns the utility funds available

func (*Transaction) B2CWorkingAccountAvailableFunds

func (tx *Transaction) B2CWorkingAccountAvailableFunds() float64

B2CWorkingAccountAvailableFunds returns the available funds for the organization

func (*Transaction) ConversationID added in v1.2.3

func (tx *Transaction) ConversationID() string

ConversationID returns value of tx.Result.ConversationID

func (*Transaction) MSISDN

func (tx *Transaction) MSISDN() string

func (*Transaction) OriginatorConversationID added in v1.2.3

func (tx *Transaction) OriginatorConversationID() string

OriginatorConversationID is the originator id

func (*Transaction) QueueTimeoutURL

func (tx *Transaction) QueueTimeoutURL() string

QueueTimeoutURL ...

func (*Transaction) ReceiverPartyPublicName

func (tx *Transaction) ReceiverPartyPublicName() string

ReceiverPartyPublicName ...

func (*Transaction) Succeeded

func (tx *Transaction) Succeeded() bool

Succeeded checks whether transaction was successful

func (*Transaction) TransactionAmount

func (tx *Transaction) TransactionAmount() float64

TransactionAmount retrievs transaction phone number

func (*Transaction) TransactionCompletedDateTime

func (tx *Transaction) TransactionCompletedDateTime() time.Time

TransactionCompletedDateTime is time the transacction was completed

func (*Transaction) TransactionReceipt

func (tx *Transaction) TransactionReceipt() string

TransactionReceipt retrieves transaction receipt

Jump to

Keyboard shortcuts

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