Skip to main content

Update user payment

Use this API to update the payment details for an existing user.

HTTP Request

POST <BASE_URL>/api/v1/users

Headers

HeaderTypeDescription
cv-api-keystringRequired. Your unique API key for authentication.
Content-TypestringRequired. Must be application/json.

Request Body

The request body is a JSON object with two top-level fields: action and data.

FieldTypeDescription
actionstringRequired. The action to be performed. This should always be UPDATE_PAYMENT_INFO.
dataobjectAn object containing the payment details.

updatePayment Object

FieldTypeDescription
emailstringRequired. The user's email address.
stripeSetupIdstringRequired. The Stripe setup ID.
nmiPaymentTokenstringRequired. The NMI payment token.
shippingAddressobjectRequired. The shipping address.

shippingAddress Object

FieldTypeDescription
addressLine1stringRequired. The address of the user.
addressLine2stringRequired. The address2 of the user.
citystringRequired. The city of the user.
statestringRequired. The state of the user.
countrystringRequired. The country of the user.
postalCodestringRequired. The postal code of the user.

Example Request

curl --location '<BASE_URL>/api/v1/users' \
--header 'cv-api-key: <redacted>' \
--header 'Content-Type: application/json' \
--data-raw '{
"action": "UPDATE_PAYMENT_INFO",
"email": "john.doe@carevalidate.com",
"data": {
"stripeSetupId": "<redacted>",
"nmiPaymentToken": "<redacted>",
"shippingAddress": {
"addressLine1": "1600 Pennsylvania Avenue NW",
"addressLine2": "",
"city": "Washington",
"state": "DC",
"country": "US",
"postalCode": "20500"
}
}
}'

Responses

Success Response

A successful request returns a 200 status code and a JSON object confirming the email update.

Response
{
    "status": 200,
    "success": true,
"data": {
"code": "PAYMENT_SETUP_UPDATED"
}
}

Failure Responses

A request can fail for several reasons, returning an error status code and a JSON object with a descriptive message.

User does not exist

If the email provided in the request body doesn't match an existing user, the API will return this response.

{
"status": 400,
"success": false,
"message": "Invalid request",
"error": "User {email} does not exist",
}

If the stripeSetupId provided in the request body doesn't match an existing setup intent, the API will return this response.

{
"status": 400,
"success": false,
"message": "Invalid request",
"error": "No such setupintent: 'seti_1SNZDLKAXrtjbq2duGldHsHf'"
}