showing the more descriptive cc payment errors in self-check. printing CC payment...
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 6 Jul 2010 19:30:04 +0000 (19:30 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 6 Jul 2010 19:30:04 +0000 (19:30 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@16859 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/circ/selfcheck/payment.js
Open-ILS/web/js/ui/default/circ/selfcheck/selfcheck.js
Open-ILS/web/templates/default/circ/selfcheck/payment.tt2

index a960e3a..b3a59fc 100644 (file)
@@ -86,6 +86,7 @@ proto.sendCCPayment = function(patron, xacts, onPaymentSubmit) {
         payments : xacts,
         cc_args : {
             where_process : 1,
+            //type : oilsSelfckCCType.attr('value'),
             number : oilsSelfckCCNumber.attr('value'),
             cvv2 : oilsSelfckCCCVV.attr('value'),
             expire_year : oilsSelfckCCYear.attr('value'),
index 2dc7c15..a4d061b 100644 (file)
@@ -106,9 +106,22 @@ SelfCheckManager.prototype.init = function() {
                 self.patron,
                 self.getSelectedFinesTotal(),
                 self.getSelectedFineTransactions(),
-                function() {
-                    self.updateFinesSummary();
-                    self.drawFinesPage();
+                function(resp) {
+                    var evt = openils.Event.parse(resp);
+                    if(evt) {
+                        var message = evt + '';
+                        if(evt.textcode == 'CREDIT_PROCESSOR_DECLINED_TRANSACTION' && evt.payload)
+                            message += '\n' + evt.payload.error_message;
+                        self.handleAlert(message, true, 'payment-failure');
+                        return;
+                    }
+                    self.printPaymentReceipt(
+                        resp,
+                        function() {
+                            self.updateFinesSummary();
+                            self.drawFinesPage();
+                        }
+                    );
                 }
             );
         },
@@ -1326,6 +1339,35 @@ SelfCheckManager.prototype.printHoldsReceipt = function(callback) {
 }
 
 
+SelfCheckManager.prototype.printPaymentReceipt = function(paymentIds, callback) {
+    
+    var self = this;
+    progressDialog.show(true);
+
+    fieldmapper.standardRequest(
+        ['open-ils.circ', 'open-ils.circ.money.payment_receipt.print'],
+        {
+            async : true,
+            params : [this.authtoken, paymentIds],
+            oncomplete : function(r) {
+                var resp = openils.Util.readResponse(r);
+                var output = resp.template_output();
+                progressDialog.hide();
+                if(output) {
+                    self.printData(output.data(), 1, callback); 
+                } else {
+                    var error = resp.error_output();
+                    if(error) {
+                        throw new Error("Error creating receipt: " + error.data());
+                    } else {
+                        throw new Error("No receipt data returned from server");
+                    }
+                }
+            }
+        }
+    );
+}
+
 /**
  * Print a receipt for this user's items out
  */
index 9ae3155..f4fe97e 100644 (file)
@@ -3,6 +3,18 @@
 </div>
 <table id='oils-selfck-cc-payment-table'>
     <tbody>
+        <!-- Technically not needed since card type is derived from the CC number
+        <tr>
+            <td>Type of Card</td>
+            <td>
+                <select dojoType='dijit.form.FilteringSelect' jsId='oilsSelfckCCType' required='true'>
+                    <option value='VISA'>VISA</option>
+                    <option value='MasterCard'>MasterCard</option>
+                    <option value='American Express'>American Express</option>
+                </select>
+            </td>
+        </tr>
+        -->
         <tr>
             <td>Credit Card #</td>
             <td><input dojoType='dijit.form.TextBox' jsId='oilsSelfckCCNumber' required='true'/></td>