diff --git a/test/js-example.js b/test/js-example.js index f1329e6..bef470e 100644 --- a/test/js-example.js +++ b/test/js-example.js @@ -165,3 +165,23 @@ function extractEvents( } } + +function mark_purchased(transaction) { + transaction.state = TransactionState.PURCHASED + for (item in transaction.items) { + if (item.mtb_product_ids) { + if (item.mtb_product_ids) { + for (mp_id in item.mtb_product_ids) { + try { + mtb_prod = get_db_mtb_product(None, mp_id, all=True, refresh=False) + mtb_prod.purchased = True + mtb_prod.save() + } + catch(exc) { + logger.error("Failed to mark mtb_product {mp_id} as purchase", exc_info=exc) + } + } + } + } + } + } \ No newline at end of file