Step 2: Create the Smart Transaction

We create a Smart Transaction for e-commerce:

Request
POST /api/v2/Smart/Transactions HTTP/1.1
Host: testing.secupay-ag.de
Authorization: Bearer qb56tjj1bcvo9n2nj4u38k84lo
Content-Type: application/json
Accept: application/json
 
{
"is_demo": true,
"contract": {
"id": "GCR_2H69XY35227V2VKP9WRA3SJ0W95RP0"
},
"device_source": {
"id": "SDV_2YJDXYESB2YBHECVB5GQGSYPNM8UA6"
},
"customer": {
"contact": {
"salutation": "Mr.",
"title": "Dr.",
"forename": "Max",
"surname": "Mustermann",
"address": {
"street": "Musterstr.",
"street_number": "25 b",
"additional_address_data": "Whg. 123",
"postal_code": "99999",
"city": "Musterstadt",
"country": "DE"
},
"email": "max123@example.org",
"phone": "+49 555 5555555",
"mobile": "+49 177 5555555",
       "dob": "1901-02-03"
}
},
"idents": [
{
"type": "card",
"value": "9276004424644352"
}
],
"basket": {
"products": [
{
"id": 1,
"articleNumber": 30037,
"desc": "Sandwich Romano",
"quantity": 1,
"priceOne": 349,
"tax": 7
},
{
"id": 2,
"articleNumber": 30200,
"desc": "Fruit salad, small bowl",
"quantity": 1,
"priceOne": 249,
"tax": 7
},
{
"id": 3,
"articleNumber": 51,
"ean": "4999012345678",
"desc": "Water, mildly sprinkling, 0.25 ltr.",
"quantity": 2,
"priceOne": 99,
"tax": 19
}
]
},
"basket_info": {
"sum": 796,
"currency": "EUR"
},
"payment_context": {
"auto_capture": true
}
}

There are only final special things to mention here:

  • A contract ID is passed (line 9 – 11). This is not needed, when you create a Smart Transaction for loyalty from a POS device. Merchant and contract would be resolved by the device credentials.

  • A source device ID is passed (line 12 – 14). This is not needed for a regular e-commerce transaction. But you need a device for the loyalty functions.

  • A card number is passed (line 15 – 20). This is the secucard that is used. It could also be set later, using PUT /api/v2/Smart/Transactions/STX_WHCJCB3SD2NSZZ73E33NP3TJJ4RKA2.

  • The auto_capture flag (line 75) allows save an additional call.

Our example shows a payment of €7.96, and articles having a gross unit price of €2.49 and €0.99.

Monetary amounts are expressed in the smallest currency unit (e. g. Euro Cent). The same will be true for the card details in the response below.

Instead of passing the customer details you could also have passed an existing Payment Customer ID.

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_WHCJCB3SD2NSZZ73E33NP3TJJ4RKA2",
    "merchant": {
"object": "general.merchants",
"id": "MRC_WVHJQFQ4JNVYNG5B55TYK748ZCHQP8",
"companyname": "Secupay Test-Shop"
},
"contract": {
"object": "general.contracts",
"id": "GCR_2H69XY35227V2VKP9WRA3SJ0W95RP0"
},
    "device_source": {
"object": "smart.devices",
"id": "SDV_2YJDXYESB2YBHECVB5GQGSYPNM8UA6"
},
"customer": {
"object": "payment.customers",
"id": "PCU_24XQFBSAS2NSZZPUYR9F20330GX6AZ",
"contact": {
"forename": "Max",
"surname": "Mustermann",
"name": "Max Mustermann",
"salutation": "Mr.",
"title": "Dr.",
"address": {
"street": "Musterstr.",
"street_number": "25 b",
"additional_address_data": "Whg. 123",
"postal_code": "99999",
"city": "Musterstadt",
"country": "DE"
},
"email": "max123@example.org",
"mobile": "+491775555555",
"phone": "+495555555555",
"dob": "1901-02-03T00:00:00+01:00"
}
},
"transactions": [],
"created": "2020-10-23T10:18:14+02:00",
"status": "created",
"transactionRef": null,
"merchantRef": null,
"intent": "sale",
"basket": {
"products": [
{
"id": 1,
"parent": null,
"articleNumber": "30037",
"ean": "",
"desc": "Sandwich Romano",
"quantity": 1,
"priceOne": 349,
"tax": 7,
"group": [],
"serialNumber": null,
"item_type": "article",
"reference_id": null,
"contract_id": null,
"sum": null
},
{
"id": 2,
"parent": null,
"articleNumber": "30200",
"ean": "",
"desc": "Fruit salad, small bowl",
"quantity": 1,
"priceOne": 249,
"tax": 7,
"group": [],
"serialNumber": null,
"item_type": "article",
"reference_id": null,
"contract_id": null,
"sum": null
},
{
"id": 3,
"parent": null,
"articleNumber": "51",
"ean": "4999012345678",
"desc": "Water, mildly sprinkling, 0.25 ltr.",
"quantity": 2,
"priceOne": 99,
"tax": 19,
"group": [],
"serialNumber": null,
"item_type": "article",
"reference_id": null,
"contract_id": null,
"sum": null
}
],
"texts": [],
"type": "default"
},
"basket_info": {
"sum": 796,
"gratuity": null,
"currency": "EUR"
},
"idents": [
{
"object": "smart.idents",
"id": "smi_1",
"prefix": "9276",
"name": "secucard Kundenkarte",
"type": "card",
"value": "9276004424644352",
"valid": true,
"merchantcard": {
"object": "loyalty.merchantcards",
"id": "MCD_2UXQJ84A62MENH7UWH6QXDYJSBNAA9",
"merchant": {
"object": "general.merchants",
"id": "MRC_WVHJQFQ4JNVYNG5B55TYK748ZCHQP8"
},
"created_for_merchant": {
"object": "general.merchants",
"id": "MRC_F40KSJYW5AAJHHC93TQ6C7A8X76WO6"
},
"card": {
"object": "loyalty.cards",
"id": "CRD_22H4H5D47Q44URN2K8KTP876H6M3PM",
"cardnumber": "9276004424644352",
"created": "2015-02-20T08:51:46+01:00"
},
"cardgroup": {
"object": "loyalty.cardgroups",
"id": "CRG_4VA6040D2DWRYHJKCWXZEW24654PRH",
"display_name": "Bonus",
"display_name_raw": "Bonus",
"stock_warn_limit": 0,
"picture": "https://connect.secucard.com/ds_g/8e79737df1e2513db48908b342c3cc436edf501a"
},
"created_for_store": {
"object": "general.stores",
"id": "STO_3522R8MS2MSHCN7D37UVJYR4P6C4PX"
},
"is_base_card": false,
"points": 0,
"cash_balance": 200,
"bonus_balance": 20,
"balance": 220,
"last_usage": "2017-10-11T09:34:42+02:00",
"last_charge": "2017-10-11T09:34:42+02:00",
"stock_status": "inactive",
"lock_status": "unlocked",
"passcode": 0,
"expiry_date": null
}
}
],
"is_demo": true,
"application_context": {
"locks": {
"customer": false
},
"return_urls": null,
"iframe_opts": null
},
"checkout_links": null,
"payment_links": null
}

Amongst other things that are added automatically, the idents field (lines 109 – 160) carries information about the secucard now. There is a total card balance of €2.20 for this merchant, that results of a cash top-up of €2.00, and €0.20 collected as bonus previously (lines 126 – 128). The bonus balance is distinct since it can be handled differently in accounting.

Finally you need to remember the Smart Transaction ID (line 7, STX_...). It is used in some of the following requests.