alt

Important information

Please be advised that there will be a scheduled downtime across our API network on November 05 and November 07, 2024. For more information, visit our platform status portal.:
- Scheduled maintenance on November 5, 2024
- Scheduled maintenance on November 7, 2024

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. 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">
    <div id="card-element-id-holder" class="unzerInput">
        <!-- Cardholder 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>

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>
  <div id="card-element-id-holder">
    <!-- Cardholder UI Element is inserted here. -->
  </div>
  <button id="submit-button" type="submit">Pay</button>
</form>

Form with email field

This the default form with an email field.

icon
  • Email of the cardholder 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.
  • 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 that you send the customer resource with the email. To learn more about the customer resource, see Manage customers.
<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="card-element-id-holder" class="unzerInput">
        <!-- Cardholder UI Element is inserted here. -->
    </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. 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://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.unzer.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');

$authorization = (new Authorization(20.0, 'EUR', 'https://www.my-shop-url.de/returnhandler'));
$typeId = 's-crd-3qujdbdjas5w';

$unzer->performAuthorization($authorization, $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.unzer.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-chg-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 (see Here) , 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.

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. Currently, it is not possible to have multiple partial cancellations.


POST https://api.unzer.com/v1/payments/s-pay-1/authorize/cancels
{
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$payment = $unzer->fetchPayment('s-pay-1');
$unzer->cancelAuthorizationByPayment($payment, 20.00);
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Authorization authorization = unzer.fetchAuthorization('s-pay-1');
Cancel cancel = authorization.cancel();

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" : "20.00",
  "paymentReference": "Test charge transaction"
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$charge = $unzer->performChargeOnPayment('s-pay-1', new Charge(20.00));
Unzer unzer = new Unzer(new HttpClientBasedRestCommunication(), "s-priv-xxxxxxxxxx");
Charge charge = unzer.chargeAuthorization("s-pay-1", new BigDecimal("20.00")

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" : "20.00",
  "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");

Card use cases

Store credentials for future usage and process recurring transactions

To start a recurring payment with the UI components, 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 card payment in a web-shop and is storing their card credentials during the initial payment.
  • The customer is using their stored 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://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, or lottery wins.

To learn more about payouts, see Create a payout

TRA/SCP/LVP

To learn more about various options that are out of the scope of SCA, go to

Example for Low Value Exemption (LVP, TRA, SCP, NO_EXEMPTION)

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"
          // To set more exemption types. you can put them as a comma sepatarated string.
          // "exemptionType": "lvp, scp, tra, no_exemption"
      }
  }
}
$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