Skip to main content

Use SOFORT

Last updated: 14-Dec-2023
Rate this article:

Overview

SOFORT is a payment method used primarily in Germany, Austria, Belgium, Switzerland, and The Netherlands. SOFORT supports a direct credit transfer system designed to allow the immediate delivery of goods and services through instant notification and confirmation support.

Currencies

SOFORT supports transactions in EUR and CHF.

Workflow

  1. Shoppers select SOFORT as a payment option in the checkout interface you provide to them.
  2. Create the order object. Use “DIRECT_EBANKING” as the type of the PaymentDetails object.
  3. Use the placeOrder method to send the data to 2Checkout.
  4. Use the PaymentMethod object to create a redirect URL for the shoppers. Using the provided URL, make a request using the provided method (usually a GET request) and add the parameters (located in the Params object) as key-value pairs to the URL of the request.
  5. 2Checkout returns an Order object as the output of the placeOrder method. 
  6. Once you place the order, 2Checkout logs it into the system. At this point in time, the status of the order is PENDING.

Parameters

Parameters Type/Description

sessionID

Required (string)

 

Session identifier, the output of the Login method. Include sessionID into all your requests. 2Checkout throws an exception if the values are incorrect.  The sessionID expires in 10 minutes.

Order

Required (Object)

 

Object designed to collect all data necessary for an order, including billing, product/subscription plan and payment details.

See code sample for more details. 

Request sample

<?php

/**
 * Sofort / Direct-Ebanking pay method order on RPC protocol
 */

function callRPC($Request, $hostUrl, $Debug = false)
{
    $curl = curl_init($hostUrl);
    curl_setopt($curl, CURLOPT_POST, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($curl, CURLOPT_SSLVERSION, 0);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_HTTPHEADER, array(
        'Content-Type: application/json',
        'Accept: application/json',
        'Cookie: XDEBUG_SESSION=PHPSTORM'
    ));
    $RequestString = json_encode($Request);
    curl_setopt($curl, CURLOPT_POSTFIELDS, $RequestString);

    if ($Debug) {
        var_dump($RequestString);
    }
    $ResponseString = curl_exec($curl);
    if ($Debug) {
        var_dump($ResponseString);
    }

    if (!empty($ResponseString)) {
        $Response = json_decode($ResponseString);
        if (isset($Response->result)) {
            return $Response->result;
        }
        var_dump($Response);

        if (!empty($Response->error)) {
            var_dump($Request->method, $Response->error);
        }
    } else {
        return null;
    }
}

$apiVersion = '6.0';
//$resource = 'orders';
//$host = "http://api.secure.avangate.local/rest/".$apiVersion."/".$resource."/";
$host = "http://api.avangate.local:8081/rpc/" . $apiVersion . "/";
//$host = "http://api.sandbox72.avangate.local/rest/".$apiVersion."/".$resource."/";

//
// IdAccount 21478
$merchantCode = "120000589445";
$key = "i9u2+w8%s4^5#8%t)A8?";
$productCode = "BDG8899343FE";
//$productCode = "TANGIBLEP"; // physical product
//*/

/*/ IdAccount 21743 (AlexB Migrated Co)
$merchantCode = "123456789000";
$key = "F34=P9?1&R0=8)O7O5E=";
//$productCode = "JBGL20192";
$productCode = "TINYPRICEPROD";
//*/

/*/ CC1268 merchant @ tests DB
$merchantCode = "CC1268";
$key = "SECRET_KEY";
$productCode = "TNGB1USD";
//*/

$date = gmdate('Y-m-d H:i:s');
$string = strlen($merchantCode) . $merchantCode . strlen($date) . $date;
//var_dump(gmdate('Y-m-d H:i:s'));
//var_dump(date('Y-m-d H:i:s')); die();
$hash = hash_hmac('md5', $string, $key);

$i = 1; // counter for api calls
// call login
$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'login';
$jsonRpcRequest->params = array($merchantCode, $date, $hash);
$jsonRpcRequest->id = $i++;


$sessionID = callRPC($jsonRpcRequest, $host);
//$sessionID = "dad08e7e9a2e2812fbe89e2980b07170c867f8f6";
var_dump("session: ".$sessionID);

$currency = 'EUR';
//$currency = 'USD';

$country = 'DE'; $state = ''; $city = 'Munchen';
//$country = 'US'; $state = 'GA'; $city = 'Atlanta';

$phone = '0049-0130-5529901';

$CartObj = new stdClass();
$CartObj->Currency = $currency;
$CartObj->Language = "EN";
$CartObj->Country = $country;
$CartObj->CountryCode = $country;
$CartObj->CustomerIP = '91.220.121.21';
$CartObj->Source = "sourceAPI.net";

//$CartObj->ExternalReference = "API2.5_PLACE_ORDER_EXT_" . date("Y-m-d h:m:i");
//$CartObj->Affiliate = new stdClass();
//$CartObj->Affiliate->AffiliateCode = 'Partner123'
//$CartObj->Affiliate->AffiliateSource = 'MobilePlatform'
$CartObj->LocalTime = date('Y-m-d H:i:s');
$CartObj->CustomerReference = '421820' . strval(rand (100, 999));
$CartObj->Items = array();

$CartObj->Items[0] = new stdClass();
$CartObj->Items[0]->Code = $productCode;//"3333399999_COPY1";//"155887799"; - vld_licence_1month //"12345"; -vld_regular
$CartObj->Items[0]->Quantity = 1;
//$CartObj->Items[0]->Price = 3;

$CartObj->Items[0]->PriceOptions = [];

$priceOption = new stdClass();
$priceOption->Name = 'Users';
$priceOption->Code = 'USERS_1';
$priceOption->Options = [];

$priceOptionOption = new stdClass();
$priceOptionOption->Name = '10 users';
$priceOptionOption->Value = '10_users';
$priceOptionOption->Surcharge = 0;

$priceOption->Options[] = $priceOptionOption;
$CartObj->Items[0]->PriceOptions[] = $priceOption;

$priceOption2 = new stdClass();
$priceOption2->Name = 'Maintenance period';
$priceOption2->Code = 'MAINTE_PERIOD';
$priceOption2->Options = [];

$priceOptionOption2 = new stdClass();
$priceOptionOption2->Name = '12 months';
$priceOptionOption2->Value = 'jira_maintenance_12_mths';
$priceOptionOption2->Surcharge = 0;

$priceOption2->Options[] = $priceOptionOption2;
$CartObj->Items[0]->PriceOptions[] = $priceOption2;

/**/
$additionalField1 = new stdClass();
$additionalField1->Code = "additional_field_order_1";
$additionalField1->Text = "REST";
$additionalField1->Value = "1";

$additionalField2 = new stdClass();
$additionalField2->Code = "additional_field_order_2";
$additionalField2->Text = "REST";
$additionalField2->Value = "a";

$additionalField3 = new stdClass();
$additionalField3->Code = "additional_field_order_3";
$additionalField3->Text = "REST";
$additionalField3->Value = "a";

$CartObj->AdditionalFields = array();
$CartObj->AdditionalFields[0] = $additionalField1;
$CartObj->AdditionalFields[1] = $additionalField2;
$CartObj->AdditionalFields[2] = $additionalField3;


$additionalField1 = new stdClass();
$additionalField1->Code = "additional_field_product_1";
$additionalField1->Text = "PRODUCT1 TEXT";
$additionalField1->Value = true;

$CartObj->Items[0]->AdditionalFields = array();
$CartObj->Items[0]->AdditionalFields[0] = $additionalField1;

//$CartObj->Promotions = ["48606DBB"];

$CartObj->MachineId = 'machineIdTestAlexB';
$CartObj->Discount = null;
$CartObj->ExternalReference = null;

$CartObj->BillingDetails = new stdClass();
$CartObj->BillingDetails->IsCompany = false;
//$CartObj->BillingDetails->Company = '';
$CartObj->BillingDetails->Address1 = '37 Mannheim Strasse, A8';
$CartObj->BillingDetails->Address2 = 'floor 3';
$CartObj->BillingDetails->City = $city;
$CartObj->BillingDetails->State = $state;
$CartObj->BillingDetails->CountryCode = $country;
$CartObj->BillingDetails->Phone = $phone;
$CartObj->BillingDetails->Email = 'reinhardt@trashmail.net';
$CartObj->BillingDetails->FirstName = 'Willy';
$CartObj->BillingDetails->LastName = 'Reinhardt';
$CartObj->BillingDetails->Zip = 99234;

/**/
$CartObj->DeliveryDetails = new stdClass();
$CartObj->DeliveryDetails->Address1 = '37 Mannheim Strasse, A8';
$CartObj->DeliveryDetails->Address2 = 'floor 3';
$CartObj->DeliveryDetails->City = $city;
$CartObj->DeliveryDetails->State = $state;
$CartObj->DeliveryDetails->CountryCode = $country;
$CartObj->DeliveryDetails->Phone = $phone;
$CartObj->DeliveryDetails->Email = 'reinhardt@trashmail.net';
$CartObj->DeliveryDetails->FirstName = 'Willy';
$CartObj->DeliveryDetails->LastName = 'Reinhardt';
$CartObj->DeliveryDetails->Zip = 99234;
/**/
$CartObj->PaymentDetails = new stdClass();
$CartObj->PaymentDetails->Type = 'DIRECT_EBANKING';
$CartObj->PaymentDetails->Currency = $currency;
$CartObj->PaymentDetails->CustomerIP = '91.220.121.21';

$CartObj->PaymentDetails->PaymentMethod = new stdClass();
//$CartObj->PaymentDetails->PaymentMethod->RecurringEnabled = true;
$CartObj->PaymentDetails->PaymentMethod->RecurringEnabled = false;
$CartObj->PaymentDetails->PaymentMethod->ReturnURL = 'https://yourreturnurl.com';
$CartObj->PaymentDetails->PaymentMethod->CancelURL= 'https://yourcancelurl.com ';


if ($CartObj->PaymentDetails->Type == 'PREVIOUS_ORDER') {
    $CartObj->ExternalReference ='orderbyref_exteranalref' . $CartObj->PaymentDetails->PaymentMethod->RefNo;
} elseif ($CartObj->PaymentDetails->Type == 'PAYPAL') {
    $CartObj->ExternalReference ='orderbyref_exteranalref_PAYPAL';
}

var_dump('Request', json_encode($CartObj));

$jsonRpcRequest = new stdClass();
$jsonRpcRequest->jsonrpc = '2.0';
$jsonRpcRequest->method = 'placeOrder';
$jsonRpcRequest->params = array($sessionID, $CartObj);
$jsonRpcRequest->id = $i++;


$response = json_encode(callRPC($jsonRpcRequest, $host));

var_dump('Response encoded', $response);

$response = json_decode($response);

var_dump('Response', $response);

Response Parameters

Parameter Type/Description

Order information

Object

  Object containing order information.

 Response Example

{
    "RefNo": "189897220",
    "OrderNo": 0,
    "ExternalReference": null,
    "ShopperRefNo": null,
    "Status": "PENDING",
    "ApproveStatus": "WAITING",
    "VendorApproveStatus": "OK",
    "MerchantCode": "251772850506",
    "Language": "en",
    "OrderDate": "2022-08-23 14:50:21",
    "FinishDate": null,
    "Source": "testAPI.com",
    "WSOrder": null,
    "Affiliate": {
        "AffiliateCode": null,
        "AffiliateSource": null,
        "AffiliateName": null,
        "AffiliateUrl": null
    },
    "HasShipping": true,
    "BillingDetails": {
        "FiscalCode": null,
        "TaxOffice": null,
        "Phone": "010-6552-9988",
        "FirstName": "John",
        "LastName": "Doe",
        "Company": null,
        "Email": "test@verifone.com",
        "Address1": "Test Address",
        "Address2": null,
        "City": "Test City",
        "Zip": "35005",
        "CountryCode": "de",
        "State": null
    },
    "DeliveryDetails": {
        "Phone": "010-6552-9988",
        "FirstName": "John",
        "LastName": "Doe",
        "Company": null,
        "Email": "test@verifone.com",
        "Address1": "Test Address",
        "Address2": null,
        "City": "Test City",
        "Zip": "35005",
        "CountryCode": "de",
        "State": null
    },
    "PaymentDetails": {
        "Type": "DIRECT_EBANKING",
        "Currency": "eur",
        "PaymentMethod": {
            "Amount": "35.5",
            "Currency": "eur",
            "Redirect": {
                "Url": "https://www.sofortueberweisung.de/payment/start",
                "Method": "POST",
                "Params": {
                    "user_id": "21352",
                    "project_id": "72016",
                    "sender_holder": "",
                    "sender_account_number": "",
                    "sender_bank_code": "",
                    "sender_country_id": "DE",
                    "amount": "35.5",
                    "currency_id": "EUR",
                    "reason_1": "BANKTRANSFER FOR: #189897220",
                    "reason_2": "",
                    "user_variable_0": "189897220",
                    "user_variable_1": 1423,
                    "user_variable_2": "secure.2checkout.com",
                    "user_variable_3": "",
                    "user_variable_4": "",
                    "user_variable_5": "",
                    "hash": "d88e50f1d90e0fc5a7858766db74e3be78e3b7b736d0598161a1a8e6115f4ed8"
                },
                "FullHtml": "<!DOCTYPE html><html><body><form action=\"https://www.sofortueberweisung.de/payment/start\" method=\"POST\" id=\"postform\"><input type=\"hidden\" name=\"user_id\" value=\"21352\" /><input type=\"hidden\" name=\"project_id\" value=\"72016\" /><input type=\"hidden\" name=\"sender_holder\" value=\"\" /><input type=\"hidden\" name=\"sender_account_number\" value=\"\" /><input type=\"hidden\" name=\"sender_bank_code\" value=\"\" /><input type=\"hidden\" name=\"sender_country_id\" value=\"DE\" /><input type=\"hidden\" name=\"amount\" value=\"35.5\" /><input type=\"hidden\" name=\"currency_id\" value=\"EUR\" /><input type=\"hidden\" name=\"reason_1\" value=\"BANKTRANSFER FOR: #189897220\" /><input type=\"hidden\" name=\"reason_2\" value=\"\" /><input type=\"hidden\" name=\"user_variable_0\" value=\"189897220\" /><input type=\"hidden\" name=\"user_variable_1\" value=\"1423\" /><input type=\"hidden\" name=\"user_variable_2\" value=\"secure.2checkout.com\" /><input type=\"hidden\" name=\"user_variable_3\" value=\"\" /><input type=\"hidden\" name=\"user_variable_4\" value=\"\" /><input type=\"hidden\" name=\"user_variable_5\" value=\"\" /><input type=\"hidden\" name=\"hash\" value=\"d88e50f1d90e0fc5a7858766db74e3be78e3b7b736d0598161a1a8e6115f4ed8\" /></form><script type=\"text/javascript\">document.getElementById(\"postform\").submit();</script></body></html>"
            },
            "ReturnURL": https://yourreturnurl.com,
            "CancelURL": https://yourcancelurl.com
            "Vendor3DSReturnURL": null,
            "Vendor3DSCancelURL": null,
            "InstallmentsNumber": null
        },
        "CustomerIP": "91.220.121.21"
    },
    "DeliveryInformation": {
        "ShippingMethod": {
            "Code": null,
            "TrackingUrl": null,
            "TrackingNumber": null,
            "Comment": null
        }
    },
    "CustomerDetails": null,
    "Origin": "API",
    "AvangateCommission": 2.63,
    "OrderFlow": "REGULAR",
    "GiftDetails": null,
    "PODetails": null,
    "ExtraInformation": null,
    "PartnerCode": null,
    "PartnerMargin": null,
    "PartnerMarginPercent": null,
    "ExtraMargin": null,
    "ExtraMarginPercent": null,
    "ExtraDiscount": null,
    "ExtraDiscountPercent": null,
    "LocalTime": null,
    "TestOrder": false,
    "FxRate": 0.960096,
    "FxMarkup": 4,
    "PayoutCurrency": "USD",
    "DeliveryFinalized": false,
    "Errors": null,
    "Items": [
        {
            "ProductDetails": {
                "Name": "Test Product",
                "ShortDescription": "<p>Join all your clouds in a big one</p>",
                "Tangible": false,
                "IsDynamic": false,
                "ExtraInfo": null,
                "RenewalStatus": false,
                "Subscriptions": null,
                "DeliveryInformation": {
                    "Delivery": "BY_AVANGATE",
                    "DownloadFile": null,
                    "DeliveryDescription": "",
                    "CodesDescription": "",
                    "Codes": []
                }
            },
            "PriceOptions": [],
            "Price": {
                "UnitNetPrice": 29.83,
                "UnitGrossPrice": 35.5,
                "UnitVAT": 5.67,
                "UnitDiscount": 0,
                "UnitNetDiscountedPrice": 29.83,
                "UnitGrossDiscountedPrice": 35.5,
                "UnitAffiliateCommission": 0,
                "ItemUnitNetPrice": null,
                "ItemUnitGrossPrice": null,
                "ItemNetPrice": null,
                "ItemGrossPrice": null,
                "VATPercent": 19,
                "HandlingFeeNetPrice": 0,
                "HandlingFeeGrossPrice": 0,
                "Currency": "eur",
                "NetPrice": 29.83,
                "GrossPrice": 35.5,
                "NetDiscountedPrice": 29.83,
                "GrossDiscountedPrice": 35.5,
                "Discount": 0,
                "VAT": 5.67,
                "AffiliateCommission": 0
            },
            "LineItemReference": "a37ea622e0d0aab958ac08f190842d9b66b42b6c",
            "PurchaseType": "PRODUCT",
            "Code": "LPUJL13OZ6",
            "ExternalReference": "",
            "Quantity": 1,
            "SKU": null,
            "CrossSell": null,
            "Trial": null,
            "AdditionalFields": null,
            "Promotion": null,
            "RecurringOptions": null,
            "SubscriptionStartDate": null,
            "SubscriptionCustomSettings": null,
            "UpSell": null
        }
    ],
    "Promotions": [],
    "AdditionalFields": null,
    "Currency": "eur",
    "NetPrice": 29.83,
    "GrossPrice": 35.5,
    "NetDiscountedPrice": 29.83,
    "GrossDiscountedPrice": 35.5,
    "Discount": 0,
    "VAT": 5.67,
    "AffiliateCommission": 0,
    "CustomParameters": null,
    "Refunds": null
}

For more on how to redirect shoppers to the payment method page to finalize the payment, please read here.

Rate this article:

Need help?

Do you have a question? If you didn’t find the answer you are looking for in our documentation, you can contact our Support teams for more information. If you have a technical issue or question, please contact us. We are happy to help.

Not yet a Verifone customer?

We’ll help you choose the right payment solution for your business, wherever you want to sell, in-person or online. Our team of experts will happily discuss your needs.

Verifone logo