> ## Documentation Index
> Fetch the complete documentation index at: https://docs.alignet.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Automatic debit functionality

> Initialize and display the Alignet One Flex automatic debit form.

<Warning>
  That functionality was currently under development. Documentation, parameters and flows can be changed before their final availability.
</Warning>

## Retiring Automatic Flow component

When a new instance of the component is created a concurrently with the properties are necessary **nonce**, **payload** and **sittings**.

### Parameters

<AccordionGroup>
  <Accordion title="Affiliation data">
    | Field                       | Type              | Mandatory | Description                                                |
    | --------------------------- | ----------------- | --------- | ---------------------------------------------------------- |
    | `action`                    | String            | If        | Action to run. Values: `subscribe` / `update_subscription` |
    | `merchant_affiliation_code` | String            | If        | Affiliation code generated by the merchant.                |
    | `merchant_code`             | String            | If        | Merchant code that starts Affiliation.                     |
    | `type`                      | String            | If        | Affiliation type. It's only allowed `MANUAL`.              |
    | `frequency`                 | String            | NO        | Frequency of Affiliation collection.                       |
    | `amount`                    | String            | NO        | That's how we get money.                                   |
    | `maxAmount`                 | String            | NO        | Maximum amount for recurrent payments in cents.            |
    | `currency`                  | String (ISO 4217) | If        | Money from collection. Ej.: `604` = PEN.                   |
  </Accordion>

  <Accordion title="Data of the recipient">
    | Field                                      | Type              | Mandatory | Description                              |
    | ------------------------------------------ | ----------------- | --------- | ---------------------------------------- |
    | `beneficiary.first_name`                   | String            | If        | Name of recipient.                       |
    | `beneficiary.last_name`                    | String            | If        | The name of the recipient.               |
    | `beneficiary.email`                        | String            | If        | Email from the recipient.                |
    | `beneficiary.phone.country_code`           | String            | If        | Telephone country code. Ej.: `51`.       |
    | `beneficiary.phone.subscriber`             | String            | If        | The recipient's phone number.            |
    | `beneficiary.identity_document.type`       | String            | NO        | Type of ID. Ej.: `DNI`.                  |
    | `beneficiary.identity_document.identifier` | String            | NO        | Identification document number.          |
    | `beneficiary.identity_document.country`    | String (ISO-3166) | NO        | Country of issue of document. Ej.: `PE`. |
    | `beneficiary.location.line_1`              | String            | If        | Main address.                            |
    | `beneficiary.location.line_2`              | String            | NO        | Additional address.                      |
    | `beneficiary.location.city`                | String            | If        | The town of residence.                   |
    | `beneficiary.location.state`               | String            | If        | Department or region.                    |
    | `beneficiary.location.country`             | String (ISO-3166) | If        | Code ISO from the country. Ej.: `PE`.    |
  </Accordion>

  <Accordion title="Additional fields">
    | Field                              | Type   | Mandatory | Description                                                 |
    | ---------------------------------- | ------ | --------- | ----------------------------------------------------------- |
    | `additional_fields.FACTURACION_ID` | String | NO        | Customer's ID or billing contract.                          |
    | `additional_fields.PLAN`           | String | NO        | Name or code of the plan referred to by the recipient.      |
    | `wallet.user_id`                   | String | NO        | User's ID at the walk to associate a card with Affiliation. |
  </Accordion>
</AccordionGroup>

### Flow available

<CardGroup cols={3}>
  <Card title="autoize" icon="credit-card">
    It shows a payment form with the different methods enabling the merchant.
  </Card>

  <Card title="Subscribe" icon="user-plus">
    Sample the Affiliation form to register a new automatic debit.
  </Card>

  <Card title="update_Subscription" icon="pen-to-square">
    It shows a form to update an existing affiliation.
  </Card>
</CardGroup>

***

## Show Alignet One Flex Automatic defect

That's the final step. It's indicated within what **and DOM** form and functions to be shown **callback** to run during the process.

### Callbackes

<CardGroup cols={3}>
  <Card title="responseCallback" icon="circle-check">
    It runs after the component delivers a response to the process.
  </Card>

  <Card title="trackingCallback" icon="chart-line">
    It runs for every event fired during the process.
  </Card>

  <Card title="Failed" icon="circle-xmark">
    It runs with an error during the process.
  </Card>
</CardGroup>

<Warning>
  Do not use `meta.status.code` as an authorized or refused payment validator. That code indicates only the result of service processing. For an authorisation, valid transaction status and confirm result from backend before closing order.
</Warning>

### Cases of use

<Tabs>
  <Tab title="Authorisation with Wallet">
    ```json theme={"system"} theme={"system"}
        {
            "action": "authorize",
            "channel": "ecommerce",
            "merchant_code": "your_merchant_code",
            "merchant_operation_number": "976867",
            "payment_details": {
                "amount": "387000",
                "currency": "604",
                "billing": {
                    "first_name": "Mateo",
                    "last_name": "Zayas Meza",
                    "email": "Mateo_ZayasMeza85@yahoo.com",
                    "phone": { "country_code": "51", "subscriber": "945831902" },
                    "location": {
                        "line_1": "Poblado Concepción 7",
                        "line_2": "Puerta 249",
                        "city": "LIMA",
                        "state": "LIMA",
                        "country": "PE"
                    }
                },
                "wallet": { "user_id": "72661927" }
            }
        }
    ```
  </Tab>

  <Tab title="Affiliation form">
    ```json theme={"system"} theme={"system"}
        {
            "action": "subscribe",
            "merchant_affiliation_code": "122947_RPS_USER",
            "merchant_code": "your_merchant_code",
            "type": "MANUAL",
            "currency": "604",
            "beneficiary": {
                "first_name": "Pilar",
                "last_name": "Ordóñez Tirado",
                "email": "Pilar.OrdonezTirado61@gmail.com",
                "phone": { "country_code": "51", "subscriber": "965097539" },
                "identity_document": {
                    "type": "DNI",
                    "identifier": "38216803",
                    "country": "PE"
                },
                "location": {
                    "line_1": "Colonia Victor Manuel 2498",
                    "city": "LIMA",
                    "state": "LIMA",
                    "country": "PE"
                }
            },
            "additional_fields": {
                "FACTURACION_ID": "133445",
                "PLAN": "POST PAGO 250"
            }
        }
    ```
  </Tab>

  <Tab title="Affiliation with Wallet">
    ```json theme={"system"} theme={"system"}
        {
            "action": "subscribe",
            "merchant_affiliation_code": "023007_RPS_USER",
            "merchant_code": "your_merchant_code",
            "type": "MANUAL",
            "currency": "604",
            "beneficiary": {
                "first_name": "Mónica",
                "last_name": "Duarte Deleón",
                "email": "Monica.DuarteDeleon89@nearbpo.com",
                "phone": { "country_code": "51", "subscriber": "944169494" },
                "identity_document": {
                    "type": "DNI",
                    "identifier": "41134394",
                    "country": "PE"
                },
                "location": {
                    "line_1": "Ferrocarril Pilar Quintairos 45",
                    "city": "LIMA",
                    "state": "LIMA",
                    "country": "PE"
                }
            },
            "additional_fields": {
                "FACTURACION_ID": "133445",
                "PLAN": "POST PAGO 250"
            },
            "wallet": { "user_id": "72661927" }
        }
    ```
  </Tab>

  <Tab title="Updating Affiliation">
    ```json theme={"system"} theme={"system"}
        {
            "action": "update_subscription",
            "merchant_affiliation_code": "10011_LEVIS",
            "merchant_code": "your_merchant_code"
        }
    ```
  </Tab>

  <Tab title="Updating Affiliation with Wallet">
    ```json theme={"system"} theme={"system"}
        {
            "action": "update_subscription",
            "merchant_affiliation_code": "10011_LEVIS",
            "merchant_code": "your_merchant_code",
            "wallet": { "user_id": "72661927" }
        }
    ```
  </Tab>
</Tabs>

### Affiliation response

<AccordionGroup>
  <Accordion title="Affiliation data">
    | Field                                   | Type              | Mandatory | Description                                          |
    | --------------------------------------- | ----------------- | --------- | ---------------------------------------------------- |
    | `success`                               | Boolean           | If        | It indicates if the process was performed correctly. |
    | `affiliation.affiliation_id`            | String (UUID)     | If        | A system-generated affiliation ID.                   |
    | `affiliation.merchant_affiliation_code` | String            | If        | Affiliation code generated by the merchant.          |
    | `affiliation.merchant_code`             | String (UUID)     | If        | Merchant code.                                       |
    | `affiliation.state`                     | String            | If        | Affiliation status. Ej.: `ACTIVE`.                   |
    | `affiliation.type`                      | String            | If        | Affiliation type. Ej.: `MANUAL`.                     |
    | `affiliation.frequency`                 | String            | NO        | Loan frequency.                                      |
    | `affiliation.amount`                    | String            | NO        | Affiliation money in cents.                          |
    | `affiliation.max_amount`                | String            | NO        | Maximum amount allowed.                              |
    | `affiliation.currency`                  | String (ISO 4217) | If        | Money from collection.                               |
  </Accordion>

  <Accordion title="Data of the recipient">
    | Field                                                  | Type   | Mandatory | Description                |
    | ------------------------------------------------------ | ------ | --------- | -------------------------- |
    | `affiliation.beneficiary.first_name`                   | String | If        | Name of recipient.         |
    | `affiliation.beneficiary.last_name`                    | String | If        | The name of the recipient. |
    | `affiliation.beneficiary.email`                        | String | If        | Email.                     |
    | `affiliation.beneficiary.phone.country_code`           | String | If        | Telephone country code.    |
    | `affiliation.beneficiary.phone.subscriber`             | String | If        | phone number.              |
    | `affiliation.beneficiary.identity_document.type`       | String | NO        | Type of document.          |
    | `affiliation.beneficiary.identity_document.identifier` | String | NO        | document number.           |
    | `affiliation.beneficiary.identity_document.country`    | String | NO        | Country of document.       |
    | `affiliation.beneficiary.location.line_1`              | String | If        | Main address.              |
    | `affiliation.beneficiary.location.city`                | String | If        | City.                      |
    | `affiliation.beneficiary.location.state`               | String | If        | Department or region.      |
    | `affiliation.beneficiary.location.country`             | String | If        | Country.                   |
  </Accordion>

  <Accordion title="Card details">
    | Field                               | Type   | Mandatory | Description                                                                                       |
    | ----------------------------------- | ------ | --------- | ------------------------------------------------------------------------------------------------- |
    | `affiliation.card.token`            | String | If        | Token from the affiliated card.                                                                   |
    | `affiliation.card.brand`            | String | If        | Card name. Ej.: VISA, MSCD.                                                                       |
    | `affiliation.card.bin`              | String | If        | BIN from the card.                                                                                |
    | `affiliation.card.last_pan`         | String | If        | Last 4 digits of the card.                                                                        |
    | `affiliation.card.issuer_name`      | String | NO        | Name of the card issuer.                                                                          |
    | `affiliation.card.card_holder_name` | String | If        | Name of the card holder.                                                                          |
    | `meta.status.code`                  | String | If        | Code of technical result of processing. It does not apply if a payment was authorized or refused. |
    | `meta.status.message_ilgn[].locale` | String | If        | Language of response message.                                                                     |
    | `meta.status.message_ilgn[].value`  | String | If        | A description of the result.                                                                      |
  </Accordion>
</AccordionGroup>
