alt

Important information

The API reference is now available here.
The deprecated API reference is available here.

Unzer

Accept card with UI components

Use Unzer UI component to add Unzer Card payment to your checkout page.

Overview

Using UI components for Credit Card and Debit Card, you get a ready-made form with the fields necessary to make this type of payment. You can check a demo version of the component here. Basic steps for integrating using UI components are the same for all payment methods, and you can read about them here.

Before you begin

Step 1: Add UI components to your payment page
client side

First, you need to initiate our UI components library and add the payment form to your payment page.

Initiate UI component

Load our JS script and CSS stylesheet

Include Unzer’s script and stylesheet on your website.

Always load the script and stylesheet directly from Unzer:

<link rel="stylesheet" href="https://static.unzer.com/v1/unzer.css" />
<script type="text/javascript" src="https://static.unzer.com/v1/unzer.js"></script>
icon
Faster load time
To make your website load faster, insert JavaScript scripts at the bottom of your HTML document.
icon
Importing Unzer styles
To minimize the risk of Unzer styles affecting the styles of your webpage, we suggest putting unzer.css on top of other imported CSS files.

Create an Unzer instance

Create an unzer instance with your public key:

// Creating an unzer instance with your public key
var unzerInstance = new unzer('s-pub-xxxxxxxxxx');
icon
Placeholder keys
In the previous example, we used a placeholder API key for example purposes. You should replace it with your public key.

Localization and languages

We support localization with locale option parameters. Check the Localization page for a list of all the supported locales.

The auto option (applied by default) uses the client’s browser language.

Here you can see how to set the language, in our case ‘de-DE’ - to do so, add a comma separated parameter to your unzer instance:

// Creating an unzer instance with your public key
var unzerInstance = new unzer('s-pub-xxxxxxxxxx', {locale: 'de-DE'});

Implement the payment form

To securely collect payment data from your customer, you need to create a payment form with empty DOM elements and unique IDs within them. That way unzer.js will know where to place its UI components. 3DS2.x requires an email to be sent to our payment system for a card payment. So, if you choose not to use the optional form with the email field, you need to send the customers email via a customer resource to our system to charge a card.

Default form

This is the default form with the fields required for a card payment.

<form id="payment-form" class="unzerUI form" novalidate>
  <div class="field">
    <div id="card-element-id-number" class="unzerInput">
        <!-- Card number UI Element is inserted here. -->
    </div>
  </div>
  <div class="two fields">
    <div class="field ten wide">
      <div id="card-element-id-expiry" class="unzerInput">
        <!-- Card expiry date UI Element is inserted here. -->
      </div>
    </div>
    <div class="field six wide">
      <div id="card-element-id-cvc" class="unzerInput">
        <!-- Card CVC UI Element is inserted here. -->
      </div>
    </div>
  </div>
  <div class="field">
    <button
      id="submit-button"
      class="unzerUI primary button fluid"
      type="submit">
      Pay
    </button>
  </div>
</form>

Lightweight form

If you want to style the form by yourself you can use the lightweight form.

<form id="payment-form" class="unzerInput form" novalidate>
  <div id="card-element-id-number">
    <!-- Card number UI Element is inserted here. -->
  </div>
  <div id="card-element-id-expiry">
    <!-- Card expiry date UI Element is inserted here. -->
  </div>
  <div id="card-element-id-cvc">
    <!-- Card CVC UI Element is inserted here. -->
  </div>
  <button id="submit-button" type="submit">Pay</button>
</form>

Optional: Form with cardholder name

This is the default form with an added card holder field. Adding a card holder field will improve the credit rating of the buyer and thus the conversion rate.

<form id="payment-form" class="unzerInput form" novalidate>
  <div class="field">
    <div id="card-element-id-number" class="unzerInput">
        <!-- Card number UI Element is inserted here. -->
    </div>
  </div>
  <div class="two fields">
    <div class="field ten wide">
      <div id="card-element-id-expiry" class="unzerInput">
        <!-- Card expiry date UI Element is inserted here. -->
      </div>
    </div>
    <div class="field six wide">
      <div id="card-element-id-cvc" class="unzerInput">
        <!-- Card CVC UI Element is inserted here. -->
      </div>
    </div>
  </div>
  <div class="field">
    <div id="card-element-id-holder" class="unzerInput">
      <!-- Card holder UI Element is inserted here. -->
    </div>
  </div>

  <div class="field">
    <button
      id="submit-button"
      class="unzerUI primary button fluid"
      type="submit">
      Pay
    </button>
  </div>
</form>

Optional: Form with email field

This the default form with an added email field.

icon
Email of the card holder is required by the 3DS regulatory standards You can either add an email field to your form or send a customer resource containing the email with the transaction in Step 2. We recommend the latter.
<form id="payment-form" class="unzerUI form" novalidate>
  <div class="field">
    <div id="card-element-id-number" class="unzerInput">
        <!-- Card number UI Element is inserted here. -->
    </div>
  </div>
  <div class="two fields">
    <div class="field ten wide">
      <div id="card-element-id-expiry" class="unzerInput">
        <!-- Card expiry date UI Element is inserted here. -->
      </div>
    </div>
    <div class="field six wide">
      <div id="card-element-id-cvc" class="unzerInput">
        <!-- Card CVC UI Element is inserted here. -->
      </div>
    </div>
  </div>
  <div class="field">
    <div id="example-cardemail-email" class="unzerInput">
        <!-- Card E-Mail UI Element is inserted here. -->
    </div>
  </div>
  <div class="field">
    <button
      id="submit-button"
      class="unzerUI primary button fluid"
      type="submit">
      Pay
    </button>
  </div>
</form>

Create a Payment Type resource

Call the method unzerInstance.card() to create an instance of the payment type card.


// Creating an Card instance
var card = unzerInstance.Card();

// Rendering input field card number
card.create('number', {
    containerId: 'card-element-id-number',
    onlyIframe: false
});

// Rendering input field card expiry
card.create('expiry', {
    containerId: 'card-element-id-expiry',
    onlyIframe: false
});

// Rendering input field card cvc
card.create('cvc', {
    containerId: 'card-element-id-cvc',
    onlyIframe: false
});

// Optional: Rendering the field e-mail
card.create('email', {
    containerId: 'example-cardemail-email',
    onlyIframe: false,
});

Add an event listener for “submit” of the form. Inside, create a Promise on the Card object. The Promise gets either resolved or rejected:

let form = document.getElementById('payment-form');
form.addEventListener('submit', function(event) {
    event.preventDefault();

    card.createResource()
        .then(function(result) {
            // Submit the id of the created payment type to your
            // backend to perform the payment transaction with it.
            typeId = result.id;
        })
        .catch(function(error) {
            // handle errors
            document.getElementById('error-holder').innerText = error.customerMessage || error.message || 'Error'
        })
});

Optional: Customize UI components

You can easily customize the font of the forms by changing the options within the create method. Here you can set the following styles: fontSize, fontColor, and fontFamily.

card.create('number', {
    containerId: 'card-element-id-number',
    onlyIframe: false,
    fontSize: '16px',
    fontColor: 'lightgrey',
    fontFamily: 'Arial, Helvetica, sans-serif'
});

Step 2: Make a payment
server side

Charge or Authorize

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

  • Option 1: Charge the card directly
  • Option 2: Authorize an amount and charge the card later

Option 1: Charge the card directly

To charge the card directly, make a charge transaction with the card resource that you created in the front end. With a successful charge transaction, money is transferred from the customer to the merchant and a payment resource is created.

POST https://api.unzer.com/v1/payments/charges
   
Body:
{
  "amount" : "20",
  "currency": "EUR",
  "returnUrl": "https://www.my-shop-url.de/returnhandler",
  "resources" : {
    "typeId" : "s-crd-jldsmlmiprwe"
  }
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$card = $unzer->fetchPaymentType('s-crd-0ajzmaxcuvhc');
$charge = $card->charge(20.0, 'EUR', 'https://www.my-shop-url.de/returnhandler');
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Charge charge = unzer.charge(new BigDecimal("100.0"), Currency.getInstance("EUR"), "s-crd-0ajzmaxcuvhc", new URL("https://www.my-shop-url.de/returnhandler"));

The response looks similar to the following example:

{
    "id": "s-chg-1",
    "isSuccess": false,
    "isPending": true,
    "isError": false,
    "redirectUrl": "https://stg-payment.unzer.com/v1/redirect/crd/s-sGYdGywWpxzW",
    "message": {
        "code": "COR.000.100.112",
        "merchant": "Request successfully processed in 'Merchant in Connector Test Mode'",
        "customer": "Your payments have been successfully processed in sandbox mode."
    },
    "amount": "20.0000",
    "currency": "EUR",
    "returnUrl": "https://www.my-shop-url.de/returnhandler",
    "date": "2021-05-10 00:51:03",
    "resources": {
        "paymentId": "s-pay-131937",
        "traceId": "70ddf3152a798c554d9751a6d77812ae",
        "typeId": "s-crd-jldsmlmiprwe"
    },
    "paymentReference": "",
    "processing": {
        "uniqueId": "31HA07BC8157BD2BC04D483EFA914465",
        "shortId": "4845.3426.1987",
        "traceId": "70ddf3152a798c554d9751a6d77812ae"
    }
}

For a full description of the charge transaction, refer to the relevant server-side integration documentation page: Charge a payment (direct API calls), Charge a payment (PHP SDK), Charge a payment (Java SDK).

Option 2: Authorize and then charge the card

To authorize an amount, make an authorize transaction with the card resource that you created in the frontend. With a successful authorize transaction, money is reserved on the customer account and a Payment resource is created.

POST https://api.heidelpay.com/v1/payments/authorize


 Body:
{
  "amount" : "20",
  "currency": "EUR",
  "returnUrl": "https://www.my-shop-url.de/returnhandler",
  "resources" : {
    "typeId" : "s-crd-jldsmlmiprwe"
  }
}
$unzer     = new UnzerSDK\Unzer('s-priv-xxxxxxxxxx');

$chargeInstance = new Charge(100.00, 'EUR', $returnUrl);
$typeId = 's-crd-jldsmlmiprwe';
$transaction = $unzer->performCharge($chargeInstance, $typeId);
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Authorization authorization = unzer.authorize(BigDecimal.valueOf(20), Currency.getInstance("EUR"), "s-crd-jldsmlmiprwe", returnUrl);

The response looks similar to the following example:

{
    "id": "s-aut-1",
    "isSuccess": true,
    "isPending": false,
    "isError": false,
    "card3ds": false,
    "redirectUrl": "",
    "message": {
        "code": "COR.000.100.112",
        "merchant": "Request successfully processed in 'Merchant in Connector Test Mode'",
        "customer": "Your payments have been successfully processed in sandbox mode."
    },
    "amount": "20.0000",
    "currency": "EUR",
    "returnUrl": "https://www.my-shop-url.de/returnhandler",
    "date": "2021-06-04 11:19:10",
    "resources": {
        "paymentId": "s-pay-8435",
        "traceId": "8ee5c53960f8b39839b70799fe224d84",
        "typeId": "s-crd-3yx6lamvu2te"
    },
    "paymentReference": "",
    "processing": {
        "uniqueId": "31HA07BC8198C2F9107E0E3536444655",
        "shortId": "4867.3194.9885",
        "traceId": "8ee5c43960f8b39839b70799fe224d84"
    }
}

For a full description of the authorize transaction please refer to relevant server-side integration documentation page: authorize a payment (direct API calls), Authorize a payment (PHP SDK), Authorize a payment (Java SDK).

To charge the authorized amount, make a charge transaction by referring to the paymentId created with the previous authorize. With a successful charge transaction money is transferred from the customer to the merchant. You can charge the specified amount either partially or fully.

POST https://api.heidelpay.com/v1/payments/s-pay-8435/charges/
   
Body:
{
    "amount": "20",
}
$unzer     = new UnzerSDK\Unzer('s-priv-xxxxxxxxxx');

$charge = new Charge(20.00);
$unzer->performChargeOnPayment('s-pay-1', $charge);
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Authorization authorization = unzer.authorize(BigDecimal.valueOf(20), Currency.getInstance("EUR"), "s-crd-jldsmlmiprwe", returnUrl);
authorization.charge(BigDecimal.valueOf(20));

The response looks similar to the following example:

{
    "id": "s-aut-1",
    "isSuccess": true,
    "isPending": false,
    "isError": false,
    "card3ds": false,
    "redirectUrl": "",
    "message": {
        "code": "COR.000.100.112",
        "merchant": "Request successfully processed in 'Merchant in Connector Test Mode'",
        "customer": "Your payments have been successfully processed in sandbox mode."
    },
    "amount": "20.0000",
    "currency": "EUR",
    "date": "2021-06-04 11:19:10",
    "resources": {
        "paymentId": "s-pay-8435",
        "traceId": "8ee5c53960f8b39839b70799fe224d84",
        "typeId": "s-crd-3yx6lamvu2te"
    },
    "paymentReference": "",
    "processing": {
        "uniqueId": "31HA07BC8198C2F9107E0E3536444655",
        "shortId": "4867.3194.9885",
        "traceId": "8ee5c43960f8b39839b70799fe224d84"
    }
}

3D Secure

It is possible that 3DS is not applied that means both of the following workflows need to be implemented:

  1. Redirect URL is returned → redirect to RedirectURL.
  2. Redirect URL is not present → ‘manual’ redirect to Return URL to handle the result of the Transaction.

If 3DS challenge is applied, the charge or authorize call returns a redirectUrl. Use this URL to forward the customer to their bank’s 3DS page. The customer enters their credentials on the page and confirms the transaction. After this, they are forwarded to the returnUrl, which is part of the initial transaction request.

If 3DS challenge is not applied, the charge or authorize call won’t return a redirectUrl.
Redirect

To learn more about 3D Secure and to see a full description of the checkout flow with 3-D Secure, please check 3D Secure page.

Step 3: Check status of the payment
server side

Once the customer is redirected to the returnUrl, you can fetch the payment details from the API, by using the resources.paymentId from the Charge response above to handle the payment according to its status. If the status of the payment is completed, the payment process has been finished successfully and can be considered as paid. Check all possible payment states here.

GET https://api.unzer.com/v1/payments/{payment_ID}

{
    "id": "s-pay-131937",
    "state": {
        "id": 1,
        "name": "completed"
    },
    "amount": {
        "total": "20.0000",
        "charged": "20.0000",
        "canceled": "0.0000",
        "remaining": "0.0000"
    },
    "currency": "EUR",
    "orderId": "",
    "invoiceId": "",
    "resources": {
        "customerId": "",
        "paymentId": "s-pay-131937",
        "basketId": "",
        "metadataId": "",
        "payPageId": "",
        "traceId": "70ddf3152a798c554d9751a6d77812ae",
        "typeId": "s-crd-grpucjmy5zrk"
    },
    "transactions": [
        {
            "date": "2021-05-10 00:51:03",
            "type": "charge",
            "status": "success",
            "url": "https://api.unzer.com/v1/payments/s-pay-131937/charges/s-chg-1",
            "amount": "20.0000"
        }
    ]
}

Notifications

We recommend subscribing to the payment event to receive notifications about any changes to the payment resource. As soon as the event is triggered you should fetch the payment and update the order status in your shop according to its status.

  {
    "event":"payment.pending",
    "publicKey":"s-pub-xxxxxxxxxx",
    "retrieveUrl":"https://api.unzer.com/v1/payments/s-pay-774",
    "paymentId":"s-pay-774"
  }

For more details on implementing webhooks to receive notifications, see Notifications page.

Step 4: Display the payment result
client side

Use the information from the Check status of the payment step to display the payment result to your customer.
This can be the success or error page of your shop. If something went wrong, you can use the client message from the API response and show it to the customer.

Manage payment
server side

After the successful charge or authorize transaction, you can perform additional operations on the payment resource. Below you can see the most important cases for the Card payment type. For a full reference of managing payments please refer to the relevant Server-side integration documentation page: Manage API resources (direct API calls), Manage API resources (PHP SDK), Manage API resources (Java SDK).

Cancel after authorization (Reversal)

Release the reserved money for the customer’s payment method. It is also possible to perform multiple cancellations for an authorization with partial amounts.

POST https://api.unzer.com/v1/payments/s-pay-1/authorize/cancels

{
  "amount" : "10.00"
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$payment = $unzer->fetchPayment('s-pay-1');
$unzer->cancelAuthorizationByPayment($payment, 10.00);

The response looks similar to the following example:

Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Authorization authorization = unzer.fetchAuthorization('s-pay-1');
Cancel cancel = authorization.cancel();

Cancel after charge (Refund)

You can refund up to the amount of the received payment. To do this you have to make a Cancel transaction on the Charge transaction.

POST https://api.unzer.com/v1/payments/s-pay-1/charges/s-chg-1/cancels
{
  "amount" : "12.450",
  "paymentReference": "Test cancel transaction"
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$charge = $unzer->fetchChargeById('s-pay-1', 's-chg-1');
$cancel = $charge->cancel();
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Cancel cancel = unzer.cancelCharge("s-pay-1", "s-chg-1");

Charge after Authorize

You can charge amounts up to the authorized amount with one or more Charge transactions. This is usually the amount from the Authorize transaction, but it can change for example if a reversal is done.

POST https://api.unzer.com/v1/payments/s-pay-188789/charges

{
  "amount" : "12.450",
  "paymentReference": "Test cancel transaction"
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$charge = $unzer->performChargeOnPayment('s-pay-1', new Charge(10.0));
Unzer unzer = new Unzer(new HttpClientBasedRestCommunication(), "s-priv-xxxxxxxxxx");
Charge charge = unzer.chargeAuthorization("s-pay-1", new BigDecimal("50")

Card use cases

Store credentials for future usage and process recurring transactions-

To start a recurring payment with the UI component, first you have to create the payment type resource. After this, depending on the use case you want to support, follow the steps as described in the following section.

One click

One-click use cases

  • The customer is initializing a credit card payment in a web-shop and is storing their credit card credentials during the initial payment.
  • The customer is using their stored credit card credentials to initialize a subsequent payment in a web-shop or similar.

To learn more, go to the one-click payment use case page.

Recurring COF, UCOF

Recurring Use cases

  • COF/scheduled
    • The customer is initializing a subscription web-shop or similar and is directly triggering the initial payment by themselves (CIT/customer initiated transaction).
    • The merchant is triggering subsequent payments (MIT/merchant initiated transaction) for this subscription without having the customer in session.
    • Each time, the frequency and amount of the payments (mostly) are the same.

To learn more, go to the scheduled payment use case page.

  • UCOF/unscheduled
    • The customer is initializing a contract in a web-shop or similar and is directly triggering the initial payment by himself (CIT/customer initiated transaction).
    • Merchant is triggering subsequent payments (MIT/merchant initiated transaction) for this contract without having the customer in session.
    • The frequency or the amount of the payments can be different.
    • Examples:
      • Prepaid mobile phone contract, where the merchant is initializing a subsequent payment as soon as the wallet balance falls below a defined threshold.

To learn more, go the unscheduled payment use case page.

There are three types of recurrences:

  • oneclick
  • scheduled
  • unscheduled

Transaction types

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

  • Option 1: Charge the card directly
  • Option 2: Authorize an amount and charge the card later

Option 1: 1-Step - Direct Charge

To charge the card directly, make a charge transaction with the card resource that you created in the front end or directly via the Unzer API and provide the recurrenceType according to your recurring use case.

One-step

With a successful charge transaction, money is transferred from the customer to the merchant and a payment resource is created. Now you can start initializing subsequent charge transactions by referring to the initial card resource and providing the recurrenceType of the initial payment.

POST https://api.unzer.com/v1/payments/charges
   
Body:
{
  "amount" : "20",
  "currency": "EUR",
  "returnUrl": "https://www.my-shop-url.de/returnhandler",
  "resources" : {
    "typeId" : "s-crd-jldsmlmiprwe"
  },
    "additionalTransactionData": {
        "card": {
            "recurrenceType": "[oneclick, scheduled, unscheduled]"
        }
    }
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$card = $unzer->fetchPaymentType('s-crd-0ajzmaxcuvhc');
$chargeResponse = $card->charge('20.00', 'EUR', 'https://unzer.com', null, null, null, null, null, null, null, RecurrenceTypes::ONE_CLICK);
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Charge charge = unzer.charge(new BigDecimal("100.0"), Currency.getInstance("EUR"), "s-crd-0ajzmaxcuvhc", new URL("https://www.my-shop-url.de/returnhandler"), RecurrenceType.ONECLICK [ONECLICK, SCHEDULED, UNSCHEDULED]);

The response looks similar to the following example:

{
    "id": "s-chg-1",
    "isSuccess": false,
    "isPending": true,
    "isError": false,
    "redirectUrl": "https://stg-payment.unzer.com/v1/redirect/crd/s-sGYdGywWpxzW",
    "message": {
        "code": "COR.000.100.112",
        "merchant": "Request successfully processed in 'Merchant in Connector Test Mode'",
        "customer": "Your payments have been successfully processed in sandbox mode."
    },
    "amount": "20.0000",
    "currency": "EUR",
    "returnUrl": "https://www.my-shop-url.de/returnhandler",
    "date": "2021-05-10 00:51:03",
    "resources": {
        "paymentId": "s-pay-131937",
        "traceId": "70ddf3152a798c554d9751a6d77812ae",
        "typeId": "s-crd-jldsmlmiprwe"
    },
    "additionalTransactionData": {
    "card": {
        "recurrenceType": "[oneclick, scheduled, unscheduled]"
      }
    },
    "paymentReference": "",
    "processing": {
        "uniqueId": "31HA07BC8157BD2BC04D483EFA914465",
        "shortId": "4845.3426.1987",
        "traceId": "70ddf3152a798c554d9751a6d77812ae"
    }
}

Option 2: 2-Step - Authorize and then charge the card

To authorize an amount, make an Authorize transaction with the card resource that you created in the front end or directly via the Unzer API and provide the recurrenceType according to your recurring use case. With a successful Authorize transaction, money is reserved on the customer account and a Payment resource is created.

Two-step

Now you can start initializing subsequent Authorize transactions by referring to the initial card resource and providing the recurrenceType of the initial Payment.

1. Authorize the transaction
POST https://api.unzer.com/v1/payments/authorize


 Body:
{
  "amount" : "20",
  "currency": "EUR",
  "returnUrl": "https://www.my-shop-url.de/returnhandler",
  "resources" : {
    "typeId" : "s-crd-jldsmlmiprwe"
  },
  "additionalTransactionData": {
      "card": {
          "recurrenceType": "[oneclick, scheduled, unscheduled]"
      }
  }
}
$unzer = new Unzer('s-priv-xxxxxxxxx');
$authorize= $card->authorize('20.00', 'EUR', 'https://unzer.com', null, null, null, null, null, null, null, RecurrenceTypes::ONE_CLICK);
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Authorization authorization = unzer.authorize(BigDecimal.valueOf(20), Currency.getInstance("EUR"), "s-crd-jldsmlmiprwe", returnUrl, RecurrenceType.ONECLICK [ONECLICK, SCHEDULED, UNSCHEDULED]);

The response looks similar to the following example:

{
    "id": "s-aut-1",
    "isSuccess": true,
    "isPending": false,
    "isError": false,
    "card3ds": false,
    "redirectUrl": "",
    "message": {
        "code": "COR.000.100.112",
        "merchant": "Request successfully processed in 'Merchant in Connector Test Mode'",
        "customer": "Your payments have been successfully processed in sandbox mode."
    },
    "amount": "20.0000",
    "currency": "EUR",
    "returnUrl": "https://www.my-shop-url.de/returnhandler",
    "date": "2021-06-04 11:19:10",
    "resources": {
        "paymentId": "s-pay-8435",
        "traceId": "8ee5c53960f8b39839b70799fe224d84",
        "typeId": "s-crd-3yx6lamvu2te"
    },
    "additionalTransactionData": {
      "card": {
        "recurrenceType": "[oneclick, scheduled, unscheduled]"
      }
    },
    "paymentReference": "",
    "processing": {
        "uniqueId": "31HA07BC8198C2F9107E0E3536444655",
        "shortId": "4867.3194.9885",
        "traceId": "8ee5c43960f8b39839b70799fe224d84"
    }
}
2. Charge transaction

To charge the authorized amount, make a Charge transaction by referring to the paymentId created with the previous Authorize. With a successful Charge transaction money is transferred from the customer to the merchant. You can charge the specified amount either partially or fully.

POST https://api.unzer.com/v1/payments/s-pay-8435/charges/
   
Body:
{
    "amount": "20",
}
$unzer     = new UnzerSDK\Unzer('s-priv-xxxxxxxxxx');
$charge = $unzer->performChargeOnPayment('s-pay-1', new Charge(20));
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Authorization authorization = unzer.authorize(BigDecimal.valueOf(20), Currency.getInstance("EUR"), "s-crd-jldsmlmiprwe", returnUrl);
authorization.charge(BigDecimal.valueOf(20));

The response looks similar to the following example:

{
    "id": "s-aut-1",
    "isSuccess": true,
    "isPending": false,
    "isError": false,
    "card3ds": false,
    "redirectUrl": "",
    "message": {
        "code": "COR.000.100.112",
        "merchant": "Request successfully processed in 'Merchant in Connector Test Mode'",
        "customer": "Your payments have been successfully processed in sandbox mode."
    },
    "amount": "20.0000",
    "currency": "EUR",
    "date": "2021-06-04 11:19:10",
    "resources": {
        "paymentId": "s-pay-8435",
        "traceId": "8ee5c53960f8b39839b70799fe224d84",
        "typeId": "s-crd-3yx6lamvu2te"
    },
    "paymentReference": "",
    "processing": {
        "uniqueId": "31HA07BC8198C2F9107E0E3536444655",
        "shortId": "4867.3194.9885",
        "traceId": "8ee5c43960f8b39839b70799fe224d84"
    }
}

Chargeback

A negative booking on the merchant’s account, which is generally triggered by a return of a charge transaction by the customer or customer’s bank.

Payout

You can use payout to send money to your customer without any reference to previous transactions. Possible use cases for this transaction could be paying out sellers on your marketplace, online gaming, lottery wins, and so on.

To learn more about payouts, see Create a payout

Low Value Exemptions

Transactions less than or equal to 30€ can qualify for a low value exemption, which means that Strong Customer Authentication (SCA) and therefore a 3DS challenge can be skipped. This can happen up to 5 times in a row or for a maximum amount of 150€. If the amount gets exceeded a so called soft-decline happens and the customer is presented with the usual 3DS flow. After a card resource is created the lvp exemption type can be passed as part of additional transaction data for an authorization or a charge.

Option 1: Authorize

POST https://api.unzer.com/v1/payments/authorize

 Body:
{
  "amount" : "20",
  "currency": "EUR",
  "returnUrl": "https://www.my-shop-url.de/returnhandler",
  "resources" : {
    "typeId" : "s-crd-jldsmlmiprwe"
  },
  "additionalTransactionData": {
      "card": {
          "exemptionType": "lvp"
      }
  }
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');

$cardData = (new \UnzerSDK\Resources\EmbeddedResources\CardTransactionData())
    ->setExemptionType(\UnzerSDK\Constants\ExemptionType::LOW_VALUE_PAYMENT);

$authorize = (new Authorization(20))
    ->setCardTransactionData($cardData);
$typeId = 's-crd-9wmri5mdlqps';
$unzer->performAuthorization($authorize, $typeId);
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Authorization authorization = unzer.authorize(
        (Authorization) new Authorization()
            .setTypeId(card.getId())
            .setReturnUrl(new URL("https://www.my-shop-url.de/returnhandler"))
            .setAmount(new BigDecimal("20.00"))
            .setCurrency(Currency.getInstance("EUR"))
            .setAdditionalTransactionData(
                  new AdditionalTransactionData()
                    .setCard(
                        new CardTransactionData()
                            .setExemptionType(CardTransactionData.ExemptionType.LVP)
                  )
            )
        );

The response looks similar to the following example:

{
  "id": "s-aut-1",
  "isSuccess": true,
  "isPending": false,
  "isResumed": false,
  "isError": false,
  "card3ds": false,
  "redirectUrl": "",
  "message": {
    "code": "COR.000.100.112",
    "merchant": "Request successfully processed in 'Merchant in Connector Test Mode'",
    "customer": "Your payments have been successfully processed in sandbox mode."
  },
  "amount": "20.0000",
  "currency": "EUR",
  "returnUrl": "https://www.my-shop-url.de/returnhandler",
  "date": "2023-02-24 11:49:01",
  "resources": {
    "paymentId": "s-pay-300873",
    "traceId": "3c16318bb57d7f07224ea7aa8f8c7190",
    "typeId": "s-crd-4ullzge0zawk"
  },
  "additionalTransactionData": {
    "card": {
      "exemptionType": "lvp"
    }
  },
  "paymentReference": "",
  "processing": {
    "uniqueId": "31HA07BC8199ADDE98141B2AA4B38840",
    "shortId": "5411.6574.0831",
    "traceId": "3c16318bb57d7f07224ea7aa8f8c7190"
  }
}

Now you can charge the authorization as described in manage payment section.

Option 2: Direct charge

POST https://api.unzer.com/v1/payments/charges

 Body:
{
  "amount" : "20",
  "currency": "EUR",
  "returnUrl": "https://www.my-shop-url.de/returnhandler",
  "resources" : {
    "typeId" : "s-crd-jldsmlmiprwe"
  },
  "additionalTransactionData": {
      "card": {
          "exemptionType": "lvp"
      }
  }
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');

$cardData = (new \UnzerSDK\Resources\EmbeddedResources\CardTransactionData())
    ->setExemptionType(\UnzerSDK\Constants\ExemptionType::LOW_VALUE_PAYMENT);

$charge = (new Charge())
    ->setCardTransactionData($cardData);
$typeId = 's-crd-9wmri5mdlqps';
$unzer->performCharge($charge, $typeId);
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Charge charge = unzer.charge(
        (Charge) new Charge()
            .setTypeId(card.getId())
            .setReturnUrl(new URL("https://www.my-shop-url.de/returnhandler"))
            .setAmount(new BigDecimal("20.00"))
            .setCurrency(Currency.getInstance("EUR"))
            .setAdditionalTransactionData(
                  new AdditionalTransactionData()
                    .setCard(
                        new CardTransactionData()
                            .setExemptionType(CardTransactionData.ExemptionType.LVP)
                  )
            )
        );

The response looks similar to the following example:

{
    "id": "s-chg-1",
    "isSuccess": true,
    "isPending": false,
    "isResumed": false,
    "isError": false,
    "card3ds": false,
    "redirectUrl": "",
    "message": {
        "code": "COR.000.100.112",
        "merchant": "Request successfully processed in 'Merchant in Connector Test Mode'",
        "customer": "Your payments have been successfully processed in sandbox mode."
    },
    "amount": "20.0000",
    "currency": "EUR",
    "returnUrl": "https://www.my-shop-url.de/returnhandler",
    "date": "2023-02-24 11:51:16",
    "resources": {
        "paymentId": "s-pay-300874",
        "traceId": "36ff71f1e4d3aa9828a04b2e0ff4f49e",
        "typeId": "s-crd-uqunzgwcxhni"
    },
    "additionalTransactionData": {
        "card": {
            "exemptionType": "lvp"
        }
    },
    "paymentReference": "",
    "processing": {
        "uniqueId": "31HA07BC8199ADDE98144252701CEAE4",
        "shortId": "5411.6587.5895",
        "traceId": "36ff71f1e4d3aa9828a04b2e0ff4f49e"
    }
}

Notifications

We recommend subscribing to the payment event to receive notifications about any changes to the payment resource. As soon as the event is triggered you should fetch the payment and update the order status in your shop according to its status.

  {
    "event":"payment.pending",
    "publicKey":"s-pub-xxxxxxxxxx",
    "retrieveUrl":"https://api.unzer.com/v1/payments/s-pay-774",
    "paymentId":"s-pay-774"
  }

For more details on implementing webhooks to receive notifications, see Notifications page.

Error handling

All requests to the API can result in an error that should be handled. Refer to the Error handling guide to learn more about Unzer API (and other) errors and handling them.

Test & go live

You should always test your integration before going live. First perform test transactions using test data. Next, check against Integration checklist and Go-live checklist to make sure the integration is complete and you’re ready to go live.

See also