checkout process call. would be more secure if this logic was built in to the server...
authorOwen Smith <owen@omsmith.ca>
Mon, 19 Nov 2012 06:35:12 +0000 (01:35 -0500)
committerOwen Smith <owen@omsmith.ca>
Mon, 19 Nov 2012 06:35:12 +0000 (01:35 -0500)
www/assets/js/client.js
www/assets/js/ui.js

index ac2f54c..e4f72cc 100644 (file)
@@ -20,3 +20,24 @@ PosClientWrapper.prototype.getPrice = function (upc, callback) {
 
        this._client.getUPCPrice(upc, callback);
 }
+
+PosClientWrapper.prototype.process = function (cardData, selection) {
+       var total = 0;
+       for (var i in selection) {
+               var entry = selection[i];
+
+               if (entry.quantity > 0) {
+                       total += entry.quantity * entry.price;
+               }
+       }
+
+       this._client.doTransactionOnHash(this._authKey, cardData, total);
+
+       for (var i in selection) {
+               var entry = selection[i];
+
+               if (entry.quantity > 0) {
+                       this._client.doStockChange(this._authKey, i, entry.quantity);
+               }
+       }
+}
index ded8c8d..3b03bec 100644 (file)
@@ -103,3 +103,15 @@ function request_upc_data (upc, callback) {
        $.ajax( 'upc.php?upc=' + upc )
                .done(function (data) { callback(JSON.parse(data)); });
 }
+
+$('input[name=card-number]').keypress(function (e) {
+       var keyCode = e.keyBode || e.which;
+
+       if (keyCode === 13) {// enter
+               var input = $(this);
+
+               var cardData = input.val();
+
+               client.process(cardData, entries);
+       }
+});