Skip to content

Instantly share code, notes, and snippets.

@anagromataf
Created December 20, 2018 14:27
Show Gist options
  • Save anagromataf/47faa0c9a67e497251b6e52aebba2756 to your computer and use it in GitHub Desktop.
Save anagromataf/47faa0c9a67e497251b6e52aebba2756 to your computer and use it in GitHub Desktop.
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