# Authorize Charge

Authorize already created charge on a debit card

```
POST {{ BASE_URL }}/v1/corporate/authorize-charge
```

#### Body Parameters

<table><thead><tr><th width="193">Property</th><th width="114">Data Type</th><th width="445">Description</th><th width="184">Example</th><th width="198">Required</th></tr></thead><tbody><tr><td>type</td><td>string</td><td>Type of authorization. Check <a href="https://docs.terraswitching.com/api-endpoints/collections/charge/authorize-charge#authorization-types">below</a> for list of types</td><td>"pin"</td><td>Yes</td></tr><tr><td>reference</td><td>string</td><td>Transaction reference returned in <a href="https://docs.terraswitching.com/api-endpoints/collections/charge/create-charge">charge api</a></td><td>"23456789876CBD"</td><td>No</td></tr><tr><td>deviceIp</td><td>string</td><td>IP address of the customer's device or your device</td><td>"192.168.206.32"</td><td>Yes</td></tr><tr><td></td><td></td><td></td><td></td><td></td></tr><tr><td>authorize</td><td>object</td><td>The object that holds authorize properties</td><td>{...}</td><td>Yes</td></tr><tr><td>authorize.pin</td><td>string</td><td>Debit card pin</td><td>"1111"</td><td>If <code>type</code> is pin</td></tr><tr><td>authorize.otp</td><td>string</td><td>OTP sent to customer</td><td>"037895"</td><td>If <code>type</code> is otp</td></tr><tr><td>authorize.phone</td><td>string</td><td>Customer's phone number</td><td>"08137031202"</td><td>If <code>type</code> is phone</td></tr><tr><td>authorize.birthday</td><td>string</td><td>Customer birthday</td><td>"1992-01-12"</td><td>If <code>type</code> is birthday</td></tr></tbody></table>

{% tabs %}
{% tab title="Node.js" %}
{% code lineNumbers="true" %}

```javascript
import Axios from 'axios';

// set the api url
const API_URL = `${BASE_URL}/v1/corporate/authorize-charge`;

// define request body
const data = {
    type: "pin",
    reference: "TSX64D469F547F04752",
    deviceIp: "",
    authorize: {
      pin: "1111",
      otp: "",
      phone: "",
      birthday: "",
      address: {
        city: "",
        state: "",
        zipCode: "",
        address: ""
      }
    }
}

// make request using axios
Axios({
    method: "POST",
    url: `${API_URL}`,
    headers: {
        lg: 'en',
        ch: 'web'
        Authorization: `Bearer ${API_KEY}`,
        'Content-Type': 'application/json',
    },
    data: data
}).then((resp) => {
    console.log(resp)
}).catch((err) => {
    console.log(err)
})
```

{% endcode %}
{% endtab %}

{% tab title="Response . 200 Ok" %}
{% code lineNumbers="true" %}

```javascript
{
  error: false,
  errors: [],
  data: {
    status: "successful",
    type: "credit",
    domain: "test",
    reference: "TSXFD77BA471CD84E82",
    merchantRef: "",
    amount: 20,
    fee: 0.2,
    vat: 0.015,
    feature: "payment-link",
    ipAddress: "",
    currency: "NGN",
    description: "incoming payment of NGN20 to Gnik Digitals Limited via payment link",
    vasData: {
      ref: "",
      type: "",
      network: "",
      phoneNumber: "",
      billerCode: "",
      billerName: "",
      hasToken: false,
      token: ""
    },
    metadata: [
      {
        staffId: "002RTOPG",
        department: "engineering"
      }
    ],
    bank: {
      name: "",
      accountName: "",
      accountNo: "",
      bankCode: ""
    },
    customer: {
      firstName: "Oluwatobi",
      lastName: "Immanuel",
      email: "emmabidem@gmail.com",
      phoneNumber: "08137031202",
      phoneCode: "+234",
      city: "",
      state: "",
      accountNo: "",
      sourceAccount: ""
    },
    createdAt: "2024-06-02T01:09:15.582Z",
    updatedAt: "2024-06-02T01:09:26.876Z",
    card: {
      brand: "visa",
      cardBin: "400758",
      cardLast: "9961",
      expiryMonth: "06",
      expiryYear: "27",
      createdAt: "2024-06-01T23:46:15.036Z",
      updatedAt: "2024-06-01T23:53:21.777Z",
      authCode: "TAUTH_MY5NABBW"
    }
  },
  message: "successful",
  status: 200
}
```

{% endcode %}
{% endtab %}

{% tab title="Response . OTP Required" %}

```typescript
{
  error: false,
  errors: [],
  data: {
    nextStep: "OTP is required",
    displayText: "enter the otp sent to your phone number and/or email",
    status: "pending",
    reference: "TSXA96227AAAB93491B",
    type: "otp",
    path: "send_otp",
    url: "",
    statusCode: 206,
    metadata: {
      reference: "TSXA96227AAAB93491B",
      type: "send_otp"
    }
  },
  message: "OTP is required",
  status: 206
}
```

{% endtab %}
{% endtabs %}

### Authorization types

<table><thead><tr><th width="197">Type</th><th width="471">Description</th></tr></thead><tbody><tr><td>pin</td><td>Customer's debit card pin</td></tr><tr><td>otp</td><td>OTP sent to customer's phone/email</td></tr><tr><td>phone</td><td>Customer's phone number</td></tr><tr><td>birthday</td><td>Customer's birthday</td></tr></tbody></table>
