Skip to main content
Create a transaction on the platform

create_transaction

Params

ref
string
required
A customer provided ref for this transaction.
token
string
required
A token obtained from calling token_scan.

Response

success
boolean
required
Whether or not the transaction was successful.
code
string
A failure code indicating why a transaction operation wasn’t successful.Available values are FAULT, TOKEN_INVALID, COUPON_EXPIRED, COUPON_ALREADY_REDEEMED, COUPON_INVALID
message
string
A failure message if the transaction operation wasn’t successful.
id
string
required
The id of the transaction
effects
Effect Array
required
coupon
Coupon
required
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}`);