Create a Loyalty Card on-the-Fly

Process to Create a Loyalty Card

You can also create a new virtual secucard on-the-fly. It is a card that works like any other, but has no physical representation yet.

You can load the card, or collect bonus balance for the same order. If the card group allows for negative balance, you can even use it for the first payment.

In order to create the loyalty card, you must:

  • Create a Smart Transaction with a special item instead of an existing card.

  • Authorize and capture the payment.

It makes sense for your shop system to manage the cards for registered users.

The card group needs to be activated for card creation via STX. If you don't know whether it is active, or you need help to find the card group, please ask our friendly help desk. Please have the name of the card group ready.

Create the Smart Transaction

We prepare a Smart Transaction for a known customer. Instead of an existing card, you would pass a card creation request together with the card group ID in the idents parameter.

Request
POST /api/v2/Smart/Transactions HTTP/1.1
Host: connect-testing.secupay-ag.de
Authenticate: Bearer qb56tjj1bcvo9n2nj4u38k84lo
Content-Type: application/json
Accept: application/json
 
{
"is_demo": true,
"contract": {
"id": "GCR_9OIH9JOL8KIV5PFJBEOS2NN8TCM1DF"
},
"device_source": {
"id": "SDV_WPX6NU09Q2NDF0KJD3H584EXJR3XA2"
},
"customer": {
"id": "PCU_3ZSETWCS62X06V7FT64RS8W3KU9EAZ"
},
"intent": "sale",
"idents": [
{
"type": "create_card",
"value": "CRG_442AC7B8XCVU3XG2NX9E5XHJWH4CRK"
}
],
"basket": {
"products": [
{
"id": 1,
"articleNumber": 30200,
"desc": "Dining service Puslnitz, 26 pieces",
"quantity": 1,
"priceOne": 5900,
"tax": 19
}
]
},
"basket_info": {
"sum": 5900,
"currency": "EUR"
}
}

If you were to create a gift card, you would use another card program configuration. You then needed to add a special card loading article in the basket (s. Load the Loyalty Card with Cash Balance).

If everthing is fine, the API responds with 200 OK, and the representation of the Smart Transaction:

Response
HTTP/1.1 200 OK
Content-Type: application/json
...
 
{
"object": "smart.transactions",
"id": "STX_27V90VC9K2X06V7GD5NYYWYHKHT3AZ",
   "merchant": {
"object": "general.merchants",
"id": "MRC_G8SE48FRHVITKILAPNCEDU0NUD55W8",
"companyname": "Secupay Test-Shop"
},
"contract": {
"object": "general.contracts",
"id": "GCR_9OIH9JOL8KIV5PFJBEOS2NN8TCM1DF"
},
    "customer": {
"object": "payment.customers",
"id": "PCU_3ZSETWCS62X06V7FT64RS8W3KU9EAZ",
"contact": {
"forename": "Laisha",
"surname": "Mustermann",
"name": "Laisha Mustermann",
"address": {
"street": "Musterstr.",
"street_number": "994",
"additional_address_data": "App. 848",
"postal_code": "09999",
"city": "Port Keelyton",
"country": "DE"
},
"email": "Hubert69@example.org",
"mobile": "+491775555555",
"phone": "+495555555555",
"dob": "1965-12-31T00:00:00+01:00"
}
},
"device_source": {
"object": "smart.devices",
"id": "SDV_WPX6NU09Q2NDF0KJD3H584EXJR3XA2"
},
"transactions": [],
"created": "2021-01-19T16:25:20+01:00",
"status": "created",
"transactionRef": null,
"merchantRef": null,
"intent": "sale",
"basket": {
"products": [{
"id": 1,
"parent": null,
"item_type": "article",
"desc": "Dining service Puslnitz, 26 pieces",
"articleNumber": "30200",
"ean": "",
"quantity": 1,
"priceOne": 5900,
"tax": 19,
"reference_id": null,
"group": []
}],
"type": "default",
"texts": []
},
"basket_info": {
"sum": 5900,
"gratuity": null,
"currency": "EUR"
},
"idents": [{
"object": "smart.idents",
"id": "smi_3",
"prefix": "CRG_",
"name": "secucard Kundenkarte erstellen",
"type": "create_card",
"value": "CRG_442AC7B8XCVU3XG2NX9E5XHJWH4CRK",
"valid": true,
"merchantcard": {
"id": "auto_create",
"cardgroup": {
"id": "CRG_GO7GQ6DHW3TJYGDF64WD16PUIDHQ8Y"
},
"merchant": {
"id": "MRC_G8SE48FRHVITKILAPNCEDU0NUD55W8"
},
"contract": {
"id": "GCR_9OIH9JOL8KIV5PFJBEOS2NN8TCM1DF"
},
"lock_status": "unlocked"
}
}],
"is_demo": true,
"application_context": {
"locks": {
"customer": false
},
"return_urls": null,
"iframe_opts": null
},
"checkout_links": null,
"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?..."
}
}

The new card is already considered, but is not actually created yet.

Capture the Payment

You would carry out the payment as described in the integration guide for payment. We assume this is already implemented.

The last step is always a call to /start:

Request
POST /api/v2/Smart/Transactions/STX_27V90VC9K2X06V7GD5NYYWYHKHT3AZ/start HTTP/1.1
Host: connect-testing.secupay-ag.de
Authenticate: Bearer qb56tjj1bcvo9n2nj4u38k84lo
Accept: application/json

At this time, the card will be created. If the card is loaded or already used the needed Loyalty Transactions will be created too.

If everthing is fine, the API responds with 200 OK, and the representation of the Smart Transaction:

Response
HTTP/1.1 200 OK
Content-Type: application/json
...
 
{
"object": "smart.transactions",
"id": "STX_27V90VC9K2X06V7GD5NYYWYHKHT3AZ",
// ...
"updated": "2021-01-19T16:25:22+01:00",
"status": "ok",
// ...
"receipt": [{
"type": "separator",
"value": {
"caption": "Kundenkarte"
}
}, {
"type": "name-value",
"value": {
"name": "Kartennummer: ",
"value": "9276004429776746",
"decoration": []
}
}, {
"type": "name-value",
"value": {
"name": "TA Code: ",
"value": "32051450",
"decoration": []
}
}, {
"type": "space"
}, {
"type": "textline",
"value": {
"text": "Umsatz erfasst:",
"decoration": []
}
}, {
"type": "textline",
"value": {
"text": "59,00 EUR",
"decoration": ["important"]
}
}, {
"type": "space"
}, {
"type": "textline",
"value": {
"text": "Aktuelle Punkte:",
"decoration": []
}
}, {
"type": "textline",
"value": {
"text": "0",
"decoration": ["important"]
}
}, {
"type": "space"
}, {
"type": "textline",
"value": {
"text": "Bonus:",
"decoration": []
}
}, {
"type": "textline",
"value": {
"text": "5,90 EUR",
"decoration": ["important"]
}
}, {
"type": "space"
}, {
"type": "textline",
"value": {
"text": "Aktuelles Guthaben",
"decoration": []
}
}, {
"type": "textline",
"value": {
"text": "5,90 EUR",
"decoration": ["important"]
}
}],
// ...
"idents": [{
"object": "smart.idents",
"id": "smi_3",
"prefix": "CRG_",
"name": "secucard Kundenkarte erstellen",
"type": "create_card",
"value": "CRG_442AC7B8XCVU3XG2NX9E5XHJWH4CRK",
"valid": true,
"merchantcard": {
"id": "MCD_3ZYHHRFP62X06V7ZFHXXF3S07S0FAZ",
"cardgroup": {
"id": "CRG_GO7GQ6DHW3TJYGDF64WD16PUIDHQ8Y",
"object": "loyalty.cardgroups",
"display_name": "Entwickler Card",
"display_name_raw": "Entwickler Card",
"stock_warn_limit": 0,
"picture": "https://connect.secucard.com\/ds_g\/8e79737df1e2513db48908b342c3cc436edf501a"
},
"merchant": {
"id": "MRC_G8SE48FRHVITKILAPNCEDU0NUD55W8",
"object": "general.merchants"
},
"contract": {
"id": "GCR_9OIH9JOL8KIV5PFJBEOS2NN8TCM1DF"
},
"lock_status": "unlocked",
"object": "loyalty.merchantcards",
"created_for_merchant": {
"object": "general.merchants",
"id": "MRC_G8SE48FRHVITKILAPNCEDU0NUD55W8"
},
"card": {
"object": "loyalty.cards",
"id": "CRD_25493S2R9NNNCTR0VW74KQTRP2KXPX",
"cardnumber": "9276004429776746",
"created": "2021-01-19T16:25:24+01:00"
},
"created_for_store": {
"object": "general.stores",
"id": "STO_2ZCZRU9V6U8QA7B49K94667UP6C4PJ"
},
"is_base_card": true,
"points": 0,
"cash_balance": 0,
"bonus_balance": 590,
"balance": 590,
"last_usage": "2021-01-19T16:25:25+01:00",
"last_charge": "2021-01-19T16:25:25+01:00",
"stock_status": "stored",
"passcode": 1,
"expiry_date": null
}
}],
// ...
}

Now you see the actual card (line 164-207). The first revenues are tracked, and a bonus balance of €5.90 was already granted.

We recommend to save the card number to the login account of your customer. If there is no such account, or if you have created and loaded a gift card, you would send the card number to the buyer.