Finalize an in-progress transaction.
finalize_transaction
Params
The transaction id obtained from calling create_transaction.
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 txResult = await sdk.createTransaction("tx-ref", scanResult.token);
if (!txResult.success) {
console.log(`Failed to create transaction: ${txResult.message}`);
return;
}
const finalizeResult = await sdk.finalizeTransaction(txResult.id);
if (!finalizeResult.success) {
console.log(`Failed to finalize transaction: ${txResult.message}`);
return;
}
console.log('Transaction successful');
console.log(`id: ${finalizeResult.id}`);
console.log(`auth_code: ${finalizeResult.auth_code}`);
console.log(`credit amount: ${finalizeResult.effects[0].amount}`);
console.log(`coupon id: ${finalizeResult.coupon.id}`);