diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..841238b --- /dev/null +++ b/docs/index.html @@ -0,0 +1,1152 @@ + + +
+ + + + +const ( + // ENVIRONMENT_SANDBOX is the sandbox environment + ENVIRONMENT_SANDBOX = "sandbox" + // ENVIRONMENT_PRODUCTION is the production environment + ENVIRONMENT_PRODUCTION = "production" +)+ + + + + + + +
type Authorization struct {
+ // contains filtered or unexported fields
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ B2BPayload represents a request payload for the B2C API. + +
type B2BPayload struct { + // InitiatorName is the initiator name. + InitiatorName string `json:"InitiatorName"` + + // SecurityCredential is the security credential. + SecurityCredential string `json:"SecurityCredential"` + + // CommandID is the command ID. + CommandID string `json:"CommandID"` + + // Amount is the amount to be transferred. + Amount string `json:"Amount"` + + // PartyA is the party A (the organization making the payment). + PartyA string `json:"PartyA"` + + // PartyB is the party B (the customer receiving the payment). + PartyB string `json:"PartyB"` + + // Remarks are any remarks for the request. + Remarks string `json:"Remarks"` + + // QueueTimeOutURL is the queue timeout URL. + QueueTimeOutURL string `json:"QueueTimeOutURL"` + + // ResultURL is the result URL. + ResultURL string `json:"ResultURL"` + + // Occasion is the occasion for the payment. + Occasion string `json:"Occasion"` +} ++ + + + + + + + + + + + + + + +
B2BResponse is the response from the C2B API + +
type B2BResponse struct { + OriginatorConversationID string `json:"OriginatorConversationID"` + ConversationID string `json:"ConversationID"` + ResponseDescription string `json:"ResponseDescription"` +} ++ + + + + + + + + + + + + + + +
type B2CConfig struct { + Initiator string `json:"Initiator"` + SecurityCredential string `json:"SecurityCredential"` + CommandID string `json:"CommandID"` + SenderIdentifierType string `json:"SenderIdentifierType"` + RecieverIdentifierType string `json:"RecieverIdentifierType"` + Amount string `json:"Amount"` + PartyA string `json:"PartyA"` + PartyB string `json:"PartyB"` + AccountReference string `json:"AccountReference"` + Remarks string `json:"Remarks"` + QueueTimeOutURL string `json:"QueueTimeOutURL"` + ResultURL string `json:"ResultURL"` +} ++ + + + + + + + + + + + + + + +
B2CPayload represents a request payload for the B2C API. + +
type B2CPayload struct { + // InitiatorName is the initiator name. + // This is the API operator's username as set on the portal when the user was created. + // For Sandbox users, the username is already created and assigned to them and is available + // on the docs credentials page as Initiator Name (Shortcode 1). + InitiatorName string `json:"InitiatorName"` + + // SecurityCredential is the security credential. + SecurityCredential string `json:"SecurityCredential"` + + // CommandID eg. + // + //· SalaryPayment + // + //· BusinessPayment + // + //· PromotionPayment + CommandID string `json:"CommandID"` + + // Amount is the amount to be transferred. + Amount string `json:"Amount"` + + // PartyA is the party A (the organization making the payment). + // This is the B2C organization shortcode from which the money is sent from. + PartyA string `json:"PartyA"` + + // PartyB is the party B (the customer receiving the payment). + // This is the customer mobile number to receive the amount. + //-The number should have the country code (254) without the plus sign. + PartyB string `json:"PartyB"` + + // Remarks are any remarks for the request. + Remarks string `json:"Remarks"` + + // QueueTimeOutURL is the queue timeout URL. + // This is the URL to be specified in your request that will be used by API Proxy + // to send notification in case the payment request is timed out while awaiting processing in the queue. + QueueTimeOutURL string `json:"QueueTimeOutURL"` + + // ResultURL is the result URL. + ResultURL string `json:"ResultURL"` + + // Occasion is the occasion for the payment. + // Any additional information to be associated with the transaction. + Occasion string `json:"Occasion"` +} ++ + + + + + + + + + + + + + + +
B2CResponse is the response from the B2C API + +
type B2CResponse struct { + // OriginatorConversationID is the unique request ID for tracking a transaction. + OriginatorConversationID string `json:"OriginatorConversationID"` + + // ConversationID is the unique request ID returned by Mpesa for each request made. + ConversationID string `json:"ConversationID"` + + // ResponseDescription is the response description message. + ResponseDescription string `json:"ResponseDescription"` +} ++ + + + + + + + + + + + + + + +
BalanceQuery is used to query the balance of an M-Pesa account + +
type BalanceQuery struct { + Initiator string `json:"Initiator"` + SecurityCredential string `json:"SecurityCredential"` + CommandID string `json:"CommandID"` + PartyA string `json:"PartyA"` + IdentifierType string `json:"IdentifierType"` + Remarks string `json:"Remarks"` + QueueTimeOutURL string `json:"QueueTimeOutURL"` + ResultURL string `json:"ResultURL"` +} ++ + + + + + + + + + + + + + + +
C2B Simulate paying bills online + +
type C2B struct { + ShortCode string `json:"ShortCode"` + CommandID string `json:"CommandID"` + Amount string `json:"Amount"` + Msisdn string `json:"Msisdn"` + BillRefNumber string `json:"BillRefNumber"` +} ++ + + + + + + + + + + + + + + +
C2BRegistrationPayload is the payload for C2B shortcode registration. + +
type C2BRegistrationPayload struct { + // ValidationURL is the URL that receives the validation request from the API upon payment submission. + // The validation URL is only called if the external validation on the registered shortcode is enabled. + ValidationURL string `json:"ValidationURL"` + + // ConfirmationURL is the URL that receives the confirmation request from the API upon payment completion. + ConfirmationURL string `json:"ConfirmationURL"` + + // ResponseType specifies what is to happen if the validation URL is not reachable. + // Only two values are allowed: Completed or Cancelled. + // Completed means MPesa will automatically complete the transaction, + // whereas Cancelled means MPesa will automatically cancel the transaction. + ResponseType string `json:"ResponseType"` + + // ShortCode is the short code of the organization. + ShortCode string `json:"ShortCode"` +} ++ + + + + + + + + + + + + + + +
C2BRegistrationResponse is the response from the C2B API + +
type C2BRegistrationResponse struct { + OriginatorConversationID string `json:"OriginatorConversationID"` + ConversationID string `json:"ConversationID"` + // ResponseDescription This is the status of the request. + ResponseDescription string `json:"ResponseDescription"` +} ++ + + + + + + + + + + + + + + +
C2BResponse is the response from the C2B API + +
type C2BResponse struct { + OriginatorConversationID string `json:"OriginatorConversationID"` + ConversationID string `json:"ConversationID"` + ResponseDescription string `json:"ResponseDescription"` +} ++ + + + + + + + + + + + + + + +
C2BURLRegistration is used to register the confirmation and validation URLs + +
type C2BURLRegistration struct { + ShortCode string `json:"ShortCode"` + ResponseType string `json:"ResponseType"` + ConfirmationURL string `json:"ConfirmationURL"` + ValidationURL string `json:"ValidationURL"` +} ++ + + + + + + + + + + + + + + +
type DarajaApi struct { + ConsumerKey string // Consumer key + ConsumerSecret string // Consumer secret + // contains filtered or unexported fields +} ++ + + + + + + + + + + +
func NewDarajaApi(consumerKey, consumerSecret string, environment Environment) *DarajaApi+
NewDarajaApi is a function that creates a new DarajaApi struct. + It takes a consumer key, a consumer secret, and an Environment as input, + and returns a pointer to the DarajaApi struct. + + + + + + + +
func (d *DarajaApi) Authorize() (*Authorization, error)+
Authorize is a function that retrieves an authorization token from the Mpesa API. + It returns an Authorization struct representing the authorization token, + or an error if an error occurred during the request. + + + + + + +
func (d *DarajaApi) MakeB2BPayment(b2c B2CPayload, certPath string) (*B2CResponse, *ErrorResponse)+
MakeB2BPayment makes a B2C payment. + + + + + + +
func (d *DarajaApi) MakeB2CPayment(b2c B2CPayload, certPath string) (*B2CResponse, *ErrorResponse)+
MakeB2CPayment is a function that makes a B2C payment using the Mpesa API. + It takes a B2CPayload struct representing the payment request payload as input, + and returns a pointer to a B2CResponse struct representing the payment response, + or a pointer to an ErrorResponse struct representing an error that occurred during the request. + + + + + + +
func (d *DarajaApi) MakeC2BPayment(c2b C2B) (*C2BResponse, *ErrorResponse)+ + + + + + +
func (d *DarajaApi) MakeC2BPaymentV2(c2b C2B) (*C2BResponse, *ErrorResponse)+ + + + + + +
func (d *DarajaApi) MakeQRCodeRequest(payload QRPayload) (*QRResponse, *ErrorResponse)+
MakeQRCodeRequest is a function that generates a QR code for a payment. + It takes in a QRPayload struct representing the payment configuration, + and returns a QRResponse struct representing the response from the QR code generation API, + or an ErrorResponse struct representing an error that occurred during the request. + + + + + + +
func (d *DarajaApi) MakeSTKPushRequest(mpesaConfig LipaNaMpesaPayload) (*LipaNaMpesaResponse, *ErrorResponse)+
MakeSTKPushRequest is a function that initiates a Lipa Na Mpesa Online payment. + It takes in a LipaNaMpesaPayload struct representing the payment configuration, + and returns a LipaNaMpesaResponse struct representing the response from the Lipa Na Mpesa API, + or an ErrorResponse struct representing an error that occurred during the request. + + + + + + +
func (d *DarajaApi) RegisterC2BCallback(payload C2BRegistrationPayload) (*C2BRegistrationResponse, *ErrorResponse)+ + + + + + +
func (d *DarajaApi) ReverseTransaction(transation ReversalPayload, certPath string) (*ReversalResponse, *ErrorResponse)+ + + + + + + + +
type Environment string+ + + + + + + + + + + + + + + +
type ErrorResponse struct { + RequestID string `json:"requestId"` + ErrorCode string `json:"errorCode"` + ErrorMessage string `json:"errorMessage"` + Raw []byte `json:"-"` + // contains filtered or unexported fields +} ++ + + + + + + + + + + + + + + +
LipaNaMpesaPayload is used to initiate a transaction on Lipa Na M-Pesa Online Payment + +
type LipaNaMpesaPayload struct { + BusinessShortCode string `json:"BusinessShortCode"` + Password string `json:"Password"` + Timestamp string `json:"Timestamp"` + TransactionType string `json:"TransactionType"` + Amount string `json:"Amount"` + PartyA string `json:"PartyA"` + PartyB string `json:"PartyB"` + PhoneNumber string `json:"PhoneNumber"` + CallBackURL string `json:"CallBackURL"` + AccountReference string `json:"AccountReference"` + TransactionDesc string `json:"TransactionDesc"` +} ++ + + + + + + + + + + + + + + +
LipaNaMpesaResponse represents a response from the Lipa Na Mpesa API. + +
type LipaNaMpesaResponse struct { + // MerchantRequestID is the unique request ID for tracking a transaction. + MerchantRequestID string `json:"MerchantRequestID"` + + // CheckoutRequestID is the unique request ID for the checkout process. + CheckoutRequestID string `json:"CheckoutRequestID"` + + // ResponseCode is the response code for the request. + ResponseCode string `json:"ResponseCode"` + + // ResponseDescription is a description of the response. + ResponseDescription string `json:"ResponseDescription"` + + // CustomerMessage is a message for the customer. + CustomerMessage string `json:"CustomerMessage"` +} ++ + + + + + + + + + + + + + + +
MerchantStatus is used to check the status of a transaction on Lipa Na M-Pesa Online Payment + +
type MerchantStatus struct { + BusinessShortCode string `json:"BusinessShortCode"` + Password string `json:"Password"` + Timestamp string `json:"Timestamp"` + CheckoutRequestID string `json:"CheckoutRequestID"` +} ++ + + + + + + + + + + + + + + +
QRPayload represents a request payload for a QR code payment. + +
type QRPayload struct { + // MerchantName is the merchant name. + MerchantName string `json:"MerchantName"` + + // RefNo is the reference number. + RefNo string `json:"RefNo"` + + // Amount is the amount to be paid. + Amount int `json:"Amount"` + + // TrxCode is the transaction code. + //Transaction Type. The supported types are: + // + //BG: Pay Merchant (Buy Goods). + // + //WA: Withdraw Cash at Agent Till. + // + //PB: Paybill or Business number. + // + //SM: Send Money(Mobile number). + // + //SB: Sent to Business. Business number CPI in MSISDN format. + TrxCode string `json:"TrxCode"` + + // CPI Credit Party Identifier. Can be a Mobile Number, Business Number, + //Agent Till, Paybill or Business number, Merchant Buy Goods. + CPI string `json:"CPI"` +} ++ + + + + + + + + + + + + + + +
QRResponse represents a response from a QR code payment request. + +
type QRResponse struct { + // ResponseCode is the response code. + ResponseCode string `json:"ResponseCode"` + + // RequestID is the request ID. + RequestID string `json:"RequestID"` + + // ResponseDescription is the response description. + ResponseDescription string `json:"ResponseDescription"` + + // QRCode is the QR code as a base64-encoded string. + QRCode string `json:"QRCode"` +} ++ + + + + + + + + + + + + + + +
type RegisterURLConfig struct { + ShortCode string `json:"ShortCode"` + ResponseType string `json:"ResponseType"` + ConfirmationURL string `json:"ConfirmationURL"` + ValidationURL string `json:"ValidationURL"` +} ++ + + + + + + + + + + + + + + +
type ReversalPayload struct { + Initiator string `json:"Initiator"` + SecurityCredential string `json:"SecurityCredential"` + CommandID string `json:"CommandID"` + TransactionID string `json:"TransactionID"` + Amount string `json:"Amount"` + ReceiverParty string `json:"ReceiverParty"` + RecieverIdentifierType string `json:"RecieverIdentifierType"` + ResultURL string `json:"ResultURL"` + QueueTimeOutURL string `json:"QueueTimeOutURL"` + Remarks string `json:"Remarks"` + Occasion string `json:"Occasion"` +} ++ + + + + + + + + + + + + + + +
ReversalResponse represents a response from the Mpesa Reversal. + +
type ReversalResponse struct { + // OriginatorConversationID is the unique request ID for tracking a transaction. + OriginatorConversationID string `json:"OriginatorConversationID"` + + // ConversationID is the unique request ID returned by mpesa for each request made. + ConversationID string `json:"ConversationID"` + + // ResponseDescription is the response description message. + ResponseDescription string `json:"ResponseDescription"` +} ++ + + + + + + + + + + + + + + +
type TransactionStatus struct { + Initiator string `json:"Initiator"` + SecurityCredential string `json:"SecurityCredential"` + CommandID string `json:"CommandID"` + TransactionID string `json:"TransactionID"` + PartyA string `json:"PartyA"` + IdentifierType string `json:"IdentifierType"` + ResultURL string `json:"ResultURL"` + QueueTimeOutURL string `json:"QueueTimeOutURL"` + Remarks string `json:"Remarks"` + Occasion string `json:"Occasion"` +} ++ + + +
' + + 'Your download should begin shortly. ' + + 'If it does not, click this link.
' + ); + message.find('a').attr('href', download); + message.insertAfter('#nav'); + + window.location = download; + } + + function updateVersionTags() { + var v = window.goVersion; + if (/^go[0-9.]+$/.test(v)) { + $('.versionTag') + .empty() + .text(v); + $('.whereTag').hide(); + } + } + + function addPermalinks() { + function addPermalink(source, parent) { + var id = source.attr('id'); + if (id == '' || id.indexOf('tmp_') === 0) { + // Auto-generated permalink. + return; + } + if (parent.find('> .permalink').length) { + // Already attached. + return; + } + parent + .append(' ') + .append($("¶").attr('href', '#' + id)); + } + + $('#page .container') + .find('h2[id], h3[id]') + .each(function() { + var el = $(this); + addPermalink(el, el); + }); + + $('#page .container') + .find('dl[id]') + .each(function() { + var el = $(this); + // Add the anchor to the "dt" element. + addPermalink(el, el.find('> dt').first()); + }); + } + + $('.js-expandAll').click(function() { + if ($(this).hasClass('collapsed')) { + toggleExamples('toggle'); + $(this).text('(Collapse All)'); + } else { + toggleExamples('toggleVisible'); + $(this).text('(Expand All)'); + } + $(this).toggleClass('collapsed'); + }); + + function toggleExamples(className) { + // We need to explicitly iterate through divs starting with "example_" + // to avoid toggling Overview and Index collapsibles. + $("[id^='example_']").each(function() { + // Check for state and click it only if required. + if ($(this).hasClass(className)) { + $(this) + .find('.toggleButton') + .first() + .click(); + } + }); + } + + $(document).ready(function() { + generateTOC(); + addPermalinks(); + bindToggles('.toggle'); + bindToggles('.toggleVisible'); + bindToggleLinks('.exampleLink', 'example_'); + bindToggleLinks('.overviewLink', ''); + bindToggleLinks('.examplesLink', ''); + bindToggleLinks('.indexLink', ''); + setupDropdownPlayground(); + setupInlinePlayground(); + fixFocus(); + setupTypeInfo(); + setupCallgraphs(); + toggleHash(); + personalizeInstallInstructions(); + updateVersionTags(); + + // godoc.html defines window.initFuncs in the tag, and root.html and + // codewalk.js push their on-page-ready functions to the list. + // We execute those functions here, to avoid loading jQuery until the page + // content is loaded. + for (var i = 0; i < window.initFuncs.length; i++) window.initFuncs[i](); + }); + + // -- analysis --------------------------------------------------------- + + // escapeHTML returns HTML for s, with metacharacters quoted. + // It is safe for use in both elements and attributes + // (unlike the "set innerText, read innerHTML" trick). + function escapeHTML(s) { + return s + .replace(/&/g, '&') + .replace(/\"/g, '"') + .replace(/\'/g, ''') + .replace(//g, '>'); + } + + // makeAnchor returns HTML for an element, given an anchorJSON object. + function makeAnchor(json) { + var html = escapeHTML(json.Text); + if (json.Href != '') { + html = "" + html + ''; + } + return html; + } + + function showLowFrame(html) { + var lowframe = document.getElementById('lowframe'); + lowframe.style.height = '200px'; + lowframe.innerHTML = + "" + + html + + '
\n' + + "' + escapeHTML(data.Callee) + '
:' + escapeHTML(caller.Func) + '
';
+ var sites = caller.Sites;
+ if (sites != null && sites.length > 0) {
+ html += ' at line ';
+ for (var j = 0; j < sites.length; j++) {
+ if (j > 0) {
+ html += ', ';
+ }
+ html += '' + makeAnchor(sites[j]) + '
';
+ }
+ }
+ html += '' + makeAnchor(data.Callees[i]) + '
' +
+ data.Name +
+ '
: ' +
+ ' (size=' +
+ data.Size +
+ ', align=' +
+ data.Align +
+ ')' + escapeHTML(group.Descr) + '
';
+ for (var j = 0; j < group.Facts.length; j++) {
+ var fact = group.Facts[j];
+ var y = '' + makeAnchor(fact.Other) + '
';
+ if (fact.ByKind != null) {
+ html += escapeHTML(fact.ByKind) + ' type ' + y + ' implements ' + x;
+ } else {
+ html += x + ' implements ' + y;
+ }
+ html += '' + makeAnchor(info.Methods[i]) + '
' +
+ escapeHTML(ops[i].Fn) +
+ '
t |