Accept Unzer Installment with UI components v2
BetaUse Unzer UI component v2 to add Unzer Installment payment to your checkout page.
Overview
Using UI components for Unzer Installment, you can create a unzer-paylater-installment
payment type resource that is used to make the payment.
The form of this payment type will show all fields necessary to make this type of payment
Basic steps for integrating using UI components v2 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.
basket
resource, please refer to relevant server-side integration documentation page:
Manage basket (direct API calls)Before you begin
Before you begin- Check the basic integration requirements.
- Familiarize yourself with general guide on integrating using UI components.
Step 1: Add UI components v2 to your payment pageclient side
Step 1: Add UI components v2 to your payment page [client side]First, you need to initiate our UI components v2 library and add the needed payment type component to your payment page.
Initiate UI Components
Initiate UI Components v2Load the Unzer JS script
Load the Unzer JS scriptInclude the Unzer JS script on your website. This will load all the Unzer custom UI components, prefixed with unzer-
e.g <unzer-paylater-invoice>
.
Make sure to always include the script directly from the Unzer domain https://static.unzer.com
<script
type="module"
src="https://static.unzer.com/v2/ui-components/index.js"
></script>
To make your website load faster, import the unzer script at the bottom of your HTML document.
Make sure to import the script as type=“module”
To learn which URLs must be added to the allowlist for Unzer UI components in your content security policy, please refer to Content security policy section.
It is a good practice to put your website in loading state until the Unzer script is loaded, and the UI components are ready to use.
// Make sure initially your application is in loading state
// until all Unzer components are loaded
Promise.all([
customElements.whenDefined("unzer-payment"),
// Probably add any other Unzer components used here. For example:
// customElements.whenDefined("unzer-paylater-invoice"),
]).then(() => {
// Hide the loading state and proceed with next steps
}).catch((error) => {
// Handle any error that might occur during the
// loading process and initialization
});
UI setup and configuration
UI setup and configurationTo securely collect payment data from your customer, you need to add the <unzer-payment>
component, inside which you insert the needed payment type components.
<unzer-checkout>
element.
This will provide automatic handling for enabling/disabling the submit button depending on the current status,
and showing/hiding of brand icons.<unzer-payment
id="unzer-payment"
publicKey="s-pub-xyz"
locale="de-DE">
<!-- ... Here you will need to add the Unzer payment type tag, so the form UI elements will be inserted -->
<!-- e.g <unzer-paylater-invoice></unzer-paylater-invoice> -->
</unzer-payment>
<unzer-checkout id='unzer-checkout'>
<button type="submit" id="yourPaymentButtonId">Pay</button>
</unzer-checkout>
Following parameters need to be passed.
Parameter | Type | Description | Default value |
---|---|---|---|
publicKey (required) | String | The merchant public key. | - |
locale | String | The used locale. For more information on supported locales, see Localization. | Browser user defined locale. |
initData | object | A key/value object in JSON-format containing data to initialize the payment type. For more information, Check payment methods and their features. | Empty object {} |
Optional: Customize UI components
Optional: Customize UI componentsOur UI Components v2 are provided with a default theme that contains base styles. You can easily customize these styles by overriding the following CSS variables.
Variable name | Description | Affected components |
---|---|---|
--unzer-font | Replaces all fonts with the given font. Users can define any font-face and provide the name of the custom font-face. | typography |
--unzer-text-color | The font color use for typography. | typography, icons |
--unzer-brand-color | The main color of the application. | button, checkbox, radio, loader |
--unzer-background-color | The page background. | |
--unzer-link-color | The color of links. | link |
--unzer-corner-radius | Whether controls will have rounded corners or not. Values can be either 0 or 1. | button, tags, chips |
--unzer-shadows | Whether shadows are enabled or not. Values can be either 0 or 1. | button, card |
<head>
<style>
:root {
--unzer-font: SFMono;
--unzer-brand-color: #ee1818;
--unzer-text-color: #f19316;
--unzer-background-color: #6a9472;
--unzer-link-color: #1330ef;
--unzer-corner-radius: 0;
--unzer-shadows: 1;
}
</style>
</head>
Implement the payment form
First you need to insert the Unzer Installment element <unzer-paylater-installment>
inside the <unzer-payment>
and
add your submit button.
You should also call the setBasketData()
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.
<unzer-payment
id="unzer-payment"
publicKey="s-pub-xyz"
locale="de-DE">
<unzer-paylater-installment></unzer-paylater-installment>
</unzer-payment>
<unzer-checkout id='unzer-checkout'>
<button type="submit" id="yourPaymentButtonId">Pay</button>
</unzer-checkout>
const unzerPaymentElement = document.getElementById('unzer-payment');
unzerPaymentElement.setBasketData({amount: 123, currenyType: 'EUR'})
Please make sure to pass valid parameters to the setBasketData()
function.
Parameter | Type | Description | Default value |
---|---|---|---|
amount required | number | Total amount of the purchase | - |
currencyType required | String | The currency code of the transaction is a 3-letter code according to ISO_4217. | - |
country | String | The customer’s country in ISO country code ISO 3166 ALPHA-2 | "DE" |
In case you want also to create/update your customer information, then you will need to use our Unzer UI customer elements.
Option 1: Implement with customer elements
Option 1: Implement with customer elementsIf you don’t have information about the customer (and the corresponding customerID) or want to update information of an already existing customer, you can do so using Unzer UI customer elements.
Customer element | Description |
---|---|
<unzer-personal-info> | Adds the customer personal information (email, salutation, firstname, lastname) |
<unzer-shipping-address> | Adds the customer shipping address information (country, street, post code, city, mobile number) |
<unzer-billing-address> | Adds the customer billing address information (firstname, lastname, country, street, post code, city). |
The Unzer UI customer elements can be inserted either inside or outside the <unzer-payment>
element.
On submit, all data from the added Unzer UI customer elements will be gathered and submitted together with the payment form,
in order to create the customer and payment type resources.
In case you wish to initialize the customer elements with the data of an already created customer, you will need to call
the setCustomerData()
function of the <unzer-payment>
element, and pass a customer object in JSON format.
customer object
Parameter | Type | Description | Default value |
---|---|---|---|
id | String | The ID of the customer you wish to update. If not passed, then a new customer will be created. | |
salutation | String | The salutation for the customer. Allowed values are:"mr" , "mrs" , "diverse" | "mr" |
firstname | String | The first name of the customer. | "" |
lastname | String | The last name of the customer. | "" |
birthDate | String | The birth date of the customer. | "" |
email | String | The E-mail of the customer. | "" |
mobileNumber | mobileNumber Object | The mobile number | {} |
shippingAddress | address object | The shipping address for the customer in JSON format. | {} |
billingAddress | address object | The billing address for the customer in JSON format. | {} |
address object
Parameter | Type | Description | Default value |
---|---|---|---|
name | String | The firstname + lastname of the customer | "" |
street | String | The street and house number | "" |
zip | String | The zip-code | "" |
city | String | The city | "" |
state | String | The state | "" |
country | String | The country ISO country code ISO 3166 ALPHA-2 | "DE" |
shippingType only in shippingAddress | String | The shippingType. Allowed values are:"equals-billing" , "different-address" , "branch-pickup" , "post-office-pickup" , "pack-station" | "DE" |
mobileNumber object
Parameter | Type | Description | Default value |
---|---|---|---|
prefix | String | The country prefix of the mobile number | "" |
phone | String | The mobile number | "" |
The following code example shows the options described above:
<unzer-payment
id="unzer-payment"
publicKey="s-pub-xyz"
locale="de-DE">
<unzer-paylater-installment></unzer-paylater-installment>
</unzer-payment>
<p>Shipping Information</p>
<unzer-personal-info></unzer-personal-info>
<unzer-shipping-address></unzer-shipping-address>
<p>Billing Information</p>
<unzer-billing-address></unzer-billing-address>
<unzer-checkout id='unzer-checkout'>
<button type="submit" id="yourPaymentButtonId">Pay</button>
</unzer-checkout>
const unzerPaymentElement = document.getElementById('unzer-payment');
unzerPaymentElement.setBasketData({amount: 123, currenyType: 'EUR'})
unzerPaymentElement.setCheckOutType("full");
unzerPaymentElement.setCustomerData({
"id": "s-cst-xyz",
"lastname": "Universum",
"firstname": "Peter",
"salutation": "mr",
"birthDate": "20.12.1987",
"mobileNumber": {
"prefix": "49",
"phone": "1234"
},
"shippingAddress": {
"name": "Peter Universum",
"street": "Hugo-Junkers-Str. 5",
"zip": "60386",
"city": "Frankfurt am Main",
"country": "DE",
"shippingType": "equals-billing"
},
"billingAddress": {
"state": "Peter Universum",
"street": "Hugo-Junkers-Str. 5",
"zip": "60386",
"city": "Frankfurt am Main",
"country": "DE"
}
})
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.
In that case you just need to render the payment type form and create a simple HTML button on the client side:
Create Payment Type and Customer Resources
Create Payment Type and Customer ResourcesAfter the submit button is clicked, the customer and payment data are automatically submitted. You will then need
to query the unzer-checkout
element and handle the response inside its onPaymentSubmit
event listener.
The following code example shows how to read customer and payment data from the response.
// ...
const unzerCheckout = document.getElementById('unzer-checkout');
unzerCheckout.onPaymentSubmit = (response) => {
if (response.submitResponse && response.customerResponse) {
if (response.customerResponse.success) {
// Optional: Only in case a new customer is created in the frontend.
const customerId = response.customerResponse.data.id;
}
if (response.submitResponse.success) {
const paymentTypeId = response.submitResponse.data.id;
}
// Submit all IDs to your server-side integration to perform the payment transaction.
}
};
Step 2: Make a paymentserver side
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 available:
Parameter | Type | Description |
---|---|---|
language | string | The language for customer correspondence. Must be in ISO 639 alpha-2 code format. |
salutation | string | Specify the customer’s Salutation. Available values are mr , mrs , unknown . |
firstname (required) | string | The customer’s first name. |
lastname (required) | string | The customer’s last name. |
email (required) | string | The customer’s email address. |
birthDate (required) | string | The birth date of the customer in ‘YYYY-MM-DD’ format. |
billingAddress (required) | object | The customer’s billing address. |
billingAddress.name (required) | string | The customer’s first- & last name for the billing address. |
billingAddress.street (required) | string | The customer’s street including house number. |
billingAddress.zip (required) | string | The customer’s postal code. |
billingAddress.city (required) | string | The customer’s city. |
billingAddress.country (required) | string | The 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"
}
}
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$address = (new Address())
->setName('Max Mustermann')
->setStreet('Schöneberger Str. 21a')
->setZip('10963')
->setCity('Berlin')
->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("Schöneberger Str. 21a")
.setCity("Berlin")
.setZip("10963")
.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.
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
}
]
}
$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
Add the ThreatMetrix scriptWe 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.
- 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 (-)
- 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. - 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>
- 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 the
org_id=363t8kgq
as a static value that does not change for each ThreatMetrix script or for an individual merchant. - 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/subsequent request.
Do a risk check for the customerserver side
Do a risk check for the customerCustomer risk check is an optional step after the payment method is selected. It is used for the risk evaluation of the end customer data.
When sending the request, you must also add the x-CLIENTIP=<YOUR Client's IP>
attribute in the header.
This operation is not part of the payment process. Like credit card check, it is used to pre-check customer data immediately after the payment method selection step in the checkout. This way customer receives direct feedback before finishing the order, avoiding irritation. The riskCheck
request contains customer resource’s reference and transactional details.customer receives direct feedback before finishing the order, avoiding irritation. The riskCheck
request contains customer resource’s reference and transactional details.
POST: https://api.unzer.com/v1/types/paylater-installment/risk-check
{
"amount": "190",
"currency": "EUR",
"orderId": "ORD-123456",
"invoiceId" : "INS-123456",
"resources": {
"customerId": "s-cst-472f919218b5",
"typeId": "s-pit-0n86y5sdbahc",
"basketId": "s-bsk-17387257b8fa"
},
"additionalTransactionData": {
"riskData": {
"threatMetrixId": "merchantshop_cd-695a7565-979b-4af9",
"customerGroup":"TOP",
"confirmedAmount":"2569",
"confirmedOrders":"14",
"registrationLevel":"1",
"registrationDate":"20160412"
}
}
}
{
"id": "GHZC-PQVK-RLGP",
"timestamp": "2024-04-09 12:46:00",
"isSuccess": true,
"isPending": false,
"isResume": false,
"isError": false
}
{
"id": "s-err-70a411aa69854880a727eb27e6f",
"isSuccess": false,
"isPending": false,
"isResumed": false,
"isError": true,
"url": "https://api.unzer.com/v1/types/paylater-installment/risk-check",
"timestamp": "2024-04-09 12:47:09",
"traceId": "dd34bcd31b347817559ac4d780a7db30",
"errors": [
{
"code": "API.901.100.300",
"merchantMessage": "Invalid amount.invalid amount (probably too large) [details: Amount 1000000.00 outside transaction limits: [1.00, 5000.00]]",
"customerMessage": "An error occurred. Please contact us for more information."
}
]
}
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.
Parameter | Type | Description |
---|---|---|
amount (required) | float | The authorization amount. |
currency (required) | string | The authorization currency, in the ISO 4217 alpha-3 format (for example, EUR ) |
orderId | string | Your customer facing order number (if available at that point) |
customerId (required) | string | The ID of the customers resource to be used (for example, s-cst-e692f3892497 ) |
basketId (required) | string | The basket ID for the payment (such as s-bsk-17387257b8fa ) |
typeId (required) | string | The 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:
Parameter | Type | Description |
---|---|---|
threatMetrixId | string | The ThreatMetrix session ID |
customerGroup | string | Customer 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 |
confirmedAmount | string | The amount/value of the successful transactions paid by the end customer |
confirmedOrders | string | The number of successful transactions paid* by the end customer |
registrationLevel | string | Customer registration level 0=guest, 1=registered |
registrationDate | string | Customer 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"
}
}
}
$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 paymentserver side
Step 4: 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
$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 resultclient side
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 paymentserver side
For more details on managing Unzer Installment payments, such as refunding them, see Manage Unzer Installment payments.
Notifications
NotificationsWe 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
Error handlingAll 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
Test & go liveYou 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.