Skip to content

Latest commit

 

History

History
184 lines (134 loc) · 5.06 KB

cards.md

File metadata and controls

184 lines (134 loc) · 5.06 KB

Cards

CardsApi cardsApi = client.getCardsApi();

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.

CompletableFuture<ListCardsResponse> listCardsAsync(
    final String cursor,
    final String customerId,
    final Boolean includeDisabled,
    final String referenceId,
    final String sortOrder)

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.
customerId String Query, Optional Limit results to cards associated with the customer supplied.
By default, all cards owned by the merchant are returned.
includeDisabled Boolean Query, Optional Includes disabled cards.
By default, all enabled cards owned by the merchant are returned.
referenceId String Query, Optional Limit results to cards associated with the reference_id supplied.
sortOrder String Query, Optional Sorts the returned list by when the card was created with the specified order.
This field defaults to ASC.

Response Type

ListCardsResponse

Example Usage

Boolean includeDisabled = false;

cardsApi.listCardsAsync(null, null, includeDisabled, null, null).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Create Card

Adds a card on file to an existing merchant.

CompletableFuture<CreateCardResponse> createCardAsync(
    final CreateCardRequest body)

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.

Response Type

CreateCardResponse

Example Usage

CreateCardRequest body = new CreateCardRequest.Builder(
    "4935a656-a929-4792-b97c-8848be85c27c",
    "cnon:uIbfJXhXETSP197M3GB",
    new Card.Builder()
        .cardholderName("Amelia Earhart")
        .billingAddress(new Address.Builder()
            .addressLine1("500 Electric Ave")
            .addressLine2("Suite 600")
            .locality("New York")
            .administrativeDistrictLevel1("NY")
            .postalCode("10003")
            .country("US")
            .build())
        .customerId("VDKXEEKPJN48QDG3BGGFAK05P8")
        .referenceId("user-id-1")
        .build()
)
.build();

cardsApi.createCardAsync(body).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Retrieve Card

Retrieves details for a specific Card.

CompletableFuture<RetrieveCardResponse> retrieveCardAsync(
    final String cardId)

Parameters

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

Response Type

RetrieveCardResponse

Example Usage

String cardId = "card_id4";

cardsApi.retrieveCardAsync(cardId).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});

Disable Card

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

CompletableFuture<DisableCardResponse> disableCardAsync(
    final String cardId)

Parameters

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

Response Type

DisableCardResponse

Example Usage

String cardId = "card_id4";

cardsApi.disableCardAsync(cardId).thenAccept(result -> {
    // TODO success callback handler
    System.out.println(result);
}).exceptionally(exception -> {
    // TODO failure callback handler
    exception.printStackTrace();
    return null;
});