# Declined Payment Calls

This endpoint allows you to initiate large-scale processing of calls and WhatsApp messages related to declined payments. To use the endpoint, you have to provide an object containing detailed information about the declined payment.

**POST** `/smart-support/external/payments/recover`

Base URL: `https://api-sandbox.whitelabel.com/v1`

Declined Payment Calls

## Authorization

- public-api-key (apiKey in header)
- private-secret-key (apiKey in header)

## Body

Content type: `application/json`

- `settings` (object, required)
  AI agent configuration
  - `contact_details` (object, required)
    Object with the contact details
    - `channel` ("PHONE_CALL" | "WHATSAPP_MESSAGE", required)
      The list of possible contact channels.
    - `initial_template_message` (object)
      Required if `channel = WHATSAPP_MESSAGE`. Initial template message configuration for `WHATSAPP_MESSAGE`.
      - `id` (string)
        WHITELABEL template ID
      - `variables` (object)
        Object with template's variables
    - `pdf_template` (object)
      PDF template configuration for WHATSAPP_MESSAGE.
      - `id` (string)
        WHITELABEL PDF template ID
      - `variables` (object)
        Object with pdf template's variables
    - `payment_methods` (object)
      Available payment methods to offer the customer payer
      - `available` (string[], required)
        The list of available payment methods to be offered to the user as alternatives to complete the payment.
- `additional_information` (object)
  All relevant information to feed to the AI to improve context.
  - `seller_details` (object)
    Object containing the merchant's contact information to be used if the agent is unable to answer the inquiry.
    - `name` (string)
      The merchant's name, used by the AI to introduce itself.
    - `fallback_instructions` (string)
      Instruction to be provided to the user on how to contact customer support in case the AI cannot solve the issue.
    - `redirection_url` (string)
      URL to redirect the customer for additional support.
  - `payment` (object)
    Declined payment information
    - `account_id` (string)
      The unique identifier of the account.
    - `id` (string)
      The unique identifier of the payment.
    - `merchant_order_id` (string)
      Identification of the Order.
    - `country` (string)
      Country where the payment was processed (ISO 3166-1).
    - `description` (string)
      The description of product or service the user tried to purchase.
    - `created_at` (string<date-time>)
      The timestamp of when the payment was made (ISO 8601).
    - `declined_reason` (string)
      The declined reason for the payment provided by the payment provider.
    - `payment_method` (object)
      - `type` (string)
        The type of payment method selected by the customer.
      - `detail` (object)
        - `card_data` (object)
          - `expiration_month` (number)
            Card's expiration month - MM
          - `expiration_year` (number)
            Card's expiration year - YYYY
          - `iin` (string)
            The Institution identification number (IIN) refers to the first few digits of a payment card number issued by a financial institution.
          - `lfd` (string)
            Last four digits of the card.
          - `issuer` (string)
            Card issuer.
          - `type` ("CREDIT" | "DEBIT" | "PREPAID")
            Card's issuer type.
    - `amount` (object)
      - `value` (number)
        The amount of the payment that was declined.
      - `currency` (string)
        The currency of the payment that was declined (ISO 4217).
    - `customer_payer` (object)
      - `first_name` (string)
        The customer's first name.
      - `last_name` (string)
        The customer's last name.
      - `phone` (object)
        - `country_code` (string)
          Customer payer cell phone area code.
        - `number` (string)
          Customer payer cell phone number.

Example:

```json
{
  "settings": {
    "contact_details": {
      "channel": "WHATSAPP_MESSAGE",
      "initial_template_message": {
        "id": "HX8e7ac569f40a064c71a37e5d672bb9123",
        "variables": {
          "name": "Maria",
          "amount": "$10.0000"
        }
      },
      "pdf_template": {
        "id": "string",
        "variables": {
          "seller_name": "RAPPI",
          "merchant_order_id": "MX_Verification_50708779"
        }
      },
      "payment_methods": {
        "available": [
          "MERCADO_PAGO",
          "NEQUI",
          "CREDIT_CARD"
        ]
      }
    }
  },
  "additional_information": {
    "seller_details": {
      "name": "RAPPI",
      "fallback_instructions": "Go to the application and click on the top right corner to contact a customer support agent.",
      "redirection_url": "www.test.com/purchase"
    },
    "payment": {
      "account_id": "e4c03f29-b0f6-403a-8814-9aee1a88d60e",
      "id": "f1fbad16-93c1-4335-b735-2b01ec94ea9e",
      "merchant_order_id": "ORDER-12345",
      "country": "US",
      "description": "Online store purchase",
      "created_at": "2022-05-09T20:46:54.786342Z",
      "declined_reason": "insufficient funds",
      "payment_method": {
        "type": "Credit Card",
        "detail": {
          "card_data": {
            "expiration_month": 12,
            "expiration_year": 2030,
            "iin": "411111",
            "lfd": "1234",
            "issuer": "CHASE",
            "type": "CREDIT"
          }
        }
      },
      "amount": {
        "value": 149.99,
        "currency": "USD"
      },
      "customer_payer": {
        "first_name": "John",
        "last_name": "Doe",
        "phone": {
          "country_code": "1",
          "number": "5551234567"
        }
      }
    }
  }
}
```

## Responses

### 200

Success

- `id` (string)
- `message` (string)

Example:

```json
{
  "id": "7c3a9c6e-9bf0-4c2c-9f67-752b16ba5dd5",
  "message": "Communication processed successfully"
}
```

### 400

Bad Request

- `message` (string)

Example:

```json
{
  "message": "Missing customer_payer.first_name required field"
}
```

### 500

Internal Server Error

- `message` (string)

Example:

```json
{
  "message": "Internal error"
}
```