Current section
11 Versions
Jump to
Current section
11 Versions
Compare versions
6
files changed
+42
additions
-10
deletions
| @@ -3,8 +3,9 @@ | |
| 3 3 | {<<"description">>,<<"Elixir library for Conekta api calls">>}. |
| 4 4 | {<<"elixir">>,<<"~> 1.4">>}. |
| 5 5 | {<<"files">>, |
| 6 | - [<<"lib/client.ex">>,<<"lib/conekta/conekta_structs.ex">>, |
| 7 | - <<"lib/customers.ex">>,<<"lib/error_handler.ex">>,<<"lib/handler.ex">>, |
| 6 | + [<<"lib">>,<<"lib/client.ex">>,<<"lib/conekta">>, |
| 7 | + <<"lib/conekta/conekta_structs.ex">>,<<"lib/customers.ex">>, |
| 8 | + <<"lib/error_handler.ex">>,<<"lib/handler.ex">>,<<"lib/mocks">>, |
| 8 9 | <<"lib/mocks/customers_mock.ex">>,<<"lib/mocks/orders_mock.ex">>, |
| 9 10 | <<"lib/mocks/plans_mock.ex">>,<<"lib/mocks/webhook_mock.ex">>, |
| 10 11 | <<"lib/orders.ex">>,<<"lib/plans.ex">>,<<"lib/webhook.ex">>, |
| @@ -18,9 +19,11 @@ | |
| 18 19 | [[{<<"app">>,<<"poison">>}, |
| 19 20 | {<<"name">>,<<"poison">>}, |
| 20 21 | {<<"optional">>,false}, |
| 22 | + {<<"repository">>,<<"hexpm">>}, |
| 21 23 | {<<"requirement">>,<<"~> 3.0">>}], |
| 22 24 | [{<<"app">>,<<"httpoison">>}, |
| 23 25 | {<<"name">>,<<"httpoison">>}, |
| 24 26 | {<<"optional">>,false}, |
| 25 | - {<<"requirement">>,<<"~> 0.11">>}]]}. |
| 26 | - {<<"version">>,<<"1.0.7">>}. |
| 27 | + {<<"repository">>,<<"hexpm">>}, |
| 28 | + {<<"requirement">>,<<"~> 1.2.0">>}]]}. |
| 29 | + {<<"version">>,<<"1.0.9">>}. |
| @@ -162,3 +162,13 @@ defmodule Conekta.WebHookLogs do | |
| 162 162 | @moduledoc false |
| 163 163 | defstruct id: nil, url: nil, failed_attempts: nil, last_http_response_status: nil, object: nil, last_attempted_at: nil |
| 164 164 | end |
| 165 | + |
| 166 | + defmodule Conekta.Refund do |
| 167 | + @moduledoc false |
| 168 | + defstruct reason: nil |
| 169 | + end |
| 170 | + |
| 171 | + defmodule Conekta.PartialRefund do |
| 172 | + @moduledoc false |
| 173 | + defstruct reason: nil, amount: nil |
| 174 | + end |
| @@ -9,7 +9,7 @@ defmodule Conekta.ErrorHandler do | |
| 9 9 | |
| 10 10 | def catch_error(content) do |
| 11 11 | {:ok, error} = Poison.decode(content.body, as: %ErrorResponse{}) |
| 12 | - raise ConektaError, message: hd(error.details)["debug_message"] |
| 12 | + raise ConektaError, message: hd(error.details)["message"] |
| 13 13 | end |
| 14 14 | |
| 15 15 | def raise_error(content) when is_map(content) do |
| @@ -114,4 +114,19 @@ defmodule Conekta.Orders do | |
| 114 114 | end |
| 115 115 | end |
| 116 116 | |
| 117 | + def refund(order_id, refund) do |
| 118 | + case Client.post_request("orders/" <> order_id <> "/refunds", refund) do |
| 119 | + {:ok, content} -> |
| 120 | + body = Handler.handle_status_code(content) |
| 121 | + {:ok, Poison.decode!(body)} |
| 122 | + end |
| 123 | + end |
| 124 | + |
| 125 | + def partial_refund(order_id, refund) do |
| 126 | + case Client.post_request("orders/" <> order_id <> "/refunds", refund) do |
| 127 | + {:ok, content} -> |
| 128 | + body = Handler.handle_status_code(content) |
| 129 | + {:ok, Poison.decode!(body)} |
| 130 | + end |
| 131 | + end |
| 117 132 | end |
| @@ -13,11 +13,15 @@ defmodule Conekta.Wrapper do | |
| 13 13 | |
| 14 14 | def headers do |
| 15 15 | basic_auth = "Basic " <> Base.encode64(key() <> ":") |
| 16 | - ["Accept": @conekta_accept_header, "Content-type": "application/json", "Authorization": basic_auth] |
| 16 | + ["Accept": @conekta_accept_header, "Accept-Language": locale(),"Content-type": "application/json", "Authorization": basic_auth] |
| 17 17 | end |
| 18 18 | |
| 19 19 | def key do |
| 20 20 | Application.get_env(:conekta, :privatekey) |
| 21 21 | end |
| 22 22 | |
| 23 | + def locale do |
| 24 | + Application.get_env(:conekta, :locale) |
| 25 | + end |
| 26 | + |
| 23 27 | end |
Loading more files…