Create a transaction on the platform
create_transaction
Params
A customer provided ref for this transaction.
A token obtained from calling token_scan.
Response
Whether or not the transaction was successful.
A failure code indicating why a transaction operation wasn’t successful.Available values are FAULT, TOKEN_INVALID, COUPON_EXPIRED, COUPON_ALREADY_REDEEMED, COUPON_INVALID
A failure message if the transaction operation wasn’t successful.
The id of the transaction
Show Basket Credit Effect
A ‘basket-credit’ effect is one where an amount should be credited to the customer basket
type
string 'basket-credit'
required
Represents an amount that should be credited to a customers basket (tender).
The amount to be credited to the customers basket in cents
A ‘product’ effect is one where a customer should be provided a ‘free’ product
Represents a (free) product that should be provided to the customer
Name of the product to provide
Code of the product to provide to the customer
An identifying id for the coupon
A category code for the coupon. Can also be used as a tender type.
import * as sdk from "k42-sdk"
const session = sdk.createSession("ref");
const scanResult = await sdk.tokenScan(30000, 3);
...
const txResult = await sdk.createTransaction("tx-ref", scanResult.token);
if (!txResult.success) {
console.log(`Failed to create transaction: ${txResult.code} - ${txResult.message}`);
}
console.log('Transaction created');
console.log(`id: ${txResult.id}`);
console.log(`credit amount: ${txResult.effects[0].amount}`);
console.log(`coupon id: ${txResult.coupon.id}`);