Skip to content

    How to refund a payment

    This article describes how to perform a refund of PayPal payment via curl. Refunds can only be applied on refund or capture transactions with the status SUCCESS.

    Request body

    We start with the body of the request:

    Request body

    {
      "initialAmount": 100,
      "currency": "EUR"
    }
    ParameterMandatoryDescription
    initialAmountmandatoryAmount as smallest currency unit e.g 100€ will be the result of `amount = 10000`
    currencymandatoryCurrency code according to ISO 4217

    Find more information in our API reference.

    Send request via curl

    With the body ready we can now send the request via curl.

    Curl - Request. Line breaks for readability

    curl \
    --user MerchantID:APIKey \
    -H "Content-Type: application/json" \
    -X POST \

    curl command - descriptions

    We will now touch on every part of this command.

    --user MerchantID:APIKey Curl Option for HTTP basic access authentication.

    -H "Content-Type: application/json" content-type header "application/json" for our API.

    -X POST We want the request to be a HTTP POST.

    -d '{"initialAmount": 100,"currency": "EUR"}' The body for our request in JSON format.

    https://apitest.payengine.de/v1/orders/{orderId}/transactions/{transactionId}/refund/ The transactions refund endpoint of our API (Test in this case).

    Prequisites need to be fullfilled for a successful refund transaction:

    • Refunds can only be applied to successful (status: SUCCESS) debit or capture transactions

    • We need the orderId, the orderId will be returned upon a successful debit or capture

    • We need the transactionId, the orderId will be returned upon a successful debit or capture

    curl command - response

    If the request was successful we should get a response that looks like this:

    response

    {
        "createdAt": 1502096296617,
        "modifiedAt": 1502096298619,
        "type": "REFUND",

    Find more information in our API reference.

    Was this helpful?

    What was your feeling about it?