alt

Important information

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

Unzer

Accept Unzer Installment with UI components

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

Overview

Using UI components for Unzer Installment you get a ready-made form with 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.

With Unzer Installment you need to provide information about the customer via a customer resource and the purchased products via a basket resource when you make the transaction. This is required for customer assessment and transaction approval.

icon
You must use basket v2 for Unzer Installment payment method.

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

Option 1: Implement with the customer form

If you don’t have information about the customer (and accompanying customer ID) or want to update information of an already existing customer, you can do so using the customer form. Check Customer UI component page for more information.

Insert the customer form

To use the customer form, you must insert it into your payment form. We recommend placing it above the payment elements.

<form id="example-payment-form" class="unzerUI form">
    <div id="example-customer" class="field">
      <!-- The customer form UI elements will be inserted here -->
    </div>
    <div id="example-paylater-installment">
      <!-- The payment form UI elements will be inserted here -->
    </div>
    <div id="error-holder" class="field" style="color: #d0021b">
      <!-- Errors will be inserted here -->    
    </div>
    <!-- Submit button (hidden and disabled) -->
    <button class="unzerUI primary button fluid" id="submit-button" type="submit" style="display: none" disabled>Pay</button>
</form>

Create a customer instance and render the form

A customer instance is created like any other UI component. In Order to render the customer form, you will need to call either create() or update() method.

In case you wish to initialize the form with the data of an already created customer, you need to call the initFormFields() function. This has to be done before calling update().

icon
Currently only b2c customer is supported.
// Create a customer instance
let customer = unzerInstance.Customer();

// render the customer form
customer.create({
  containerId: 'example-customer',
  paymentTypeName: 'paylater-installment'
});

// Optional event handling.
let customer = unzerInstance.Customer();

// Initialize the form and pass the ID of the customer
customer.initFormFields({
  "lastname": "Universum",
  "firstname": "Peter",
  "salutation": "mr",
  "birthDate": "1987-12-2",
  "email": "john.doe@unzer.com",
  "shippingAddress": {
    "street": "Hugo-Junkers-Str. 5",
    "state": "DE-BO",
    "zip": "60386",
    "city": "Frankfurt am Main",
    "country": "DE"
  }
});

// Optional event handling. It has to be called before the update() call

// render the customer form
customer.update('p-cst-xxxxxxxxxxxxx', {
  containerId: 'example-customer',
  paymentTypeName: 'paylater-installment'
});
icon
Note that the customer data should be presented in the same form the Unzer API returns the customer object. This includes the birth date, which is accepted in the format “yyyy-mm-dd” only.

Event handling (optional)

Optionally, you can add a custom event listener that handles the validation result of all customer and payment input fields.

icon
The event listener has to be called before the update() call.
var isValidCustomerInput = false
var isValidPaymentInput = false
customer.addEventListener('validate', function(e) {
  if (e.success) {
    isValidCustomerInput = true
    if (isValidPaymentInput) {
      // run some code (for example, enable the `pay` button)
      submitButton.removeAttribute('disabled');
    }
  } else if (e.success === false) {
    // run some code (for example, disable the `pay` button)
    submitButton.setAttribute('disabled', true);
  }
})

Option 2: Create the customer on the server side

You can also use the customer data provided by your shop system to create the customer resource on the server side. This way you can omit rendering the customer form in the front end and just create the resource and use the ID in your transaction request.

For server-side customer resource creation, you just need to render the payment type form and create a simple HTML button on the client side:

<form id="example-payment-form" class="unzerUI form">
  <div id="example-paylater-installment">
    <!-- The payment form UI elements will be inserted here -->
  </div>
  <div id="error-holder" class="field" style="color: #d0021b">
    <!-- Errors will be inserted here -->
  </div>
  <!-- Submit button (hidden and disabled) -->
  <button class="unzerUI primary button fluid" id="submit-button" type="submit" style="display: none" disabled>Pay</button>
</form>

Create the payment type resource

To create an Unzer Installment instance, call the unzerInstance.PaylaterInstallment() function. You should also call the create function to fetch the installment plans and render the Unzer Installment payment form (including the IBAN and account holder name fields), which will display the fetched installment plans.

let paylaterInstallment = unzerInstance.PaylaterInstallment();
// Render the payment form
paylaterInstallment.create({
  containerId: 'example-paylater-installment',
  amount: 500,
  currency: 'EUR',
  // country: 'AT', // Optional, default is 'DE'
})

Please make sure to pass valid parameters to the create function.

ParameterTypeDescriptionDefault value
containerId

required
StringThe HTML ID of the DOM element, where the UI component will be inserted.-
amount

required
numberTotal amount of the purchase-
currency

required
StringThe currency code of the transaction is a 3-letter code according to ISO_4217.-
countryStringThe customer’s country in ISO country code ISO 3166 ALPHA-2"DE"
threatMetrixIdStringA unique identifier for the transaction. For more details, see Add the ThreatMetrix script.
If set, the ThreatMetrix script shall be called automatically after successful payment type form rendering.
-
icon
ThreatMetrix

If you are using our UI components, you can just pass along the unique session ID (threatMetrixId), as described above. The UI components will automatically load and invoke the threatMetrix scripts for you.

If you decide to not use our ThreatMetrix integration (e.g. if you are using custom ui components), then you need to proceed as described here Add the ThreatMetrix script.

Plan list/details event handling (optional)

Optionally, you can add a custom paylaterInstallmentEvent event listener that handles the plan selection and validation result of all customer and payment input fields.

var submitButton = document.getElementById('submit-button')

paylaterInstallment.addEventListener('paylaterInstallmentEvent', function(e) {
  switch (e.currentStep) {
    case 'plan-list':
      // run some code (for example, hide and disable the `pay` button)
      submitButton.setAttribute('style', 'display: none')
      submitButton.setAttribute('disabled', true)
      break;

    case 'plan-detail':
      // run some code (for example, show the `pay` button)
      submitButton.setAttribute('style', 'display: block')
      break;

    default:
      break;
  }

  if (e.action === 'validate' && e.success) {
    isValidPaymentInput = true
    if (isValidCustomerInput) {
      // run some code (for example, enable the `pay` button)
      submitButton.removeAttribute('disabled');
    }
  } else if (e.action === 'validate' && !e.success) {
    // run some code (for example, disable the `pay` button)
    submitButton.setAttribute('disabled', true)
  }
})

Refetching plans

Installment plans are first fetched when the create() method is called with the required parameters. If you need to refetch the plans with new parameters, then you should call the fetchPlans(params) function.

Please make sure to pass valid parameters inside the params object to the fetchPlans() function.

ParameterTypeDescription
amount (required)numberTotal amount of the purchase
country (required)stringThe customer’s country in ISO country code ISO 3166 ALPHA-2
currency (required)stringThe currency code of the transaction is a 3-letter code according to ISO_4217.
icon
The fetchPlans function has to be called after the create() call.

Country change Event handling

When a new country is selected in the customer address form, then the installment plans for the chosen country need to be refetched.

For this, you need to add a custom countryChange event listener and call the fetchPlans() function with country parameter using the billingAddressCountry or shippingAddressCountry properties from the event parameter.


customer.addEventListener('countryChange', function(event) {
var params = {
  country: event.billingAddressCountry || event.shippingAddressCountry,
}

var fetchPlansPromise = paylaterInstallment.fetchPlans(params)
fetchPlansPromise.then(function(data){
        // Plans successfully fetched
        // Nothing special to do here. You might log the data in the data object
      })
      .catch(function(error) {
        // Error while fetching plans.
        // Nothing special to do here. You might log the data in the error object
      })
})

Add an event listener and submit the form

Option 1: Without the customer form

Get the HTML form for example, by its unique ID, and add an event listener.

Inside, create a Promise on the PaylaterInstallment object. The Promise gets either resolved or rejected:

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

    paylaterInstallment.createResource()
        .then(function(result) {
            let typeId = result.id;
            // submit the payment type ID to your server-side integration
        })
        .catch(function(error) {
            document.getElementById('error-holder').innerText = error.customerMessage || error.message || 'Error'
        })
});

Option 2: With the customer form

Get the HTML form, for example, using its unique ID, and add an event listener.

Create a Promise for the PaylaterInstallment object and a second one for the customer object, and handle both at once using Promise.all().

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

    let customerPromise = customer.createCustomer();
    let paymentTypePromise = paylaterInstallment.createResource();
    Promise.all([customerPromise, paymentTypePromise])
        .then(function(values) {
            let customerId = values[0].id;
            let typeId = values[1].id;
            // Submit the IDs to your server-side integration.
        })
        .catch(function(error) {
            document.getElementById('error-holder').innerText = error.customerMessage || error.message || 'Error'
        })
});
let form = document.getElementById('example-payment-form');
form.addEventListener('submit', function(event) {
    event.preventDefault();

    let customerPromise = customer.updateCustomer();
    let paymentTypePromise = paylaterInstallment.createResource();
    Promise.all([customerPromise, paymentTypePromise])
        .then(function(values) {
            let customerId = values[0].id;
            let typeId = values[1].id;
            // Submit the IDs to your server-side integration.
        })
        .catch(function(error) {
            document.getElementById('error-holder').innerText = error.customerMessage || error.message || 'Error'
        })
});

When creating the Promises, be sure you use the following methods:

  • createResource() for the payment type
  • createCustomer() or updateCustomer() for the customer resource

Step 2: Make a payment
server side

Besides an always mandatory step of creating the inquiry and paymentType resource, Unzer Installment also requires a customer and a basket resource.

Create a customer resource (only B2C)

This step is applicable only if you didn’t create a customer resource yet, on the client side.

To process transactions for b2c customers, the following customer fields are mandatory:

ParameterTypeDescription
language (required)stringThe selected language of your customer on your website
salutationstringSpecify the customer’s Salutation. Available values are mr, mrs, unknown
firstname (required)stringThe customer’s first name
lastname (required)stringThe customer’s last name
email(required)stringThe customer’s email address
birthDate(required)stringThe birth date of the customer in ‘YYYY-MM-DD’ format.
billingAddress(required)objectThe customer’s billing address.
billingAddress.name(required)stringThe customer’s first- & last name for the billing address.
billingAddress.street(required)stringThe customer’s street including house number.
billingAddress.zip (required)stringThe customer’s postal code.
billingAddress.city (required)stringThe customer’s city.
billingAddress.country (required)stringThe customer’s country in ISO country code ISO 3166 ALPHA-2 (only for billing address).
POST https://api.unzer.com/v1/customers

{
"language": "de",
"salutation": "mr",
"firstname": "Peter",
"lastname": "Paylater",
"birthDate": "1987-12-20",
"email": "peter.paylater@example.com",
"billingAddress" : {
      "name" : "Peter Paylater",
      "street" : "Hugo-Junkers-Str. 5",
      "zip" : "60386",
      "city" : "Frankfurt am Main",
      "country" : "DE"
    }
}
<?php
$unzer = new Unzer('s-priv-xxxxxxxxxx');

$address = (new Address())
            ->setName('Max Mustermann')
            ->setStreet('Vangerowstr. 18')
            ->setZip('69115')
            ->setCity('Heidelberg')
            ->setCountry('DE');

$customer = (new Customer())
            ->setFirstname('Max')
            ->setLastname('Mustermann')
            ->setSalutation(Salutations::MR)
            ->setCompany('Unzer GmbH')
            ->setBirthDate('1972-12-24')
            ->setEmail('Max.Mustermann@unzer.com')
            ->setMobile('+49 123456789')
            ->setPhone('+49 123456789')
            ->setBillingAddress($address)
            ->setShippingAddress($address);

$unzer->createCustomer($customer);
Address address = new Address();
address
  .setName("Max Mustermann")
  .setStreet("Vangerowstr. 18")
  .setCity("Heidelberg")
  .setZip("69115")
  .setCountry("DE");
      
Customer customer = new Customer("Max", "Mustermann");
customer
  .setCustomerId(customerId)
  .setSalutation(Salutation.mr)
  .setEmail("max.mustermann@unzer.com")
  .setMobile("+49123456789")
  .setBirthDate(getDate("12.12.2000"))
  .setBillingAddress(address)
  .setShippingAddress(address);

Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
customer = unzer.createCustomer(customer);

The response looks similar to the following example:

{
  "id":"s-cst-c552940bca23"
}

For a full description of customer resource, refer to the relevant server-side integration documentation page: Manage customer (direct API calls).

Create a basket resource

The basket resource stores information about the purchased products, used vouchers, and the shipment costs.

icon info
Note that you must send the basket resource with the with the payment request.
icon
You must use basket v2 for Unzer Invoice payment method.
POST https://api.unzer.com/v2/baskets

{
  "totalValueGross": 190.0,
  "currencyCode": "EUR",
  "note": "Test Basket",
  "orderId": "Order-12345",
  "basketItems": [
    {
      "amountDiscountPerUnitGross": 1.0,
      "amountPerUnitGross": 20.0,
      "basketItemReferenceId": "Item-d030efbd4963",
      "imageUrl": "https://a.storyblok.com/f/91629/x/1ba8deb8cc/unzer_primarylogo__white_rgb.svg",
      "quantity": 10,
      "subTitle": "This is brand new Mid 2019 version",
      "title": "SDM 6 CABLE",
      "type": "goods",
      "unit": "m",
      "vat": 19.0
    }
  ]
}
<?php
$unzer = new Unzer('s-priv-xxxxxxxxxx');

$basketItem = (new BasketItem())
    ->setBasketItemReferenceId('Item-d030efbd4963')
    ->setQuantity(10)
    ->setUnit('m')
    ->setAmountPerUnitGross(20.00)
    ->setAmountDiscountPerUnitGross(1.00)
    ->setVat(19.0)
    ->setTitle('SDM 6 CABLE')
    ->setSubTitle('This is brand new Mid 2019 version')
    ->setImageUrl('https://a.storyblok.com/f/91629/x/1ba8deb8cc/unzer_primarylogo__white_rgb.svg')
    ->setType(BasketItemTypes::GOODS);

$basket = (new Basket())
    ->setTotalValueGross(190.00)
    ->setCurrencyCode('EUR')
    ->setOrderId('Order-12345')
    ->setNote('Test Basket')
    ->addBasketItem($basketItem);

$unzer->createBasket($basket);
BasketItem basketItem = new BasketItem()
        .setBasketItemReferenceId("Item-d030efbd4963")
        .setQuantity(BigDecimal.valueOf(10))
        .setUnit("m")
        .setAmountPerUnitGross(BigDecimal.valueOf(20.00))
        .setAmountDiscountPerUnitGross(BigDecimal.valueOf(1.00))
        .setVat(BigDecimal.valueOf(19.0))
        .setTitle("SDM 6 CABLE")
        .setSubTitle("This is brand new Mid 2019 version")
        .setImageUrl(new URL("https://a.storyblok.com/f/91629/x/1ba8deb8cc/unzer_primarylogo__white_rgb.svg"))
        .setType(BasketItem.Type.GOODS);

Basket basket  = new Basket()
        .setTotalValueGross(BigDecimal.valueOf(190.00))
        .setCurrencyCode(Currency.getInstance("EUR"))
        .setOrderId("Order-12345")
        .setNote("Test Basket")
        .addBasketItem(basketItem);

Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
unzer.createBasket(basket);

The response looks similar to the following example:

{
    "id": "s-bsk-17387257b8fa"
}

For a full description of basket resource, refer to the relevant server-side-integration documentation page: Manage basket (direct API calls).

Add the ThreatMetrix script

We use ThreatMetrix for fraud prevention to protect your business from potential fraudsters. For this, insert a code snippet with a unique(!) parameter on your payments page and later, send this parameter as threatMetrixId in the authorize request to us. The next steps are managed by us and no additional steps are required from you.

  1. Define a 128 byte long and unique variable as identifier for this transaction. Make sure it only consists of the following characters:
    • upper and lowercase English letters ([a-z], [A-Z])
    • digits (0-9)
    • underscore (_)
    • hyphen (-)
  2. Use this variable in the ThreatMetrix script (next step) in the GET parameter session_id and store it temporarily so that you can also send it in the authorize request later on.
  3. Add the ThreatMetrix script to your payment page. To get full fraud protection, use both the JavaScript part in thesection and the iFrame version in the body section of your page.
<html>
<head>
    <script type="text/javascript" async
         src="https://h.online-metrix.net/fp/tags.js?org_id=363t8kgq&session_id=[SessionID]">
    </script>
</head>
<body>
<noscript>
<iframe 
    style="width: 100px; height: 100px; border: 0; position: absolute; top: -5000px;" 
    src="https://h.online-metrix.net/fp/tags?org_id=363t8kgq&session_id=[SessionID]">
</iframe>
</noscript>
</body>
icon info
Recommendations for creation of session ID
  • Use a merchant identifier (URL without domain additions), append an existing session identifier from a cookie, append the date and time in milliseconds to the end of the identifier and then applying a hexadecimal hash to the concatenated value to produce a completely unique Session ID.
  • Use a merchant identifier (URL without domain additions), append an existing session identifier from the web application, and apply a hexadecimal hash to the value to obfuscate the identifier.
    Example: merchantshop_cd-695a7565-979b-4af9
    The session_id must be stored temporarily for later use in XML request.

Make an authorize transaction

Now, make an authorize transaction with the paylater-installment resource that you created earlier. You must also add the x-CLIENTIP=<YOUR Client's IP> attribute in the header. With a successful authorize transaction, the amount is authorized and a payment resource is created. At this point no money has been transferred but the amount is reserved.

ParameterTypeDescription
amount
(required)
floatThe authorization amount.
currency
(required)
stringThe authorization currency, in the ISO 4217 alpha-3 format (for example, EUR)
orderIdstringYour customer facing order number (if available at that point)
customerId (required)stringThe ID of the customers resource to be used (for example, s-cst-e692f3892497)
basketId (required)stringThe basket ID for the payment (such as s-bsk-17387257b8fa)
typeId (required)stringThe ID of the payment type resource to be used (such as s-pit-0n86y5sdbahc)

Provide the customer risk information

To increase the acceptance rate of your invoice payments, we strongly recommend that you provide additional information about your customer. The following fields can be provided to allow us to apply a detailed risk check:

ParameterTypeDescription
threatMetrixIdstringThe ThreatMetrix session ID
customerGroupstringCustomer classification for the customer if known valid values:
TOP: Customers with more than 3 paid* transactions
GOOD: Customers with more than 1 paid* transactions
BAD: Customers with defaulted/fraudulent orders
NEUTRAL: Customers without paid* transactions
confirmedAmountstringThe amount/value of the successful transactions paid by the end customer
confirmedOrdersstringThe number of successful transactions paid* by the end customer
registrationLevelstringCustomer registration level
0=guest, 1=registered
registrationDatestringCustomer registration date in your shop
(YYYYMMDD)

*paid: A paid transaction is a transaction where you have the payment status of the customer for previous transactions (external factoring invoice, installment or direct debit transactions must be excluded because you might have no information about the actual payment status of the customer).

Authorize request

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

Body
{
    "amount": "190.00",
    "currency": "EUR",
    "orderId": "BE-123456",
    "resources": {
        "customerId": "s-cst-e692f3892497", 
        "typeId": "s-pit-0n86y5sdbahc",
        "basketId": "s-bsk-17387257b8fa"
    },
    "additionalTransactionData": {
      "riskData": {
        "threatMetrixId": "merchantshop_cd-695a7565-979b-4af9",
        "customerGroup":"TOP",
        "customerId":"C-122345",
        "confirmedAmount":"2569",
        "confirmedOrders":"4",
        "registrationLevel":"1",
        "registrationDate":"20160412"
      }
    }
}
<?php
$unzer     = new UnzerSDK\Unzer('s-priv-xxxxxxxxxx');

$riskData = (new RiskData())
    ->setThreatMetrixId('merchantshop_cd-695a7565-979b-4af9')
    ->setCustomerGroup('TOP')
    ->setCustomerId('C-122345')
    ->setConfirmedAmount('2569')
    ->setConfirmedOrders('4')
    ->setRegistrationLevel('1')
    ->setRegistrationDate('20160412');

$authorization = (new Authorization(190.00, 'EUR', $returnUrl))
    ->setOrderId('BE-123456')
    ->setRiskData($riskData);

$unzer->performAuthorization(
    $authorization,
    's-pit-xxxxxxxxxxx',
    's-cst-xxxxxxxxxx',
    null,
    's-bsk-xxxxxxxxxx'
);
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");

RiskData riskData = (new RiskData())
    .setThreatMetrixId("merchantshop_cd-695a7565-979b-4af9")
    .setCustomerGroup("TOP")
    .setCustomerId("C-122345")
    .setConfirmedAmount("2569")
    .setConfirmedOrders("14")
    .setRegistrationLevel("1")
    .setRegistrationDate(new Date());
    
Authorization authorizationInstance = (new Authorization())
        .setAmount(BigDecimal.valueOf(190.00))
        .setCurrency(Currency.getInstance("EUR"))
        .setRiskData(riskData)
        .setTypeId("s-piv-zex7c9iibpek")
        .setCustomerId("s-cst-e692f3892497")
        .setBasketId("s-bsk-49277b9f7ee0");

Authorization transaction = unzer.authorize(authorizationInstance);

The response looks similar to the following example:

{
    "id": "s-aut-1",
    "isSuccess": true,
    "isPending": false,
    "isResumed": false,
    "isError": false,
    "message": {
        "code": "COR.000.000.000",
        "merchant": "Transaction succeeded",
        "customer": "Your payments have been successfully processed."
    },
    "amount": "190.00",
    "currency": "EUR",
    "returnUrl": "",
    "date": "2023-04-13 14:20:07",
    "resources": {
        "customerId": "s-cst-e692f3892497",
        "paymentId": "s-pay-8",
        "basketId": "s-bsk-17387257b8fa",
        "traceId": "",
        "typeId": "s-pit-0n86y5sdbahc"
    },
    "additionalTransactionData": {
        "riskData": {
            "threatMetrixId": "merchantshop_cd-695a7565-979b-4af9",
            "customerGroup": "TOP",
            "customerId": "C-122345",
            "confirmedAmount": "2569",
            "confirmedOrders": "4",
            "registrationLevel": "1",
            "registrationDate": "20160412"
        }
    },
    "orderId": "BE-123456",
    "paymentReference": "",
    "processing": {
        "uniqueId": "Tx-e5wkw4kt7mj",
        "shortId": "Tx-e5wkw4kt7mj",
        "descriptor": "TBGW-LGKS-WKZV",
        "traceId": ""
    }
}

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

Step 3: Check status of the payment
server side

Once the transaction is made, you can fetch the payment details from the API, by using the resources.paymentId from the authorize response above to handle the payment according to its status, such as s-pay-124. Check all possible payment states here.

GET: https://api.unzer.com/v1/payments/s-pay-xxxxxxx
<?php
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$payment = $unzer->fetchPayment('s-pay-1');
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Payment payment = unzer.fetchPayment("s-pay-1");

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

For more details on managing Unzer Installment payments, such as refunding them, see Manage Unzer Installment payments.

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