Daraja.Express.Request (daraja v0.1.0)

Copy Markdown View Source

Input struct for an STK Push request.

Required fields: amount, phone_number, account_reference.

Phone numbers in local 07XXXXXXXX form are normalized to 254XXXXXXXXX. Account reference is displayed to the customer in the USSD prompt (max 12 chars). Transaction description is optional (max 13 chars).

Summary

Types

t()

@type t() :: %Daraja.Express.Request{
  account_reference: String.t(),
  amount: pos_integer(),
  phone_number: String.t(),
  transaction_desc: String.t() | nil,
  transaction_type: String.t()
}

Functions

new(params)

@spec new(map()) ::
  {:ok, t()}
  | {:error, :invalid_request,
     [
       atom()
       | {:amount, String.t()}
       | {:phone_number, String.t()}
       | {:account_reference, String.t()}
       | {:transaction_desc, String.t()}
       | {:transaction_type, String.t()}
     ]}