Skip to content

Latest commit

 

History

History
203 lines (154 loc) · 5.77 KB

cards.md

File metadata and controls

203 lines (154 loc) · 5.77 KB

Cards

const cardsApi = client.cardsApi;

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.

async listCards(
  cursor?: string,
  customerId?: string,
  includeDisabled?: boolean,
  referenceId?: string,
  sortOrder?: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<ListCardsResponse>>

Parameters

Parameter Type Tags Description
cursor string | undefined 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.
customerId string | undefined Query, Optional Limit results to cards associated with the customer supplied.
By default, all cards owned by the merchant are returned.
includeDisabled boolean | undefined Query, Optional Includes disabled cards.
By default, all enabled cards owned by the merchant are returned.
Default: false
referenceId string | undefined Query, Optional Limit results to cards associated with the reference_id supplied.
sortOrder string | undefined Query, Optional Sorts the returned list by when the card was created with the specified order.
This field defaults to ASC.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

ListCardsResponse

Example Usage

const includeDisabled = false;
try {
  const { result, ...httpResponse } = await cardsApi.listCards(None, None, includeDisabled);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Create Card

Adds a card on file to an existing merchant.

async createCard(
  body: CreateCardRequest,
  requestOptions?: RequestOptions
): Promise<ApiResponse<CreateCardResponse>>

Parameters

Parameter Type Tags Description
body CreateCardRequest Body, Required An object containing the fields to POST for the request.

See the corresponding object definition for field details.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

CreateCardResponse

Example Usage

const contentType = null;
const bodyCardBillingAddress: Address = {};
bodyCardBillingAddress.addressLine1 = '500 Electric Ave';
bodyCardBillingAddress.addressLine2 = 'Suite 600';
bodyCardBillingAddress.locality = 'New York';
bodyCardBillingAddress.administrativeDistrictLevel1 = 'NY';
bodyCardBillingAddress.postalCode = '10003';
bodyCardBillingAddress.country = 'US';

const bodyCard: Card = {};
bodyCard.cardholderName = 'Amelia Earhart';
bodyCard.billingAddress = bodyCardBillingAddress;
bodyCard.customerId = 'VDKXEEKPJN48QDG3BGGFAK05P8';
bodyCard.referenceId = 'user-id-1';

const body: CreateCardRequest = {
  idempotencyKey: '4935a656-a929-4792-b97c-8848be85c27c',
  sourceId: 'cnon:uIbfJXhXETSP197M3GB',
  card: bodyCard,
};

try {
  const { result, ...httpResponse } = await cardsApi.createCard(body);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Retrieve Card

Retrieves details for a specific Card.

async retrieveCard(
  cardId: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<RetrieveCardResponse>>

Parameters

Parameter Type Tags Description
cardId string Template, Required Unique ID for the desired Card.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

RetrieveCardResponse

Example Usage

const cardId = 'card_id4';
try {
  const { result, ...httpResponse } = await cardsApi.retrieveCard(cardId);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}

Disable Card

Disables the card, preventing any further updates or charges. Disabling an already disabled card is allowed but has no effect.

async disableCard(
  cardId: string,
  requestOptions?: RequestOptions
): Promise<ApiResponse<DisableCardResponse>>

Parameters

Parameter Type Tags Description
cardId string Template, Required Unique ID for the desired Card.
requestOptions RequestOptions | undefined Optional Pass additional request options.

Response Type

DisableCardResponse

Example Usage

const cardId = 'card_id4';
try {
  const { result, ...httpResponse } = await cardsApi.disableCard(cardId);
  // Get more response info...
  // const { statusCode, headers } = httpResponse;
} catch(error) {
  if (error instanceof ApiError) {
    const errors = error.result;
    // const { statusCode, headers } = error;
  }
}