This chapter refers to the chapter "3.2 Initializing / submission of transactions" of the flex.API documentation.

General

Authentication

To authenticate against the API, it's necessary to pass some so-called "credentials". In the old API there was an API-Key which you have sent with each request. Now you need to use the OAuth 2.0 standard to authenticate you against the API. For this you will receive in general a client-ID and a client-secret. Which is similar to an username and password. With this you will ask for a session token (bearer token), which then you need to sent with each request. This session token will be expire in a short time, so you will need to authenticate again after some minutes.

Payment Methods

The payment methods are now separated into one URL per payment method.

Old API-URL: https://api.secupay.ag/payment/init

New API-URL: https://connect.secucard.com/api/v2/Payment/... - prepay: https://connect.secucard.com/api/v2/Payment/Secupayprepays - debit: https://connect.secucard.com/api/v2/Payment/Secupaydebits - invoice: https://connect.secucard.com/api/v2/Payment/Secupayinvoices - credit card: https://connect.secucard.com/api/v2/Payment/Secupaycreditcards

Customer

It is now possible to transmit the customer data separately. This is called "create customer" in the documentation of the secuconnect-API. After you have save the new customer you will get an ID. This ID you will transmit instead of the hold customer data on creating new payment transactions with the same customer. But it's also possible to transmit the customer data on creating a new payment transaction.

API-Version and other params

Old API-Params: - apiversion - shop - shopversion - shopversion - moduleversion

In the new API you should transmit this information in the User-Agent header. For example: User-Agent: Wordpress/4.7.1 WooCommerce/2.6.11 PHP-SDK/1.0.2 Guzzle/4.0 curl/7.21.4 PHP/5.5.7

Old API-Params: - language

In the new API you can transmit this information by using the Accept-Language header. For example: Accept-Language: fr-CH, fr;q=0.9, en;q=0.8, de;q=0.7, *;q=0.5

API-Call

Old API

URL: https://api.secupay.ag/payment/init

HTTP-Method: POST

Request-Body

{
  "data":{
    "apikey":"d7a78f8363ed086e3235df4e627e2d69a57ed61a",
    "demo":"1",
    "payment_type":"debit",
    "payment_action":"sale",
    "url_success":"http://shop.example.com/success.php",
    "url_failure":"http://shop.example.com/failure.php",
    "url_push":"http://shop.example.com/push.php",
    "apiversion":"2.11",
    "shop":"APITest Shop",
    "shopversion":"1.0",
    "moduleversion":"1.0",
    "language":"de_DE",
    "title":"Herr",
    "firstname":"Test FN",
    "lastname":"Test LN",
    "company":"Test Company",
    "street":"Test Street",
    "housenumber":"5t",
    "zip":"12345",
    "city":"TestCity",
    "country":"DE",
    "telephone":"+4912342134123",
    "dob_value":"01.02.1903",
    "email":"test@ema.il",
    "ip":"172.31.6.49",
    "amount":"199",
    "currency":"EUR",
    "purpose":"Test Order #1",
    "order_id":"100203",
    "delivery_address":{
      "firstname":"Test FN",
      "lastname":"Test LN",
      "company":"Test Company",
      "street":"Test Street",
      "housenumber":"5t",
      "zip":"12345",
      "city":"TestCity",
      "country":"DE"
    },
    "basket":[
      {
        "item_type":"shipping",
        "name":"standard delivery",
        "tax":"19",
        "total":"1324"
      },
      {
        "item_type":"article",
        "article_number":"3211",
        "quantity":"2",
        "name":"Testname 1",
        "ean":"4123412341243",
        "tax":"19",
        "total":"1324",
        "price":"1000"
      },
      {
        "item_type":"article",
        "article_number":"48875",
        "quantity":"2",
        "name":"Testname 1",
        "ean":"4123412341236",
        "tax":"19",
        "total":"1324",
        "price":"1000"
      }
    ]
  }
}

Response-Body

{
  "status":"ok",
  "data":{
    "hash":"zqpprymhogcn2210038",
    "iframe_url":"https://api.secupay.ag/payment/zqpprymhogcn2210038"
  },
  "errors":null
}

New API

URL: https://connect.secucard.com/api/v2/Payment/Secupaydebits

HTTP-Method: POST

Request-Body

{
  "payment_action":"sale",
  "redirect_url":{
    "url_success":"http://shop.example.com/success.php",
    "url_failure":"http://shop.example.com/failure.php",
    "url_push":"http://shop.example.com/push.php"
  },
  "customer":{
    "contact":{
      "salutation":"Herr",
      "forename":"Test FN",
      "surname":"Test LN",
      "companyname":"Test Company",
      "address":{
        "street":"Test Street",
        "street_number":"5t",
        "postal_code":"12345",
        "city":"TestCity",
        "country":"DE"
      },
      "phone":"+4912342134123",
      "dob":"1901-02-03",
      "email":"example@example.com"
    }
  },
  "amount":"199",
  "currency":"EUR",
  "purpose":"Test Order #1",
  "order_id":"100203",
  "recipient":{
    "contact":{
      "forename":"Test FN",
      "surname":"Test LN",
      "companyname":"Test Company",
      "address":{
        "street":"Test Street",
        "street_number":"5t",
        "postal_code":"12345",
        "city":"TestCity",
        "country":"DE"
      },
      "phone":"+4912342134123",
      "dob":"1901-02-03",
      "email":"example@example.com"
    }
  },
  "basket":[
    {
      "item_type":"shipping",
      "name":"standard delivery",
      "tax":"19",
      "total":"1324"
    },
    {
      "item_type":"article",
      "article_number":"3211",
      "quantity":"2",
      "name":"Testname 1",
      "ean":"4123412341243",
      "tax":"19",
      "total":"1324",
      "price":"1000"
    },
    {
      "item_type":"article",
      "article_number":"48875",
      "quantity":"2",
      "name":"Testname 1",
      "ean":"4123412341236",
      "tax":"19",
      "total":"1324",
      "price":"1000"
    }
  ]
}

Response-Body

{
  "object":"payment.secupaydebits",
  "id":"zqpprymhogcn2210038",
  "trans_id":"9984095",
  "status":"internal_server_status",
  "amount":"199",
  "currency":"EUR",
  "purpose":"Test Order #1",
  "order_id":"100203",
  "transaction_status":"1",
  "basket":[
    {
      "item_type":"shipping",
      "name":"standard delivery",
      "tax":19,
      "total":1324
    },
    {
      "item_type":"article",
      "article_number":3211,
      "quantity":2,
      "name":"Testname 1",
      "ean":"4123412341243",
      "tax":19,
      "total":1324,
      "price":1000
    },
    {
      "item_type":"article",
      "article_number":48875,
      "quantity":2,
      "name":"Testname 1",
      "ean":"4123412341236",
      "tax":19,
      "total":1324,
      "price":1000
    }
  ],
  "payment_action":"sale",
  "customer":{
    "object":"payment.customers",
    "id":"PCU_29H566U4Q2MDZ9H2X75XU5T7QAA0AJ",
    "contract":{
      "object":"payment.contracts",
      "id":"PCR_2C0S37QHH2MASN9V875XU3YFNM8UA6"
    },
    "contact":{
      "forename":"Test FN",
      "surname":"Test LN",
      "companyname":"Test Company",
      "name":"Test FN Test LN",
      "salutation":"Herr",
      "address":{
        "street":"Test Street",
        "street_number":"5t",
        "postal_code":"12345",
        "city":"TestCity",
        "country":"DE"
      },
      "email":"example@example.com",
      "phone":"+4912342134123",
      "dob":"1901-02-03T00:00:00+01:00"
    },
    "created":"2017-09-08T09:52:37+02:00"
  },
  "redirect_url":{
    "iframe_url":"https://api.secupay.ag/payment/zqpprymhogcn2210038",
    "url_success":"http://shop.example.com/success.php",
    "url_failure":"http://shop.example.com/failure.php"
  },
  "iframe_url":"https://api.secupay.ag/payment/zqpprymhogcn2210038"
}