ex_openpay v0.1.2 ExOpenpay.Cards
Functions for working with cards at Openpay. Through this API you can:
- create a card,
- update a card,
- get a card,
- list cards,
- count cards,
- refund a card,
- partially refund a card.
Openpay API reference: https://www.openpay.mx/docs/api/?shell#tarjetas
Link to this section Summary
Functions
List all cards
List all cards. Accepts ExOpenpay API key
Get total number of cards
Get total number of cards. Accepts ExOpenpay API key
Create a card. Creates a card for given owner type, owner ID using params.
- object,
- number,
- cvv2,
- expiration_month,
- expiration_year.
Returns a
{:ok, card}
tuple.
Examples
params = [
card_number: "4111111111111111",
holder_name: "Juan Perez Ramirez",
expiration_year: "20",
expiration_month: "12",
cvv2: "110"
# device_session_id: "",
]
{:ok, card} = ExOpenpay.Cards.create(:customer, customer_id, params)
Create a card. Accepts ExOpenpay API key. Creates a card for given owner using params.
- object,
- number,
- cvv2,
- expiration_month,
- expiration_year.
Returns a
{:ok, card}
tuple.
Examples
{:ok, card} = ExOpenpay.Cards.create(:customer, customer_id, params, key)
Delete a card.
Deletes a card for given owner using card ID.
Returns a {:ok, card}
tuple.
Examples
{:ok, deleted_card} = ExOpenpay.Cards.delete("card_id")
Delete a card. Accepts ExOpenpay API key.
Deletes a card for given owner using card ID.
Returns a {:ok, card}
tuple.
Examples
{:ok, deleted_card} = ExOpenpay.Cards.delete("card_id", key)
Delete all cards
Delete all cards. Accepts ExOpenpay API key
Get a card.
Gets a card for given owner using card ID.
Returns a {:ok, card}
tuple.
Examples
{:ok, card} = ExOpenpay.Cards.get(:customer, customer_id, card_id)
Get a card. Accepts ExOpenpay API key.
Gets a card for given owner using card ID.
Returns a {:ok, card}
tuple.
Examples
{:ok, card} = ExOpenpay.Cards.get(:customer, customer_id, card_id, key)
Get a list of cards. Gets a list of cards for given owner. Accepts the following parameters:
starting_after
- an offset (optional),limit
- a limit of items to be returned (optional; defaults to 10). Returns a{:ok, cards}
tuple, wherecards
is a list of cards.
Examples
{:ok, cards} = ExOpenpay.Cards.list(:customer, customer_id, 5) # Get a list of up to 10 cards, skipping first 5 cards
{:ok, cards} = ExOpenpay.Cards.list(:customer, customer_id, 5, 20) # Get a list of up to 20 cards, skipping first 5 cards
Get a list of cards. Accepts ExOpenpay API key. Gets a list of cards for a given owner. Accepts the following parameters:
starting_after
- an offset (optional),limit
- a limit of items to be returned (optional; defaults to 10). Returns a{:ok, cards}
tuple, wherecards
is a list of cards.
Examples
{:ok, cards} = ExOpenpay.Cards.list(:customer, customer_id, key, 5) # Get a list of up to 10 cards, skipping first 5 cards
{:ok, cards} = ExOpenpay.Cards.list(:customer, customer_id, key, 5, 20) # Get a list of up to 20 cards, skipping first 5 cards
Link to this section Functions
List all cards.
Lists all cards for a given owner.
Accepts the following parameters:
accum
- a list to start accumulating cards to (optional; defaults to[]
).,starting_after
- an offset (optional; defaults to""
).
Returns {:ok, cards}
tuple.
Examples
{:ok, cards} = ExOpenpay.Cards.all(:customer, customer_id, accum, starting_after)
List all cards. Accepts ExOpenpay API key.
Lists all cards for a given owner.
Accepts the following parameters:
accum
- a list to start accumulating cards to (optional; defaults to[]
).,starting_after
- an offset (optional; defaults to""
).
Returns {:ok, cards}
tuple.
Examples
{:ok, cards} = ExOpenpay.Cards.all(:customer, customer_id, accum, starting_after, key)
Get total number of cards.
Gets total number of cards for a given owner.
Returns {:ok, count}
tuple.
Examples
{:ok, count} = ExOpenpay.Cards.count(:customer, customer_id)
Get total number of cards. Accepts ExOpenpay API key.
Gets total number of cards for a given owner.
Returns {:ok, count}
tuple.
Examples
{:ok, count} = ExOpenpay.Cards.count(:customer, customer_id, key)
Create a card. Creates a card for given owner type, owner ID using params.
- object,
- number,
- cvv2,
- expiration_month,
- expiration_year.
Returns a
{:ok, card}
tuple.
Examples
params = [
card_number: "4111111111111111",
holder_name: "Juan Perez Ramirez",
expiration_year: "20",
expiration_month: "12",
cvv2: "110"
# device_session_id: "",
]
{:ok, card} = ExOpenpay.Cards.create(:customer, customer_id, params)
Create a card. Accepts ExOpenpay API key. Creates a card for given owner using params.
- object,
- number,
- cvv2,
- expiration_month,
- expiration_year.
Returns a
{:ok, card}
tuple.
Examples
{:ok, card} = ExOpenpay.Cards.create(:customer, customer_id, params, key)
Delete a card.
Deletes a card for given owner using card ID.
Returns a {:ok, card}
tuple.
Examples
{:ok, deleted_card} = ExOpenpay.Cards.delete("card_id")
Delete a card. Accepts ExOpenpay API key.
Deletes a card for given owner using card ID.
Returns a {:ok, card}
tuple.
Examples
{:ok, deleted_card} = ExOpenpay.Cards.delete("card_id", key)
Delete all cards.
Deletes all cards from given owner.
Returns :ok
atom.
Examples
:ok = ExOpenpay.Cards.delete_all(:customer, customer_id)
Delete all cards. Accepts ExOpenpay API key.
Deletes all cards from given owner.
Returns :ok
atom.
Examples
:ok = ExOpenpay.Cards.delete_all(:customer, customer_id, key)
Get a card.
Gets a card for given owner using card ID.
Returns a {:ok, card}
tuple.
Examples
{:ok, card} = ExOpenpay.Cards.get(:customer, customer_id, card_id)
Get a card. Accepts ExOpenpay API key.
Gets a card for given owner using card ID.
Returns a {:ok, card}
tuple.
Examples
{:ok, card} = ExOpenpay.Cards.get(:customer, customer_id, card_id, key)
Get a list of cards. Gets a list of cards for given owner. Accepts the following parameters:
starting_after
- an offset (optional),limit
- a limit of items to be returned (optional; defaults to 10). Returns a{:ok, cards}
tuple, wherecards
is a list of cards.
Examples
{:ok, cards} = ExOpenpay.Cards.list(:customer, customer_id, 5) # Get a list of up to 10 cards, skipping first 5 cards
{:ok, cards} = ExOpenpay.Cards.list(:customer, customer_id, 5, 20) # Get a list of up to 20 cards, skipping first 5 cards
Get a list of cards. Accepts ExOpenpay API key. Gets a list of cards for a given owner. Accepts the following parameters:
starting_after
- an offset (optional),limit
- a limit of items to be returned (optional; defaults to 10). Returns a{:ok, cards}
tuple, wherecards
is a list of cards.
Examples
{:ok, cards} = ExOpenpay.Cards.list(:customer, customer_id, key, 5) # Get a list of up to 10 cards, skipping first 5 cards
{:ok, cards} = ExOpenpay.Cards.list(:customer, customer_id, key, 5, 20) # Get a list of up to 20 cards, skipping first 5 cards