Accept payments with Unzer API

Accept payments through direct communication with the Unzer API.

Introduction

You can accept payments by making direct calls to the Unzer API. This gives you full control of the customer-facing UI on your side: the way you gather the customer’s input on your website or in your app is entirely up to you.

Read this guide for a general overview of how to accept a payment with the Unzer API. For more detailed information on a specific payment method, go to our tutorials on individual payment methods.

Step 1: Create a payment type resource

Whatever payment method you use, you need to create a dedicated payment type resource first.

To create a payment type resource:

  1. Make a POST call to the right endpoint:

    Payment method Unzer API endpoint
    Unzer Bank Transfer types/pis
    Unzer Direct Debit types/sepa-direct-debit
    Unzer Direct Debit Secured types/sepa-direct-debit-secured
    Unzer Prepayment types/prepayment
    Unzer Instalment types/installment-secured
    Unzer Invoice types/invoice
    Unzer Invoice Secured types/invoice-secured
    Bancontact types/bancontact
    Credit card types/card
    EPS types/eps/
    Alipay types/alipay
    Apple Pay types/applepay
    Giropay types/giropay/
    iDEAL types/ideal/
    PayPal types/paypal/
    Przelewy24 types/przelewy24/
    SOFORT types/sofort/
    WeChat Pay types/wechatpay
  2. In the request body of your POST call, include all the information required for your chosen payment method.
    For details on a specific payment method, see individual payment method tutorials.

For example, creating a payment type resource for a credit card payment looks like this:

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

{
  "number" : "4444333322221111",
  "expiryDate" : "04/25",
  "cvc": "123",
  "3ds": "false",
  "cardHolder": "Anna Smith"
}
{
    "id": "s-crd-wln5j3zcmjzi",
    "method": "card",
    "number": "444433******1111",
    "brand": "VISA",
    "cvc": "***",
    "expiryDate": "04/2025",
    "3ds": false,
    "cardHolder": "Anna Smith",
    "cardDetails": {
        "cardType": "",
        "account": "CREDIT",
        "countryIsoA2": "US",
        "countryName": "UNITED STATES",
        "issuerName": "",
        "issuerUrl": "",
        "issuerPhoneNumber": ""
      },
  	"geoLocation": {
    	"clientIp": "115.77.189.143",
    	"countryCode": "VN"
 		}
}

Step 2: Charge the payment type resource

After you create the right payment type resource, you can charge it:

  1. Locate the payment type resource’s id that you received in response (Step 1).
  2. Make a POST call to payments/charges.
    In the request body of your POST call, include the id and all other information required for your chosen payment method. For details, see individual payment method tutorials.

For example, charging a credit card looks like this:

POST https://api.unzer.com/v1/payments/charges
{
  "amount": "100",
  "currency": "EUR",
  "card3ds": "false",
  "returnUrl": "https://www.unzer.com",
  "cardHolder": "Anna Smith",
  "resources": {
    "typeId": "s-crd-wln5j3zcmjzi"
  }
}
{
    "id": "s-chg-1",
    "isSuccess": true,
    "isPending": false,
    "isError": false,
    "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": "http://tinhte.vn",
    "date": "2020-11-04 15:41:11",
    "resources": {
        "paymentId": "s-pay-97200",
        "traceId": "4210ab81d09a0f504b45307b4d36ef00",
        "typeId": "s-crd-wln5j3zcmjzi"
    },
    "paymentReference": "",
    "processing": {
        "creatorId": "13213213344324324",
        "identification": "4684.3087.1849",
        "iban": "DE89370400440532013000",
        "bic": "COBADEFFXXX",
        "uniqueId": "31HA07BC81A7A34627C2AED4F3C3EE07",
        "shortId": "4684.3087.1849",
        "traceId": "4210ab81d09a0f504b45307b4d36ef00"
    }
}

Step 3: Get a notification

Now, you can get a webhook notification triggered by a successful transaction:

{
  "event":"charge.succeeded",
  "publicKey":"s-pub-xxxxxxxxxx",
  "retrieveUrl":"https://api.unzer.com/v1/payments/s-pay-97200",
  "paymentId":"s-pay-97200"
}

For more details on setting up notifications, go to Notifications.