Skip to content

Latest commit

 

History

History
181 lines (127 loc) · 4.86 KB

cards.md

File metadata and controls

181 lines (127 loc) · 4.86 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(self,
              cursor=None,
              customer_id=None,
              include_disabled=False,
              reference_id=None,
              sort_order=None)

Parameters

Parameter Type Tags Description
cursor str 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 str Query, Optional Limit results to cards associated with the customer supplied.
By default, all cards owned by the merchant are returned.
include_disabled bool Query, Optional Includes disabled cards.
By default, all enabled cards owned by the merchant are returned.
reference_id str Query, Optional Limit results to cards associated with the reference_id supplied.
sort_order str (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 body property of this instance returns the response data which is of type List Cards Response.

Example Usage

include_disabled = False

result = cards_api.list_cards(
    include_disabled=include_disabled
)
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Create Card

Adds a card on file to an existing merchant.

def create_card(self,
               body)

Parameters

Parameter Type Tags Description
body Create Card Request 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 body property of this instance returns the response data which is of type Create Card Response.

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)
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

Retrieve Card

Retrieves details for a specific Card.

def retrieve_card(self,
                 card_id)

Parameters

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

Response Type

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

Example Usage

card_id = 'card_id4'

result = cards_api.retrieve_card(card_id)
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)

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(self,
                card_id)

Parameters

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

Response Type

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

Example Usage

card_id = 'card_id4'

result = cards_api.disable_card(card_id)
print(result)

if result.is_success():
    print(result.body)
elif result.is_error():
    print(result.errors)