NAV
.NET (C#) PHP JAVA curl HTTP form
English

Overview

Intro

en-GB

The TrustPay Acceptance API (service) is an internet based tool that merchants can use to create SEPA DirectDebit mandates, request direct debits with previously created mandate in TrustPay or to request direct debits with external mandates created via their own channels.

API endpoints:
Live - https://aapi.trustpay.eu/

OAuth

Getting access token

Direct debit API endpoints:
Live - https://aapi.trustpay.eu/api/oauth2/token

This method grants you an authentication token that can be used to call other REST API methods from TrustPay.

Request

Obtain token example:

using System;
using System.Net;
using System.Text;
using System.Web.Script.Serialization;

public string OAuth()
{
   using (var client = new WebClient())
   {
      string url = "https://aapi.trustpay.eu/api/oauth2/token";
      string userName = "test";
      string password = "test";
      string auth = $"Basic {Convert.ToBase64String(Encoding.UTF8.GetBytes($"{userName}:{password}"))}";
      client.Headers = new WebHeaderCollection
      {
         "Authorization:" + auth,
         "Content-Type: application/x-www-form-urlencoded"
      };

      JavaScriptSerializer serializer = new JavaScriptSerializer();
      var request = Encoding.UTF8.GetBytes("grant_type=client_credentials");
      var responseData = client.UploadData(url, request);
      var response = serializer.Deserialize<dynamic>(Encoding.UTF8.GetString(responseData));
      return response["access_token"];
   }
}

$url = 'https://aapi.trustpay.eu/api/oauth2/token';
$data = array('grant_type' => 'client_credentials');

$username = "abcdef";
$password = "123abc";
$auth = base64_encode("$username:$password");

$options = array(
   'http' => array(
      'header'  => array(
         "Authorization:Basic $auth",
         "Content-type:application/x-www-form-urlencoded",
      ),
      'method'  => 'POST',
      'content' => http_build_query($data)
   ),
);
$context  = stream_context_create($options);
$response = file_get_contents($url, false, $context);
$response = json_decode(file_get_contents($url, false, $context), true);
return $response['access_token'];

This code is using external library Jackson to parse text from and to json format
import org.codehaus.jackson.map.ObjectMapper; import javax.net.ssl.HttpsURLConnection; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.Base64; import java.util.Map; public String OAuth(){ HttpsURLConnection con = null; try { URL obj = new URL("https://aapi.trustpay.eu/api/oauth2/token"); con = (HttpsURLConnection) obj.openConnection(); con.setRequestMethod("POST"); String username = "abcdef"; String password = "123abc"; String encoded = "Basic " + Base64.getEncoder().encodeToString((username + ":" + password).getBytes()); con.setRequestProperty("Authorization", encoded); con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); con.setDoOutput(true); try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) { wr.writeBytes("grant_type=client_credentials"); wr.flush(); } String response = ""; try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) { String inputLine; while ((inputLine = in.readLine()) != null) { response += inputLine; } } ObjectMapper JsonParser = new ObjectMapper(); Map<String,String> deserialized = JsonParser.readValue(response, Map.class); return deserialized.get("access_token"); } catch(Exception ex){ throw new RuntimeException(ex.getMessage()); } finally { if(con != null) { con.disconnect(); } } }
Name Description Format Required
username ProjectID Varchar(20) Yes
password SecretKey Varchar(256) Yes

Response

Response example:
{
    "access_token":"L3_DbiQdateYLPYmp31AHEeErRzF84SVRcyr5Zw4jgw3CqDZjn4dbmVilTQx6dh_8ZbPztJGQh-9",
    "token-type":"bearer",
    "expires-in":1799
}
Name Description Format
access_token Authorization token Varchar(235)
token-type Type of token Varchar(20)
expires-in Duration of recieved token Smallint

SEPA Direct Debits

Payment process

Prepare mandate

API endpoints:
Live - https://aapi.trustpay.eu/api/SepaDirectDebitMandates/Mandate

Prepares the mandate and returns the URL of the form in which the customer needs to fill some additional information. After this information is submitted, the mandate will start being processed by TrustPay together with possible payment (if pay now was chosen).

Request

Prepare mandate example:

using System;
using System.Net;
using System.Text;
using System.Web.Script.Serialization;

public string PrepareMandate(string token)
{
   string url = "https://aapi.trustpay.eu/api/SepaDirectDebitMandates/Mandate";
   using (var client = new WebClient())
   {
      client.Headers = new WebHeaderCollection
      {
         "Authorization: bearer " + token,
         "Content-Type: text/json"
      };
      var request = new
      {
         PayNow = true,
         ReducedPeriod = 4,
         MerchantIdentification = new
         {
            ProjectId = "1234567",
         },
         PaymentInformation = new
         {
            DueDate = "2017-07-28",
            RemittanceInformation = "test123",
            Amount = new
             {
                Amount = 1.50,
                Currency = "EUR",
             },
            References = new
             {
                MerchantReference = "Order #12345",
                EndToEnd = "e2e",
             },
            SepaDirectDebitInformation = new
             {
                SequenceType = "RCUR",
             },
         },
         CallbackUrls = new
         {
            Notification = "https://somedomain.eu/notification_handler",
         }
      };

      JavaScriptSerializer serializer = new JavaScriptSerializer();

      var requestData = Encoding.UTF8.GetBytes(serializer.Serialize(request));
      var responseData = client.UploadData(url, requestData);
      var response = serializer.Deserialize<dynamic>(Encoding.UTF8.GetString(responseData));

      return response["PreparedMandateUrl"];
   }
}

function PrepareMandate($token)
{
   $url = 'https://aapi.trustpay.eu/api/SepaDirectDebitMandates/Mandate';
   $data = array(
      'PayNow' => 'true',
      'ReducedPeriod' => '',
      
      'MerchantIdentification' => array(
         'ProjectId' => '1234567890',
      ),
      'PaymentInformation' => array(
         'DueDate' => '2017-07-28',
         'RemittanceInformation' => 'test123',
         'Amount' => array(
            'Amount' => '1.50',
            'Currency' => 'EUR',
          ),
         'References' => array(
            'MerchantReference' => '123456',
            'EndToEnd' => 'test123',
          ),
         'SepaDirectDebitInformation' => array(
            'SequenceType' => 'RCUR',
          ),
      ),
      'CallbackUrls' => array(
         'Notification' => 'https://somedomain.eu/notification_handler',
      ),
   );  
   $options = array(
      'http' => array(
         'header'  => array(
            "Authorization:bearer $Token",
            'Content-type: text/json',
         ),
         'method'  => 'POST',            
         'content' => json_encode($data)
      ),
   );
   $context  = stream_context_create($options);
   $response = json_decode(file_get_contents($url, false, $context), true);
   return $response['PreparedMandateUrl'];
}

This code is using external library Jackson to parse text from and to json format

import org.codehaus.jackson.map.ObjectMapper;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Map;

public String PrepareMandate(String token){
    try{
        URL obj = new URL("https://aapi.trustpay.eu/api/SepaDirectDebitMandates/Mandate");
        HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
        con.setRequestMethod("POST");
        con.setRequestProperty("Authorization", "bearer " + token);
        con.setRequestProperty("Content-type", "text/json");
        Object request = new Object() {
            public boolean PayNow = true;
            public Byte ReducedPeriod = null;
            public Object MerchantIdentification = new Object(){
                public long ProjectId = 2107058607;
            };
            public Object PaymentInformation = new Object(){
                public String DueDate = "2017-03-27";
                public String RemittanceInformation = "test";
                public Object Amount = new Object(){
                        public double Amount = 1.50;
                        public String Currency = "EUR";
                };
                public Object References = new Object(){
                        public String MerchantReference = "merch ref. no. #555";
                        public String EndToEnd = "e2e";
                };
                public Object SepaDirectDebitInformation = new Object(){
                        public String SequenceType = "RCUR";
                };
            };
            public Object CallbackUrls = new Object(){
                public String Notification = "https://somedomain.eu/notification_handler";
            };
        };

        ObjectMapper JsonParser = new ObjectMapper();
        String jsonrequest = JsonParser.writeValueAsString(request);
        con.setDoOutput(true);

        try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
            wr.writeBytes(jsonrequest);
            wr.flush();
        }

        String response = "";
        try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
            String inputLine;
            while ((inputLine = in.readLine()) != null) {
                response += inputLine;
            }
        }

        Map<String,String> deserialized = JsonParser.readValue(response, Map.class);
        return deserialized.get("PreparedMandateUrl");
    }
    catch(Exception ex){
        throw new RuntimeException(ex.getMessage());
    }
}
Name Description Format Required
Token Authorization token Varchar(235) Yes
PayNow Create first direct debit together with the mandate Boolean Yes
ReducedPeriod Reduces direct debit pre-notification period by up to 13 days. Byte No
MerchantIdentification Identification of merchant MerchantIdentification Yes
PaymentInformation Payment information PaymentInformation Yes
CallbackUrls Return URLs CallbackUrls No

Request/MerchantIdentification

Name Description Format Required
ProjectId Merchant project ID (assigned by TrustPay) Numeric(20) Yes

Request/PaymentInformation

Name Description Format Required
DueDate Date to which the transaction should be carried out Varchar(10) For paynow
RemittanceInformation Remittance advice - additional information Varchar(35) No
Amount Amount of the payment Amount For paynow
References Reference (merchant’s payment identification) References For paynow
SepaDirectDebitInformation Mandate information SepaDirectDebit Information Yes

Request/PaymentInformation/Amount

Name Description Format Required
Amount Amount of the payment (exactly 2 decimal places) Numeric(13,2) en-US format For paynow
Currency Currency of the payment Char(3) For paynow

Request/PaymentInformation/References

Name Description Format Required
MerchantReference Reference (merchant’s payment identification) Varchar(35) For paynow
EndToEnd Reference between merchant and client Varchar(35) No

Request/PaymentInformation/SepaDirectDebitInformation

Name Description Format Required
SequenceType Type of mandate:
RCUR - Recurrent payment
OOFF - One-off payment
Char(4)
en-US format
Yes

Request/CallbackUrls

Name Description Format Required
Notification Url address to which the notifications regarding this payment should be sent (if PayNow was chosen) Varchar(256) No

Response

Response example:
{
    "PrepareMandateUrl":"https://aapi.trustpay.eu/SepaDirectDebitMandates/input/ba7db67e-7h73-4bt0-880f-7ec0f07b1c4e"
}
Name Description Format
PrepareMandateUrl Url to site where Debtors credentials can be submited (sent only when call succeeded) Varchar(256)
ErrorCode Id of error that ocurred durring service call (sent only when call failed) Numeric(10)
ErrorMessage Description of error that ocurred durring service call (sent only when call failed) Varchar(235)

Cancel mandate

API endpoints:
Live - https://aapi.trustpay.eu/api/SepaDirectDebitMandates/Mandate/[UMR]/Cancel

This function allows you to cancel an active mandate.

Request

Cancel mandate example:

using System.Net;
using System.Text;
using System.Web.Script.Serialization;

public void CancelMandate(string token)
{
   string url = "https://aapi.trustpay.eu/api/SepaDirectDebitMandates/Mandate/[UMR]/Cancel";
   using (var client = new WebClient())
   {
      client.Headers = new WebHeaderCollection
      {
         "Authorization: bearer " + token,
         "Content-Type: text/json"
      };
      var request = new
      {
         Umr = "12345678901234567890"
      };

      JavaScriptSerializer serializer = new JavaScriptSerializer();

      var requestData = Encoding.UTF8.GetBytes(serializer.Serialize(request));
      var responseData = client.UploadData(url, requestData);
      var response = Encoding.UTF8.GetString(responseData);
      if (response == "{}")
      {
         return;
      }
      throw new Exception(serializer.Deserialize<dynamic>(response)["ResultMessage"]);
   }
}

function CancelMandate($token)
{
   $url = 'https://aapi.trustpay.eu/api/SepaDirectDebitMandates/Mandate/[UMR]/Cancel';
   $data = array('Umr' => '12345678901234567890'); 

   $options = array(
      'http' => array(
         'header'  => array(
            "Authorization:bearer $Token",
            'Content-type: text/json',
         ),
         'method'  => 'POST',            
         'content' => json_encode($data)
      ),
   );
   $context  = stream_context_create($options);
   $response = file_get_contents($url, false, $context);
   if ($response == "{}"){
      return;
   }
   throw new Exception(json_decode($response, true)['ResultMessage']);
}

This code is using external library Jackson to parse text from and to json format
import org.codehaus.jackson.map.ObjectMapper; import javax.net.ssl.HttpsURLConnection; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.Map; public void CancelMandate(String token){ try { URL obj = new URL("https://aapi.trustpay.eu/api/SepaDirectDebitMandates/Mandate/[UMR]/Cancel"); HttpsURLConnection con = (HttpsURLConnection) obj.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Authorization", "bearer " + token); con.setRequestProperty("Content-type", "text/json"); Object request = new Object() { public String Umr = "12345678901234567890"; }; ObjectMapper JsonParser = new ObjectMapper(); String jsonrequest = JsonParser.writeValueAsString(request); con.setDoOutput(true); try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) { wr.writeBytes(jsonrequest); wr.flush(); } String response = ""; try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) { String inputLine; while ((inputLine = in.readLine()) != null) { response += inputLine; } } if (response == "{}") { return; } Map<String,String> deserialized = JsonParser.readValue(response, Map.class); throw new Exception(deserialized.get("PreparedMandateUrl")); } catch (Exception ex){ throw new RuntimeException(ex.getMessage()); } }
Name Description Format Required
Token Authorization token Varchar(235) Yes
Umr Unique Mandate Reference of mandate that you want to cancel Char(20) Yes

Response

Response example:
{}
Name Description Format
ResultCode Id of the response returned by service (sent only when call succeeded) Varchar(256)
ResultMessage Description of the outcome of your call (sent only when call succeeded) Varchar(256)

Capture payment

API endpoints:
Live - https://aapi.trustpay.eu/api/Payments/Payment

Creates new direct debit accounted to an already existing mandate based on it's UMR (Unique Mandate Reference).

Request

Capture payment example:

using System.Net;
using System.Text;
using System.Web.Script.Serialization;

public int CapturePayment(string token)
{
   string url = "https://aapi.trustpay.eu/api/Payments/Payment";
   using (var client = new WebClient())
   {
      client.Headers = new WebHeaderCollection
      {
         "Authorization: bearer " + token,
         "Content-Type: text/json"
      };
      var request = new
      {
         PaymentMethod = "SepaDirectDebit",
         MerchantIdentification = new
         {
             ProjectId = "1234567",
         },
         PaymentInformation = new
         {
             DueDate = "2017-07-28",
             RemittanceInformation = "test123",
             Amount = new
             {
                 Amount = 1.50,
                 Currency = "EUR",
             },
             References = new
             {
                 MerchantReference = "Order #12345",
                 EndToEnd = "e2e",
             },
             SepaDirectDebitInformation = new
             {
                 MandateInformation = new
                 {
                     Umr = "12345678901234567890",
                 },
             },
         },
         CallbackUrls = new
         {
             Notification = "https://somedomain.eu/notification_handler",
         }
      };

      JavaScriptSerializer serializer = new JavaScriptSerializer();

      var requestData = Encoding.UTF8.GetBytes(serializer.Serialize(request));
      var responseData = client.UploadData(url, requestData);
      var response = serializer.Deserialize<dynamic>(Encoding.UTF8.GetString(responseData));

      return response["PaymentRequestId"];
   }
}

function CapturePayment($token)
{
   $url = 'https://aapi.trustpay.eu/api/Payments/Payment';
   $data = array(
      'PaymentMethod' => 'SepaDirectDebit',
      'MerchantIdentification' => array(
         'ProjectId' => '1234567890',
      ),
      'PaymentInformation' => array(
         'DueDate' => '2017-07-28',
         'RemittanceInformation' => 'test123',
         'Amount' => array(
            'Amount' => '1.50',
            'Currency' => 'EUR',
          ),
         'References' => array(
            'MerchantReference' => '123456',
            'EndToEnd' => 'test123',
          ),
          'SepaDirectDebitInformation' => array(
            'MandateInformation' => array(
              'Umr' => '12345678901234567890',
            ),
          ),
      ),
      'CallbackUrls' => array(
         'Notification' => 'https://somedomain.eu/notification_handler',
      ),
   );  

   $options = array(
      'http' => array(
         'header'  => array(
            "Authorization:bearer $Token",
            'Content-type: text/json',
         ),
         'method'  => 'POST',            
         'content' => json_encode($data)
      ),
   );
   $context  = stream_context_create($options);
   $response = json_decode(file_get_contents($url, false, $context), true);
   return $response['PaymentRequestId'];
}

This code is using external library Jackson to parse text from and to json format

import org.codehaus.jackson.map.ObjectMapper;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Map;

public String CapturePayment(String token){
    try {
        URL obj = new URL("https://aapi.trustpay.eu/api/Payments/Payment");
        HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
        con.setRequestMethod("POST");
        con.setRequestProperty("Authorization", "bearer " + token);
        con.setRequestProperty("Content-type", "text/json");
        Object request = new Object() {
            public String PaymentMethod = "SepaDirectDebit";
            public Object MerchantIdentification = new Object(){
                public long ProjectId = 2107058607;
            };
            public Object PaymentInformation = new Object(){
                public String DueDate = "2017-03-27";
                public String RemittanceInformation = "test";
                public Object Amount = new Object(){
                        public double Amount = 1.50;
                        public String Currency = "EUR";
                };
                public Object References = new Object(){
                        public String MerchantReference = "merch ref. no. #555";
                        public String EndToEnd = "e2e";
                };
                public Object SepaDirectDebitInformation = new Object(){
                        public Object MandateInformation = new Object(){
                            public String Umr = "12345678901234567890";
                        };
                };
            };
            public Object CallbackUrls = new Object(){
                public String Notification = "https://somedomain.eu/notification_handler";
            };
        };
        ObjectMapper JsonParser = new ObjectMapper();
        String jsonrequest = JsonParser.writeValueAsString(request);
        con.setDoOutput(true);

        try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
            wr.writeBytes(jsonrequest);
            wr.flush();
        }

        String response = "";
        try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
            String inputLine;
            while ((inputLine = in.readLine()) != null) {
                response += inputLine;
            }
        }

        Map<String,String> deserialized = JsonParser.readValue(response, Map.class);
        return String.valueOf(deserialized.get("PaymentRequestId"));
    }
    catch (Exception ex){
        throw new RuntimeException(ex.getMessage());
    }
}
Name Description Format Required
Token Authorization token Varchar(235) Yes
PaymentMethod SepaDirectDebit Varchar Yes
MerchantIdentification Identification of merchant Merchant Identification Yes
PaymentInformation Payment information PaymentInformation Yes
CallbackUrls Callback URLs CallbackUrls No

Request/MerchantIdentification

Name Description Format Required
ProjectId Merchant project ID (assigned by TrustPay) Numeric(20) Yes

Request/PaymentInformation

Name Description Format Required
DueDate Date to which the transaction should be carried out Varchar(10) Yes
RemittanceInformation Remittance advice - additional information Varchar(35) No
Amount Amount of the payment Amount Yes
References Reference (merchant’s payment identification) References Yes
SepaDirectDebitInformation Mandate information SepaDirectDebit Information Yes

Request/PaymentInformation/Amount

Name Description Format Required
Amount Amount of the payment (exactly 2 decimal places) Numeric(13,2) en-US format Yes
Currency Currency of the payment Char(3) Yes

Request/PaymentInformation/References

Name Description Format Required
MerchantReference Reference (merchant’s payment identification) Varchar(35) Yes
EndToEnd Reference between merchant and client Varchar(35) No

Request/PaymentInformation/SepaDirectDebitInformation

Name Description Format Required
MandateInformation Mandate Information Mandate Information Yes

Request/PaymentInformation/SepaDirectDebitInformation/MandateInformation

Name Description Format Required
Umr Unique Mandate Reference of mandate to which should this payment be assigned Varchar(35) Yes

Request/CallbackUrls

Name Description Format Required
Notification Url address to which the notifications regarding this payment should be sent Varchar(256) No

Response

Response example:
{
    "PaymentRequestId":1
}
Name Description Format
PaymentRequestId Id of payment requestId for the direct debit that was just created (sent only when call succeeded) Numeric(20)
ErrorCode Id of error that ocurred durring service call (sent only when call failed) Numeric(10)
ErrorMessage Description of error that ocurred durring service call (sent only when call failed) Varchar(235)

Capture payment with external mandate

API endpoints:
Live - https://aapi.trustpay.eu/api/Payments/Payment

Creates new direct debit without previously creating a mandate in TrustPay. This API has the same request and response as Capture payment, with these additional parameters in the request:

Request

Capture payment with external mandate example:

using System.Net;
using System.Text;
using System.Web.Script.Serialization;

public int CapturePayment(string token)
{
   string url = "https://aapi.trustpay.eu/api/Payments/Payment";
   using (var client = new WebClient())
   {
      client.Headers = new WebHeaderCollection
      {
         "Authorization: bearer " + token,
         "Content-Type: text/json"
      };
      var request = new
      {
         PaymentMethod = "SepaDirectDebit",
         MerchantIdentification = new
         {
             ProjectId = "1234567",
         },
         PaymentInformation = new
         {
             DueDate = "2017-07-28",
             RemittanceInformation = "test123",
             Amount = new
             {
                 Amount = 1.50,
                 Currency = "EUR",
             },
             References = new
             {
                 MerchantReference = "Order #12345",
                 EndToEnd = "e2e",
             },
             SepaDirectDebitInformation = new
             {
                 SequenceType = "FRST",
                 MandateInformation = new
                 {
                     Umr = "12345678901234567890",
                     SignatureCity = "Bratislava",
                     SignatureDate = "2017-07-28",
                 },
             },
             Debtor = new
             {
                 Name = "John Doe",
                 Email = "client@somedomain.eu",
                 IpAddress = "1.2.3.4",
                 Address = new
                 {
                     PostalCode = "12345",
                     City = "Bratislava",
                     CountryCode = "SK",
                     Lines = new[]
                     {
                         "Street 1/A",
                     },
                 },
             },
             DebtorAccount = new
             {
                 Iban = "SK3112000000198742637541",
             },
             DebtorAgent = new
             {
                 Bic = "TPAYSKBX",
             },
         },
         CallbackUrls = new
         {
             Notification = "https://somedomain.eu/notification_handler",
         }
      };

      JavaScriptSerializer serializer = new JavaScriptSerializer();

      var requestData = Encoding.UTF8.GetBytes(serializer.Serialize(request));
      var responseData = client.UploadData(url, requestData);
      var response = serializer.Deserialize<dynamic>(Encoding.UTF8.GetString(responseData));

      return response["PaymentRequestId"];
   }
}

function CapturePayment($token)
{
   $url = 'https://aapi.trustpay.eu/api/Payments/Payment';
    $data = array(
      'PaymentMethod' => 'SepaDirectDebit',
      'MerchantIdentification' => array(
          'ProjectId' => '1234567890',
      ),
      'PaymentInformation' => array(
          'DueDate' => '2017-07-28',
          'RemittanceInformation' => 'test123',
          'Amount' => array(
            'Amount' => '1.50',
            'Currency' => 'EUR',
          ),
          'References' => array(
            'MerchantReference' => '123456',
            'EndToEnd' => 'test123',
          ),
          'SepaDirectDebitInformation' => array(
            'SequenceType' => 'FRST',
            'MandateInformation' => array(
                'Umr' => '12345678901234567890',
                'SignatureCity' => 'Bratislava',
                'SignatureDate' => '2017-07-28',
             ),
          ),
          'Debtor' => array(
            'Name' => 'John Doe',
            'Email' => 'client@somedomain.eu',
            'IpAddress' => '1.2.3.4',
            'Address' => array(
                'PostalCode' => '12345',
                'City' => 'Bratislava',
                'CountryCode' => 'SK',
                'Lines' => array('Street 1/A'),
             ),
          ),
          'DebtorAccount' => array(
            'Iban' => 'SK3112000000198742637541',
          ),
          'DebtorAgent' => array(
            'Bic' => 'TPAYSKBX',
          ),
      ),
      'CallbackUrls' => array(
         'Notification' => 'https://somedomain.eu/notification_handler',
      ),
    ); 

   $options = array(
      'http' => array(
         'header'  => array(
            "Authorization:bearer $Token",
            'Content-type: text/json',
         ),
         'method'  => 'POST',            
         'content' => json_encode($data)
      ),
   );
   $context  = stream_context_create($options);
   $response = json_decode(file_get_contents($url, false, $context), true);
   return $response['PaymentRequestId'];
}

This code is using external library Jackson to parse text from and to json format

import org.codehaus.jackson.map.ObjectMapper;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Map;

public String CapturePayment(String token){
    try {
        URL obj = new URL("https://aapi.trustpay.eu/api/Payments/Payment");
        HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
        con.setRequestMethod("POST");
        con.setRequestProperty("Authorization", "bearer " + token);
        con.setRequestProperty("Content-type", "text/json");
        Object request = new Object() {
            public String PaymentMethod = "SepaDirectDebit";
            public Object MerchantIdentification = new Object(){
                public long ProjectId = 2107058607;
                public String Currency = "EUR";
            };
            public Object PaymentInformation = new Object(){
                public String DueDate = "2017-03-27";
                public String RemittanceInformation = "test";
                public Object Amount = new Object(){
                        public double Amount = 1.50;
                };
                public Object References = new Object(){
                        public String MerchantReference = "merch ref. no. #555";
                        public String EndToEnd = "e2e";
                };
                public Object SepaDirectDebitInformation = new Object(){
                        public String SequenceType = "FRST";
                        public Object MandateInformation = new Object(){
                            public String Umr = "12345678901234567890";
                            public String SignatureDate = "2020-06-01";
                            public String SignatureCity = "Bratislava";
                        };
                };
                public Object Debtor = new Object(){
                        public String Name = "John Doe";
                        public String Email = "client@somedomain.eu";
                        public String IpAddress = "1.2.3.4";
                        public Object Address = new Object(){
                            public String PostalCode = "12345";
                            public String City = "Bratislava";
                            public String CountryCode = "SK";
                            public String[] Lines  = {"Street 1/A"};
                        };
                };
                public Object DebtorAccount = new Object(){
                        public String Iban = "SK3112000000198742637541";
                };
                public Object DebtorAgent = new Object(){
                        public String Bic = "TPAYSKBX";
                };
            };
            public Object CallbackUrls = new Object(){
                public String Notification = "https://somedomain.eu/notification_handler";
            };
        };
        ObjectMapper JsonParser = new ObjectMapper();
        String jsonrequest = JsonParser.writeValueAsString(request);
        con.setDoOutput(true);

        try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
            wr.writeBytes(jsonrequest);
            wr.flush();
        }

        String response = "";
        try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
            String inputLine;
            while ((inputLine = in.readLine()) != null) {
                response += inputLine;
            }
        }

        Map<String,String> deserialized = JsonParser.readValue(response, Map.class);
        return String.valueOf(deserialized.get("PaymentRequestId"));
    }
    catch (Exception ex){
        throw new RuntimeException(ex.getMessage());
    }
}
Name Description Format Required
Token Authorization token Varchar(235) Yes
PaymentMethod SepaDirectDebit Varchar Yes
MerchantIdentification Identification of merchant Merchant Identification Yes
PaymentInformation Payment information Payment Information Yes
CallbackUrls Callback URLs CallbackUrls No

Request/MerchantIdentification

Name Description Format Required
ProjectId Merchant project ID (assigned by TrustPay) Numeric(20) Yes

Request/PaymentInformation

Name Description Format Required
DueDate Date to which the transaction should be carried out Varchar(10) Yes
RemittanceInformation Remittance advice - additional information Varchar(35) No
Amount Amount of the payment Amount Yes
References Reference (merchant’s payment identification) References Yes
SepaDirectDebitInformation Mandate information SepaDirectDebit Information Yes
Debtor Debtor information Debtor Information Yes
DebtorAccount Debtor Account information Debtor Account Information Yes
DebtorAgent Debtor Agent information Debtor Agent Information Yes

Request/PaymentInformation/Amount

Name Description Format Required
Amount Amount of the payment (exactly 2 decimal places) Numeric(13,2) en-US format Yes
Currency Currency of the payment Char(3) Yes

Request/PaymentInformation/References

Name Description Format Required
MerchantReference Reference (merchant’s payment identification) Varchar(35) Yes
EndToEnd Reference between merchant and client Varchar(35) No

Request/PaymentInformation/SepaDirectDebitInformation

Name Description Format Required
SequenceType Type of direct debit payment:
FRST - First payment
FNAL - Final payment payment
RCUR - Recurrent payment
OOFF - One-off payment
Char(4) Yes
MandateInformation Mandate Information Mandate Information Yes

Request/PaymentInformation/SepaDirectDebitInformation/MandateInformation

Name Description Format Required
Umr Unique Mandate Reference of mandate to which should this payment be assigned Varchar(35) No
SignatureDate Signature date of the mandate Varchar(10) Yes
SignatureCity Signature city of the mandate Varhar(35) Yes

Request/PaymentInformation/Debtor

Name Description Format Required
Name Debtor's name Varchar(70) Yes
Email Debtor's email address Varhar(320) No
IpAddress Debtor's IP address Varhar(15) No
Address Debtor's address Address Yes

Request/PaymentInformation/Debtor/Address

Name Description Format Required
PostalCode Debtor's postal code Varchar(16) Yes
City Debtor's city Varchar(35) Yes
CountryCode Debtor's country (ISO 3166-1 alpha-2) Char(2) Yes
Lines Address lines string[] Yes

Request/PaymentInformation/DebtorAccount

Name Description Format Required
Iban Debtor's Iban Varchar(34) Yes

Request/PaymentInformation/DebtorAgent

Name Description Format Required
Bic Debtor's bank Bic Varchar(11) Yes

Request/CallbackUrls

Name Description Format Required
Notification Url address to which the notifications regarding this payment should be sent Varchar(256) No

Response

Response example:
{
    "PaymentRequestId":1
}
Name Description Format
PaymentRequestId Id of payment requestId for the direct debit that was just created (sent only when call succeeded) Numeric(20)
ErrorCode Id of error that ocurred durring service call (sent only when call failed) Numeric(10)
ErrorMessage Description of error that ocurred durring service call (sent only when call failed) Varchar(235)

Cancel direct debit

???api.endpoints@ips3.documentation.en???:
Live - https://aapi.trustpay.eu/api/Payments/Payment/[PaymentRequestId]/Cancel

This function allows you to reject a direct debit.

Request

Cancel direct debit example:

using System.Net;
using System.Text;
using System.Web.Script.Serialization;

public string CancelDirectDebit(string token)
{
   string url = "https://aapi.trustpay.eu/api/Payments/Payment/[PaymentRequestId]/Cancel";
   using (var client = new WebClient())
   {
      client.Headers = new WebHeaderCollection
      {
         "Authorization: bearer " + token,
         "Content-Type: text/json"
      };
      var request = new
      {
        
      };

      JavaScriptSerializer serializer = new JavaScriptSerializer();
                
      var requestdata = Encoding.UTF8.GetBytes(serializer.Serialize(request));
      var responseData = client.UploadData(url, requestdata);
      var response = serializer.Deserialize<dynamic>(Encoding.UTF8.GetString(responseData));
      if (Encoding.UTF8.GetString(responseData) == "{}")
      {
         return "DirectDebit was canceled";
      }
      return response["ErrorMessage"];
   }
}

function CancelDirectDebit($token)
{
   $url = 'https://aapi.trustpay.eu/api/Payments/Payment/[PaymentRequestId]/Cancel';
   $data = array(
      
   );  

   $options = array(
      'http' => array(
         'header'  => array(
            "Authorization:bearer $Token",
            'Content-type: text/json',
         ),
         'method'  => 'POST',            
         'content' => json_encode($data)
      ),
   );
   $context  = stream_context_create($options);
   $response = file_get_contents($url, false, $context);
   if ($response == "{}"){
      return null;
   }
   throw new Exception(json_decode($response, true)['ErrorMessage']);
}

This code is using external library Jackson to parse text from and to json format
import org.codehaus.jackson.map.ObjectMapper; import javax.net.ssl.HttpsURLConnection; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.Map; public String CancelDirectDebit(String token){ try { URL obj = new URL("https://aapi.trustpay.eu/api/Payments/Payment/[PaymentRequestId]/Cancel"); HttpsURLConnection con = (HttpsURLConnection) obj.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Authorization", "bearer " + token); con.setRequestProperty("Content-type", "text/json"); Object request = new Object() { }; ObjectMapper JsonParser = new ObjectMapper(); String jsonrequest = JsonParser.writeValueAsString(request); con.setDoOutput(true); try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) { wr.writeBytes(jsonrequest); wr.flush(); } String response = ""; try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) { String inputLine; while ((inputLine = in.readLine()) != null) { response += inputLine; } } System.out.println(response); Map<String,String> deserialized = JsonParser.readValue(response, Map.class); return deserialized.get("ErrorMessage"); } catch (Exception ex){ throw new RuntimeException(ex.getMessage()); } }
Name Description Format Required
Token Authorization token Varchar(235) Yes
PaymentRequestId Identification number of direct debit that should be canceled Char(20) Yes

Response

Response example:
{}
Name Description Format
ErrorCode Id of error that ocurred durring service call (sent only when call failed) Numeric(10)
ErrorMessage Description of error that ocurred durring service call (sent only when call failed) Varchar(235)

Refund direct debit

API endpoints:
Live - https://aapi.trustpay.eu/api/Payments/Payment/[PaymentRequestId]/Refund

This function allows you to refund a direct debit.

Request

Refund direct debit example:

using System.Net;
using System.Text;
using System.Web.Script.Serialization;

public string RefundDirectDebit(string token)
{
   string url = "https://aapi.trustpay.eu/api/Payments/Payment/[PaymentRequestId]/Refund";
   using (var client = new WebClient())
   {
      client.Headers = new WebHeaderCollection
      {
         "Authorization: bearer " + token,
         "Content-Type: text/json"
      };
      var request = new
      {
         PaymentInformation = new
         {
             Amount = new
             {
                 Amount = 1.50,
                 Currency = "EUR",
             },
         },
      };

      JavaScriptSerializer serializer = new JavaScriptSerializer();
                
      var requestdata = Encoding.UTF8.GetBytes(serializer.Serialize(request));
      var responseData = client.UploadData(url, requestdata);
      var response = serializer.Deserialize<dynamic>(Encoding.UTF8.GetString(responseData));
      if (Encoding.UTF8.GetString(responseData) == "{}")
      {
         return "Refund was successful";
      }
      return response["ErrorMessage"];
   }
}

function RefundDirectDebit($token)
{
   $url = 'https://aapi.trustpay.eu/api/Payments/Payment/[PaymentRequestId]/Refund';
   $data = array(
      'PaymentInformation' => array(
         'Amount' => array(
            'Amount' => '1.50',
            'Currency' => 'EUR',
          ),
      ),
   );  

   $options = array(
      'http' => array(
         'header'  => array(
            "Authorization:bearer $Token",
            'Content-type: text/json',
         ),
         'method'  => 'POST',            
         'content' => json_encode($data)
      ),
   );
   $context  = stream_context_create($options);
   $response = file_get_contents($url, false, $context);
   if ($response == "{}"){
      return null;
   }
   throw new Exception(json_decode($response, true)['ErrorMessage']);
}

This code is using external library Jackson to parse text from and to json format
import org.codehaus.jackson.map.ObjectMapper; import javax.net.ssl.HttpsURLConnection; import java.io.BufferedReader; import java.io.DataOutputStream; import java.io.InputStreamReader; import java.net.URL; import java.util.Map; public String RefundDirectDebit(String token){ try { URL obj = new URL("https://aapi.trustpay.eu/api/Payments/Payment/[PaymentRequestId]/Refund"); HttpsURLConnection con = (HttpsURLConnection) obj.openConnection(); con.setRequestMethod("POST"); con.setRequestProperty("Authorization", "bearer " + token); con.setRequestProperty("Content-type", "text/json"); Object request = new Object() { public Object PaymentInformation = new Object(){ public Object Amount = new Object(){ public double Amount = 1.50; public String Currency = "EUR"; }; }; }; ObjectMapper JsonParser = new ObjectMapper(); String jsonrequest = JsonParser.writeValueAsString(request); con.setDoOutput(true); try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) { wr.writeBytes(jsonrequest); wr.flush(); } String response = ""; try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) { String inputLine; while ((inputLine = in.readLine()) != null) { response += inputLine; } } System.out.println(response); Map<String,String> deserialized = JsonParser.readValue(response, Map.class); return deserialized.get("ErrorMessage"); } catch (Exception ex){ throw new RuntimeException(ex.getMessage()); } }
Name Description Format Required
Token Authorization token Varchar(235) Yes
PaymentInformation Payment information PaymentInformation Yes

Request/PaymentInformation

Name Description Format Required
Amount Amount of the refund Amount Yes

Request/PaymentInformation/Amount

Name Description Format Required
Amount Amount of the refund (exactly 2 decimal places) Numeric(13,2) en-US format Yes
Currency Currency of the payment Char(3) Yes

Response

Response example:
{}
Name Description Format
ErrorCode Id of error that ocurred durring service call (sent only when call failed) Numeric(10)
ErrorMessage Description of error that ocurred durring service call (sent only when call failed) Varchar(235)

DirectDebit notifications

DirectDebit URL notification example:
https://example.handler.com/

{
  "PaymentMethod": "SepaDirectDebit",
  "MerchantIdentification": {
    "ProjectId": "4101111111"
  },
  "PaymentInformation": {
    "Amount": {
      "Amount": "25.00",
      "Currency": "EUR"
    },
    "CreditDebitIndicator": "CRDT",
    "Status": "Paid",
    "StatusReasonInformation": {
      "Reason": {
        "Code": "MD06"
      }
    },
    "References": {
      "MerchantReference": "1234567890",
      "EndToEnd": "e2eReference",
      "PaymentId": "49863043"
    },
    "Debtor": {
      "Name": "John"
    },
    "DebtorAccount": {
      "Iban": "DE75512108001245126199"
    },
    "DebtorAgent": {
      "Bic": "SOGEDEFF"
    },
    "Creditor": {
      "Name": "John"
    },
    "CreditorAccount": {
      "Iban": "DE75512108001245126199"
    },
    "CreditorAgent": {
      "Bic": "SOGEDEFF"
    },
    "SepaDirectDebitInformation": {
      "MandateInformation": {
        "UMR": "31011111110000001234"
      }
    },
  "Signature": "013B192245EF81995E3F219E064F42DC1E1F4A6BC67CB546E1CCA6DC35E5CB73"
  }
}

DirectDebit E-mail notification: contains the same JSON notification in message body.
Name Description Format Included
PaymentMethod Payment method Varchar(50) Always
MerchantIdentification Identification of merchant MerchantIdentification Always
PaymentInformation Payment information PaymentInformation Always
Signature Data signature calculated from concatenated values of all values in the notification. Slash character ('/') is used as separator. Not empty values are sorted in ascending order and then concatenated using the separator. Char(64) Always

Notification/MerchantIdentification

Name Description Format Included
ProjectId Merchant project ID (assigned by TrustPay) Numeric(20) Always

Notification/PaymentInformation

Name Description Format Included
Amount Amount of the payment Amount Always
CreditDebitIndicator Values: CRDT or DBIT Varchar(4) Always
Status Status of payment, values: Paid, Rejected Varchar(50) Always
References Reference (merchant’s payment identification) References Always
StatusReasonInformation If available then Status reason for the Rejected payment StatusReasonInformation Only Rejected
Debtor Debtor details Debtor Only for CRDT
DebtorAccount Debtor's account details DebtorAccount Only for CRDT
DebtorAgent Debtor's agent details DebtorAgent Only for CRDT
Creditor Creditor details Creditor Only for DBIT
CreditorAccount Creditor's account details CreditorAccount Only for DBIT
CreditorAgent Creditor's agent details CreditorAgent Only for DBIT
SepaDirectDebitInformation Mandate information SepaDirectDebit Information Always

Notification/PaymentInformation/Amount

Name Description Format Included
Amount Amount of the payment (exactly 2 decimal places) Numeric(13,2) en-US format Always
Currency Currency of the payment Char(3) Always

Notification/PaymentInformation/References

Name Description Format Included
MerchantReference Reference (merchant’s payment identification) Varchar(512) Always
EndToEnd Reference between merchant and client Varchar(35) Always
PaymentId Id of payment Numeric(20) Always

Notification/PaymentInformation/StatusReasonInformation

Name Description Format Included
Reason Reason Reason If reason specified

Notification/PaymentInformation/StatusReasonInformation/Reason

Name Description Format Included
Code Code Varchar(4) If reason specified

Notification/PaymentInformation/Debtor

Name Description Format Included
Name Debtor's name Varchar Always
Address Debtor's address Address Always

Notification/PaymentInformation/Creditor

Name Description Format Included
Name Creditor's name Varchar Always

Notification/PaymentInformation/Debtor/Address

Name Description Format Included
CountryCode Country code ISO 3166-1 alpha-2 Char(2) Always

Notification/PaymentInformation/DebtorAccount

Name Description Format Included
Iban Debtor's IBAN Char(22) Always

Notification/PaymentInformation/CreditorAccount

Name Description Format Included
Iban Creditor's IBAN Char(22) Always

Notification/PaymentInformation/DebtorAgent

Name Description Format Included
Bic Debtor's agent's bank identifier code Varchar(11) Always

Notification/PaymentInformation/CreditorAgent

Name Description Format Included
Bic Creditor's agent's bank identifier code Varchar(11) Always

Notification/PaymentInformation/SepaDirectDebitInformation

Name Description Format Required
MandateInformation Mandate details Mandate Information Always

Notification/PaymentInformation/SepaDirectDebitInformation/MandateInformation

Name Description Format Always
UMR Unique Mandate Reference Unique Yes

Mandate notifications

Mandate URL notification example:
https://example.handler.com/result.php?AID=4107111111&UMR=12345678901234567890

{
  "PaymentMethod": "SepaDirectDebit",
  "MerchantIdentification": {
    "ProjectId": "4101111111",
    "CID": "12345678"
  },
  "PayNow": "True",
  "ReducedPeriod": "3",
  "PaymentInformation": {
    "Amount": {
      "Amount": "25.00",
      "Currency": "EUR"
    },
    "CreditDebitIndicator": "CRDT",
    "References": {
      "MerchantReference": "1234567890"
    },
    "Debtor": {
      "Name": "John",
      "Email": "Smith",
      "Address": {
        "Lines": [
          "221B Baker St"
        ],
        "City": "London",
        "CountryCode": "UK",
        "PostCode": "NW1 6XE"
      }
    },
    "DebtorAccount": {
      "Iban": "DE75512108001245126199"
    },
    "DebtorAgent": {
      "Bic": "SOGEDEFF"
    },
    "DueDate": "2/14/2021",
    "SepaDirectDebitInformation": {
      "SequenceType": "RCUR",
      "MandateInformation": {
        "UMR": "31011111110000001234",
        "SigningCity": "London",
        "SigningDate": "2/14/2021"
      }
    }
  }
}

Mandate E-mail notification: contains the same JSON notification in message body.
Name Description Format Included
PaymentMethod Payment method Varchar(50) Always
MerchantIdentification Identification of merchant MerchantIdentification Always
PayNow Create first direct debit together with the mandate Boolean Always
ReducedPeriod Reduces direct debit pre-notification period by up to 13 days. Byte Always
PaymentInformation Payment information PaymentInformation Always
CreditDebitIndicator Values: CRDT or DBIT Varchar(4) Always

Notification/MerchantIdentification

Name Description Format Included
ProjectId Merchant project ID (assigned by TrustPay) Numeric(20) Always
CID Company identifier (assigned by TrustPay) Unique Always

Notification/PaymentInformation

Name Description Format Included
Amount Amount of the payment Amount For paynow
References Reference (merchant’s payment identification) References For paynow
Debtor Debtor details Debtor Always
DebtorAccount Debtor's account details DebtorAccount Always
DebtorAgent Debtor's agent details DebtorAgent Always
DueDate Date to which the transaction should be carried out Varchar(10) For paynow
SepaDirectDebitInformation Mandate information SepaDirectDebit Information Always

Notification/PaymentInformation/Amount

Name Description Format Included
Amount Amount of the payment (exactly 2 decimal places) Numeric(13,2) en-US format For paynow
Currency Currency of the payment Char(3) For paynow

Notification/PaymentInformation/References

Name Description Format Included
MerchantReference Reference (merchant’s payment identification) Varchar(35) Always
EndToEnd Reference between merchant and client Varchar(35) For paynow

Notification/PaymentInformation/Debtor

Name Description Format Included
Name Debtor's name Varchar Always
Email Debtor's email address Varchar Always
Address Debtor's address Address Always

Notification/PaymentInformation/Debtor/Address

Name Description Format Included
Lines Address lines Array of Varchar Always
City City Varchar Always
CountryCode Country code ISO 3166-1 alpha-2 Char(2) Always
PostCode Postal code Varchar Always

Notification/PaymentInformation/DebtorAccount

Name Description Format Included
Iban Debtor's IBAN Char(22) Always

Notification/PaymentInformation/DebtorAgent

Name Description Format Included
Bic Debtor's agent's bank identifier code Varchar(11) Always

Notification/PaymentInformation/SepaDirectDebitInformation

Name Description Format Required
SequenceType Type of mandate:
RCUR - Recurrent payment
OOFF - One-off payment
Char(4)
en-US format
Yes
MandateInformation Mandate details Mandate Information Always

Notification/PaymentInformation/SepaDirectDebitInformation/MandateInformation

Name Description Format Always
UMR Unique Mandate Reference Unique Yes
SigningCity Place of signature Varchar Yes
SigningDate Date of signature Varchar(10) Yes

Paysafecard

Payment process

Payment

API endpoints:
Live - https://aapi.trustpay.eu/api/Payments/Payment

Initiates new Paysafecard payment request.

Request

Payment example:

using System.Net;
using System.Text;
using System.Web.Script.Serialization;

public string Payment(string token)
{
   string url = "https://aapi.trustpay.eu/api/Payments/Payment";
   using (var client = new WebClient())
   {
      client.Headers = new WebHeaderCollection
      {
         "Authorization: bearer " + token,
         "Content-Type: text/json"
      };
      var request = new
      {
         PaymentMethod = "Paysafecard",
         MerchantIdentification = new
         {
             ProjectId = "1234567"
         },
         PaymentInformation = new
         {
             RemittanceInformation = "test123",
             Amount = new
             {
                 Amount = 1.50,
                 Currency = "EUR"
             },
             Debtor = new
             {
                 Email = "email@example.com"
             },
             References = new
             {
                 MerchantReference = "Order #12345"
             }
         },
         CallbackUrls = new
         {
             Success = "https://somedomain.eu/success",
             Cancel = "https://somedomain.eu/cancel",
             Error = "https://somedomain.eu/error",
             Notification = "https://somedomain.eu/notification_handler"
         }
      };

      JavaScriptSerializer serializer = new JavaScriptSerializer();

      var requestData = Encoding.UTF8.GetBytes(serializer.Serialize(request));
      var responseData = client.UploadData(url, requestData);
      var response = serializer.Deserialize<dynamic>(Encoding.UTF8.GetString(responseData));

      return response["GatewayUrl"];
   }
}

function Payment($token)
{
   $url = 'https://aapi.trustpay.eu/api/Payments/Payment';
   $data = array(
      'PaymentMethod' => 'Paysafecard',
      'MerchantIdentification' => array(
         'ProjectId' => '1234567890'
      ),
      'PaymentInformation' => array(
         'RemittanceInformation' => 'test123',
         'Amount' => array(
            'Amount' => '1.50',
            'Currency' => 'EUR'
          ),
         'Debtor' => array(
            'Email' => 'email@example.com'
          ),
         'References' => array(
            'MerchantReference' => '123456'
          )
      ),
      'CallbackUrls' => array(
         'Success' => 'https://somedomain.eu/success',
         'Cancel' => 'https://somedomain.eu/cancel',
         'Error' => 'https://somedomain.eu/error',
         'Notification' => 'https://somedomain.eu/notification_handler'
      ),
   );  

   $options = array(
      'http' => array(
         'header'  => array(
            "Authorization:bearer $Token",
            'Content-type: text/json',
         ),
         'method'  => 'POST',            
         'content' => json_encode($data)
      ),
   );
   $context  = stream_context_create($options);
   $response = json_decode(file_get_contents($url, false, $context), true);
   return $response['GatewayUrl'];
}

This code is using external library Jackson to parse text from and to json format

import org.codehaus.jackson.map.ObjectMapper;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Map;

public String CapturePayment(String token){
    try {
        URL obj = new URL("https://aapi.trustpay.eu/api/Payments/Payment");
        HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
        con.setRequestMethod("POST");
        con.setRequestProperty("Authorization", "bearer " + token);
        con.setRequestProperty("Content-type", "text/json");
        Object request = new Object() {
            public String PaymentMethod = "Paysafecard";
            public Object MerchantIdentification = new Object(){
                public long ProjectId = 2107058607;
            };
            public Object PaymentInformation = new Object(){
                public String RemittanceInformation = "test";
                public Object Amount = new Object(){
                        public double Amount = 1.50;
                        public String Currency = "EUR";
                };
                public Object Debtor = new Object(){
                        public String Email = "email@example.com";
                };
                public Object References = new Object(){
                        public String MerchantReference = "merch ref. no. #555";
                };
            };
            public Object CallbackUrls = new Object(){
                public String Success = "https://somedomain.eu/success";
                public String Cancel = "https://somedomain.eu/cancel";
                public String Error = "https://somedomain.eu/error";
                public String Notification = "https://somedomain.eu/notification_handler";
            };
        };
        ObjectMapper JsonParser = new ObjectMapper();
        String jsonrequest = JsonParser.writeValueAsString(request);
        con.setDoOutput(true);

        try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
            wr.writeBytes(jsonrequest);
            wr.flush();
        }

        String response = "";
        try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
            String inputLine;
            while ((inputLine = in.readLine()) != null) {
                response += inputLine;
            }
        }

        Map<String,String> deserialized = JsonParser.readValue(response, Map.class);
        return String.valueOf(deserialized.get("GatewayUrl"));
    }
    catch (Exception ex){
        throw new RuntimeException(ex.getMessage());
    }
}
Name Description Format Required
Token Authorization token Varchar(235) Yes
PaymentMethod Paysafecard Varchar Yes
MerchantIdentification Identification of merchant Merchant Identification Yes
PaymentInformation Payment information PaymentInformation Yes
ReturnUrls Return URLs CallbackUrls No

Request/MerchantIdentification

Name Description Format Required
ProjectId Merchant project ID (assigned by TrustPay) Numeric(20) Yes

Request/PaymentInformation

Name Description Format Required
RemittanceInformation Remittance advice - additional information Varchar(35) No
Amount Amount of the payment Amount Yes
Debtor Debtor information Debtor Information Yes
References Reference (merchant’s payment identification) References Yes

Request/PaymentInformation/Amount

Name Description Format Required
Amount Amount of the payment (exactly 2 decimal places) Numeric(13,2) en-US format Yes
Currency Currency of the payment Char(3) Yes

Request/PaymentInformation/References

Name Description Format Required
MerchantReference Reference (merchant’s payment identification) Varchar(35) Yes

Request/PaymentInformation/Debtor

Name Description Format Required
Email Debtor's email Varchar Yes

Request/CallbackUrls

Name Description Format Required
Success Url address to which the customer is redirected after successful payment Varchar(256) No
Cancel Url address to which the customer is redirected after payment is canceled Varchar(256) No
Error Url address to which the customer is redirected after payment processing failed Varchar(256) No
Notification Url address to which the notifications regarding this payment should be sent Varchar(256) No

Response

Response example:
{
    "GatewayUrl":"https://aapi.trustpay.eu/Payments/Gateway?paymentRequestId=123123&sig=58B2FA9C45AEE707FFB6A4A0749D2"
    "PaymentRequestId":123123
}
Name Description Format
GatewayUrl Url to site where Customer should be redirected to complete the payment (sent only when call succeeded) Varchar(256)
PaymentRequestId Id of payment request that was just created (sent only when call succeeded) Numeric(20)
ErrorCode Id of error that ocurred durring service call (sent only when call failed) Numeric(10)
ErrorMessage Description of error that ocurred durring service call (sent only when call failed) Varchar(235)

Paysafecard notifications

Paysafecard URL notification example:
https://example.handler.com/

{
  "PaymentMethod": "Paysafecard",
  "MerchantIdentification": {
    "ProjectId": "4101111111"
  },
  "PaymentInformation": {
    "Amount": {
      "Amount": "25.00",
      "Currency": "EUR"
    },
    "CreditDebitIndicator": "CRDT",
    "Status": "Paid",
    "References": {
      "MerchantReference": "1234567890",
      "EndToEnd": "e2eReference",
      "PaymentId": "49863043",
      "PaymentRequestId": "1234"
    },
    "Debtor": {
      "Address": {
        "CountryCode": "SK"
      }
    },
    "DebtorAccount": {
      "Other": "8219820508456139"
    }
  "Signature": "013B192245EF81995E3F219E064F42DC1E1F4A6BC67CB546E1CCA6DC35E5CB73"
  }
}

Paysafecard E-mail notification: contains the same JSON notification in message body.
Name Description Format Included
PaymentMethod Payment method Varchar(50) Always
MerchantIdentification Identification of merchant MerchantIdentification Always
PaymentInformation Payment information PaymentInformation Always
Signature Data signature calculated from concatenated values of all values in the notification. Slash character ('/') is used as separator. Not empty values are sorted in ascending order and then concatenated using the separator. Char(64) Always

Notification/MerchantIdentification

Name Description Format Included
ProjectId Merchant project ID (assigned by TrustPay) Numeric(20) Always

Notification/PaymentInformation

Name Description Format Included
Amount Amount of the payment Amount Always
CreditDebitIndicator Values: CRDT or DBIT Varchar(4) Always
Status Status of payment, values: Paid Varchar(50) Always
References Reference (merchant’s payment identification) References Always
Debtor Debtor details Debtor Always

Notification/PaymentInformation/Amount

Name Description Format Included
Amount Amount of the payment (exactly 2 decimal places) Numeric(13,2) en-US format Always
Currency Currency of the payment Char(3) Always

Notification/PaymentInformation/References

Name Description Format Included
MerchantReference Reference (merchant’s payment identification) Varchar(512) Always
EndToEnd Reference between merchant and client Varchar(35) Always
PaymentId Id of payment Numeric(20) Always
PaymentRequestId Id of payment payment request Numeric(20) Always

Notification/PaymentInformation/Debtor

Name Description Format Included
Address Debtor's address Address Always

Notification/PaymentInformation/Debtor/Address

Name Description Format Included
CountryCode Country code ISO 3166-1 alpha-2 Char(2) Always

Notification/PaymentInformation/DebtorAccount

Name Description Format Included
Other Card Serial Number Varchar Always

EPS

Payment

API endpoints:
Live - https://aapi.trustpay.eu/api/Payments/Payment

Initiates new EPS (Electronic Payment Standard) payment request.

Request

Payment example:

using System.Net;
using System.Text;
using System.Web.Script.Serialization;

public string Payment(string token)
{
   string url = "https://aapi.trustpay.eu/api/Payments/Payment";
   using (var client = new WebClient())
   {
      client.Headers = new WebHeaderCollection
      {
         "Authorization: bearer " + token,
         "Content-Type: text/json"
      };
      var request = new
      {
         PaymentMethod = "EPS",
         MerchantIdentification = new
         {
             ProjectId = "1234567"
         },
         PaymentInformation = new
         {
             RemittanceInformation = "test123",
             Amount = new
             {
                 Amount = 1.50,
                 Currency = "EUR"
             },
             References = new
             {
                 MerchantReference = "Order #12345"
             }
         },
         CallbackUrls = new
         {
             Success = "https://somedomain.eu/success",
             Cancel = "https://somedomain.eu/cancel",
             Error = "https://somedomain.eu/error",
             Notification = "https://somedomain.eu/notification_handler"
         }
      };

      JavaScriptSerializer serializer = new JavaScriptSerializer();

      var requestData = Encoding.UTF8.GetBytes(serializer.Serialize(request));
      var responseData = client.UploadData(url, requestData);
      var response = serializer.Deserialize<dynamic>(Encoding.UTF8.GetString(responseData));

      return response["GatewayUrl"];
   }
}

function Payment($token)
{
   $url = 'https://aapi.trustpay.eu/api/Payments/Payment';
   $data = array(
      'PaymentMethod' => 'EPS',
      'MerchantIdentification' => array(
         'ProjectId' => '1234567890'
      ),
      'PaymentInformation' => array(
         'RemittanceInformation' => 'test123',
         'Amount' => array(
            'Amount' => '1.50',
            'Currency' => 'EUR'
          ),
         'References' => array(
            'MerchantReference' => '123456'
          )
      ),
      'CallbackUrls' => array(
         'Success' => 'https://somedomain.eu/success',
         'Cancel' => 'https://somedomain.eu/cancel',
         'Error' => 'https://somedomain.eu/error',
         'Notification' => 'https://somedomain.eu/notification_handler'
      ),
   );  

   $options = array(
      'http' => array(
         'header'  => array(
            "Authorization:bearer $Token",
            'Content-type: text/json',
         ),
         'method'  => 'POST',            
         'content' => json_encode($data)
      ),
   );
   $context  = stream_context_create($options);
   $response = json_decode(file_get_contents($url, false, $context), true);
   return $response['GatewayUrl'];
}

This code is using external library Jackson to parse text from and to json format

import org.codehaus.jackson.map.ObjectMapper;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Map;

public String CapturePayment(String token){
    try {
        URL obj = new URL("https://aapi.trustpay.eu/api/Payments/Payment");
        HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
        con.setRequestMethod("POST");
        con.setRequestProperty("Authorization", "bearer " + token);
        con.setRequestProperty("Content-type", "text/json");
        Object request = new Object() {
            public String PaymentMethod = "EPS";
            public Object MerchantIdentification = new Object(){
                public long ProjectId = 2107058607;
            };
            public Object PaymentInformation = new Object(){
                public String RemittanceInformation = "test";
                public Object Amount = new Object(){
                        public double Amount = 1.50;
                        public String Currency = "EUR";
                };
                public Object References = new Object(){
                        public String MerchantReference = "merch ref. no. #555";
                };
            };
            public Object CallbackUrls = new Object(){
                public String Success = "https://somedomain.eu/success";
                public String Cancel = "https://somedomain.eu/cancel";
                public String Error = "https://somedomain.eu/error";
                public String Notification = "https://somedomain.eu/notification_handler";
            };
        };
        ObjectMapper JsonParser = new ObjectMapper();
        String jsonrequest = JsonParser.writeValueAsString(request);
        con.setDoOutput(true);

        try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
            wr.writeBytes(jsonrequest);
            wr.flush();
        }

        String response = "";
        try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
            String inputLine;
            while ((inputLine = in.readLine()) != null) {
                response += inputLine;
            }
        }

        Map<String,String> deserialized = JsonParser.readValue(response, Map.class);
        return String.valueOf(deserialized.get("GatewayUrl"));
    }
    catch (Exception ex){
        throw new RuntimeException(ex.getMessage());
    }
}
Name Description Format Required
Token Authorization token Varchar(235) Yes
PaymentMethod EPS Varchar Yes
MerchantIdentification Identification of merchant MerchantIdentification Yes
PaymentInformation Payment information PaymentInformation Yes
ReturnUrls Return URLs CallbackUrls No

Request/MerchantIdentification

Name Description Format Required
ProjectId Merchant project ID (assigned by TrustPay) Numeric(20) Yes

Request/PaymentInformation

Name Description Format Required
RemittanceInformation Remittance advice - additional information Varchar(35) No
Amount Amount of the payment Amount Yes
References Reference (merchant’s payment identification) References Yes

Request/PaymentInformation/Amount

Name Description Format Required
Amount Amount of the payment (exactly 2 decimal places) Numeric(13,2) en-US format Yes
Currency Currency of the payment (EUR) Char(3) Yes

Request/PaymentInformation/References

Name Description Format Required
MerchantReference Reference (merchant’s payment identification) Varchar(35) Yes

Request/CallbackUrls

Name Description Format Required
Success URL address to which the customer is redirected after successful payment Varchar(256) No
Cancel URL address to which the customer is redirected after payment is canceled Varchar(256) No
Error URL address to which the customer is redirected after payment processing failed Varchar(256) No
Notification URL address to which the notifications regarding this payment should be sent Varchar(256) No

Response

Response example:
{
    "GatewayUrl":"https://aapi.trustpay.eu/Payments/Gateway?paymentRequestId=123123&sig=58B2FA9C45AEE707FFB6A4A0749D2"
    "PaymentRequestId":123123
}
Name Description Format
GatewayUrl URL to site where Customer should be redirected to complete the payment (sent only when call succeeded) Varchar(256)
PaymentRequestId Id of payment request that was just created (sent only when call succeeded) Numeric(20)
ErrorCode Id of error that occurred during service call (sent only when call failed) Numeric(10)
ErrorMessage Description of error that occurred during service call (sent only when call failed) Varchar(235)

EPS notifications

Giropay

Payment

API endpoints:
Live - https://aapi.trustpay.eu/api/Payments/Payment

Initiates new Giropay payment request.

Request

Payment example:

using System.Net;
using System.Text;
using System.Web.Script.Serialization;

public string Payment(string token)
{
   string url = "https://aapi.trustpay.eu/api/Payments/Payment";
   using (var client = new WebClient())
   {
      client.Headers = new WebHeaderCollection
      {
         "Authorization: bearer " + token,
         "Content-Type: text/json"
      };
      var request = new
      {
         PaymentMethod = "Giropay",
         MerchantIdentification = new
         {
             ProjectId = "1234567"
         },
         PaymentInformation = new
         {
             RemittanceInformation = "test123",
             Amount = new
             {
                 Amount = 1.50,
                 Currency = "EUR"
             },
             References = new
             {
                 MerchantReference = "Order #12345"
             }
         },
         CallbackUrls = new
         {
             Success = "https://somedomain.eu/success",
             Cancel = "https://somedomain.eu/cancel",
             Error = "https://somedomain.eu/error",
             Notification = "https://somedomain.eu/notification_handler"
         }
      };

      JavaScriptSerializer serializer = new JavaScriptSerializer();

      var requestData = Encoding.UTF8.GetBytes(serializer.Serialize(request));
      var responseData = client.UploadData(url, requestData);
      var response = serializer.Deserialize<dynamic>(Encoding.UTF8.GetString(responseData));

      return response["GatewayUrl"];
   }
}

function Payment($token)
{
   $url = 'https://aapi.trustpay.eu/api/Payments/Payment';
   $data = array(
      'PaymentMethod' => 'Giropay',
      'MerchantIdentification' => array(
         'ProjectId' => '1234567890'
      ),
      'PaymentInformation' => array(
         'RemittanceInformation' => 'test123',
         'Amount' => array(
            'Amount' => '1.50',
            'Currency' => 'EUR'
          ),
         'References' => array(
            'MerchantReference' => '123456'
          )
      ),
      'CallbackUrls' => array(
         'Success' => 'https://somedomain.eu/success',
         'Cancel' => 'https://somedomain.eu/cancel',
         'Error' => 'https://somedomain.eu/error',
         'Notification' => 'https://somedomain.eu/notification_handler'
      ),
   );  

   $options = array(
      'http' => array(
         'header'  => array(
            "Authorization:bearer $Token",
            'Content-type: text/json',
         ),
         'method'  => 'POST',            
         'content' => json_encode($data)
      ),
   );
   $context  = stream_context_create($options);
   $response = json_decode(file_get_contents($url, false, $context), true);
   return $response['GatewayUrl'];
}

This code is using external library Jackson to parse text from and to json format

import org.codehaus.jackson.map.ObjectMapper;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Map;

public String CapturePayment(String token){
    try {
        URL obj = new URL("https://aapi.trustpay.eu/api/Payments/Payment");
        HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
        con.setRequestMethod("POST");
        con.setRequestProperty("Authorization", "bearer " + token);
        con.setRequestProperty("Content-type", "text/json");
        Object request = new Object() {
            public String PaymentMethod = "Giropay";
            public Object MerchantIdentification = new Object(){
                public long ProjectId = 2107058607;
            };
            public Object PaymentInformation = new Object(){
                public String RemittanceInformation = "test";
                public Object Amount = new Object(){
                        public double Amount = 1.50;
                        public String Currency = "EUR";
                };
                public Object References = new Object(){
                        public String MerchantReference = "merch ref. no. #555";
                };
            };
            public Object CallbackUrls = new Object(){
                public String Success = "https://somedomain.eu/success";
                public String Cancel = "https://somedomain.eu/cancel";
                public String Error = "https://somedomain.eu/error";
                public String Notification = "https://somedomain.eu/notification_handler";
            };
        };
        ObjectMapper JsonParser = new ObjectMapper();
        String jsonrequest = JsonParser.writeValueAsString(request);
        con.setDoOutput(true);

        try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
            wr.writeBytes(jsonrequest);
            wr.flush();
        }

        String response = "";
        try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
            String inputLine;
            while ((inputLine = in.readLine()) != null) {
                response += inputLine;
            }
        }

        Map<String,String> deserialized = JsonParser.readValue(response, Map.class);
        return String.valueOf(deserialized.get("GatewayUrl"));
    }
    catch (Exception ex){
        throw new RuntimeException(ex.getMessage());
    }
}
Name Description Format Required
Token Authorization token Varchar(235) Yes
PaymentMethod Giropay Varchar Yes
MerchantIdentification Identification of merchant MerchantIdentification Yes
PaymentInformation Payment information PaymentInformation Yes
ReturnUrls Return URLs CallbackUrls No

Request/MerchantIdentification

Name Description Format Required
ProjectId Merchant project ID (assigned by TrustPay) Numeric(20) Yes

Request/PaymentInformation

Name Description Format Required
RemittanceInformation Remittance advice - additional information Varchar(35) No
Amount Amount of the payment Amount Yes
References Reference (merchant’s payment identification) References Yes

Request/PaymentInformation/Amount

Name Description Format Required
Amount Amount of the payment (exactly 2 decimal places) Numeric(13,2) en-US format Yes
Currency Currency of the payment (EUR) Char(3) Yes

Request/PaymentInformation/References

Name Description Format Required
MerchantReference Reference (merchant’s payment identification) Varchar(35) Yes

Request/CallbackUrls

Name Description Format Required
Success URL address to which the customer is redirected after successful payment Varchar(256) No
Cancel URL address to which the customer is redirected after payment is canceled Varchar(256) No
Error URL address to which the customer is redirected after payment processing failed Varchar(256) No
Notification URL address to which the notifications regarding this payment should be sent Varchar(256) No

Response

Response example:
{
    "GatewayUrl":"https://aapi.trustpay.eu/Payments/Gateway?paymentRequestId=123123&sig=58B2FA9C45AEE707FFB6A4A0749D2"
    "PaymentRequestId":123123
}
Name Description Format
GatewayUrl URL to site where Customer should be redirected to complete the payment (sent only when call succeeded) Varchar(256)
PaymentRequestId Id of payment request that was just created (sent only when call succeeded) Numeric(20)
ErrorCode Id of error that occurred during service call (sent only when call failed) Numeric(10)
ErrorMessage Description of error that occurred during service call (sent only when call failed) Varchar(235)

Giropay notifications

Sepa Credit Transfer

Payment process

Payment

API endpoints:
Live - https://aapi.trustpay.eu/api/Payments/Payment

Initiates new SepaCreditTransfer (SCT) payment request.

Request

Payment example:

using System.Net;
using System.Text;
using System.Web.Script.Serialization;

public string Payment(string token)
{
   string url = "https://aapi.trustpay.eu/api/Payments/Payment";
   using (var client = new WebClient())
   {
      client.Headers = new WebHeaderCollection
      {
         "Authorization: bearer " + token,
         "Content-Type: text/json"
      };
      var request = new
      {
         PaymentMethod = "SepaCreditTransfer",
         MerchantIdentification = new
         {
             ProjectId = "1234567"
         },
         PaymentInformation = new
         {
             Amount = new
             {
                 Amount = 1.50,
                 Currency = "EUR",
                 RequireExact = true
             },
             DueDate = "2021-04-27",
             Localization = "en",
             References = new
             {
                 MerchantReference = "Order #12345"
             }
         },
         CallbackUrls = new
         {
             Notification = "https://somedomain.eu/notification_handler"
         }
      };

      JavaScriptSerializer serializer = new JavaScriptSerializer();

      var requestData = Encoding.UTF8.GetBytes(serializer.Serialize(request));
      var responseData = client.UploadData(url, requestData);
      var response = serializer.Deserialize<dynamic>(Encoding.UTF8.GetString(responseData));

      return response["GatewayUrl"];
   }
}

function Payment($token)
{
   $url = 'https://aapi.trustpay.eu/api/Payments/Payment';
   $data = array(
      'PaymentMethod' => 'SepaCreditTransfer',
      'MerchantIdentification' => array(
         'ProjectId' => '1234567890'
      ),
      'PaymentInformation' => array(
         'Amount' => array(
            'Amount' => '1.50',
            'Currency' => 'EUR',
            'RequireExact' => 'true'
          ),
         'DueDate' => '2021-04-27',
         'Localization' => 'en',
         'References' => array(
            'MerchantReference' => '123456'
          )
      ),
      'CallbackUrls' => array(
         'Notification' => 'https://somedomain.eu/notification_handler'
      ),
   );  

   $options = array(
      'http' => array(
         'header'  => array(
            "Authorization:bearer $Token",
            'Content-type: text/json',
         ),
         'method'  => 'POST',            
         'content' => json_encode($data)
      ),
   );
   $context  = stream_context_create($options);
   $response = json_decode(file_get_contents($url, false, $context), true);
   return $response['GatewayUrl'];
}

This code is using external library Jackson to parse text from and to json format

import org.codehaus.jackson.map.ObjectMapper;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.Map;

public String CapturePayment(String token){
    try {
        URL obj = new URL("https://aapi.trustpay.eu/api/Payments/Payment");
        HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
        con.setRequestMethod("POST");
        con.setRequestProperty("Authorization", "bearer " + token);
        con.setRequestProperty("Content-type", "text/json");
        Object request = new Object() {
            public String PaymentMethod = "SepaCreditTransfer";
            public Object MerchantIdentification = new Object(){
                public long ProjectId = 2107058607;
            };
            public Object PaymentInformation = new Object(){
                public Object Amount = new Object(){
                        public double Amount = 1.50;
                        public String Currency = "EUR";
                        public boolean RequireExact = true;
                };
                public String DueDate = "2021-04-27";
                public String Localization = "en";
                public Object References = new Object(){
                        public String MerchantReference = "merch ref. no. #555";
                };
            };
            public Object CallbackUrls = new Object(){
                public String Notification = "https://somedomain.eu/notification_handler";
            };
        };
        ObjectMapper JsonParser = new ObjectMapper();
        String jsonrequest = JsonParser.writeValueAsString(request);
        con.setDoOutput(true);

        try (DataOutputStream wr = new DataOutputStream(con.getOutputStream())) {
            wr.writeBytes(jsonrequest);
            wr.flush();
        }

        String response = "";
        try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) {
            String inputLine;
            while ((inputLine = in.readLine()) != null) {
                response += inputLine;
            }
        }

        Map<String,String> deserialized = JsonParser.readValue(response, Map.class);
        return String.valueOf(deserialized.get("GatewayUrl"));
    }
    catch (Exception ex){
        throw new RuntimeException(ex.getMessage());
    }
}
Name Description Format Required
Token Authorization token Varchar(235) Yes
PaymentMethod SepaCreditTransfer Varchar Yes
MerchantIdentification Identification of merchant Merchant Identification Yes
PaymentInformation Payment information PaymentInformation Yes
ReturnUrls Return URLs CallbackUrls No

Request/MerchantIdentification

Name Description Format Required
ProjectId Merchant project ID (assigned by TrustPay) Numeric(20) Yes

Request/PaymentInformation

Name Description Format Required
Amount Amount of the payment Amount Yes
DueDate Date to which the transaction should be carried out Varchar(10) No
Localization Language Varchar(2) Yes
References Reference (merchant’s payment identification) References Yes

Request/PaymentInformation/Amount

Name Description Format Required
Amount Amount of the payment (exactly 2 decimal places) Numeric(13,2) en-US format Yes
Currency Currency of the payment Char(3) Yes
RequireExact Decline different amount Boolean Yes

Request/PaymentInformation/References

Name Description Format Required
MerchantReference Reference (merchant’s payment identification) Varchar(35) Yes

Request/CallbackUrls

Name Description Format Required
Notification Url address to which the notifications regarding this payment should be sent Varchar(256) No

Response

Response example:
{
    "GatewayUrl":"https://aapi.trustpay.eu/Payments/Gateway?paymentRequestId=123123&sig=58B2FA9C45AEE707FFB6A4A0749D2"
    "PaymentRequestId":123123
}
Name Description Format
GatewayUrl Url to site where Customer should be redirected to complete the payment (sent only when call succeeded) Varchar(256)
PaymentRequestId Id of payment request that was just created (sent only when call succeeded) Numeric(20)
ErrorCode Id of error that ocurred durring service call (sent only when call failed) Numeric(10)
ErrorMessage Description of error that ocurred durring service call (sent only when call failed) Varchar(235)

Sepa Credit Transfer notifications

Code lists

Supported currencies

The list of currencies (according to ISO 4217) supported by TrustPay.

Code ID Name SEPA Direct Debits
CZK 203 Czech koruna No
EUR 978 Euro Yes

Supported languages

The list of languages (according to ISO 639-1) supported by TrustPay.

Code Language SEPA Direct Debits
enEnglishYes
skSlovakYes

Notification Signature

Creating a secret key

You can view the project's secret key in TrustPay Merchant Portal under Technical Settings – Secret Key. You can view your secret key any time. You are also able to see the history of secret keys and generate a new key if required.

Creating a Notification signature


using System;
using System.Security.Cryptography;
using System.Text;

public static string GetSignature(string key, string message)
{
    using (var hmac = HMAC.Create("HMACSHA256"))
    {
        hmac.Key = Encoding.UTF8.GetBytes(key);
        byte[] signature = hmac.ComputeHash(Encoding.UTF8.GetBytes(message));
        return BitConverter.ToString(signature).Replace("-", "").ToUpperInvariant();
    }
}
    

function GetSignature($key, $message){
    return strtoupper(hash_hmac('sha256', pack('A*', $message), pack('A*', $key)));
}
    

public static String GetSignature(String key, String message) throws Exception
{
    byte[] keyBytes = key.getBytes("UTF-8");
    byte[] messageBytes = message.getBytes("UTF-8");
    javax.crypto.Mac mac = javax.crypto.Mac.getInstance("HmacSHA256");
    mac.init(new javax.crypto.spec.SecretKeySpec(keyBytes, mac.getAlgorithm()));
    return ByteArrayToHexString(mac.doFinal(messageBytes));
}

public static String ByteArrayToHexString(byte[] b)
{
    java.math.BigInteger bi = new java.math.BigInteger(1, b);
    return String.format("%0" + (b.length << 1) + "X", bi);
}
    

HMAC-SHA-256 (RFC 2104) code is used for checking the integrity of the data sent between TrustPay and Merchant. This Notification signature is created using the secret key and message data. Message data is obtained by concatenating all values of each message parameter in ascending order. After computing the signature, it needs to be converted to hexadecimal uppercase string.

Functions for creating the signature in .NET C#, PHP and JAVA are provided by TrustPay.

"Verification of Notification signature"

Here you can verify your implementation to check the TrustPay Notification signature. Just enter your parameters and the signature you calculated and our tool will check whether the signature is valid or not. For parameters that are not relevant leave empty.

































This site uses cookies to provide you with a better browsing experience. By browsing TrustPay websites, you agree with using cookies. Find out more on how we use cookies here.