# Credit by Credit Card

API to credit (transfer money from merchant to customer) by credit card token.

Token can be created using the [Tokenization flow](https://docs.sensepass.com/sensepay/transaction-api/payment-flows/tokenization).

### API Interface

## Credit API

<mark style="color:green;">`POST`</mark> `https://api.sensepass.com/api/transactions/credit`

#### Request Body

| Name                                    | Type   | Description                          |
| --------------------------------------- | ------ | ------------------------------------ |
| token<mark style="color:red;">\*</mark> | string | Credit card token - Required         |
| refundAmount                            | number | The credit amount (cents) - Required |

**Authentication Request Body fields**

[See here our Authentication page](https://docs.sensepass.com/sensepay/transaction-api/authentication)

{% tabs %}
{% tab title="200: OK OK" %}
**errorCode = 0 indicating successful credit operation.**

**On error see "errorMessage" field which describes the error cause.**

```javascript
{
  "errorMessage": null,
  "errorCode": 0,
  "refundConfirmation": "063-LlgKAzfRL",
  "approvedBy": "PayPal",
  "refundBy": "PayPal",
  "dateApproval": "2019-12-19T09:47:59.105Z",
  "result": "Approved",
  "providerId": "z+n1opZ+RFn50fstklvWoOsovKIY5AUfsrVdGsO653c=",
  "transaction": {
    "TransactionNumber": "14a4334a32c852aeb0cfae52cbff1314649da7f175a8e140b35c147c",
    "date": "2019-12-19T09:47:59.105Z",
    "amount": 1234.56,
    "currency": "USD",
    "status": 0,
    "businessId": 144
  }
}
```

{% endtab %}

{% tab title="400: Bad Request Invalid Input" %}

```javascript
{
    // Response
}
```

{% endtab %}

{% tab title="500: Internal Server Error Internal Error" %}

```javascript
{
    // Response
}
```

{% endtab %}
{% endtabs %}

### Example

Basic request example to credit $1.23 using Device ID:

```json
{
  "token": "YOUR-TOKEN",
  "refundAmount": 123,
  "deviceId": "2ooeww5ufzg3nkuf8a10gu5n695yolixlbgb042o03to9bxfkr7t815i5epu8o58jv1rznif3o1tr6xsb1rm"
}
```

Basic request example to credit $100.01 using Location API Key or Merchant API key:

```json
{
  "token": "YOUR-TOKEN",
  "refundAmount": 10001,
  "apiKey": "2ooeww5ufzg3nkuf8a10gu5n695yolixlbgb042o038o58jv1rznif3o1tr6xsb1rm"
}
```

### Flow Chart

[See our payment flow chart here](https://docs.sensepass.com/sensepay/transaction-api/flow-charts/payment-flow)

### Transaction Status Flow

[See our transaction status flow here](https://docs.sensepass.com/sensepay/transaction-api/flow-charts/transaction-status-flow)
