|
| 1 | +--- |
| 2 | +group: graphql |
| 3 | +title: Vault endpoint |
| 4 | +--- |
| 5 | + |
| 6 | +When the [vault]({{page.baseurl}}/payments-integrations/vault/vault-intro.html) feature is supported by a payment integration and enabled, customers have the option during checkout to save their credit card information. (Braintree supports the vault feature. Third-party payment integrations may support this feature as well.) During subsequent checkouts, the customer is presented with a list of saved payment options. If Instant Purchase is enabled, customers can even by-pass the two-step checkout process and place the order from the product page. |
| 7 | + |
| 8 | +## Query |
| 9 | + |
| 10 | +The `customerPaymentTokens` query returns an array of stored payment methods. |
| 11 | + |
| 12 | +{:.bs-callout .bs-callout-info} |
| 13 | +You must specify the customer's authorization token in the header of the call. |
| 14 | + |
| 15 | +### Syntax |
| 16 | + |
| 17 | +`{customerPaymentTokens{CustomerPaymentTokens}}` |
| 18 | + |
| 19 | +#### CustomerPaymentTokens attributes |
| 20 | + |
| 21 | +{% include graphql/customer-payment-tokens.md %} |
| 22 | + |
| 23 | +### Example usage |
| 24 | + |
| 25 | +The following example returns all the current customer's payment tokens. |
| 26 | + |
| 27 | +**Request** |
| 28 | + |
| 29 | +```text |
| 30 | +query { |
| 31 | + customerPaymentTokens { |
| 32 | + items { |
| 33 | + details |
| 34 | + public_hash |
| 35 | + payment_method_code |
| 36 | + type |
| 37 | + } |
| 38 | + } |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +**Response** |
| 43 | + |
| 44 | +```json |
| 45 | +{ |
| 46 | + "data": { |
| 47 | + "customerPaymentTokens": { |
| 48 | + "items": [ |
| 49 | + { |
| 50 | + "details": "{\"type\":\"VI\",\"maskedCC\":\"1111\",\"expirationDate\":\"09\\/2022\"}", |
| 51 | + "public_hash": "f5816fe2ab7d200c3ff84d42804b65144f9cb0a2401ce1dad1b52d3b3115fd1a", |
| 52 | + "payment_method_code": "braintree", |
| 53 | + "type": "card" |
| 54 | + }, |
| 55 | + { |
| 56 | + "details": "{\"type\":\"DI\",\"maskedCC\":\"1117\",\"expirationDate\":\"11\\/2023\"}", |
| 57 | + "public_hash": "377c1514e0bce7107a9348ddf38bc059b2f1b9e0a8bedf168a98b04807e17ff5", |
| 58 | + "payment_method_code": "braintree", |
| 59 | + "type": "card" |
| 60 | + } |
| 61 | + ] |
| 62 | + } |
| 63 | + } |
| 64 | +} |
| 65 | +``` |
| 66 | + |
| 67 | +## Mutation |
| 68 | + |
| 69 | +The `deletePaymentToken` mutation deletes a payment token from the system. |
| 70 | + |
| 71 | +{:.bs-callout .bs-callout-info} |
| 72 | +You must specify the customer's authorization token in the header of the call. |
| 73 | + |
| 74 | +### Syntax |
| 75 | + |
| 76 | +`mutation: {deletePaymentToken(public_hash) {DeletePaymentTokenOutput}}` |
| 77 | + |
| 78 | +#### DeletePaymentTokenOutput attributes |
| 79 | + |
| 80 | +The `DeletePaymentTokenOutput` object contains the result of the operation and details about the remaining customer payment tokens. |
| 81 | + |
| 82 | +Attribute | Data Type | Description |
| 83 | +--- | --- | --- |
| 84 | +`customerPaymentTokens` | `CustomerPaymentTokens` | Contains an array of customer payment tokens |
| 85 | +`result` | Boolean | A value of `true` indicates the request was successful |
| 86 | + |
| 87 | +#### CustomerPaymentTokens |
| 88 | + |
| 89 | +{% include graphql/customer-payment-tokens.md %} |
| 90 | + |
| 91 | +### Example usage |
| 92 | + |
| 93 | +The following example deletes the Discover Card listed in the results of the `customerPaymentTokens` query. |
| 94 | + |
| 95 | +**Request** |
| 96 | + |
| 97 | +``` text |
| 98 | +mutation { |
| 99 | + deletePaymentToken( |
| 100 | + public_hash: "377c1514e0bce7107a9348ddf38bc059b2f1b9e0a8bedf168a98b04807e17ff5" |
| 101 | + ) { |
| 102 | + result |
| 103 | + customerPaymentTokens { |
| 104 | + items { |
| 105 | + details |
| 106 | + public_hash |
| 107 | + payment_method_code |
| 108 | + type |
| 109 | + } |
| 110 | + } |
| 111 | + } |
| 112 | +} |
| 113 | +
|
| 114 | +``` |
| 115 | + |
| 116 | +**Response** |
| 117 | + |
| 118 | +```json |
| 119 | +{ |
| 120 | + "data": { |
| 121 | + "deletePaymentToken": { |
| 122 | + "result": true, |
| 123 | + "customerPaymentTokens": { |
| 124 | + "items": [ |
| 125 | + { |
| 126 | + "details": "{\"type\":\"VI\",\"maskedCC\":\"1111\",\"expirationDate\":\"09\\/2022\"}", |
| 127 | + "public_hash": "f5816fe2ab7d200c3ff84d42804b65144f9cb0a2401ce1dad1b52d3b3115fd1a", |
| 128 | + "payment_method_code": "braintree", |
| 129 | + "type": "card" |
| 130 | + } |
| 131 | + ] |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | +} |
| 136 | +``` |
0 commit comments