]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/templates/opac/myopac/main_payment_form.tt2
LP#1688398: revamp public catalog bill payment page
[working/Evergreen.git] / Open-ILS / src / templates / 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="opac-button"/>
42         <a href="[% mkurl(ctx.opac_root _ '/myopac/main#selected_fines', {}, 1) %]" class="opac-button">[% 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" style="padding-top:1em;">
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="opac-button"/>
85         <a href="[% mkurl(ctx.opac_root _ '/myopac/main#selected_fines', {}, 1) %]" class="opac-button">[% 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">
105           <tbody>
106               <tr>
107                   <td colspan='2' class="cc_header"><strong>[% l('Billing Information') %]</strong></td>
108                </tr>
109                <tr> 
110                 <td><label for="payment-first-name">[% l('First Name') %]</label></td>
111                     <td><input type="text"  name="billing_first" id="payment-first-name" 
112                         value="[% ctx.user.first_given_name | html %]" /></td>
113                 </tr>
114                 <tr>
115                     <td><label for="payment-last-name">[% l('Last Name') %]</label></td>
116                     <td><input type="text" name="billing_last" id="payment-last-name" 
117                         value="[% ctx.user.family_name | html %]" /></td>
118                 </tr>
119
120                 <tr>
121                     <td><label for="payment-email-addr">[% l('Email Address') %]</label></td>
122                     <td>
123                         
124                         <input id="payment-email-addr" type="text" 
125                              value="[% ctx.user.email | html %]" disabled="disabled" 
126                             readonly="readonly" />   
127                         <a title="[% l('Update Email Address') %]"
128                             href="[% ctx.opac_root %]/myopac/update_email?return_to_referer=1">[% l("Update") %]</a>
129                     </td
130                 </tr>
131                 <tr>
132                     <td><label for="payment-billing-address">[% l('Street Address') %]</label></td>
133                     <td><input type="text" name="billing_address" id="payment-billing-address" 
134                         value="[% ctx.user.billing_address.street1 _ ctx.user.billing_address.street2 | html %]" /></td>
135                 </tr>
136                 <tr>
137                     <td><label for="payment-billing-city">[% l('City' )%]</label></td>
138                     <td><input type="text" name="billing_city" id="payment-billing-city" 
139                         value="[% ctx.user.billing_address.city | html %]" /></td>
140                 </tr>
141                 <tr>
142                     <td><label for="payment-billing-state">[% l('State or Province') %]</label></td>
143                     <td><input type="text" name="billing_state" id="payment-billing-state"
144                         value="[% ctx.user.billing_address.state | html %]" /></td>
145                 </tr>
146                 <tr>
147                     <td><label for="paymenet-billing-zip">[% l('ZIP or Postal Code') %]</label></td>
148                     [% USE zip=String(ctx.user.billing_address.post_code) %]
149                     <td><input type="tel" pattern="[0-9]*" maxlength="5" size="5" name="billing_zip" id="paymenet-billing-zip"
150                         value="[% zip.truncate(5)  %]" /></td>
151                 </tr>
152                </tbody>
153                </table>
154                
155                <table id="credit_card_info_table">
156                <tbody>
157                 <tr>
158                   <td colspan='2' class="cc_header"><strong>[% l('Credit Card Information') %]</strong></td>
159                 </tr>
160                 <tr>
161                     <td><label for="payment-credit-card">[% l('Credit Card #') %]</label></td>
162                     
163                      <!-- Make type tel, which prompts for numbers in mobile -->
164                     <td><input type="tel" pattern="[0-9]*" maxlength="16" id="payment-credit-card" required 
165                     [% IF ctx.use_stripe %]
166                     data-stripe="number"
167                     [% ELSE %]
168                     name="number"
169                     [% END %]
170                     /></td>
171                 </tr>
172                 <tr>
173                     <td><label for="payment-security-code">[% l('Security Code') %]</label></td>
174                     <td>
175                          <!-- Make type tel, which prompts for numbers in mobile -->
176                         <input type="tel" pattern="[0-9]*" size="4" maxlength="5" id="payment-security-code"
177                         [% IF ctx.use_stripe %]
178                         data-stripe="cvc"
179                         [% ELSE %]
180                         name="cvv2"
181                         [% END %]
182                         /></td>
183                 </tr>
184                 <tr>
185                     <td><label for="payment-expire-month">[% l('Expiration Month') %]</label></td>
186                     <td>
187                         <select id="payment-expire-month" required
188                         [% IF ctx.use_stripe %]
189                         data-stripe="exp_month"
190                         [% ELSE %]
191                         name="expire_month"
192                         [% END %]
193                         >
194                             <option value="-1"></option>
195                             <option value="01">[% l("January (1)") %]</option>
196                             <option value="02">[% l("February (2)") %]</option>
197                             <option value="03">[% l("March (3)") %]</option>
198                             <option value="04">[% l("April (4)") %]</option>
199                             <option value="05">[% l("May (5)") %]</option>
200                             <option value="06">[% l("June (6)") %]</option>
201                             <option value="07">[% l("July (7)") %]</option>
202                             <option value="08">[% l("August (8)") %]</option>
203                             <option value="09">[% l("September (9)") %]</option>
204                             <option value="10">[% l("October (10)") %]</option>
205                             <option value="11">[% l("November (11)") %]</option>
206                             <option value="12">[% l("December (12)") %]</option>
207                         </select>
208                     </td>
209                 </tr>
210                 <tr>
211                     <td><label for="payment-expire-year">[% l('Expiration Year') %]</label></td>
212                     <td>
213                         <select id="payment-expire-year"
214                         [%- IF ctx.use_stripe %]
215                         data-stripe="exp_year"
216                         [% ELSE %]
217                         name="expire_year"
218                         [% END -%]
219                         >
220                         [% year = date.format(date.now, '%Y');
221                         y = year;
222                         WHILE y < year + 10; # show ten years starting now %]
223                             <option value="[% y %]">[% y %]</option>
224                         [% y = y + 1; END %]
225                         </select>
226                     </td>
227                 </tr>
228                 <tr>
229                    <td colspan='2'>
230                        <div id="payment_actions">
231                           [% l('Total amount:') %]
232                            <strong>[% money(ctx.fines.balance_owed) %]</strong><br />
233           
234                          <input type="submit" id="payment_submit" value="[% l('Next') %]" class="opac-button" />
235                          <a href="[% mkurl(ctx.opac_root _ '/myopac/main', {}, 1) %]" class="opac-button">[% l('Cancel') %]</a> 
236                          <br/>
237                          
238                           
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 %]