An Erlang/OTP implementation of PayStack Rest API
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
rebar.config
rebar.lock

README.md

erlpaystack

An Erlang implementation of PayStack Rest API

Quickstart

to add to a rebar3 project

Add to rebar.config

...
{erl_opts, [debug_info]}.
{deps, [
       ...
       {erlpaystack, {git, "https://github.com/abimbola/erlpaystack.git", {tag, "1.0.1"}}}
]}.
...

Build

$ rebar3 compile

Examples

Ensure that dependencies are started - inets, ssl

1> application:ensure_all_started(erlpaystack).
{ok,[inets,crypto,asn1,public_key,ssl,erlpaystack]}

Intialize transaction with only mandatory parameters

2> erlpaystack:initialize("A_Secret_Key_A_Secret_Key", 50000, "abimbola.adegun@gmail.com", []).
{ok,#{<<"data">> => #{<<"access_code">> => <<"h5tm6epimb">>,
    <<"authorization_url">> => <<"https://paystack.com/secure/h5tm6epimb">>,
    <<"reference">> => <<"nwgxk2xvfz">>},
  	<<"message">> => <<"Authorization URL created">>,
  	<<"status">> => true}}

Intialize transaction with mandatory parameters and one optional parameter

3> erlpaystack:initialize("A_Secret_Key_A_Secret_Key", 50000, "abimbola.adegun@gmail.com", 
[{"reference", "YTUtrgwkwhsfs47596"}]).
{ok,#{<<"data">> => #{<<"access_code">> => <<"mmww6r0qyn">>,
    <<"authorization_url">> => <<"https://paystack.com/secure/mmww6r0qyn">>,
    <<"reference">> => <<"YTUtrgwkwhsfs47596">>},
  	<<"message">> => <<"Authorization URL created">>,
  	<<"status">> => true}}

Data Types

apioption()

apioption() = {string(), string() | integer() | boolean() | #{}}

apioptions()

apioptions() = [apioption()] | []

queryapioption()

queryapioption() = {string(), string() | integer() | boolean()}

queryapioptions()

queryapioptions() = [queryapioption()] | []

Function Index

Transactions

| initialize/4 | | verify/2 | | list_transactions/2 | | fetch_transaction/2 | | charge_authorization/5 | | charge_token/3 | | view_transaction_timeline/2 | | transaction_totals/2 | | export_transactions/2 |

Customers

| create_customer/3 | | list_customers/2 | | fetch_customer/2 | | update_customer/3 | | white_black_list_customer/3 |

Plans

| create_plan/5 | | list_plans/2 | | fetch_plan/2 | | update_plan/3 |

Subscriptions

| create_subscription/4 | | list_subscriptions/2 | | disable_subscription/3 | | enable_subscription/3 | | fetch_subscription/2 |

Pages

| create_page/3 | | list_pages/2 | | fetch_page/2 | | update_page/3 | | check_slug_availability/2 |

SubAccounts

| create_subaccount/6 | | list_subaccounts/2 | | fetch_subaccount/2 | | update_subaccount/3 | | list_banks/2 |

Settlements

| fetch_settlements/2 |

Miscellaneous

| resolve_card_bin/2 |

Function Details

charge_authorization/5

charge_authorization(SecretKey::string(), AuthorizationCode::string(), Amount::integer(), Email::string(), Options::apioptions()) -> {ok, #{}} | {error, term()}

charge_token/3

charge_token(SecretKey::string(), Token::string(), Options::apioptions()) -> {ok, #{}} | {error, term()}

check_slug_availability/2

check_slug_availability(SecretKey::string(), Slug::string()) -> {ok, #{}} | {error, term()}

create_customer/3

create_customer(SecretKey::string(), Email::string(), Options::apioptions()) -> {ok, #{}} | {error, term()}

create_page/3

create_page(SecretKey::string(), Name::string(), Options::apioptions()) -> {ok, #{}} | {error, term()}

create_plan/5

create_plan(SecretKey::string(), Name::string(), Amount::integer(), Interval::string(), Options::apioptions()) -> {ok, #{}} | {error, term()}

create_subaccount/6

create_subaccount(SecretKey::string(), BusinessName::string(), SettlementBank::string(), AccountNumber::string(), PercentageCharge::string(), Options::apioptions()) -> {ok, #{}} | {error, term()}

create_subscription/4

create_subscription(SecretKey::string(), Customer::string(), Plan::string(), Options::apioptions()) -> {ok, #{}} | {error, term()}

disable_subscription/3

disable_subscription(SecretKey::string(), Code::string(), Token::string()) -> {ok, #{}} | {error, term()}

enable_subscription/3

enable_subscription(SecretKey::string(), Code::string(), Token::string()) -> {ok, #{}} | {error, term()}

export_transactions/2

export_transactions(SecretKey::string(), QueryOptions::queryapioptions()) -> {ok, #{}} | {error, term()}

fetch_customer/2

fetch_customer(SecretKey::string(), IdOrCode::string()) -> {ok, #{}} | {error, term()}

fetch_page/2

fetch_page(SecretKey::string(), IdOrSlug::string()) -> {ok, #{}} | {error, term()}

fetch_plan/2

fetch_plan(SecretKey::string(), IdOrCode::string()) -> {ok, #{}} | {error, term()}

fetch_settlements/2

fetch_settlements(SecretKey::string(), QueryOptions::queryapioptions()) -> {ok, #{}} | {error, term()}

fetch_subaccount/2

fetch_subaccount(SecretKey::string(), IdOrSlug::string()) -> {ok, #{}} | {error, term()}

fetch_subscription/2

fetch_subscription(SecretKey::string(), IdOrCode::string()) -> {ok, #{}} | {error, term()}

fetch_transaction/2

fetch_transaction(SecretKey::string(), Id::integer()) -> {ok, #{}} | {error, term()}

initialize/4

initialize(SecretKey::string(), Amount::integer(), Email::string(), Options::apioptions()) -> {ok, #{}} | {error, term()}

list_banks/2

list_banks(SecretKey::string(), QueryOptions::queryapioptions()) -> {ok, #{}} | {error, term()}

list_customers/2

list_customers(SecretKey::string(), QueryOptions::queryapioptions()) -> {ok, #{}} | {error, term()}

list_pages/2

list_pages(SecretKey::string(), QueryOptions::queryapioptions()) -> {ok, #{}} | {error, term()}

list_plans/2

list_plans(SecretKey::string(), QueryOptions::queryapioptions()) -> {ok, #{}} | {error, term()}

list_subaccounts/2

list_subaccounts(SecretKey::string(), QueryOptions::queryapioptions()) -> {ok, #{}} | {error, term()}

list_subscriptions/2

list_subscriptions(SecretKey::string(), QueryOptions::queryapioptions()) -> {ok, #{}} | {error, term()}

list_transactions/2

list_transactions(SecretKey::string(), QueryOptions::queryapioptions()) -> {ok, #{}} | {error, term()}

resolve_card_bin/2

resolve_card_bin(SecretKey::string(), Bin::string()) -> {ok, #{}} | {error, term()}

transaction_totals/2

transaction_totals(SecretKey::string(), QueryOptions::queryapioptions()) -> {ok, #{}} | {error, term()}

update_customer/3

update_customer(SecretKey::string(), IdOrCode::string(), Options::apioptions()) -> {ok, #{}} | {error, term()}

update_page/3

update_page(SecretKey::string(), IdOrSlug::string(), Options::apioptions()) -> {ok, #{}} | {error, term()}

update_plan/3

update_plan(SecretKey::string(), IdOrCode::string(), Options::apioptions()) -> {ok, #{}} | {error, term()}

update_subaccount/3

update_subaccount(SecretKey::string(), IdOrSlug::string(), Options::apioptions()) -> {ok, #{}} | {error, term()}

verify/2

verify(SecretKey::string(), Reference::string()) -> {ok, #{}} | {error, term()}

view_transaction_timeline/2

view_transaction_timeline(SecretKey::string(), IdOrReference::string()) -> {ok, #{}} | {error, term()}

white_black_list_customer/3

white_black_list_customer(SecretKey::string(), Customer::string(), Options::apioptions()) -> {ok, #{}} | {error, term()}