Create the Smart Transaction for Webshops

This guide is for a simple webshop with a custom checkout. There are other guides for internet marketplaces, or e-commerce platforms. And there are also guides for our Smart Checkout.

Prerequisites

As a prerequisite, you should understand:

Create a Smart Transaction

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_KTSST836QYITQJM1JGYIZ4F4OLKI04"
},
"customer": {
   "contact": {
"forename": "Max",
"surname": "Mustermann",
"salutation": "Mr.",
"address": {
"street": "Max-Muster-Str.",
"street_number": "25a",
"additional_address_data": "Whg. 202",
"postal_code": "09555",
"city": "Musterstadt",
"country": "DE"
},
"email": "max@example.net",
"mobile": "+491775555555",
"phone": "+495555555555"
}
},
"merchantRef": "K/01234",
"transactionRef": "B/001234567",
 "basket": {
"products": [
{
"id": 1,
"articleNumber": 30037,
"ean": "4999012345678",
"desc": "Höhenverstellbarer Schreibtisch",
"quantity": 1,
"priceOne": 49800,
"tax": 19
},
{
"id": 2,
"item_type": "shipping",
"desc": "Versand Spedition",
"quantity": 1,
"priceOne": 3500,
"tax": 19
}
]
},
"basket_info": {
"sum": 54300,
"currency": "EUR"
},
  "payment_context": {
"auto_capture": true
}
}

This creates a demo transaction to sell a desk. The total amount is €543.00. The auto_capture setting saves an additional API call, if it fits the flow.

If everything is fine, the API responds with 200 OK and a representation of the newly created Smart Transaction:

Response
HTTP/1.1 200 OK
Content-Type: application/json
 
{
"object": "smart.transactions",
"id": "STX_33PXAW2YN2NJTPM5KPGMK7QF5PBVA2",
"merchant": {
"object": "general.merchants",
"id": "MRC_G8SE48FRHVITKILAPNCEDU0NUD55W8",
"companyname": "Smart Checkout Testmerchant 8"
},
"provider_contract": {
"object": "general.contracts",
"id": "GCR_9OIH9JOL8KIV5PFJBEOS2NN8TCM1DF"
} ,
"contract": {
"object": "general.contracts",
"id": "GCR_KTSST836QYITQJM1JGYIZ4F4OLKI04"
},
"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": "max@example.net",
"mobile": "+491775555555",
"phone": "+495555555555"
}
},
"transactions": [],
"created": "2020-03-27T10:55:23+01:00",
"status": "created",
"merchantRef": "K/01234",
  "transactionRef": "B/001234567",
  "intent": "sale",
"basket": {
"products": [
{
"id": 1,
"item_type": "article",
"desc": "Höhenverstellbarer Schreibtisch",
       "articleNumber": 30037,
"ean": "4999012345678",
"quantity": 1,
"priceOne": 49800,
"tax": 19
      },
{
"id": 2,
        "item_type": "shipping",
"desc": "Versand Spedition",
        "quantity": 1,
"priceOne": 3500,
"tax": 19
      }
],
"type": "default"
  },
"basket_info": {
"sum": 54300,
"currency": "EUR"
},
  "is_demo": true,
// ...
"payment_context": {
"auto_capture": true,
// ...
"creditcard_schemes": [
"mastercard",
"visa",
"american express"
]
},
// ...
}

Important fields are:

Field

Type

Meaning

id

string

The object ID of the new Smart Transaction.

status

string

The status of the Smart Transaction.

The status is "created" so far. The Smart Transaction ID is needed for the subsequent API calls in your custom checkout.

For further explanation of the fields, see our API Reference: link