[% l('Credit Card Information') %]
</h4>
</div>
-<div class="modal-body tight-vert-form">
+<div class="modal-body tight-vert-form" id="patron-pay-by-credit-form">
<div class="panel panel-default">
<div class="panel-heading">[% l('Credit Card Info') %]</div>
<div class="panel-body">
<div class="row form-group">
<div class="col-md-4"><label>[% l('Approval Code') %]</label></div>
<div class="col-md-8">
- <input type='text' class="form-control" ng-model="context.cc.approval_code"/>
+ <input type='text' class="form-control"
+ required ng-model="context.cc.approval_code"/>
</div>
</div>
</div><!--cc-external-wrapper-->
/* Angular applies these classes based on the field's
* required and pattern settings */
#patron-reg-container .ng-invalid,
-#patron-reg-container .ng-invalid-required {
+#patron-reg-container .ng-invalid-required,
+#patron-pay-by-credit-form .ng-invalid {
background-color: yellow;
color: red;
}
patronSvc.current.last_xact_id()
).then(function(resp) {
console.debug('payments: ' + js2JSON(resp));
+
+ if (evt = egCore.evt.parse(resp)) {
+ // Ideally, all scenarios that lead to this alert appearing
+ // will be avoided by the application logic. Leave the alert
+ // in place now to root out any that remain to be addressed.
+ alert(evt);
+ return $q.reject(''+evt);
+ }
+
var total = 0; angular.forEach(payments,function(p) { total += p[1]; });
var msg;
switch(type) {
'total_amount' : total
}
);
- if (evt = egCore.evt.parse(resp))
- return alert(evt);
// payment API returns the update xact id so we can track it
// for future payments without having to refresh the user.
var make_payments = generatePayments();
billSvc.applyPayment($scope.payment_type,
make_payments, note, $scope.check_number, cc_args)
- .then(function(payment_ids) {
+ .then(
+ function(payment_ids) {
- if (!$scope.disable_auto_print && $scope.receipt_on_pay.isChecked) {
- printReceipt(
- $scope.payment_type, payment_ids, make_payments, note);
- }
+ if (!$scope.disable_auto_print && $scope.receipt_on_pay.isChecked) {
+ printReceipt(
+ $scope.payment_type, payment_ids, make_payments, note);
+ }
- refreshDisplay();
- })
+ refreshDisplay();
+ },
+ function(msg) {
+ console.error('Payment was rejected: ' + msg);
+ }
+ )
}
$scope.onReceiptOnPayChanged = function(){
}
$scope.ok = function() {
+ // CC payment form is not a <form>,
+ // so apply validation manually.
+ if ( $scope.context.cc.where_process == 0 &&
+ !$scope.context.cc.approval_code)
+ return;
+
$uibModalInstance.close($scope.context.cc);
}