cards_api = client.cards
CardsApi
Retrieves a list of cards owned by the account making the request. A max of 25 cards will be returned.
def list_cards(cursor: nil,
customer_id: nil,
include_disabled: false,
reference_id: nil,
sort_order: nil)
Parameter | Type | Tags | Description |
---|---|---|---|
cursor |
String |
Query, Optional | A pagination cursor returned by a previous call to this endpoint. Provide this to retrieve the next set of results for your original query. See Pagination for more information. |
customer_id |
String |
Query, Optional | Limit results to cards associated with the customer supplied. By default, all cards owned by the merchant are returned. |
include_disabled |
TrueClass|FalseClass |
Query, Optional | Includes disabled cards. By default, all enabled cards owned by the merchant are returned. Default: false |
reference_id |
String |
Query, Optional | Limit results to cards associated with the reference_id supplied. |
sort_order |
String (Sort Order) |
Query, Optional | Sorts the returned list by when the card was created with the specified order. This field defaults to ASC. |
include_disabled = false
result = cards_api.list_cards(include_disabled: include_disabled, )
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Adds a card on file to an existing merchant.
def create_card(body:)
Parameter | Type | Tags | Description |
---|---|---|---|
body |
Create Card Request Hash |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
body = {}
body[:idempotency_key] = '4935a656-a929-4792-b97c-8848be85c27c'
body[:source_id] = 'cnon:uIbfJXhXETSP197M3GB'
body[:card] = {}
body[:card][:cardholder_name] = 'Amelia Earhart'
body[:card][:billing_address] = {}
body[:card][:billing_address][:address_line_1] = '500 Electric Ave'
body[:card][:billing_address][:address_line_2] = 'Suite 600'
body[:card][:billing_address][:locality] = 'New York'
body[:card][:billing_address][:administrative_district_level_1] = 'NY'
body[:card][:billing_address][:postal_code] = '10003'
body[:card][:billing_address][:country] = 'US'
body[:card][:customer_id] = 'VDKXEEKPJN48QDG3BGGFAK05P8'
body[:card][:reference_id] = 'user-id-1'
result = cards_api.create_card(body: body)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Retrieves details for a specific Card.
def retrieve_card(card_id:)
Parameter | Type | Tags | Description |
---|---|---|---|
card_id |
String |
Template, Required | Unique ID for the desired Card. |
card_id = 'card_id4'
result = cards_api.retrieve_card(card_id: card_id)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end
Disables the card, preventing any further updates or charges. Disabling an already disabled card is allowed but has no effect.
def disable_card(card_id:)
Parameter | Type | Tags | Description |
---|---|---|---|
card_id |
String |
Template, Required | Unique ID for the desired Card. |
card_id = 'card_id4'
result = cards_api.disable_card(card_id: card_id)
if result.success?
puts result.data
elsif result.error?
warn result.errors
end