Skip to main content

User Payment & Card Management

GET List User Saved Cards

Lists all saved credit cards associated with the authenticated user in the Commerce system. The response includes details like card ID, creation and modification dates, card name, masked card number, and the associated user ID.

Path: /users/saved-cards/

Authentication Required: Yes

Headers:

Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>

Example Request

import requests

url = "https://{commerce_url}/users/saved-cards/"

headers = {
'Accept-Language: '<iso_language_code>',
'Cookie': '<cookie-name>=<session_id>'
}

response = requests.get(url, headers=headers)
print(response.text)

Example Response (200 OK)

{
"count": 2,
"next": null,
"previous": null,
"results": [
{
"id": 1,
"created_date": "2024-11-18T14:05:59.000043Z",
"modified_date": "2024-11-18T14:05:59.000798Z",
"name": "Card 1",
"token": "5420c64565001c88d4a40ea2196e0fcd",
"masked_card_number": "**** **** **** 1234",
"user": 414183
},
{
"id": 20,
"created_date": "2024-09-18T14:05:59.000043Z",
"modified_date": "2024-09-18T14:05:59.000798Z",
"name": "Card 2",
"token": "fbab4cccbfddff68dca70d1e12b072bd",
"masked_card_number": "**** **** **** 4523",
"user": 414183
}
]
}

GET Retrieve User Saved Card

Retrieves the details of a specific saved card for the authenticated user, in the Commerce system. You must provide the card ID in the URL path.

Path: /users/saved-cards/<card-id>/

Authentication Required: Yes

Headers:

Cookie: <cookie-name>=<session_id>

Example Request

import requests

url = "https://{commerce_url}/users/saved-cards/{card-id}"

headers = {
'Cookie': '<cookie-name>=<session_id>',
}

response = requests.get(url, headers=headers)
print(response.text)

Example Response (200 OK)

{
"id": 20,
"created_date": "2024-09-18T14:05:59.000043Z",
"modified_date": "2024-09-18T14:05:59.000798Z",
"name": "Card 2",
"token": "fbab4cccbfddff68dca70d1e12b072bd",
"masked_card_number": "**** **** **** 4523",
"user": 414183
}

PATCH Update User Saved Card

Updates the name of an existing specific saved card for the authenticated user, in the Commerce system. You must provide the card ID in the URL path.

Path: /users/saved-cards/<card-id>/

Authentication Required: Yes

Headers:

Content-Type: application/json
Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
x-csrftoken: <token>

Body Parameters

PropertyData TypeRequiredDescription
nameStringFalseThe name of the saved card to be updated.

Request Body

{
"name": "Travel Card"
}

Example Request

import requests

url = "https://{commerce_url}/user/saved-cards/1/"

headers = {
'Content-Type': 'application/json',
'Accept-Language: '<iso_language_code>',
'Cookie': '<cookie-name>=<session_id>',
'x-csrftoken': '<token>'
}

payload = json.dumps({
"name": "Travel Card"
})

response = requests.patch(url, headers=headers, data=payload)
print(response.json())

Example Response (200 OK)

{
"id": 20,
"created_date": "2024-09-18T14:05:59.000043Z",
"modified_date": "2024-09-18T14:05:59.000798Z",
"name": "Travel Card",
"token": "fbab4cccbfddff68dca70d1e12b072bd",
"masked_card_number": "**** **** **** 4523",
"user": 414183
}

DELETE Delete User Saved Card

Deletes a specific saved card for the authenticated user, in the Commerce system. You must provide the card ID in the URL path.

Path: /users/saved-cards/<card-id>/

Authentication Required: Yes

Headers:

Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
x-csrftoken: <token>

Example Request

import requests

url = "https://{commerce_url}/users/saved-cards/{card-id}/"

headers = {
'Accept-Language: '<iso_language_code>',
'Cookie': '<cookie-name>=<session_id>'
'x-csrftoken': '<token>'
}

response = requests.delete(url, headers=headers)
print(response.text)

Example Response (204 No Content)

No content is returned when the request is successful.

GET User List Stored Cards

This endpoint retrieves a list of the stored cards for the authenticated user, stored on a different payment gateway. The information is masked for security reasons, ensuring that full card details are not exposed.

Path: /users/stored-cards/

Authentication Required: Yes

Headers:

Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>

Example Request

import requests

url = "https://{commerce_url}/users/stored-cards/"

headers = {
'Accept-Language': '<iso_language_code>',
'Cookie': '<cookie-name>=<session_id>'
}

response = requests.get(url, headers=headers)
print(response.text)

Example Response (200 OK)

{
"cards": [
{
"card_number": "555555******4444",
"card_identifier": "f8a82d05-abe1-4ef6-a8d7-2c5ad7301bbd"
},
...
]
}

Response Parameters:

PropertyData TypeDescription
card_numberstringA masked version of the credit card number.
card_identifierstringA unique identifier for the stored card.

DELETE Delete User Stored Card

This endpoint is used to delete a stored card for the authenticated user, stored on a different payment gateway.

Path: /users/stored-cards/<card_identifier>/

Authentication Required: Yes

Headers:

Accept-Language: <iso_language_code>
Cookie: <cookie-name>=<session_id>
x-csrftoken: <token>

Example Request

import requests

url = "https://{commerce_url}/user/cards/{card_identifier}/"
headers = {
'Accept-Language': '<iso_language_code>',
'Cookie': '<cookie-name>=<session_id>'
'x-csrftoken': '<token>'
}

response = requests.delete(url, headers=headers)
print(response.status_code)

Example Response (200 OK)

No content returned.

Example Response (400 Bad Request)

If an error occurs while interacting with the gateway instance:

{
"non_field_errors": "An error occurred. Please try again later."
}

If an error occurs on a third-party API:

{
"error": "Invalid request data"
}