iVendNextDevelopers My apps

A gift card for a big spend, spendable after a hold — the recipe

A retailer wants a sale over a set amount to earn the customer the retailer's own gift card, which can be spent only after a hold (24 hours is common: the customer cannot buy, earn and spend in one visit). This recipe builds it as an outside app that reads the event feed and keeps every change of value in the retailer's own gift card records. It is for an iVendNext developer who has made an outside app before (the event feed).

Next: the sample, S25 · Gift card on spendAll recipes

In the App library: Gift card on spend

Reference implementation: samples/s25_gift_on_spend/ — Gift card on spend.

When to use it. Any reward of stored value that the retailer's own gift cards can carry: a card for a spend over a threshold, one per full threshold, held for a while before it spends. The card is not on that sale's receipt: it is made after the sale books. If the retailer wants the card in the sale itself (a promotion that gives a gift card), that is the retailer's promotion; today iVendNext POS shows such a reward as earned, complete at the register rather than issuing it.

Steps

  1. Read the sales from the feed (recipe): iVendNext's feed registration follows POS Invoice; your service acts on sale.booked, return.booked and sale.cancelled, reads each sale over the API, and marks the event done. Every other event is marked done unread.
  2. Name each card before you make it. Your manifest's own record type <PREFIX> Card is named by the sale and the card's position ("autoname": "field:card_key", the key S1:1). Write it first, holding the card's number, value, item and hold. iVendNext refuses a second record with that name, so a replayed event or a crash never earns a second card.
  3. Make the retailer's own gift card at a balance of 0. Insert the engine's Gift Card with your number (16 digits, from a secure random source, never one the retailer holds), the retailer's gift card item, its total = the card's value, its balance = 0. The till and the engine refuse a card with nothing on it, so nobody can spend it during the hold.
  4. Release it after the hold with a Gift Card Balance. Submit the engine's Gift Card Balance for the card with its value: on submit it sets the card's balance and writes a comment on the card, and the retailer's Gift Card Ledger report lists it. ⚠ It sets the balance; it does not add. Release only a card that has no submitted Gift Card Balance yet and a balance of exactly 0; anything else goes to iVendNext to decide.
  5. Read the sale again before every release. Cancelled since? Returned below what earned this card? Then void it instead. Decide from the sale and every return booked against it now, never from the order the events arrived in: a failed event is retried after later ones.
  6. Void what a cancellation or return no longer earns. A held card is simply never released. A released card still at its full value, and never used at the till (the till's own redeemed test, /api/method/ivendnext_mpos.api.v1.get_gift_card_status, from POS build 2.0.0.654; before it, ivendnext_pos.api.pos_invoice.get_gift_card_status), is set to 0 by a Gift Card Balance of 0. A card already used keeps its balance and goes to iVendNext to decide: never take back what a customer has spent.
  7. Refuse a gift card item that could turn into money. A rechargeable card would let a void take money the customer paid in; a cash-back card pays the promotion out as cash; a store-credit card is the returns' own. Check the item's flags before you issue.
  8. Tell staff. List each card under the customer and the sale (Connections links in the manifest). The till does not say whether a sale earned a card (the card is made after the sale is booked), so tell the retailer to add a line with the rule to each register's Receipt Footer on its POS Profile (Spend 5,000 or more in one sale, on your name: a 250 gift card, usable the next day.); it prints on every receipt. The kit has no way yet to send the number to the customer: an e-mail needs the product to give the framework's e-mail call an iVendNext name, and a message needs a gateway.

Settings

One record of your own type <PREFIX> Settings, named Default, edited by the retailer in Desk and read at every pass: enabled, the currency, the threshold, each card's value, the gift card item, the cards per sale, the hold in hours, and the walk-in customers and customer groups that never earn. From POS build 2.0.0.654 a manifest may declare a settings record of its own ("issingle": 1, one record with no list, chapter 7); S25 keeps a record named Default so that it installs on an older site too.

Earned gift cards

One record per card, listed under the customer and the sale: its state (Issuing, Held, Released, Voided, Review), its number and gift card, its value, the threshold and hold it was earned under, when it can be spent (the retailer's time), the Gift Card Balance that released it and the one that set it to 0, and a note when the retailer must decide.

What iVendNext needs from you

When your service is down, and when the till is offline

Nothing at the till waits for your service: the sale books as before. The feed keeps the events, so the cards are issued when your service is back, and the hold runs from then. A sale rung offline reaches the feed when the till syncs.

Technical notes

What was proven where

Needs this serves

This page in the kit