Sofort

Sofort is an online payment method used in select European countries.

About Sofort

Sofort (Klarna) is one of the most popular online payment method available in Germany and Austria. As with other redirect payment methods, when the customer selects their bank or specifies a BIC, they are redirected to their bank payment site to make the payment. Once the authentication and payment is done, they can be redirected back to your online shop.

Accept a Sofort payment

To accept a Sofort payment, follow the steps below.

When testing, do not use real customer data. Use the test data prepared by Unzer.

Step 1: Create a sofort resource

To accept a Sofort payment, create a sofort resource first.

Make an empty-body POST call to /types/sofort:

POST https://api.unzer.com/v1/types/sofort/

Body: {}

{
    "id": "s-sft-whtvt8fhtnvg",
    "method": "sofort",
    "recurring": false,
    "geoLocation": {
        "clientIp": "127.0.0.1",
        "countryIsoA2": "DE"
    }
}
Property Type Description
id String The ID of the sofort resource that you just created.
method String The payment method.
recurring Boolean Indicates if this is a recurring payment.
clientIp String The IP address of the device used for the payment.
countryCode String The country associated with clientIp, displayed in the ISO 3166-1 alpha-2 format.

Step 2: Make a charges call

To charge the Sofort resource, make a POST call to payments/charges, with the following parameters in the request body:

Parameter Required Type Description Example
amount Yes Number The charged amount. 100
currency Yes String The transaction currency, in the ISO 4217 alpha-3 format. EUR
returnURL Yes String The URL to redirect the customer to after the payment is completed. https://www.unzer.com
typeId Yes String The ID of the related payment type resource. s-sft-whtvt8fhtnvg
POST https://api.unzer.com/v1/payments/charges

{
  "amount": "100",                                    
  "currency": "EUR",
  "returnUrl": "https://www.unzer.com",
  "resources": {
    "typeId": "s-sft-whtvt8fhtnvg",
  }
}
{
    "id": "s-chg-1",
    "isSuccess": false,
    "isPending": true,
    "isError": false,
    "redirectUrl": "https://api.unzer.com/v1/redirect/sofort/s-qds2iKLj8yAu",
    "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": "100.0000",
    "currency": "EUR",
    "returnUrl": "https://unzer.com",
    "date": "2021-06-08 12:28:56",
    "resources": {
        "paymentId": "s-pay-134242",
        "traceId": "90696b80942d54561eedff9bec7b5901",
        "typeId": "s-sft-whtvt8fhtnvg"
    }
    ...

Property Type Description
id String The transaction’s unique ID.
isSuccess Boolean Set to true if the transaction was successful.
isPending Boolean Set to true if the transaction is pending (e.g. if a redirect to an external system is required).
isError Boolean Set to true if an error occurs.
redirectUrl String The URL where the customer completes the payment.

Step 3: Forward the customer to redirect URL

After you charge the sofort resource, implement the following flow:

  1. Redirect the customer to redirectURL.
  2. The customer is forwarded to the Sofort payment page.
  3. After a successful payment, the customer is redirected to the returnURL that you specified in the charges call (Step 2).

Step 4: Check the payment status

After the customer is redirected to the returnUrl, check the status of the payment.

Make a GET call with the following parameters in the request path:

Parameter Required Type Description Example
resource_ID Yes String The returned ID of the sofort resource that you created in Step 1. s-sft-whtvt8fhtnvg
transaction_ID Yes String The transaction’s unique ID that you received in Step 2. s-chg-1
GET https://api.unzer.com/v1/payments/s-pay-134242/charges/s-chg-1
{
  "id": "s-chg-1",
  "isSuccess": true,
  "isPending": false,
  "isError": false,
     ...
}
Property Type Description
id String The transaction’s unique ID.
isSuccess Boolean Set to true if the transaction was successful.
isPending Boolean Set to true if the transaction is pending (e.g. if a redirect to an external system is required).
isError Boolean Set to true if an error occurs.