Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 7961a44

Browse files
authored
Add GraphQL vault documentation (#4760)
* checkpoint * review draft * developer comments
1 parent 828105e commit 7961a44

File tree

3 files changed

+155
-0
lines changed

3 files changed

+155
-0
lines changed

_data/toc/graphql.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ pages:
138138
- label: UrlRewrite endpoint
139139
url: /graphql/reference/url-resolver.html
140140

141+
- label: Vault endpoint
142+
url: /graphql/reference/vault.html
143+
141144
- label: Wishlist endpoint
142145
url: /graphql/reference/wishlist.html
143146

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
The `CustomerPaymentTokens` output object contains an array of `items`.
2+
3+
Attribute | Data Type | Description
4+
--- | --- | ---
5+
`items` | [PaymentToken] | Contains an array of customer payment tokens
6+
7+
#### PaymentToken attributes
8+
9+
The `PaymentToken` object defines characteristics of a token stored in the payment vault.
10+
11+
Attribute | Data Type | Description
12+
--- | --- | ---
13+
`details` | String | Stored account details
14+
`payment_method_code` | String | The payment method code associated with the token
15+
`public_hash` | String | The public hash of the token generated by the vault provider
16+
`type` | `PaymentTokenTypeEnum` | `card` or `account`
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
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

Comments
 (0)