Documentation ¶
Index ¶
- Constants
- type B2BPaymentRequest
- type B2BPaymentResponse
- type B2CPaymentRequest
- type B2CPaymentResponse
- type C2BPaymentRequest
- type C2BPaymentResponse
- type CancelDirectDBReq
- type CancelDirectDBRes
- type Client
- func (c *Client) B2BPayment(ctx context.Context, payload B2BPaymentRequest) (*B2BPaymentResponse, error)
- func (c *Client) B2CPayment(ctx context.Context, payload B2CPaymentRequest) (*B2CPaymentResponse, error)
- func (c *Client) C2BPayment(ctx context.Context, payload C2BPaymentRequest) (*C2BPaymentResponse, error)
- func (c *Client) CancelDirectDebit(ctx context.Context, payload CancelDirectDBReq) (*CancelDirectDBRes, error)
- func (c *Client) DirectDebitCreate(ctx context.Context, payload DirectDBCreateReq) (*DirectDBCreateRes, error)
- func (c *Client) DirectDebitPayment(ctx context.Context, payload DebitDBPaymentReq) (*DebitDBPaymentRes, error)
- func (c *Client) NewReqWithQueryParams(ctx context.Context, method, baseUrl string, payload interface{}) (*http.Request, error)
- func (c *Client) NewRequest(ctx context.Context, method, url string, payload interface{}) (*http.Request, error)
- func (c *Client) QueryBeneficiaryName(ctx context.Context, payload QueryBenRequest) (*QueryBenResponse, error)
- func (c *Client) QueryDirectDebit(ctx context.Context, payload QueryDirectDBReq) (*QueryDirectDBRes, error)
- func (c *Client) QueryTxStatus(ctx context.Context, payload QueryTxStatusRequest) (*QueryTxStatusResponse, error)
- func (c *Client) QueryValuesFromStruct(payload interface{}) (url.Values, error)
- func (c *Client) Reversal(ctx context.Context, payload ReversalRequest) (*ReversalResponse, error)
- func (c *Client) Send(req *http.Request, v interface{}, e interface{}) error
- func (c *Client) SendWithAuth(req *http.Request, v interface{}, e interface{}) error
- func (c *Client) SendWithSessionKey(req *http.Request, v interface{}, e interface{}) error
- func (c *Client) SetHttpClient(client *http.Client)
- type DebitDBPaymentReq
- type DebitDBPaymentRes
- type DirectDBCreateReq
- type DirectDBCreateRes
- type Env
- type Keys
- type QueryBenRequest
- type QueryBenResponse
- type QueryDirectDBReq
- type QueryDirectDBRes
- type QueryTxStatusRequest
- type QueryTxStatusResponse
- type ReversalRequest
- type ReversalResponse
- type SessionKeyResponse
Constants ¶
const ( Address = "openapi.m-pesa.com" Ssl = true Port = 443 ProdEndpoint = "/openapi/ipg/v2/vodacomTZN/" SandboxEndpoint = "/sandbox/ipg/v2/vodacomTZN/" SessionEndPath = "getSession" C2BPaymentPath = "c2bPayment/singleStage" B2BPaymentPath = "b2bPayment" B2CPaymentPath = "b2cPayment" ReversalPath = "reversal" QueryTxStatusPath = "queryTransactionStatus" DirectDebitPath = "directDebitCreation" DebitDBPaymentPath = "directDebitPayment" QueryBeneficialPath = "queryBeneficiaryName" QueryDirectDBPath = "queryDirectDebit" CancelDirectDBPath = "directDebitCancel" SandboxPublicKey = "" /* 736-byte string literal not displayed */ OpenapiPublicKey = "" /* 736-byte string literal not displayed */ ReqNewSessionKeyBeforeExpiresIn = time.Duration(60) * time.Second )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type B2BPaymentRequest ¶
type B2BPaymentRequest struct { Amount string `json:"input_Amount"` ReceiverPartyCode string `json:"input_ReceiverPartyCode"` Country string `json:"input_Country"` Currency string `json:"input_Currency"` PrimaryPartyCode string `json:"input_PrimaryPartyCode"` TransactionReference string `json:"input_TransactionReference"` ThirdPartyConversationID string `json:"input_ThirdPartyConversationID"` PurchasedItemsDesc string `json:"input_PurchasedItemsDesc"` }
type B2BPaymentResponse ¶
type B2BPaymentResponse struct { ResponseCode string `json:"output_ResponseCode"` ResponseDesc string `json:"output_ResponseDesc"` TransactionID string `json:"output_TransactionID"` ConversationID string `json:"output_ConversationID"` ThirdPartyConversationID string `json:"output_ThirdPartyConversationID"` }
type B2CPaymentRequest ¶
type B2CPaymentRequest struct { Amount string `json:"input_Amount"` CustomerMSISDN string `json:"input_CustomerMSISDN"` Country string `json:"input_Country"` Currency string `json:"input_Currency"` ServiceProviderCode string `json:"input_ServiceProviderCode"` TransactionReference string `json:"input_TransactionReference"` ThirdPartyConversationID string `json:"input_ThirdPartyConversationID"` PaymentItemsDesc string `json:"input_PaymentItemsDesc"` }
type B2CPaymentResponse ¶
type B2CPaymentResponse struct { ResponseCode string `json:"output_ResponseCode"` ResponseDesc string `json:"output_ResponseDesc"` TransactionID string `json:"output_TransactionID"` ConversationID string `json:"output_ConversationID"` ThirdPartyConversationID string `json:"output_ThirdPartyConversationID"` }
type C2BPaymentRequest ¶
type C2BPaymentRequest struct { Amount string `json:"input_Amount"` CustomerMSISDN string `json:"input_CustomerMSISDN"` Country string `json:"input_Country"` Currency string `json:"input_Currency"` ServiceProviderCode string `json:"input_ServiceProviderCode"` TransactionReference string `json:"input_TransactionReference"` ThirdPartyConversationID string `json:"input_ThirdPartyConversationID"` PurchasedItemsDesc string `json:"input_PurchasedItemsDesc"` }
type C2BPaymentResponse ¶
type C2BPaymentResponse struct { ResponseCode string `json:"output_ResponseCode"` ResponseDesc string `json:"output_ResponseDesc"` TransactionID string `json:"output_TransactionID"` ConversationID string `json:"output_ConversationID"` ThirdPartyConversationID string `json:"output_ThirdPartyConversationID"` }
type CancelDirectDBReq ¶
type CancelDirectDBReq struct { MsisdnToken string `json:"input_MsisdnToken"` CustomerMSISDN string `json:"input_CustomerMSISDN"` Country string `json:"input_Country"` ServiceProviderCode string `json:"input_ServiceProviderCode"` ThirdPartyReference string `json:"input_ThirdPartyReference"` ThirdPartyConversationID string `json:"input_ThirdPartyConversationID"` MandateID string `json:"input_MandateID"` }
type CancelDirectDBRes ¶
type CancelDirectDBRes struct { ResponseCode string `json:"output_ResponseCode"` ResponseDesc string `json:"output_ResponseDesc"` TransactionReference string `json:"output_TransactionReference"` MsisdnToken string `json:"output_MsisdnToken"` ConversationID string `json:"output_ConversationID"` ThirdPartyConversationID string `json:"output_ThirdPartyConversationID"` }
type Client ¶
type Client struct { Client *http.Client Keys *Keys Environment Env SessionKey string ExpiresAt time.Time SessionLife int32 // contains filtered or unexported fields }
func (*Client) B2BPayment ¶
func (c *Client) B2BPayment(ctx context.Context, payload B2BPaymentRequest) (*B2BPaymentResponse, error)
A method to perform Business to Business transactions. It accepts B2bPaymentRequest payload as a parameter. It returns the B2BPaymentResponse as a pointer struct.
func (*Client) B2CPayment ¶
func (c *Client) B2CPayment(ctx context.Context, payload B2CPaymentRequest) (*B2CPaymentResponse, error)
A method to perform Business to Customer transactions. It accepts B2CPaymentRequest payload as a parameter. It returns the B2CPaymentResponse as a pointer struct.
func (*Client) C2BPayment ¶
func (c *Client) C2BPayment(ctx context.Context, payload C2BPaymentRequest) (*C2BPaymentResponse, error)
A method to perform Customer to Business transactions. It accepts C2BPaymentRequest request payload parameter. It returns the C2BPaymentResponse as a pointer struct.
func (*Client) CancelDirectDebit ¶
func (c *Client) CancelDirectDebit(ctx context.Context, payload CancelDirectDBReq) (*CancelDirectDBRes, error)
Cancels a Direct Debit mandate
func (*Client) DirectDebitCreate ¶
func (c *Client) DirectDebitCreate(ctx context.Context, payload DirectDBCreateReq) (*DirectDBCreateRes, error)
Direct Debit Create Mandate
func (*Client) DirectDebitPayment ¶
func (c *Client) DirectDebitPayment(ctx context.Context, payload DebitDBPaymentReq) (*DebitDBPaymentRes, error)
Direct Debit Payment
func (*Client) NewReqWithQueryParams ¶
func (c *Client) NewReqWithQueryParams(ctx context.Context, method, baseUrl string, payload interface{}) (*http.Request, error)
NewReqWithQueryParams constructs a request with query params
func (*Client) NewRequest ¶
func (c *Client) NewRequest(ctx context.Context, method, url string, payload interface{}) (*http.Request, error)
NewRequest constructs a request Convert payload to a JSON
func (*Client) QueryBeneficiaryName ¶
func (c *Client) QueryBeneficiaryName(ctx context.Context, payload QueryBenRequest) (*QueryBenResponse, error)
Query the beneficiary's name
func (*Client) QueryDirectDebit ¶
func (c *Client) QueryDirectDebit(ctx context.Context, payload QueryDirectDBReq) (*QueryDirectDBRes, error)
Query the Direct Debit status
func (*Client) QueryTxStatus ¶
func (c *Client) QueryTxStatus(ctx context.Context, payload QueryTxStatusRequest) (*QueryTxStatusResponse, error)
A method to query a trasaction status. It accepts QueryTxStatusRequest payload as a parameter. It returns QueryTxStatusResponse as a pointer struct.
func (*Client) QueryValuesFromStruct ¶
QueryValuesFromStruct converts a struct to url.Values
func (*Client) Reversal ¶
func (c *Client) Reversal(ctx context.Context, payload ReversalRequest) (*ReversalResponse, error)
A method to Perform a reversal on a transaction. It accepts ReversalRequest payload as a parameter. It returns the ReversalResponse as a pointer struct.
func (*Client) Send ¶
Send makes a request to the API, the response body will be unmarshalled into v, or if v is an io.Writer, the response will be written to it without decoding
func (*Client) SendWithAuth ¶
SendWithAuth makes a request to the API and apply authentication automatically.
func (*Client) SendWithSessionKey ¶
SendWithSessionKey makes a request to the API using generated sessionkey as bearer token.
func (*Client) SetHttpClient ¶
SetHTTPClient sets *http.Client to current client
type DebitDBPaymentReq ¶
type DebitDBPaymentReq struct { MsisdnToken string `json:"input_MsisdnToken,omitempty"` CustomerMSISDN string `json:"input_CustomerMSISDN,omitempty"` Country string `json:"input_Country"` ServiceProviderCode string `json:"input_ServiceProviderCode"` ThirdPartyReference string `json:"input_ThirdPartyReference"` ThirdPartyConversationID string `json:"input_ThirdPartyConversationID"` Amount string `json:"input_Amount"` Currency string `json:"input_Currency"` MandateID string `json:"input_MandateID,omitempty"` }
type DebitDBPaymentRes ¶
type DebitDBPaymentRes struct { ResponseCode string `json:"output_ResponseCode"` ResponseDesc string `json:"output_ResponseDesc"` TransactionID string `json:"output_TransactionID"` MsisdnToken string `json:"output_MsisdnToken,omitempty"` ConversationID string `json:"output_ConversationID"` ThirdPartyConversationID string `json:"output_ThirdPartyConversationID,omitempty"` }
type DirectDBCreateReq ¶
type DirectDBCreateReq struct { CustomerMSISDN string `json:"input_CustomerMSISDN"` Country string `json:"input_Country"` ServiceProviderCode string `json:"input_ServiceProviderCode"` ThirdPartyReference string `json:"input_ThirdPartyReference"` ThirdPartyConversationID string `json:"input_ThirdPartyConversationID"` AgreedTC string `json:"input_AgreedTC"` FirstPaymentDate string `json:"input_FirstPaymentDate,omitempty"` Frequency string `json:"input_Frequency,omitempty"` StartRangeOfDays string `json:"input_StartRangeOfDays,omitempty"` EndRangeOfDays string `json:"input_EndRangeOfDays,omitempty"` ExpiryDate string `json:"input_ExpiryDate,omitempty"` }
type DirectDBCreateRes ¶
type DirectDBCreateRes struct { ResponseCode string `json:"output_ResponseCode"` ResponseDesc string `json:"output_ResponseDesc"` TransactionReference string `json:"output_TransactionReference"` MsisdnToken string `json:"output_MsisdnToken,omitempty"` ConversationID string `json:"output_ConversationID"` ThirdPartyConversationID string `json:"output_ThirdPartyConversationID"` }
type QueryBenRequest ¶
type QueryBenRequest struct { CustomerMSISDN string `json:"input_CustomerMSISDN"` Country string `json:"input_Country"` ServiceProviderCode string `json:"input_ServiceProviderCode"` ThirdPartyConversationID string `json:"input_ThirdPartyConversationID"` KycQueryType string `json:"input_KycQueryType"` }
type QueryBenResponse ¶
type QueryBenResponse struct { ResponseCode string `json:"output_ResponseCode"` ResponseDesc string `json:"output_ResponseDesc"` CustomerFirstName string `json:"output_CustomerFirstName"` CustomerLastName string `json:"output_CustomerLastName"` ConversationID string `json:"output_ConversationID"` ThirdPartyConversationID string `json:"output_ThirdPartyConversationID"` }
type QueryDirectDBReq ¶
type QueryDirectDBReq struct { QueryBalanceAmount bool `json:"input_QueryBalanceAmount"` BalanceAmount string `json:"input_BalanceAmount,omitempty"` Country string `json:"input_Country"` CustomerMSISDN string `json:"input_CustomerMSISDN,omitempty"` MsisdnToken string `json:"input_MsisdnToken,omitempty"` ServiceProviderCode string `json:"input_ServiceProviderCode"` ThirdPartyConversationID string `json:"input_ThirdPartyConversationID"` ThirdPartyReference string `json:"input_ThirdPartyReference"` MandateID string `json:"input_MandateID,omitempty"` Currency string `json:"input_Currency"` }
type QueryDirectDBRes ¶
type QueryDirectDBRes struct { ResponseCode string `json:"output_ResponseCode"` ResponseDesc string `json:"output_ResponseDesc"` TransactionReference string `json:"output_TransactionReference"` ConversationID string `json:"output_ConversationID"` ThirdPartyConversationID string `json:"output_ThirdPartyConversationID"` SufficientBalance bool `json:"output_SufficientBalance"` MsisdnToken string `json:"output_MsisdnToken,omitempty"` MandateID string `json:"output_MandateID"` MandateStatus string `json:"output_MandateStatus"` AccountStatus string `json:"output_AccountStatus"` FirstPaymentDate string `json:"output_FirstPaymentDate,omitempty"` Frequency string `json:"output_Frequency,omitempty"` PaymentDayFrom string `json:"output_PaymentDayFrom,omitempty"` PaymentDayTo string `json:"output_PaymentDayTo,omitempty"` ExpiryDate string `json:"output_ExpiryDate,omitempty"` }
type QueryTxStatusRequest ¶
type QueryTxStatusResponse ¶
type QueryTxStatusResponse struct { ResponseCode string `json:"output_ResponseCode"` ResponseDesc string `json:"output_ResponseDesc"` ResponseTransactionStatus string `json:"output_ResponseTransactionStatus"` ConversationID string `json:"output_ConversationID"` ThirdPartyConversationID string `json:"output_ThirdPartyConversationID"` OriginalTransactionID string `json:"output_OriginalTransactionID"` }
type ReversalRequest ¶
type ReversalRequest struct { ReversalAmount string `json:"input_ReversalAmount,omitempty"` Country string `json:"input_Country"` TransactionID string `json:"input_TransactionID"` ServiceProviderCode string `json:"input_ServiceProviderCode"` ThirdPartyConversationID string `json:"input_ThirdPartyConversationID"` }
type ReversalResponse ¶
type ReversalResponse struct { ResponseCode string `json:"output_ResponseCode"` ResponseDesc string `json:"output_ResponseDesc"` TransactionID string `json:"output_TransactionID"` ConversationID string `json:"output_ConversationID"` ThirdPartyConversationID string `json:"output_ThirdPartyConversationID"` }