pp_express_order.twig (5645B)
1 <fieldset> 2 <legend>{{ text_transaction }}</legend> 3 <div id="paypal-transaction"></div> 4 </fieldset> 5 6 <fieldset> 7 <legend>{{ text_payment }}</legend> 8 <table class="table table-bordered"> 9 <tr> 10 <td>{{ text_capture_status }}</td> 11 <td id="capture-status">{{ capture_status }}</td> 12 </tr> 13 <tr> 14 <td>{{ text_amount_authorised }}</td> 15 <td>{{ total }} 16 {% if capture_status != 'Complete' %} 17 18 <button type="button" id="button-void" data-loading="{{ text_loading }}" class="btn btn-danger">{{ button_void }}</button> 19 {% endif %}</td> 20 </tr> 21 <tr> 22 <td>{{ text_amount_captured }}</td> 23 <td id="paypal-captured">{{ captured }}</td> 24 </tr> 25 <tr> 26 <td>{{ text_amount_refunded }}</td> 27 <td id="paypal-refund">{{ refunded }}</td> 28 </tr> 29 </table> 30 </fieldset> 31 32 {% if capture_status != 'Complete' %} 33 <fieldset id="capture-form"> 34 <legend>{{ tab_capture }}</legend> 35 <form id="paypal-capture" class="form-horizontal"> 36 <div class="form-group"> 37 <label class="col-sm-2 control-label" for="input-capture-amount">{{ entry_capture_amount }}</label> 38 <div class="col-sm-10"> 39 <input type="text" name="amount" value="{{ capture_remaining }}" id="input-capture-amount" class="form-control" /> 40 </div> 41 </div> 42 <div class="form-group"> 43 <label class="col-sm-2 control-label" for="input-capture-complete">{{ entry_capture_complete }}</label> 44 <div class="col-sm-10"> 45 <input type="checkbox" name="complete" value="1" id="input-capture-complete" class="form-control" /> 46 </div> 47 </div> 48 <div class="pull-right"> 49 <button type="button" id="button-capture" data-loading="{{ text_loading }}" class="btn btn-primary">{{ button_capture }}</button> 50 </div> 51 </form> 52 </fieldset> 53 {% endif %} 54 <script type="text/javascript"><!-- 55 $('#paypal-transaction').load('index.php?route=extension/payment/pp_express/transaction&user_token={{ user_token }}&order_id={{ order_id }}'); 56 57 $('#button-capture').on('click', function() { 58 $.ajax({ 59 url: 'index.php?route=extension/payment/pp_express/capture&user_token={{ user_token }}&order_id={{ order_id }}', 60 type: 'post', 61 dataType: 'json', 62 data: 'amount=' + $('#input-capture-amount').val() + '&complete=' + ($('#paypal-capture-complete').prop('checked') == true ? 1 : 0), 63 beforeSend: function() { 64 $('#button-capture').button('loading'); 65 }, 66 complete: function() { 67 $('#button-capture').button('reset'); 68 }, 69 success: function(json) { 70 $('.alert-dismissible').remove(); 71 72 if (json['error']) { 73 $('#paypal-capture').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 74 } 75 76 if (json['success']) { 77 $('#paypal-capture').prepend('<div class="alert alert-success alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 78 79 $('#paypal-captured').text(json['captured']); 80 $('#paypal-capture-amount').val(json['remaining']); 81 82 if (json['capture_status']) { 83 $('#capture-status').text(json['capture_status']); 84 85 $('#button-void').remove(); 86 87 $('#capture-form').remove(); 88 } 89 } 90 91 $('#paypal-transaction').load('index.php?route=extension/payment/pp_express/transaction&user_token={{ user_token }}&order_id={{ order_id }}'); 92 } 93 }); 94 }); 95 96 $('#button-void').on('click', function() { 97 if (confirm('{{ text_confirm_void|escape('js') }}')) { 98 $.ajax({ 99 url: 'index.php?route=extension/payment/pp_express/void&user_token={{ user_token }}&order_id={{ order_id }}', 100 dataType: 'json', 101 beforeSend: function() { 102 $('#button-void').button('loading'); 103 }, 104 complete: function() { 105 $('#button-void').button('reset'); 106 }, 107 success: function(json) { 108 $('.alert-dismissible').remove(); 109 110 if (json['error']) { 111 $('#paypal-capture').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 112 } 113 114 if (json['success']) { 115 $('#capture-status').text(json['capture_status']); 116 117 $('#button-void').remove(); 118 119 $('#capture-form').remove(); 120 } 121 122 $('#paypal-transaction').load('index.php?route=extension/payment/pp_express/transaction&user_token={{ user_token }}&order_id={{ order_id }}'); 123 } 124 }); 125 } 126 }); 127 128 $('#paypal-transaction').delegate('button', 'click', function() { 129 var element = this; 130 131 $.ajax({ 132 url: $(element).attr('href'), 133 dataType: 'json', 134 beforeSend: function() { 135 $(element).button('loading'); 136 }, 137 complete: function() { 138 $(element).button('reset'); 139 }, 140 success: function(json) { 141 $('.alert-dismissible').remove(); 142 143 if (json['error']) { 144 $('#tab-pp-express').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>'); 145 } 146 147 if (json['success']) { 148 $('#paypal-transaction').load('index.php?route=extension/payment/pp_express/transaction&user_token={{ user_token }}&order_id={{ order_id }}'); 149 } 150 } 151 }); 152 }); 153 //--></script>