# Card Management

This section focuses on managing payment cards associated with a user's account. It includes APIs for adding, retrieving, and deleting card details, allowing your customers to manage their payment methods easily.

## **Included APIs**:

1. **Get User Card Details**: Retrieves the saved card information for a user, facilitating a smoother checkout process by allowing users to choose from their saved cards.
2. **Add Card Details**: Allows users to add new card details to their account, expanding their options for payment methods.
3. **Delete Card**: Enables users to remove a saved card from their account, maintaining the relevance and accuracy of their payment options.

## **1. Get User Card Details**

{% hint style="info" %}
**Tip:** Utilize the "Add Card Details" API to securely save customer payment methods for future transactions, offering convenience without compromising security.
{% endhint %}

* **Endpoint:** `GET /api/Checkout/GetUserDetails`
* **Purpose:** Retrieves the user's saved card details.
* **Request Parameters:** `emailId=string`

```json
{
  "userVM": {
    "userId": "4936",
    "cardType": "visa",
    "lastFourDigitCardNumber": "1111"
  }
}

```

### Response:

* **Status 200:** Card details fetched successfully.

## **2. Add Card Details**

{% hint style="info" %}
**Good to know:** Card details are tokenized, meaning that actual card numbers are not stored on the Krepling cloud. This tokenization process significantly reduces the risk of data breaches.
{% endhint %}

* **Endpoint:** `POST /api/Checkout/AddCardDetails`
* **Purpose:** Adds a new payment card to the user's account.
* **Request Body:**

```json
{
  "CardNumber": "4111111111111111",
  "CardValidityDate": "1225",
  "CardCVVNumber": "123",
  "UserId": "4936"
}

```

### **Response:**

* **Status 200:** Card added successfully.

```json
{
  "status": 1,
  "message": "Card has been added successfully"
}

```

## 3. Delete Card

{% hint style="info" %}
**Good to know:** Krepling Pay allows users to manage their payment options directly, offering a feature to retrieve and delete saved cards. This direct management of payment methods emphasizes user control and security.
{% endhint %}

* **POST** `/api/Checkout/DeleteCard`
* **Purpose**: Removes a saved card from the user's account.
* **Request Body**:

```json
{
  "UserId": "4936",
  "CardId": "cardId123"
}

```

### Response:

```json
{
  "UserId": "4936",
  "CardId": "cardId123"
}

```
