CardsApi cardsApi = client.getCardsApi();
CardsApi
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)
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. Default: false |
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. |
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;
});
Adds a card on file to an existing merchant.
CompletableFuture<CreateCardResponse> createCardAsync(
final CreateCardRequest body)
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. |
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;
});
Retrieves details for a specific Card.
CompletableFuture<RetrieveCardResponse> retrieveCardAsync(
final String cardId)
Parameter | Type | Tags | Description |
---|---|---|---|
cardId |
String |
Template, Required | Unique ID for the desired Card. |
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;
});
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)
Parameter | Type | Tags | Description |
---|---|---|---|
cardId |
String |
Template, Required | Unique ID for the desired Card. |
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;
});