Affirm v0.1.2 Affirm.API

Affirm provides several API endpoints… this module defines functions to interact with the transactional endpoints authorize, capture, void and refund.

For api reference, please visit: https://docs.affirm.com/Integrate_Affirm/Direct_API

Link to this section Summary

Functions

Affirm’s Authorize endpoint requires post data containing a checkout_token and takes an optional order_id. If the token is valid, the request will return a charge_id that should be saved for future transactions

Capture takes a charge_id and optional map of post data. Will return a Affirm.Response struct containing details of the successful capture transaction

Refund takes an optional charge_id. Will return an Affirm.Response struct containing current charge status. Used to prevent duplicate charge attempts

Refund takes a charge_id and a map containing a refund amount. Will return a Affirm.Response struct containing details of the successful return transaction

Capture takes a charge_id. Will return a Affirm.Response struct containing details of the successful void transaction

Link to this section Functions

Link to this function authorize(params)
authorize(map()) :: {:ok, Affirm.Response.t()} | {:error, String.t()}

Affirm’s Authorize endpoint requires post data containing a checkout_token and takes an optional order_id. If the token is valid, the request will return a charge_id that should be saved for future transactions.

Link to this function capture(charge_id, params)
capture(String.t(), map()) ::
  {:ok, Affirm.Response.t()} |
  {:error, String.t()}

Capture takes a charge_id and optional map of post data. Will return a Affirm.Response struct containing details of the successful capture transaction.

Link to this function read(charge_id)
read(String.t()) :: {:ok, Affirm.Response.t()} | {:error, String.t()}

Refund takes an optional charge_id. Will return an Affirm.Response struct containing current charge status. Used to prevent duplicate charge attempts.

Link to this function refund(charge_id, params)
refund(String.t(), map()) ::
  {:ok, Affirm.Response.t()} |
  {:error, String.t()}

Refund takes a charge_id and a map containing a refund amount. Will return a Affirm.Response struct containing details of the successful return transaction.

Link to this function void(charge_id)
void(String.t()) :: {:ok, Affirm.Response.t()} | {:error, String.t()}

Capture takes a charge_id. Will return a Affirm.Response struct containing details of the successful void transaction.