|
Note |
|
The server component of your integration makes the API request to delete a saved payment method. |
If you allow customers to store payment cards, you can also allow them to remove payment cards by deleting the payment method from their customer record. Deleting a payment method from a customer record is permanent and the payment method cannot be reattached to their record. For more information on payment methods, see Creating a payment method.
There are two API requests associated with deleting a saved payment method from a customer record.
-
Getting a list of payment methods attached to the customer record.
-
Delete the payment method from the customer record using the
customerIdandpaymentMethodId. ThepaymentMethodIdis the unique identifier of the payment method.
To get a list of payment methods saved to a customer record,
send a GET request to the v1/customers/{customerId}/payment-methods
endpoint of the customers API. Include the
Toast-Restaurant-External-ID as a header parameter in the
request and the customerId in the request path.
|
Note |
|
Customers cannot save digital wallets such as Apple Pay and Google Pay as payment methods. |
Example response body
{
"results": 1,
"paymentMethods": [
{
"id": "f718c101-70e4-45fe-8fc1-67ba0a12a8c5",
"type": "CARD",
"cardType": "VISA",
"lastFour": "1111",
"month": "12",
"year": "27"
}
]
}|
The number of payment methods attached to the customer record. |
|
|
The |
|
|
The unique identifier for the payment card. Use this
|
|
Note |
|
You must use the hosted checkout - payment credentials for the server component of your integration. |
To delete a payment method from a customer record, send a
POST request to v1/payment-methods/{paymentMethodId}/detach
endpoint of the payment methods API. Include
Toast-Restaurant-External-ID as a header parameter in the
request and the paymentMethodId in the request path. The
paymentMethodId is the identifier for the payment card.
In the request body, include the customerId.
|
Note |
|
You cannot update the expiration date on a saved payment card. Your customer will need to add the payment card with the new expiration date and then delete the expired card. |
|
Note |
|
You can set a default payment method to be preselected for
customer use in the |
As part of the hosted checkout iframe, you can
automatically have your customer’s preferred saved payment card
preselected for use on your checkout page. If your customer is logged
into their customer profile in your integration and has set a payment
method as the default, then when they checkout, their default payment
method is preselected for use in the iframe.
To set a payment method as the default, the customer must have a customer record and have previously saved a payment card to their customer profile. The customer can save their payment card through either the setup intent or payment intent workflow. For information on the payment or setup intent workflows, see Payment intents or Setup intents.
To set a default payment method, send a POST request
to the /v1/customers/{customerId}/payment-methods/defaults
endpoint of the customers API. In the request body, include the
contextName and the paymentMethodId. The
contextName is the unique merchant or integration provided
name that identifies the application that the payment method is being
set as the default for. To get a customer’s list of payment methods,
send a GET request to the /v1/customers/{id}/payment-methods
endpoint of the customers API.
Example request body
Example response body
{
"paymentMethodId": "a1b2c3d4-5678-1234-8901-abcdef123456",
"contextName": "default-online-ordering"
}To determine what payment method will be preselected for customer
use during checkout, send a GET request to the /v1/customers/{id}/payment-methods/defaults/{contextName}
endpoint of the customers API.
Example response body
{
"paymentMethodId": "a1b2c3d4-5678-1234-8901-abcdef123456",
"contextName": "default-online-ordering"
}If your customer wants to delete a default payment method, send a
POST request to the /v1/customers/{id}/payment-methods/defaults/{contextName}
endpoint of the customers API. In the request body, include the
contextName and the paymentMethodId.
No response is returned.
Example request body
{
"paymentMethodId": "a1b2c3d4-5678-1234-8901-abcdef123456",
"contextName": "default-online-ordering"
}