Basket Details
TransactDirect supports flexible basket details through the Payments API and Checkout Page.
The Basket should be construted using the JSON format described in this article and then Base64 encoded and sent along with the payment request in the Basket
field.
Basket Format
The Basket JSON object is made up of the following elements
Field Name | Description | Req'd |
---|---|---|
items | Provides a list of all items in the basket. See Item Object. | M |
discounts | Provides a list any discounts applied to the basket. See Discount Object. | O |
taxes | Provides a list of taxes applied to the basket. See Tax Object. | O |
delivery | Provides delivery details. See Delivery Object. | O |
Item Object
Field Name | Description | Req'd | Type |
---|---|---|---|
sku | The stock code for this product. | O | A |
description | The product description for this item. | M | A |
quantity | The quantity of this item on this order line. | M | N |
unitPrice | The unit price for this product in major currency. e.g. 3.99 | M | N |
total | The total price for this order line. If not supplied it will be calculated automatically. | O | N |
Note: All items should be supplied with their unit price inclusive of any taxes and excluding any discounts.
Discount Object
Field Name | Description | Req'd | Type |
---|---|---|---|
code | The discount code. | O | A |
description | The description for this discount. | M | A |
amount | The amount of discount in major currency. e.g. 1.99 | M | N |
Tax Object
Note: All taxes are displayed against the total basket price, all basket items should be supplied inclusive of any taxes.
Field Name | Description | Req'd | Type |
---|---|---|---|
code | The tax code. | O | A |
description | Description of this tax item. | M | A |
rate | The rate at which this tax item is applied. | O | N |
amount | The amount of tax applied in major currency. e.g. 2.50 | M | N |
Delivery Object
Field Name | Description | Req'd | Type |
---|---|---|---|
carrier | The carrier used for delivery | M | A |
trackingReference | The tracking reference number for this delivery | O | A |
trackingUrl | The URL that can be used to obtain tracking information for this delivery | O | A |
amount | The cost for this delivery in major currency. e.g. 2.50 | M | N |
Character Encoding
To ensure correct display on the Checkout Page, some characters should be encoded.
Character | Description | Encoding |
---|---|---|
£ | Pound symbol | \u00A3 |
™ | Trademark symbol | \u2122 |
Request Sample
Basket in JSON format
The following is a sample of a JSON structured basket and the Base64 encoded version that would be passed to TransactDirect in the Basket
field.
{
"items": [
{
"sku": "THING001",
"description": "3for2 Things",
"quantity": 3,
"unitPrice": 6.99,
"total": 20.97
},
{
"sku": "POUND001",
"description": "Pound shop items",
"quantity": 1,
"unitPrice": 0.99,
"total": 0.99
}
],
"discounts": [
{
"code": "3FOR2",
"description": "3 for 2",
"amount": 6.99
},
{
"code": "JANPROMO5",
"description": "January Promo, \u00A35 off",
"amount": 5.00
}
],
"taxes": [
{
"code": "VAT",
"description": "VAT",
"rate": 0.20,
"amount": 1.99
}
],
"delivery": {
"carrier": "Royal Mail Tracked 48\u2122",
"amount": 1.99
}
}
Basket encoded to Base64
eyJpdGVtcyI6W3sic2t1IjoiVEhJTkcwMDEiLCJkZXNjcmlwdGlvbiI6IjNmb3I
yIFRoaW5ncyIsInF1YW50aXR5IjozLCJ1bml0UHJpY2UiOjYuOTksInRvdGFsIj
oyMC45N30seyJza3UiOiJQT1VORDAwMSIsImRlc2NyaXB0aW9uIjoiUG91bmQgc
2hvcCBpdGVtcyIsInF1YW50aXR5IjoxLCJ1bml0UHJpY2UiOjAuOTksInRvdGFs
IjowLjk5fV0sImRpc2NvdW50cyI6W3siY29kZSI6IjNGT1IyIiwiZGVzY3JpcHR
pb24iOiIzIGZvciAyIiwiYW1vdW50Ijo2Ljk5fSx7ImNvZGUiOiJKQU5QUk9NTz
UiLCJkZXNjcmlwdGlvbiI6IkphbnVhcnkgUHJvbW8sIFx1MDBBMzUgb2ZmIiwiY
W1vdW50Ijo1fV0sInRheGVzIjpbeyJjb2RlIjoiVkFUIiwiZGVzY3JpcHRpb24i
OiJWQVQiLCJyYXRlIjowLjIsImFtb3VudCI6MS45OX1dLCJkZWxpdmVyeSI6eyJ
jYXJyaWVyIjoiUm95YWwgTWFpbCBUcmFja2VkIDQ4XHUyMTIyIiwiYW1vdW50Ij
oxLjk5fX0=