# Credit (CCCREDIT)

Return funds for a captured or settled authorization.

Source: https://developer.inoviopay.com/api/credit.html  
Markdown: https://developer.inoviopay.com/api/credit.md

Merchants may request to return funds for a captured authorization. Merchants may only credit transactions that have been captured or settled.

**POST** `https://api.inoviopay.com/payment/pmt_service.cfm`

### Request Parameters

| Parameter | Description |
|---|---|
| `REQUEST_ACTION` (required) | Must be set to `CCCREDIT`. |
| `REQUEST_REF_PO_ID` (required) | Reference Order ID (`PO_ID`) of the original transaction. |
| `LI_VALUE_1` (required) | Amount to credit. The amount may not exceed the original authorization's total amount. |

### Handling the Response

When processing a refund, monitor the response to confirm the credit was applied to the original order successfully.

| Field Name | Description |
|---|---|
| `TRANS_STATUS_NAME` | Check this to ensure the credit was `APPROVED`. |
| `TRANS_VALUE` | The approved credit amount. Note that refunds will return as a negative value (e.g., `-10.00`). |
| `TRANS_ID` | The unique Transaction ID assigned specifically to this refund event. |
| `PO_ID` | The original Purchase Order ID, linking this credit back to the initial transaction. |

**cURL**

```bash
curl -X POST "https://api.inoviopay.com/payment/pmt_service.cfm" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "request_action=CCCREDIT&req_username=api_user&req_password=P%40ssw0rd%21&site_id=12345&request_api_version=4.14&request_response_format=JSON&request_ref_po_id=18103630&li_value_1=10.00"
```

**PHP**

```php
use Inovio\Gateway\{Credentials, InovioClient};
use Inovio\Gateway\Model\Money;
use Inovio\Gateway\Refs\Refs;

$client = new InovioClient(new Credentials('api_user', 'P@ssw0rd!', '12345'), 'SANDBOX');

// You can only refund what was captured.
$refund = $client->refund(Refs::order('18103630'), Money::of('10.00', 'USD'));

echo $refund->status, "\n";
echo $refund->amount?->toWire(), "\n";   // negative on the wire

// Omit the amount to refund the full order instead:
//   $client->refund(Refs::order('18103630'));
```

**Node**

```ts
import { InovioClient, Money, Refs } from '@inovio/gateway-sdk';

const client = new InovioClient(
  { reqUsername: 'api_user', reqPassword: 'P@ssw0rd!', siteId: '12345' },
  { environment: 'SANDBOX' }
);

// You can only refund what was captured.
const refund = await client.refund(Refs.order('18103630'), Money.of('10.00', 'USD'));

console.log(refund.status);
console.log(refund.amount?.amount);   // negative on the wire

// Omit the amount to refund the full order instead:
//   await client.refund(Refs.order('18103630'));
```

**Python**

```python
from inovio_gateway import Credentials, InovioClient, Money, Refs

client = InovioClient(Credentials("api_user", "P@ssw0rd!", "12345"), environment="SANDBOX")

# You can only refund what was captured.
refund = client.refund(Refs.order("18103630"), Money.of("10.00", "USD"))

print(refund.status.value)
print(refund.amount.to_wire() if refund.amount else "-")   # negative on the wire

# Omit the amount to refund the full order instead:
#   client.refund(Refs.order("18103630"))
```

**Java**

```java
import com.inoviopay.gateway.refs.Refs;

// You can only refund what was captured.
TransactionResult refund = client.refund(Refs.order("18103630"), Money.of("10.00", "USD"));

System.out.println(refund.status());
System.out.println(refund.amount() == null ? "-" : refund.amount().toWire());   // negative on the wire

// Omit the amount to refund the full order instead:
//   client.refund(Refs.order("18103630"));
```

**Response**

```json
{
  "REQUEST_ACTION": "CCCREDIT",
  "REQ_ID": "84729103",
  "TRANS_STATUS_NAME": "APPROVED",
  "TRANS_VALUE": -10.00,
  "CURR_CODE_ALPHA": "USD",
  "TRANS_VALUE_SETTLED": -10.00,
  "CURR_CODE_ALPHA_SETTLED": "USD",
  "TRANS_EXCH_RATE": "",
  "TRANS_ID": 3948572110,
  "CUST_ID": 7382910,
  "XTL_CUST_ID": "xT883mP",
  "PO_ID": 18103630,
  "XTL_ORDER_ID": "INV-999",
  "BATCH_ID": 883922,
  "PROC_NAME": "Inovio Primary",
  "MERCH_ACCT_ID": 110203,
  "CARD_BRAND_NAME": "Visa",
  "CARD_TYPE": "VISA CLASSIC",
  "CARD_CLASS": "Consumer Debit",
  "CARD_PREPAID": 1,
  "CARD_BANK": "BOFI FEDERAL BANK",
  "CARD_COUNTRY": "USA",
  "CARD_DETAIL": "Debit",
  "CARD_BALANCE": "",
  "PMT_L4": "2921",
  "PMT_ID": 4895565,
  "PMT_ID_XTL": "",
  "PMT_AAU_UPDATE_DT": "",
  "PMT_AAU_UPDATE_DESC": "",
  "PROC_UDF01": "",
  "ANI_RESP_DECISION": "",
  "PROC_UDF02": "",
  "PROC_AUTH_RESPONSE": "REF81371",
  "PROC_RETRIEVAL_NUM": "A1B2C3D4-E5F6-7A8B-9C0D-E1F2A3B4C5D6",
  "PROC_REFERENCE_NUM": "REF755033258",
  "PROC_REDIRECT_URL": "",
  "AVS_RESPONSE": "M",
  "CVV_RESPONSE": "M",
  "CARD_BRAND_TRANSID": "",
  "REQUEST_API_VERSION": "4.14",
  "P3DS_VENDOR": "",
  "P3DS_RESPONSE": "",
  "PO_LI_ID_1": "9928174",
  "PO_LI_COUNT_1": 1,
  "PO_LI_AMOUNT_1": -10.00,
  "PO_LI_PROD_ID_1": "111205",
  "MBSHP_ID_1": "",
  "TRANS_NTOKEN_USED": 0
}
```
