]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/src/templates-bootstrap/opac/myopac/main_payment_form.tt2
de357f55ccad617202ad4a9ac69ad155d719693a
[Evergreen.git] / Open-ILS / src / templates-bootstrap / opac / myopac / main_payment_form.tt2
1 [%  PROCESS "opac/parts/header.tt2";
2     PROCESS "opac/parts/misc_util.tt2";
3     WRAPPER "opac/parts/myopac/main_base.tt2";
4     myopac_page = "main";
5     myopac_main_page = "payment_form";
6
7     last_chance = CGI.param("last_chance");
8
9     IF myopac_main_page == "payment_form" AND
10         ctx.get_org_setting(ctx.user.home_ou.id, 'credit.processor.stripe.enabled') AND ctx.get_org_setting(ctx.user.home_ou.id, 'credit.processor.default') == 'Stripe';
11         ctx.use_stripe = 1;
12     END %]
13
14 <a name="payment"> </a>    
15 <h3 class="sr-only">[% l('Pay Charges') %]</h3>
16 [% IF ctx.fines.balance_owed <= 0 %]
17 <div>
18     [% l("The minimum amount you can pay is \$0.01.") %]
19 </div>
20 [% ELSE %]
21 [% IF ctx.use_stripe %]
22 <noscript>
23     [% l("Your browser does not have Javascript enabled, and we cannot " _
24         "process credit card payments without it.  Please change your " _
25         "browser settings and try again.") %]
26 </noscript>
27 [% END %]
28 <div id="pay_fines_now"[% IF ctx.use_stripe %] class="hide_me"[% END %]>
29      [% IF last_chance %]
30     
31     <p><big>[% l("Are you sure you are ready to charge ") %]
32          <strong> [% l("[_1] ", money(ctx.fines.balance_owed))%]</strong>
33         [% l("to your credit card?") %]</big></p> 
34     <form action="[% ctx.opac_root %]/myopac/main_pay_init" method="post">
35         [% FOR k IN CGI.Vars;
36             NEXT UNLESS k;
37             FOR val IN CGI.param(k) %]
38         <input type="hidden" name="[% k | html %]" value="[% val | html %]" /> 
39         [% END; END %]
40
41         <input type="submit" value="[% l('Submit') %]" class="btn btn-confirm"/>
42         <a href="[% mkurl(ctx.opac_root _ '/myopac/main#selected_fines', {}, 1) %]" class="btn btn-deny">[% l('Cancel') %]</a>
43         
44      <table title="[% l('List of Transactions') %]" id="acct_fines_confirm_header"
45         class="table_no_border_space table_no_cell_pad my-2">
46    <thead>
47       <tr>
48         <th>[% l('Charge/Fee') %]</th>
49         <th>[% l('Amount') %]</th>
50      </tr>
51    </thead>
52    <tbody>
53       [%
54        FOR f IN ctx.fines.circulation;
55          NEXT IF CGI.param('xact').size &&
56             !CGI.param('xact').grep(f.xact.id).size;
57          attrs = {marc_xml => f.marc_xml};
58          IF f.marc_xml;
59              PROCESS get_marc_attrs args=attrs;
60          ELSIF f.xact.reservation;
61               attrs.title = f.xact.reservation.target_resource_type.name;
62          END %]
63          <tr>
64             <td>[% attrs.title | html %]</td>
65             <td class="text-right">[% money(f.xact.balance_owed) %]</td>
66          </tr>
67           [%
68           END;
69           FOR f IN ctx.fines.grocery;
70               NEXT IF CGI.param('xact_misc').size &&
71                   !CGI.param('xact_misc').grep(f.xact.id).size %]
72               <tr>
73                  <td>[% f.xact.last_billing_type | html %]</td>
74                  <td class="text-right">[% money(f.xact.balance_owed) %]</td>
75             </tr>
76         [% END %]
77      </tbody>
78    </table> 
79      
80     <p style="padding-top: 2em;">
81     <big>[% l("Are you sure you are ready to charge ") %]
82          <strong> [% l("[_1] ", money(ctx.fines.balance_owed))%]</strong>
83         [% l("to your credit card?") %]</big></p>        
84         <input type="submit" value="[% l('Submit') %]" class="btn btn-confirm"/>
85         <a href="[% mkurl(ctx.opac_root _ '/myopac/main#selected_fines', {}, 1) %]" class="btn btn-deny">[% l('Cancel') %]</a>
86     [% ELSE %]
87     
88     <form method="post" id="payment_form" action='#payment'
89     [% IF ctx.use_stripe %]
90     onsubmit="return stripe_onsubmit();"
91     [% END %]
92     >
93         <input type="hidden" name="last_chance" value="1" />
94         [% FOR xact IN CGI.param('xact') %]
95         <input type="hidden" name="xact" value="[% xact | html %]" />
96         [% END %]
97         [% FOR xact IN CGI.param('xact_misc') %]
98         <input type="hidden" name="xact_misc" value="[% xact | html %]" />
99         [% END %]
100         [% IF ctx.use_stripe %]
101         <input type="hidden" name="stripe_token" id="stripe_token" />
102         [% END %]
103
104          <table id="billing_info_table" class="table table-hover">
105          <thead>
106           <th colspan='2'><strong>[% l('Billing Information') %]</strong></th>
107          </thead>
108           <tbody>
109                
110                <tr> 
111                 <td><label for="payment-first-name">[% l('First Name') %]</label></td>
112                     <td><input type="text"  name="billing_first" id="payment-first-name" 
113                         value="[% ctx.user.first_given_name | html %]" class="form-control"/></td>
114                 </tr>
115                 <tr>
116                     <td><label for="payment-last-name">[% l('Last Name') %]</label></td>
117                     <td><input type="text" name="billing_last" id="payment-last-name" 
118                         value="[% ctx.user.family_name | html %]" class="form-control"/></td>
119                 </tr>
120
121                 <tr>
122                     <td><label for="payment-email-addr">[% l('Email Address') %]</label></td>
123                     <td>
124                         
125                         <input id="payment-email-addr" type="text" 
126                              value="[% ctx.user.email | html %]" disabled="disabled" 
127                             readonly="readonly" class="form-control"/>   
128                         <a title="[% l('Update Email Address') %]"
129                             href="[% ctx.opac_root %]/myopac/update_email?return_to_referer=1">[% l("Update") %]</a>
130                     </td
131                 </tr>
132                 <tr>
133                     <td><label for="payment-billing-address">[% l('Street Address') %]</label></td>
134                     <td><input type="text" name="billing_address" id="payment-billing-address" 
135                         value="[% ctx.user.billing_address.street1 _ ctx.user.billing_address.street2 | html %]" class="form-control"/></td>
136                 </tr>
137                 <tr>
138                     <td><label for="payment-billing-city">[% l('City' )%]</label></td>
139                     <td><input type="text" name="billing_city" id="payment-billing-city" 
140                         value="[% ctx.user.billing_address.city | html %]" class="form-control"/></td>
141                 </tr>
142                 <tr>
143                     <td><label for="payment-billing-state">[% l('State or Province') %]</label></td>
144                     <td><input type="text" name="billing_state" id="payment-billing-state"
145                         value="[% ctx.user.billing_address.state | html %]" class="form-control" /></td>
146                 </tr>
147                 <tr>
148                     <td><label for="paymenet-billing-zip">[% l('Postal Code') %]</label></td>
149                     [% USE zip=String(ctx.user.billing_address.post_code) %]
150                     <td><input type="tel" pattern="[/^[a-zA-Z0-9 _-]{7}$/]*" maxlength="7" size="7" name="billing_zip" id="paymenet-billing-zip"
151                         value="[% zip.truncate(5)  %]" class="form-control"/></td>
152                 </tr>
153                </tbody>
154                </table>
155                
156                <table id="credit_card_info_table" class="table">
157                <thead>
158                 <th colspan='2'><strong>[% l('Credit Card Information') %]</strong></th>
159                </thead>
160                <tbody>
161                
162                 <tr>
163                     <td><label for="payment-credit-card">[% l('Credit Card #') %]</label></td>
164                     
165                      <!-- Make type tel, which prompts for numbers in mobile -->
166                     <td><input class="form-control" type="tel" pattern="[0-9]*" maxlength="16" id="payment-credit-card" required 
167                     [% IF ctx.use_stripe %]
168                     data-stripe="number"
169                     [% ELSE %]
170                     name="number"
171                     [% END %]
172                     /></td>
173                 </tr>
174                 <tr>
175                     <td><label for="payment-security-code">[% l('Security Code') %]</label></td>
176                     <td>
177                          <!-- Make type tel, which prompts for numbers in mobile -->
178                         <input class="form-control" type="tel" pattern="[0-9]*" size="4" maxlength="5" id="payment-security-code"
179                         [% IF ctx.use_stripe %]
180                         data-stripe="cvc"
181                         [% ELSE %]
182                         name="cvv2"
183                         [% END %]
184                         /></td>
185                 </tr>
186                 <tr>
187                     <td><label for="payment-expire-month">[% l('Expiration Month') %]</label></td>
188                     <td>
189                         <select class="form-control" id="payment-expire-month" required
190                         [% IF ctx.use_stripe %]
191                         data-stripe="exp_month"
192                         [% ELSE %]
193                         name="expire_month"
194                         [% END %]
195                         >
196                             <option value="-1"></option>
197                             <option value="01">[% l("January (1)") %]</option>
198                             <option value="02">[% l("February (2)") %]</option>
199                             <option value="03">[% l("March (3)") %]</option>
200                             <option value="04">[% l("April (4)") %]</option>
201                             <option value="05">[% l("May (5)") %]</option>
202                             <option value="06">[% l("June (6)") %]</option>
203                             <option value="07">[% l("July (7)") %]</option>
204                             <option value="08">[% l("August (8)") %]</option>
205                             <option value="09">[% l("September (9)") %]</option>
206                             <option value="10">[% l("October (10)") %]</option>
207                             <option value="11">[% l("November (11)") %]</option>
208                             <option value="12">[% l("December (12)") %]</option>
209                         </select>
210                     </td>
211                 </tr>
212                 <tr>
213                     <td><label for="payment-expire-year">[% l('Expiration Year') %]</label></td>
214                     <td>
215                         <select class="form-control" id="payment-expire-year"
216                         [%- IF ctx.use_stripe %]
217                         data-stripe="exp_year"
218                         [% ELSE %]
219                         name="expire_year"
220                         [% END -%]
221                         >
222                         [% year = date.format(date.now, '%Y');
223                         y = year;
224                         WHILE y < year + 10; # show ten years starting now %]
225                             <option value="[% y %]">[% y %]</option>
226                         [% y = y + 1; END %]
227                         </select>
228                     </td>
229                 </tr>
230                 <tr>
231                    <td colspan='2'>
232                        <div id="payment_actions">
233                           [% l('Total amount:') %]
234                            <strong>[% money(ctx.fines.balance_owed) %]</strong><br />
235           
236                          <input type="submit" id="payment_submit" value="[% l('Next') %]" class="btn btn-confirm" />
237                          <a href="[% mkurl(ctx.opac_root _ '/myopac/main', {}, 1) %]" class="btn btn-deny">[% l('Cancel') %]</a> 
238                          <br/>
239                          </div>
240                    </td>
241                 </tr>
242                 
243           </tbody>
244         </table>
245          [% INCLUDE "opac/parts/myopac/main_refund_policy.tt2" %]
246         
247     [% END %]
248     </form>
249 </div>
250 [% END %]
251 [% END %]