Important information

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


Accept TWINT with server-side-only integration

Build your own payment form to add TWINT payment to the checkout page.


TWINT doesn’t require any input from the customer on the merchant website. The customer must be redirected to TWINT to provide the required information to process the transaction. After that, the customer is redirected back your website, displaying the result of the payment.

Before you begin

Step 1: Create a payment type resource
server side

When creating the payment type twint, you need to send an empty request to the Unzer API. The response contains an id, this is later referred to as typeId. You will need this typeId to perform the transaction.


Body: {}
$unzer = new Unzer('s-priv-xxxxxxxxxx');

$twint = new Twint();
$twint = $unzer->createPaymentType($twint);
Twint twint = new Twint();
Unzer unzer = new Unzer(new HttpClientBasedRestCommunication(), "s-priv-xxxxxxxxxx");
twint = unzer.createPaymentType(twint);

The response will look similar to the following example:

  "id": "s-twt-npwvzkmfsnza",
  "method": "twint",
  "recurring": false,
  "geoLocation": {
    "clientIp": "",
    "countryIsoA2": "DE"

For more details on TWINT payment type creation, see the API reference.

Step 2: Make a payment
server side

Make a charge transaction

Now, make a charge transaction with the twint typeId that you created and the returnUrl leading back to your shop after the payment is finished on the external page. With the charge transaction an amount is requested but is not yet transferred. Initially the transaction will be pending and a payment resource is created.

  "amount" : "10",
  "currency": "CHF",
  "returnUrl": "",
  "resources" : {
    "typeId" : "s-twt-npwvzkmfsnza"
$unzer     = new UnzerSDK\Unzer('s-priv-xxxxxxxxxx');

$chargeInstance = new Charge(10.00, 'CHF', $returnUrl);
$typeId = 's-twt-npwvzkmfsnza';
$transaction = $unzer->performCharge($chargeInstance, $typeId);
Unzer unzer = new Unzer("s-priv-xxxxxxxxxx");
Charge charge = unzer.charge(BigDecimal.ONE, Currency.getInstance("CHF"), "s-twt-npwvzkmfsnza", new URL(""));

The response looks similar to the following example:

  "id": "s-chg-1",
  "isSuccess": false,
  "isPending": true,
  "isResumed": false,
  "isError": false,
  "card3ds": false,
  "redirectUrl": "",
  "message": {
    "code": "COR.000.000.000",
    "merchant": "Transaction succeeded",
    "customer": "Your payments have been successfully processed."
  "amount": "10.0000",
  "currency": "CHF",
  "returnUrl": "",
  "date": "2024-04-16 08:18:16",
  "resources": {
    "paymentId": "s-pay-5",
    "traceId": "6c3d421d0573d5dcf351d35f2514d57f",
    "typeId": "s-twt-npwvzkmfsnza"
  "paymentReference": "",
  "processing": {
    "uniqueId": "42252c96.0a7e.4c0a.8c17.56af6277fb41",
    "shortId": "8777.4978.6752",
    "traceId": "6c3d421d0573d5dcf351d35f2514d57f"

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).

Forward the customer to the external payment page

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

  1. Redirect the customer to the redirectUrl returned to the initial request.
  2. The customer is forwarded to the TWINT payment page.
  3. After a successful payment or abort on the TWINT page, the customer is redirected to the returnUrl specified in the initial Charge call.

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.


  "id": "s-pay-5",
  "state": {
    "id": 0,
    "name": "pending"
  "amount": {
    "total": "10.0000",
    "charged": "0.0000",
    "canceled": "0.0000",
    "remaining": "10.0000"
  "currency": "CHF",
  "orderId": "",
  "invoiceId": "",
  "resources": {
    "customerId": "",
    "paymentId": "s-pay-5",
    "basketId": "",
    "metadataId": "",
    "payPageId": "",
    "traceId": "6c3d421d0573d5dcf351d35f2514d57f",
    "typeId": "s-twt-npwvzkmfsnza"
  "transactions": [
      "date": "2024-04-16 08:18:16",
      "type": "charge",
      "status": "pending",
      "url": "",
      "amount": "10.0000"

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 TWINT payments, such as refunding them, see Manage TWINT payments


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.


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