Why does AlphaCommerceHub respond `1015` / «Transaction not allowed» / «The partial refund amount must be less than or equal to the remaining amount.» to a PayPal's `RefundPayment` API request even if the refund amount is less than the captured amount?

@gallaron

1. Request

1.1. Body

{
    "Header": {
        "MerchantID": "ANTERIOR001",
        "TransactionType": "RefundPayment",
        "UserID": "<...>",
        "Version": "2"
    },
    "Transaction": {
        "Amount": "1000",
        "Currency": "AUD",
        "MerchantTxnID": "1208L.775",
        "Method": "PP"
    }
}

1.2. Headers

Request: POST / HTTP/1.1
Accept-encoding: gzip, deflate
Connection: close
Content-Length: 296
Content-Type: application/json
Host: hubapiuat.alphacommercehub.com.au
User-Agent: Mage2.PRO

2. Response

{
    "Banks": null,
    "Country": null,
    "DocumentResults": null,
    "EmailChecks": null,
    "FraudChecks": null,
    "GeoChecks": null,
    "ProviderResps": {
        "ProviderResp": [
            {
                "ProviderName": "Paypal",
                "ProviderOrder": "1",
                "ProviderResponse": "10009",
                "ProviderResponseMessage": "Transaction refused. The partial refund amount must be less than or equal to the remaining amount."
            }
        ]
    },
    "Result": {
        "custom1": null,
        "custom2": null,
        "custom3": null,
        "custom4": null,
        "custom5": null,
        "MerchantID": "ANTERIOR001",
        "MerchantTxnID": "1208L.775",
        "ResponseCode": "1015",
        "ResponseMessage": "Transaction not allowed",
        "ResponseTimestamp": "12122017070802"
    },
    "ShippingService": null,
    "TaxResultLines": null
}

See also:

I have got a response from AlphaCommerceHub:

This response is coming from PayPal. We need to check the logs.

Can you try transactions in USD or EUR. We get some strange behaviour from the PayPal test system in AUD on refunds but works normally on other currencies