Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/echavezNS/conekta-elixir
Elixir library for Conekta api calls
https://github.com/echavezNS/conekta-elixir
api-client api-wrapper elixir
Last synced: 3 months ago
JSON representation
Elixir library for Conekta api calls
- Host: GitHub
- URL: https://github.com/echavezNS/conekta-elixir
- Owner: altyaper
- License: mit
- Created: 2017-05-05T17:31:02.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-03T07:25:57.000Z (7 months ago)
- Last Synced: 2024-05-21T19:19:53.545Z (6 months ago)
- Topics: api-client, api-wrapper, elixir
- Language: Elixir
- Size: 83 KB
- Stars: 16
- Watchers: 3
- Forks: 14
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- awesome-elixir - conekta - Elixir wrapper for Conekta API. (Third Party APIs)
- fucking-awesome-elixir - conekta - Elixir wrapper for Conekta API. (Third Party APIs)
- freaking_awesome_elixir - Elixir - Elixir wrapper for Conekta API. (Third Party APIs)
README
[![Build Status](https://travis-ci.org/echavezNS/conekta-elixir.svg?branch=master)](https://travis-ci.org/echavezNS/conekta-elixir)
# Conekta Library
Wrapper to connect with https://api.conekta.io.
[conekta-elixir documentation](https://hexdocs.pm/conekta/api-reference.html)
## Setup
### Installation
Add Conekta to your `mix.exs` dependencies:
```elixir
#mix.exs
defp deps do
[
#If you have trouble with poison add
#{:poison, "~> 3.1", override: true}
{:conekta, "~> 1.0"}
]
end
```### Configuration
Add your keys in your `config.exs` file```elixir
# config.exs
config :conekta,
publickey: "YOUR-PUBLIC-KEY",
privatekey: "YOUR-PRIVATE-KEY"```
## Customers
### Get
Get all current customers
```elixir
#Get the last
Conekta.Customers.customers()
```### Create
Create a customer by passing a `%Conekta.Customer{}` struct```elixir
#Create a new customer map
new_customer = %Customer{
name: "Fake Name",
email: "[email protected]",
corporate: true,
payment_sources: [%{
token_id: "tok_test_visa_4242",
type: "card"
}]
}#Create a new customer
Conekta.Customers.create(new_customer)```
### Find
Find a customer by passing the unique ID
```elixir
Conekta.Customers.find(id)
```### Delete
Delete a customer by passing the unique ID
```elixir
Conekta.Customers.delete(id)
```## Orders
### Get
```elixir
Conekta.Orders.orders()
```### Create
```elixir
#Create a new order map
new_order = %Order{currency: "MXN",
customer_info: %{
customer_id: content.id
}, line_items: [%{
name: "Product 1",
unit_price: 35000,
quantity: 1
}], charges: [%{
payment_method: %{
type: "default"
}
}]}#Create an order
response = Conekta.Orders.create(new_order)
```## WebHooks
Helper function for webhook handling. [check possible events](https://developers.conekta.com/resources/webhooks)
```elixir
case Conekta.WebHook.received(params) do
{:charge_created, struct} -> ...
{:charge_paid, struct} -> ...
{:plan_created, struct} -> ...
{:customer_created, struct} -> ...
{:subscription_created, struct} -> ...
{:subscription_paid, struct} -> ...
{:subscription_canceled, struct} -> ...
{:chargeback_created, struct} -> ...
{:chargeback_lost, struct} -> ...
end
```## Test
If you want to add something new, make sure all the tests pass before making a PR
```elixir
mix test
```### Send pull request
I would love to check new contributions to this repository.
Fork from **dev** and do a PR into **dev** again.### License
Available with [MIT License](https://github.com/echavezNS/conekta-elixir/blob/master/LICENSE).