Step 2: Create the Smart Transaction

The transaction shall use intent sale, and is created in demo mode, so that the payment is not actually made.

The API endpoint to create a Smart Transaction is POST /api/v2/Smart/Transactions:

Request
POST /api/v2/Smart/Transactions HTTP/1.1
Host: connect-testing.secupay-ag.de
Authorization: Bearer qb56tjj1bcvo9n2nj4u38k84lo
Content-Type: application/json
Accept: application/json
 
{
"is_demo": true,
"intent": "sale",
"contract": {
"id": "GCR_2H69XY35227V2VKP9WRA3SJ0W95RP0"
},
"customer": {
"contact": {
"salutation": "Mr.",
"forename": "Max",
"surname": "Mustermann",
"address": {
"street": "Max-Muster-Str.",
"street_number": "25a",
"postal_code": "09555",
"city": "Musterstadt",
"country": "DE",
"additional_address_data": "Whg. 202"
},
"email": "mmustermann@example.net",
"mobile": "+49 177 5555555",
"phone": "+49 555 5555555"
}
},
"transactionRef": "Hotelbuchung 23.10.2020 für Hrn. Muster, Musterfirma GmbH Musterstadt",
"basket_info": {
"currency": "EUR",
"sum": 11970 // €119.70 (smallest currency unit)
},
"payment_context": {
"auto_capture": true
},
"application_context": {
"return_urls": {
"url_push": "https://shop.example.org/PUSH?order=12345"
}
}
}

This creates a Smart Transaction to pay a hotel reservation. The amount is €119.70.

Monetary amounts are expressed in the smallest currency unit (e. g. Euro Cent).

The auto_capture setting saves us an additional call to capture the payment.

If everything is fine, the API responds with 200 OK:

Response
HTTP/1.1 200 OK
Content-Type: application/json
...
 
{
"object": "smart.transactions",
"id": "STX_33PXAW2YN2NJTPM5KPGMK7QF5PBVA2",
    "merchant": {
"object": "general.merchants",
"id": "MRC_WVHJQFQ4JNVYNG5B55TYK748ZCHQP8",
"companyname": "Secupay Test-Shop"
},
"contract": {
"object": "general.contracts",
"id": "GCR_2H69XY35227V2VKP9WRA3SJ0W95RP0"
},
    "customer": {
"object": "payment.customers",
"id": "PCU_38RG7MHRE2NJTPFMXRYQP3NKW6GVAZ",
"contact": {
"forename": "Max",
"surname": "Mustermann",
"name": "Max Mustermann",
"salutation": "Mr.",
"address": {
"street": "Max-Muster-Str.",
"street_number": "25a",
"additional_address_data": "Whg. 202",
"postal_code": "09555",
"city": "Musterstadt",
"country": "DE"
},
"email": "mmustermann@example.net",
"mobile": "+491775555555",
"phone": "+495555555555"
}
},
// ...
"created": "2020-03-27T10:55:23+01:00",
"status": "created",
"transactionRef": "Hotelbuchung 23.10.2020 für Hr. Muster, Musterfirma GmbH Musterstadt",
"intent": "sale",
"basket_info": {
"sum": 11970,
"gratuity": null,
"currency": "EUR"
},
"is_demo": true,
// ...
"payment_context": {
"auto_capture": true,
// ...
},
"application_context": {
"return_urls": {
"url_push": "https://shop.example.org/PUSH?order=12345"
}
}
}

As you see, the system behind the secuconnect API added some information. Most interesting for you are:

  • the ID of the Smart Transaction (here STX_33PXAW2YN2NJTPM5KPGMK7QF5PBVA2);

  • the ID of the Payment Customer (here PCU_38RG7MHRE2NJTPFMXRYQP3NKW6GVAZ);

  • the status (created so far).

The ID of the Smart Transaction ID is needed if you want to access it later, or if we had wanted capture it manually, what is explained in the reference.