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

Migrate to Payment Page v2

Beta

Upgrade your payment solutions with Unzer’s latest release—Version 2.0! Here’s why it’s a game-changer:

  • Sleek, Modern Design: Say goodbye to the outdated and embrace the new, intuitive interface that makes navigating our system easier than ever.
  • New Payment Methods: Expand your payment options with the latest methods, providing flexibility and convenience for your customers.
  • Embedded Mode: Seamlessly integrate Unzer into your platform with our redesigned embedded mode, offering a smoother and more cohesive user experience.
  • Minimal migration effort: Transition from Version 1.0 to 2.0 with our migration guide.

Feature comparison

FeaturesVersion 2Version 1
Modern Designtickcross
One API endpoint for EPP, HPP and LinkPaytickcross
Customization options for every Payment Methodtickcross
Improved Redirect Handlingtickcross
Bearer Token Authenticationtickcross
Define order of payment methodstickcross
SDKs which ease integrationtickcross

General information

The customer and basket creation stay the same and the IDs are passed during the creation of the payment page.

The new payment page creation endpoint will be used for Embedded, Hosted and LinkPay Pages and returns the following:

  • paypageId: The ID of the created Payment Page.
  • redirectUrl: The URL to which the end customer needs to be redirected (required for Hosted Payment Page and LinkPay only).
  • qrCodeSvg: QR code representation of the redirectUrl in SVG format.

This means that instead of storing the paymentId, the paypageId must be stored and used when the customer returns to the merchant shop to verify the payment.

There are a few methods to verify the payment:

  • Via a GET call and the paypageId here, which returns paymentId and transaction status.
  • Via a GET call and the paymentId, which returns paypageId and payment details same as before
  • Via Webhook: There is no change in the webhooks, except that the resources.payPageId should be used to map the paymentId to the paypageId, as it is not initially known.

Migration with SDKs

The usage of our SDKs is recommended if a Java or PHP based backend is used. It will simplify the authorization process for you and automatically takes care of the token refresh.

A new version of the Java and PHP SDK is released and available.

Check the following pages for the full documentation on our SDKs:

You can also compare the highlighted changes in the following section:

Create hosted payment page

icon info
Note
Hosted, embedded or linkpay is now a flag in the create payment page call. The same is true for charge and authorize.
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$paypage = new Paypage(9.99, 'EUR'); // charge as default type.
//or if authorize is preferred:
//$paypage = new Paypage(9.99, 'EUR', 'authorize');

//it is recommended to add a customer object.
$customer = $unzer->createCustomer(CustomerFactory::createCustomer('Max', 'Mustermann'));

$resources = new Resources($customer->getId(), null, null);

//optionally add a none default config for card payment
$cardConfig = (new PaymentMethodConfig(true, 1))
    ->setCredentialOnFile(true)
    ->setExemption(ExemptionType::LOW_VALUE_PAYMENT);

$methodConfigs = (new PaymentMethodsConfigs())->addMethodConfig(Card::class, $cardConfig)

$paypage->setLogoImage('http://www.any.ed/images/page/info-img.png')
    ->setOrderId('shop-order-id')
    ->setShopName('Any shop name')
    ->setInvoiceId('shop-invoice-id')
    ->setPaymentMethodconfigs($methodConfigs)
    ->setResources($resources);

$unzer->createPaypage($paypage);
// Redirect to the paypage
redirect($paypage->getRedirectUrl());
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$paypage = new Paypage(9.99, 'EUR'); // charge as default type.
//or if authorize is preferred:
//$paypage = new Paypage(9.99, 'EUR', 'authorize');

$paypage->setType("embedded");

//it is recommended to add a customer object.
$customer = $unzer->createCustomer(CustomerFactory::createCustomer('Max', 'Mustermann'));

$resources = new Resources($customer->getId(), null, null);
$paypage->setResources($resources);

$unzer->createPaypage($paypage);
// Redirect to the paypage
redirect($paypage->getRedirectUrl());
$unzer = new Unzer('s-priv-xxxxxxxxxx');
$paypage = new Paypage(100.00, 'EUR', 'https://www.unzer.com');

$paypage->setLogoImage('http://www.any.ed/images/page/info-img.png')
    ->setOrderId('shop-order-id')
    ->setShopName('Any shop name')
    ->setTagline('Any tagline')
    ->setInvoiceId('shop-invoice-id')
    ->setExemptionType(\UnzerSDK\Constants\ExemptionType::LOW_VALUE_PAYMENT);

$unzer->initPayPageCharge($paypage, $customer, $basket);
Coming Soon!
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Paypage paypage = new PayPage();

paypage.setAmount(new BigDecimal("100.00"));
paypage.setReturnUrl("https://www.unzer.com");
paypage.setLogoImage("http://www.any.ed/images/page/info-img.png");
paypage.setOrderId("shop-order-id");
paypage.setShopName("Any shop name");
paypage.setTagline("Any tagline");
paypage.setInvoiceId("shop-invoice-id");
paypage.setAction(Paypage.Action.CHARGE);

Map<String, String> additionalAttributes = new HashMap<>();
additionalAttributes.put("exemptionType", "lvp");
paypage.setAdditionalAttributes(additionalAttributes);

// Initialize the paypage
paypage = unzer.paypage(paypage);

Server Side without SDKs

This section describes the new endpoints and mapping of the request. If you integrate directly with our API, you need to manage the access token generation yourself.

  • Issue an Access Token
  • Create Payment Page
  • Optional: Get Payments

Issue an Access Token (new)

As long as a token is valid, it can be used multiple times for calls to Payment Page API.

To keep the token authentication mechanism safe and secure, there are some measures that need to be taken into account:

  1. A requested token is valid for 7 minutes‚ after which it expires, and you need to request a new one.
  2. There is a rate limit in place that allows 2 token creations per second.
icon
If you are using one of our SDKs, the token handling is done automatically as long as you are reusing the Unzer instance.

Authorization: Basic auth with your merchant private key.

GET https://token.upcgw.com/v1/auth/token

{
  "accessToken": "eyJraWQiOiJhbGlhcy9jb25uZWN0aXZpdHktdjItdG9rZW4ta21zIiwiYWxnIjoiUlMyNTY..."
}

To learn more, go to the Authentication page.

Create a Payment Page Resource

Endpoints

The new create payment page call has a setting to either prefer authorize or charge.

Authorization

A bearer token is needed to authenticate. See the section “Issue an Access Token”.

Mapping Fields

The following section describes the mapping of all fields, which are different in v2.

Fieldv2v1
Basic Fields
amount"amount": "100""amount": 100
returnUrl"urls": { "returnSuccess": "https://www.unzer.com", "returnFailure": "https://www.unzer.com",<br> "returnPending": "https://www.unzer.com", "returnCancel": "https://www.unzer.com" }"returnUrl": "https://www.unzer.com"
fullPageImageNot available"fullPageImage": "https://www.your-shop.com/bg.png"
shopDescriptionNot available"shopDescription": "description"
taglineNot available"tagline": "tagline"
Styling
css"style": { "fontFamily": "string", "buttonColor": "string", ... }"css": { "shopDescription": "string", ... }
URLs
termsAndConditionUrl"urls": { "termsAndCondition": "https://www.your-shop.com/terms-and-conditions" }"termsAndConditionUrl": "https://www.your-shop.com/terms-and-conditions"
privacyPolicyUrl"urls": { "privacyPolicy": "https://www.your-shop.com/privacy-policy" }"privacyPolicyUrl": "https://www.your-shop.com/privacy-policy"
impressumUrl / imprintUrl"urls": { "imprint": "https://www.your-shop.com/imprint" }"impressumUrl": "https://www.your-shop.com/imprint"
helpUrl"urls": { "help": "https://www.your-shop.com/help" }"helpUrl": "https://www.your-shop.com/help"
contactUrl"urls": { "contact": "https://www.your-shop.com/contact" }"contactUrl": "https://www.your-shop.com/contact"
Additional AttributesSome fields are simplified under risk section"additionalAttributes": { "property1": "string"... },
Payment Configuration
excludeTypes"paymentMethodsConfigs": { "sepaDirectDebit": { "enabled": false }, "paylaterInvoice": { "enabled": false } }"excludeTypes": "['sepa', 'invoice-secured']"
New Fields in v2
mode"mode": "charge or authorize"Not available
type"type": "hosted, embedded or linkpay"Not available
recurrenceType"recurrenceType": "scheduled or unscheduled"Not available
checkoutType"checkoutType": "full, payment_only or no_shipping"Not available
paymentMethodsConfigsConfigure the order, specific details about a payment method or disable specific ones.Not available
risk"risk": { "registrationLevel": "string", "registrationDate": "string", "customerGroup": "top", "confirmedOrders": 0, "confirmedAmount": 0 }passed in additional attributes

Ensure that all necessary fields from v1 are correctly mapped to their counterparts in v2. Some fields might need to be restructured or placed under new keys.

{
  "paypageId": "string",
  "redirectUrl": "string"
}

Optional: Get payments

Optionally, this endpoint can be called after the payment page is finished and the customer has returned to the shop. It will contain the paymentId, status and information about failures. We recommend this step even though you will also be notified via a webhook. Check Notifications to learn how to use them.

The current status of the payment can be seen in the response.


GET https://paypage.unzer.com/v2/merchant/paypage/{paypageId}
{
  "payments": [
    {
      "paymentId": "s-pay-1",
      "transactionStatus": "success",
      "creationDate": "2024-08-22T14:42:57.944Z",
      "messages": [
        {
          "code": "string",
          "customer": "string",
          "merchant": "string"
        }
      ]
    }
  ],
  "total": 0
}

Hosted Payment Page migration

There is no change on the client site for the hosted payment page. The browser needs to be redirected to the payment page as before. The return URL can now be specified for every different transaction state as shown above. If you want to use a specific locale, you need to adapt the parameter slightly with an & instead of an ?. For example,

var redirectUrl = returnData.redirectUrl
// Setting the page to always load in German language
redirectUrl += '&locale=de-DE'

// redirect the customer to customized Hosted Payment Page
window.location.href = redirectUrl

Embedded Payment Page migration

The most significant change is, that the embedded flag needs to be set during the creation of the payment page with the type attribute now. In contrast to v1, where a flag was attached to the URL.

The changes on the server site depend on your type of integration. Either see the SDK or direct integration above. The client site implementation didn’t change much and are available here: Embedded Payment Page.

See also