Created
December 20, 2018 14:27
-
-
Save anagromataf/47faa0c9a67e497251b6e52aebba2756 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Capture do | |
def prepare(checkout, payment) do | |
request = %{ | |
amount: checkout.amount, | |
card_pan: payment.card_pan, | |
request_id: UUID.uuid4() | |
} | |
{:ok, request} | |
end | |
def commit(checkout, request) do | |
with {:ok, response} <- send_request(request) do | |
if response.success do | |
{:ok, %{checkout | captured_amount: response.amount}} | |
else | |
{:error, response.error} | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment