Charge your customer

Charge your customer either directly or after authorization.

About charging

You can charge an amount on your customer’s account, and the payment will be transferred to your account.

You can charge a payment in two different ways:

  • Option 1: Charge your customer directly
  • Option 2: Authorize an amount and then charge your customer

Supported payment methods

The following payment methods support direct charge:

The following payment methods support charge after authorization:

Charge your customer

To charge your customer, follow the steps below.

Step 1: Charge or Authorize an amount

After you create a charge resource, you have two options:

  • Option 1: Charge your customer directly
  • Option 2: Authorize an amount and then charge your customer

Option 1: Charge your customer directly

To charge your customer, make a payments/charges POST call with the following parameters in the request body:

Parameter Required Type Default Description Example
amount Yes Number / The transaction amount. 50
currency Yes Number / The authorization currency, in the ISO 4217 alpha-3 format. EUR
returnUrl Yes String / Required for redirect payments and credit card payments if 3-D Secure is used. https://www.unzer.com
customerId No String / The ID of the customers resource to be used.
typeId Yes String / The ID of the payment type resource to be used. s-crd-fm7tifzkqewy
POST https://api.unzer.com/v1/payments/charges
{
  "amount" : "50",
  "currency" : "EUR",
  "returnUrl" : "https://www.heidelpay.com",
  "resources" : {
    "customerId" : "",
    "typeId" : "s-crd-fm7tifzkqewy"
  }
}
{
    "id": "s-chg-1",
    "isSuccess": true,
    "isPending": false,
    "isError": false,
    "message": {
        "code": "COR.000.100.112",
        "customer": "Request successfully processed in 'Merchant in Connector Test Mode'"
    },
    "amount": "100.0000",
    "currency": "EUR",
    "returnUrl": "https://www.unzer.com",
    "paymentReference": "Test charge transaction",
    "date": "2018-09-13 21:27:16",
    "resources": {
        "customerId": "",
        "paymentId": "s-pay-2",
        "basketId": "",
        "metadataId": "",
        "typeId": "s-crd-fm7tifzkqewy"
    },
    "processing": {
        "uniqueId": "31HA07BC8179DC97ADB61081D525202A",
        "shortId": "4008.0043.6848",
        "3dsecure": false //card only
    }
}
Property Type Description
id String The charge’s unique ID.
isSuccess Boolean Set to true if the transaction was successful.
isPending Boolean Set to true if the transaction is pending
(e.g. if a redirect to an external system is required).
isError Boolean Set to true if an error occurs.
message String An error message describing the error in more detail.
code String A unique ID of the message.

For details, go to Error code structure.
customer String Message displayed to the customer.
amount Number The charged amount.
currency String The charged currency, in the ISO 4217 alpha-3 format.
returnUrl String The URL to redirect the customer to after the payment is completed.
paymentReference String Additional description of the transaction.
date String Date and time of the transaction.
customerId String The ID of the customers resource.
paymentId String The ID of the related payment resource.
basketId String The ID of the related baskets resource.
metadataId String The ID of the related metadata resource.
typeId String The ID of the related payment type resource.
uniqueId String The ID of the transaction process.
shortId String The short ID of the transaction process.
3dsecure Boolean Only for the card payment method:
if set to true, the card is configured with the 3-D Secure protocol enabled.

Option 2: Authorize an amount and then charge your customer

The money is first reserved from the customer, and then charged.

To authorize and charge your customer, complete the following steps:

  1. Make a POST call to payments/authorize.
  2. Make a POST call to payments/{orderId}/charges.

Make an authorize call

Make a POST call to payments/authorize, with the following parameters in the request body:

Parameter Required Type Default Description Example
amount Yes Float / The transaction amount. 12.23
currency Yes String / The transaction currency, in the ISO 4217 alpha-3 format. EUR
returnUrl String Yes / Needed for redirect payments and credit card payments if 3-D Secure is used. https://www.unzer.com
customerId String Yes / The ID of the customers resource to be used.
typeId String Yes / The ID of the types/card resource to be used. s-crd-fm7tifzkqewy


POST https://api.unzer.com/v1/payments/authorize
{
  "amount" : "100.00",
  "currency" : "EUR",
  "returnUrl": "https://www.unzer.com",
  "resources" : {
    "customerId" : "",
    "typeId" : "`s-crd-fm7tifzkqewy`"
  }
}

For more information on authorization, go to Authorize.

Make a charges call

There are two ways to make a charge call:

  • Without parameters.
    The full authorization amount is charged.
  • With a specific amount.
    Only the passed amount is charged.
curl https://api.unzer.com/v1/payments/s-pay-1/charges -X POST \
  -u s-priv-xxxxxxxxxx: \
  -d amount=1.00
  -d paymentReference=Test charge transaction
{
  "amount": 50,
  "paymentReference": "Test charge transaction"
}

Step 2: Check the payment status

To check the status of the payment, make a GET call to payments/{resource_ID}/charges/{transaction_ID}, with an empty request body:

GET https://api.unzer.com/v1/payments/{resource_ID}>/charges/{transaction_ID}
{
  "id": "s-chg-1",
  "isSuccess": true,
  "isPending": false,
  "isError": false,
}
Property Type Description
id String The transaction’s unique ID.
isSuccess Boolean Set to true if the transaction was successful.
isPending Boolean Set to true if the transaction is pending (e.g. if a redirect to an external system is required).
isError Boolean Set to true if an error occurs.