Skip to content

Latest commit

 

History

History
179 lines (121 loc) · 4.7 KB

cards.md

File metadata and controls

179 lines (121 loc) · 4.7 KB

Cards

cards_api = client.cards

Class Name

CardsApi

Methods

List Cards

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)

Parameters

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.
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.

Response Type

This method returns a \ApiResponse instance. The data property in this instance returns the response data which is of type List Cards Response Hash.

Example Usage

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

Create Card

Adds a card on file to an existing merchant.

def create_card(body:)

Parameters

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.

Response Type

This method returns a \ApiResponse instance. The data property in this instance returns the response data which is of type Create Card Response Hash.

Example Usage

body = {
  :idempotency_key => '4935a656-a929-4792-b97c-8848be85c27c',
  :source_id => 'cnon:uIbfJXhXETSP197M3GB',
  :card => {
    :cardholder_name => 'Amelia Earhart',
    :billing_address => {
      :address_line_1 => '500 Electric Ave',
      :address_line_2 => 'Suite 600',
      :locality => 'New York',
      :administrative_district_level_1 => 'NY',
      :postal_code => '10003',
      :country => 'US'
    },
    :customer_id => 'VDKXEEKPJN48QDG3BGGFAK05P8',
    :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

Retrieve Card

Retrieves details for a specific Card.

def retrieve_card(card_id:)

Parameters

Parameter Type Tags Description
card_id String Template, Required Unique ID for the desired Card.

Response Type

This method returns a \ApiResponse instance. The data property in this instance returns the response data which is of type Retrieve Card Response Hash.

Example Usage

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

Disable Card

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:)

Parameters

Parameter Type Tags Description
card_id String Template, Required Unique ID for the desired Card.

Response Type

This method returns a \ApiResponse instance. The data property in this instance returns the response data which is of type Disable Card Response Hash.

Example Usage

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