I am trying to refund a payment made through the terminal api, but I get the following error
code: 'REFUND_AMOUNT_INVALID',
detail: 'The requested refund amount exceeds the amount available to refund.',
category: 'REFUND_ERROR'
This is the payment
{
"payment": {
"id": "bP1GqGdh2OZtBXO8SBkeR1isuaB",
"created_at": "2023-06-30T12:23:59.887Z",
"updated_at": "2023-06-30T13:21:39.234Z",
"amount_money": {
"amount": 30,
"currency": "GBP"
},
"refunded_money": {
"amount": 30,
"currency": "GBP"
},
"status": "COMPLETED",
"source_type": "CARD",
"card_details": {
"status": "CAPTURED",
"card": {
"card_brand": "VISA",
"last_4": "----",
"exp_month": -,
"exp_year":----,
"fingerprint": "----------------------------",
"card_type": "DEBIT",
"prepaid_type": "NOT_PREPAID",
"bin": "481898"
},
"entry_method": "CONTACTLESS",
"cvv_status": "CVV_NOT_CHECKED",
"avs_status": "AVS_NOT_CHECKED",
"auth_result_code": "030437",
"application_identifier": "A0000000031010",
"application_name": "Visa DEBIT",
"application_cryptogram": "5a0cfde11381c75d",
"verification_method": "ON_DEVICE",
"verification_results": "SUCCESS",
"statement_description": "SQ *11800373",
"device_details": {
"device_id": "-------------",
"device_name": "",
"device_installation_id": "-------------------",
"device_credential": {
"token": "--------------",
"name": "Kennel Terminal"
}
},
"card_payment_timeline": {
"authorized_at": "2023-06-30T12:24:00.073Z",
"captured_at": "2023-06-30T12:24:02.754Z"
}
},
"location_id": "-----------------",
"order_id": "lOkYTYqSf8C9GZ6gn31EQUueV",
"refund_ids": [
"bP1GqGdh2OZtBXO8SBkeR1isuaB_mQTwRPufbLHFyMUyITy5S"
],
"terminal_checkout_id": "------------------",
"processing_fee": [
{
"effective_at": "2023-07-01T03:24:02.000Z",
"type": "INITIAL",
"amount_money": {
"amount": 1,
"currency": "GBP"
}
}
],
"customer_id": "-----------------",
"total_money": {
"amount": 30,
"currency": "GBP"
},
"approved_money": {
"amount": 30,
"currency": "GBP"
},
"receipt_number": "bP1G",
"receipt_url": "--------------",
"device_details": {
"device_id": "----------",
"device_name": "",
"device_installation_id": "----------------"
},
"application_details": {
"square_product": "TERMINAL_API",
"application_id": "-----------------"
},
"version_token": "UCyedsrbpL6CyPlVXaK1bq7iUlpxiayOBb4TExU1Sbz6o"
}
}
this is the refund request object
{
"idempotency_key": "1ad63ed6-537c-4079-bc88-8ad614225165",
"amount_money": {
"amount": 20,
"currency": "GBP"
},
"payment_id": "bP1GqGdh2OZtBXO8SBkeR1isuaB"
}
The amount is clearly less than the payment, so why am I getting the error?