[badges][badges] [badges]

AtEx

An API Wrapper for the Africas Talking API https://africastalking.com/

Table of contents

Features

We hope to cover all the endpoints of Africas Talking to help elixir developers integrate its services in their applications. Here are the main modules we hope to develop in the process.

Installation

Available in Hex, the package can be installed by adding at_ex to your list of dependencies in mix.exs:

def deps do
  [
    {:at_ex, "~> 0.20.20"}
  ]
end

Configuration

Example Configuration setup

config :at_ex,
  api_key: "===INSERT AFRICAS_TALKING_API_KEY HERE ===",
  content_type: "application/x-www-form-urlencoded",
  accept: "application/json",
  username: "sandbox", #change to live username for prod.ex
  stk_product_name: "AtEx", #Add your specific product name.
  b2c_product_name: "AtEx",
  b2b_product_name: "AtEx",
  bank_checkout_product_name: "AtEx",
  bank_transfer_product_name: "AtEx",
  card_checkout_product_name: "AtEx",
  # When changed to "YES" one will use the live endpoint url when in development
  force_live_url: "NO"

Documentation

The docs can be found at https://hexdocs.pm/at_ex.

Quick examples

Sending SMS

    iex> AtEx.Sms.send_sms(%{to: "+254728833181", message: "Howdy"})
    {:ok,
    %{
        "SMSMessageData" => %{
        "Message" => "Sent to 1/1 Total Cost: ZAR 0.1124",
        "Recipients" => [
        %{
            "cost" => "KES 0.8000",
            "messageId" => "ATXid_96e52a761a82c1bad58e885109224aad",
            "number" => "+254728833181",
            "status" => "Success",
            "statusCode" => 101
        }
        ]
    }
    }}

Payment Mobile checkout

    iex>AtEx.Payment.mobile_checkout(%{phoneNumber: "254724540000", amount: 10, currencyCode: "KES"})
    %{
        "description" => "Waiting for user input",
        "providerChannel" => "525900",
        "status" => "PendingConfirmation",
        "transactionId" => "ATPid_bbd0bcd713e27d9201807076c6db0ed5"
    }

Contribution

If you'd like to contribute, start by searching through the issues and pull requests to see whether someone else has raised a similar idea or question. If you don't see your idea listed, Open an issue.

Check the Contribution guide on how to contribute.

Licence

AtEx is released under MIT License

license