Sofort (Klarna)

Accept Sofort/Klarna payments in your online store.


Sofort allows your customers to make payments through direct bank transfer. Use the emerchantpay Sofort API to accept Sofort as a payment method across all of emerchantpay’s payment integrations.

emerchantpay Klarna
Payment method Countries/regions Supported payments
Real time bank transfer Austria, Belgium, Germany, Italy, Netherlands, Poland, Spain, Switzerland Online banking

Prerequisites


1. Create a Sofort payment request

To submit a payment using Sofort, create a payment request to the emerchantpay Genesis payment gateway. Specify sofort as the transaction_type.

Example of passing an Sofort payment request:
  <?xml version=”1.0″ encoding=”UTF-8″?>
  <payment_transaction>
    <transaction_type>sofort</transaction_type>
    <transaction_id>119643250547501c79d8295</transaction_id>
    <usage>40208 concert tickets</usage>
    <remote_ip>123.456.789.0</remote_ip>
    <return_success_url>http://www.example.com/success</return_success_url>
    <return_failure_url>http://www.example.com/failure</return_failure_url>
    <return_pending_url>http://www.example.com/pending</return_pending_url>
<return_notification_url>http://www.example.com/notification</return_notification_url>
    <amount>100</amount>
    <currency>EUR</currency>

2. Receive a response

You will receive a Success or Error response to your payment request.

Example of a Success response:
  <?xml version=”1.0″ encoding=”UTF-8″?>
  <payment_response>
    <transaction_type>sofort</transaction_type>
    <status>pending_async</status>
    <mode>live</mode>
    <transaction_id>119643250547501c79d8295</transaction_id>
    <unique_id>44177a21403427eb96664a6d7e5d5d48</unique_id>
    <technical_message>Transaction successful!</technical_message>
    <message>Transaction successful!</message>
    <redirect_url>https://staging.gate.emerchantpay.net/redirect/to_acquirer/649e1ff35c61</redirect_url>
    <timestamp>2022-06-29T15:36:40Z</timestamp>
    <descriptor>Descriptor one</descriptor>
    <amount>100</amount>
    <currency>EUR</currency>
    <sent_to_acquirer>true</sent_to_acquirer>
  </payment_response>

Asynchronous notification

Because the Sofort payment transaction is asynchronous, the result of your customer’s payment is sent as a separate HTTP POST notification from the gateway to the notification_url that you supplied with the transaction request.

Example of a notification for an Sofort transaction:
“transaction_id”: “45353c0c179bafc4a1cf79bf00720c47”
“terminal_token”: “ec1a6c3fd379accb048eeb76bf9e9dd858af42e1”
“unique_id”: “a96f8bc88c392b691e17856f8f2864b2”
“transaction_type”: “sofort”
“status”: “approved”
“signature”: “ef595c87c2fc2ad3eeb7581c672a2b2cf2f0e506”
“amount”: “1100”
“funds_status”: “WAITING”
“account_holder”: “John Smith”
“bank_account_number”: “DE06000000000023456789”
“bank_identifier_code”: “SFRTDE20XXX”

Use the signature field to verify that the notification has been sent by the Genesis gateway. Each session signature is generated by combining the unique_id of the transaction and your API password, and generating a SHA-1 hash function of the combined string.

signature = SHA-1 hash value of <unique_id><API password>

Notification signature examples:
unique_id API password signature
26aa150ee68b1b2d6758a0e6c44fce4c 50fd87e65eb415f42fb5af4c9cf497662e00b785 c5219b3d385e74496b2b48a549
3f760162ef57a829011e5e2379b3fa17 50fd87e65eb415f42fb5af4c9cf497662e00b785 14519d0db2f7f8f407efccc9b099

After you have verified the notification state and validity, render an XML page containing the transaction’s unique id to acknowledge that you have received the notification.

Example of a notification reply you use to confirm a notification:
<?xml version=”1.0″ encoding=”UTF-8″?>
<notification_echo>
  <unique_id>3f760162ef57a829011e5e2379b3fa17</unique_id>
</notification_echo>

3. Test your integration

Before you can accept live payments, you must test your integration in the emerchantpay staging environment.

  1. Add an item to your cart in your online store.
  2. Proceed to the checkout page and check out using Sofort.
  3. Follow the redirect link to the Sofort login.
  4. Search for and select Demo Bank.
  5. Complete the order and verify that you are redirected to the order confirmation page.
  6. Log in to Genesis.
  7. In the navigation menu, go to Payment transactions.
  8. Verify that the transaction appears at the top of the list and is successful.

4. Accept live payments

After you have successfully tested your Sofort integration, you are ready to move to the production environment and accept live payments. Contact your emerchantpay Account Manager to get your login credentials for the Genesis production environment.

You are now ready to accept live payments using Sofort.