|
| 1 | +# Cards |
| 2 | + |
| 3 | +```java |
| 4 | +CardsApi cardsApi = client.getCardsApi(); |
| 5 | +``` |
| 6 | + |
| 7 | +## Class Name |
| 8 | + |
| 9 | +`CardsApi` |
| 10 | + |
| 11 | +## Methods |
| 12 | + |
| 13 | +* [List Cards](/doc/api/cards.md#list-cards) |
| 14 | +* [Create Card](/doc/api/cards.md#create-card) |
| 15 | +* [Retrieve Card](/doc/api/cards.md#retrieve-card) |
| 16 | +* [Disable Card](/doc/api/cards.md#disable-card) |
| 17 | + |
| 18 | + |
| 19 | +# List Cards |
| 20 | + |
| 21 | +Retrieves a list of cards owned by the account making the request. |
| 22 | +A max of 25 cards will be returned. |
| 23 | + |
| 24 | +```java |
| 25 | +CompletableFuture<ListCardsResponse> listCardsAsync( |
| 26 | + final String cursor, |
| 27 | + final String customerId, |
| 28 | + final Boolean includeDisabled, |
| 29 | + final String referenceId, |
| 30 | + final String sortOrder) |
| 31 | +``` |
| 32 | + |
| 33 | +## Parameters |
| 34 | + |
| 35 | +| Parameter | Type | Tags | Description | |
| 36 | +| --- | --- | --- | --- | |
| 37 | +| `cursor` | `String` | Query, Optional | A pagination cursor returned by a previous call to this endpoint.<br>Provide this to retrieve the next set of results for your original query.<br><br>See [Pagination](https://developer.squareup.com/docs/basics/api101/pagination) for more information. | |
| 38 | +| `customerId` | `String` | Query, Optional | Limit results to cards associated with the customer supplied.<br>By default, all cards owned by the merchant are returned. | |
| 39 | +| `includeDisabled` | `Boolean` | Query, Optional | Includes disabled cards.<br>By default, all enabled cards owned by the merchant are returned.<br>**Default**: `false` | |
| 40 | +| `referenceId` | `String` | Query, Optional | Limit results to cards associated with the reference_id supplied. | |
| 41 | +| `sortOrder` | [`String`](/doc/models/sort-order.md) | Query, Optional | Sorts the returned list by when the card was created with the specified order.<br>This field defaults to ASC. | |
| 42 | + |
| 43 | +## Response Type |
| 44 | + |
| 45 | +[`ListCardsResponse`](/doc/models/list-cards-response.md) |
| 46 | + |
| 47 | +## Example Usage |
| 48 | + |
| 49 | +```java |
| 50 | +String cursor = "cursor6"; |
| 51 | +String customerId = "customer_id8"; |
| 52 | +Boolean includeDisabled = false; |
| 53 | +String referenceId = "reference_id2"; |
| 54 | +String sortOrder = "DESC"; |
| 55 | + |
| 56 | +cardsApi.listCardsAsync(cursor, customerId, includeDisabled, referenceId, sortOrder).thenAccept(result -> { |
| 57 | + // TODO success callback handler |
| 58 | +}).exceptionally(exception -> { |
| 59 | + // TODO failure callback handler |
| 60 | + return null; |
| 61 | +}); |
| 62 | +``` |
| 63 | + |
| 64 | + |
| 65 | +# Create Card |
| 66 | + |
| 67 | +Adds a card on file to an existing merchant. |
| 68 | + |
| 69 | +```java |
| 70 | +CompletableFuture<CreateCardResponse> createCardAsync( |
| 71 | + final CreateCardRequest body) |
| 72 | +``` |
| 73 | + |
| 74 | +## Parameters |
| 75 | + |
| 76 | +| Parameter | Type | Tags | Description | |
| 77 | +| --- | --- | --- | --- | |
| 78 | +| `body` | [`CreateCardRequest`](/doc/models/create-card-request.md) | Body, Required | An object containing the fields to POST for the request.<br><br>See the corresponding object definition for field details. | |
| 79 | + |
| 80 | +## Response Type |
| 81 | + |
| 82 | +[`CreateCardResponse`](/doc/models/create-card-response.md) |
| 83 | + |
| 84 | +## Example Usage |
| 85 | + |
| 86 | +```java |
| 87 | +Address bodyCardBillingAddress = new Address.Builder() |
| 88 | + .addressLine1("500 Electric Ave") |
| 89 | + .addressLine2("Suite 600") |
| 90 | + .addressLine3("address_line_34") |
| 91 | + .locality("New York") |
| 92 | + .sublocality("sublocality8") |
| 93 | + .administrativeDistrictLevel1("NY") |
| 94 | + .postalCode("10003") |
| 95 | + .country("US") |
| 96 | + .build(); |
| 97 | +Card bodyCard = new Card.Builder() |
| 98 | + .id("id0") |
| 99 | + .cardBrand("INTERAC") |
| 100 | + .last4("last_42") |
| 101 | + .expMonth(236L) |
| 102 | + .expYear(60L) |
| 103 | + .cardholderName("Amelia Earhart") |
| 104 | + .billingAddress(bodyCardBillingAddress) |
| 105 | + .customerId("VDKXEEKPJN48QDG3BGGFAK05P8") |
| 106 | + .referenceId("user-id-1") |
| 107 | + .build(); |
| 108 | +CreateCardRequest body = new CreateCardRequest.Builder( |
| 109 | + "4935a656-a929-4792-b97c-8848be85c27c", |
| 110 | + "cnon:uIbfJXhXETSP197M3GB", |
| 111 | + bodyCard) |
| 112 | + .verificationToken("verification_token0") |
| 113 | + .build(); |
| 114 | + |
| 115 | +cardsApi.createCardAsync(body).thenAccept(result -> { |
| 116 | + // TODO success callback handler |
| 117 | +}).exceptionally(exception -> { |
| 118 | + // TODO failure callback handler |
| 119 | + return null; |
| 120 | +}); |
| 121 | +``` |
| 122 | + |
| 123 | + |
| 124 | +# Retrieve Card |
| 125 | + |
| 126 | +Retrieves details for a specific Card. |
| 127 | + |
| 128 | +```java |
| 129 | +CompletableFuture<RetrieveCardResponse> retrieveCardAsync( |
| 130 | + final String cardId) |
| 131 | +``` |
| 132 | + |
| 133 | +## Parameters |
| 134 | + |
| 135 | +| Parameter | Type | Tags | Description | |
| 136 | +| --- | --- | --- | --- | |
| 137 | +| `cardId` | `String` | Template, Required | Unique ID for the desired Card. | |
| 138 | + |
| 139 | +## Response Type |
| 140 | + |
| 141 | +[`RetrieveCardResponse`](/doc/models/retrieve-card-response.md) |
| 142 | + |
| 143 | +## Example Usage |
| 144 | + |
| 145 | +```java |
| 146 | +String cardId = "card_id4"; |
| 147 | + |
| 148 | +cardsApi.retrieveCardAsync(cardId).thenAccept(result -> { |
| 149 | + // TODO success callback handler |
| 150 | +}).exceptionally(exception -> { |
| 151 | + // TODO failure callback handler |
| 152 | + return null; |
| 153 | +}); |
| 154 | +``` |
| 155 | + |
| 156 | + |
| 157 | +# Disable Card |
| 158 | + |
| 159 | +Disables the card, preventing any further updates or charges. |
| 160 | +Disabling an already disabled card is allowed but has no effect. |
| 161 | + |
| 162 | +```java |
| 163 | +CompletableFuture<DisableCardResponse> disableCardAsync( |
| 164 | + final String cardId) |
| 165 | +``` |
| 166 | + |
| 167 | +## Parameters |
| 168 | + |
| 169 | +| Parameter | Type | Tags | Description | |
| 170 | +| --- | --- | --- | --- | |
| 171 | +| `cardId` | `String` | Template, Required | Unique ID for the desired Card. | |
| 172 | + |
| 173 | +## Response Type |
| 174 | + |
| 175 | +[`DisableCardResponse`](/doc/models/disable-card-response.md) |
| 176 | + |
| 177 | +## Example Usage |
| 178 | + |
| 179 | +```java |
| 180 | +String cardId = "card_id4"; |
| 181 | + |
| 182 | +cardsApi.disableCardAsync(cardId).thenAccept(result -> { |
| 183 | + // TODO success callback handler |
| 184 | +}).exceptionally(exception -> { |
| 185 | + // TODO failure callback handler |
| 186 | + return null; |
| 187 | +}); |
| 188 | +``` |
| 189 | + |
0 commit comments