failure modals on purchase
authorOwen Smith <owen@omsmith.ca>
Sat, 24 Nov 2012 03:44:29 +0000 (22:44 -0500)
committerOwen Smith <owen@omsmith.ca>
Sat, 24 Nov 2012 03:44:29 +0000 (22:44 -0500)
www/assets/js/ui.js
www/index.html

index e4899a7..0527b58 100644 (file)
@@ -76,12 +76,17 @@ function SelectionsViewModel () {
 
                var input = $(e.target);
                var cardData = input.val();
-               input.val('');
 
                var result = client.process(cardData, selected);
-               if (result === 2) {
-                       self.clearSelection();
-                       $('#checkout-modal').modal('hide');
+
+               input.val('');
+               self.clearSelection();
+               $('#checkout-modal').modal('hide');
+
+               if (result === E_PURCHASE_STATUS['EPS_FAIL']) {
+                       $('#fail-modal').modal();
+               } else if (result === E_PURCHASE_STATUS['EPS_NOMONEY']) {
+                       $('#nomoney-modal').modal();
                }
        };
 
index 62e67d4..4494414 100644 (file)
                        </div>
                </div>
 
+               <div id="fail-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="fail-modal-label" aria-hidden="true">
+                       <div class="modal-header">
+                               <h3 id="fail-modal-label">Transaction failed</h3>
+                       </div>
+                       <div class="modal-body">
+                               <p>Transaction failed for some reason. Like... 99% sure we didn't lose your moneys. If you think we did, let us know.</p>
+                       </div>
+                       <div class="modal-footer">
+                               <a href="#" class="btn btn-primary" data-dismiss="modal">Dismiss</a>
+                       </div>
+               </div>\
+
+               <div id="nomoney-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="nomoney-modal-label" aria-hidden="true">
+                       <div class="modal-header">
+                               <h3 id="nomoney-modal-label">Insufficient moneys!</h3>
+                       </div>
+                       <div class="modal-body">
+                               <p>You haven't given us enough moneys. Give us more moneys and try again.</p>
+                       </div>
+                       <div class="modal-footer">
+                               <a href="#" class="btn btn-primary" data-dismiss="modal">Dismiss</a>
+                       </div>
+               </div>
+
                <div id="config-modal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="config-modal-label" aria-hidden="true" data-backdrop="static" data-keyboard="false" data-show="true">
                        <div class="modal-header">
                                <h3 id="config-modal-label">Configuration</h3>