Git Product home page Git Product logo

daraja-api-for-mpesa's Introduction

Actions Status Hex.pm Hex.pm Coverage Status

ExMpesa

Payment Library For Most Mpesa(Daraja) Payment API's in Kenya. Let us get this ๐Ÿ’ฐ

Table of contents

Homepage

Features

  • STK Transaction Validation
  • B2C
  • B2B
  • C2B
  • Reversal
  • Transaction Status
  • Account Balance

Installation

If available in Hex, the package can be installed by adding ex_mpesa to your list of dependencies in mix.exs:

def deps do
  [
    {:ex_mpesa, "~> 0.1.0"}
  ]
end

Configuration

Create a copy of config/dev.exs or config/prod.exs from config/dev.sample.exs Use the sandbox key to true when you are using sandbox credentials, chnage to false when going to :prod

Mpesa (Daraja)

Mpesa Daraja API link: https://developer.safaricom.co.ke

Add below config to dev.exs / prod.exs files This asumes you have a clear understanding of how Daraja API works.

You can also refer to this Safaricom Daraja API Tutorial: https://peternjeru.co.ke/safdaraja/ui/ by Peter Njeru

config :ex_mpesa,
    consumer_key: "72yw1nun6g1QQPPgOsAObCGSfuimGO7b",
    consumer_secret: "vRzZiD5RllMLIdLD",
    mpesa_short_code: "174379",
    mpesa_passkey: "bfb279f9aa9bdbcf158e97dd71a467cd2e0c893059b10f78e6b72ada1ed2c919",
    mpesa_callback_url: "http://91eb0af5.ngrok.io/api/payment/callback"

Documentation

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

Quick Examples

Mpesa Express (STK)

  iex> ExMpesa.Stk.request(%{amount: 10, phone: "254724540000", reference: "reference", description: "description"})
      {:ok,
        %{
        "CheckoutRequestID" => "ws_CO_010320202011179845",
        "CustomerMessage" => "Success. Request accepted for processing",
        "MerchantRequestID" => "25558-10595705-4",
        "ResponseCode" => "0",
        "ResponseDescription" => "Success. Request accepted for processing"
        }}

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

ExPesa is released under MIT License

license

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.