Step 2: Create the Smart Transaction

Using our credentials we create a Smart Transaction. The enpoint 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,
"contract": {
"id": "GCR_2H69XY35227V2VKP9WRA3SJ0W95RP0"
},
"customer": {
"contact": {
"forename": "Max",
"surname": "Mustermann",
"email": "max@example.net"
}
},
"intent": "sale",
"basket_info": {
"sum": 500,
"currency": "EUR"
},
"application_context": {
"checkout_template": "COT_WD0DE66HN2XWJHW8JM88003YG0NEA2",
       "return_urls": {
"url_success": "https://shop.example.com/payment-success",
"url_error": "https://shop.example.com/payment-failure",
"url_abort": "https://shop.example.com/payment-abort"
}
},
"payment_context": {
"auto_capture": true
}
}

The customer is created with the minumum data. Many use cases require further details, being explained in the Reference part.

The amount is 5 EUR, and there are return URLs to redirect the user back to your shop. Intent sale instructs Smart Checkout to ask the payer for conclusion of contract, and then to capture the payment automatically.

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

The checkout_template (line 25) has the fixed value COT_WD0DE66HN2XWJHW8JM88003YG0NEA2 for ordinary payments. There is another value for subscriptions.

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

Response
HTTP/1.1 200 OK
Content-Type: application/json
...
 
{
"object": "smart.transactions",
"id": "STX_35Q5KZEMZ2X0G7SA8WRDP82H7W06A3",
    "merchant": {
"object": "general.merchants",
"id": "MRC_WVHJQFQ4JNVYNG5B55TYK748ZCHQP8",
"companyname": "Secupay Test-Shop"
},
"contract": {
"object": "general.contracts",
"id": "GCR_2H69XY35227V2VKP9WRA3SJ0W95RP0"
},
    "customer": {
"object": "payment.customers",
"id": "PCU_2CSW25X4U2X0G7S78WRDP82H7W06A2",
"contact": {
"forename": "Max",
"surname": "Mustermann",
"name": "Max Mustermann",
           "email": "max@example.net"
}
},
// ...
"created": "2021-01-26T17:11:00+01:00",
"status": "created",
// ...
"intent": "sale",
"basket": {
"products": [],
"type": "default",
"texts": []
},
"basket_info": {
"sum": 500,
"gratuity": null,
"currency": "EUR"
},
"is_demo": true,
"application_context": {
// ...
"return_urls": {
"url_success": "https://shop.example.com/payment-success",
"url_error": "https://shop.example.com/payment-failure",
"url_abort": "https://shop.example.com/payment-abort"
},
// ...
"checkout_template": "COT_WD0DE66HN2XWJHW8JM88003YG0NEA2"
    },
"payment_context": {
"auto_capture": true
},
// ...
"payment_links": {
"creditcard": "https://checkout-dev.secuconnect.com?...",
"debit": "https://checkout-dev.secuconnect.com?...",
"invoice": "https://checkout-dev.secuconnect.com?...",
"general": "https://checkout-dev.secuconnect.com?..."
}
}

As you see, the system behind the secuconnect API added a number of things. Most interesting for you are:

  • the ID of the Smart Transaction, here STX_35Q5KZEMZ2X0G7SA8WRDP82H7W06A3;

  • the status of it;

  • a merchant object, recognized by the contract;

  • a number of specific payment URLs (payment_links/creditcard, etc.);

  • a generic payment URL (payment_links/general), letting the payer choose.

You need the Smart Transaction ID to access the details, or to mark it as shipped.