DB upgrade script for Stripe payments; seed data; minor template fixes
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Thu, 19 Sep 2013 13:51:47 +0000 (09:51 -0400)
committerDan Wells <dbw2@calvin.edu>
Thu, 20 Feb 2014 21:31:35 +0000 (16:31 -0500)
Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Conflicts:
Open-ILS/src/templates/opac/myopac/main_payment_form.tt2

Signed-off-by: Remington Steed <rjs7@calvin.edu>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/XXXX.data.stripe-payments.sql [new file with mode: 0644]
Open-ILS/src/templates/opac/myopac/main_payment_form.tt2
Open-ILS/src/templates/opac/parts/stripe.tt2

index 964389c..04f3883 100644 (file)
@@ -3752,7 +3752,7 @@ INSERT into config.org_unit_setting_type
         'Name default credit processor',
         'coust', 'label'),
     oils_i18n_gettext('credit.processor.default',
-        'This might be "AuthorizeNet", "PayPal", etc.',
+        'This might be "AuthorizeNet", "PayPal", "PayflowPro", or "Stripe".',
         'coust', 'description'),
     'string', null)
 
@@ -3873,11 +3873,11 @@ INSERT into config.org_unit_setting_type
         'coust', 'description'),
     'string', null)
 
-,( 'credit.processor.stripe.privatekey', 'credit',
-    oils_i18n_gettext('credit.processor.stripe.privatekey',
+,( 'credit.processor.stripe.secretkey', 'credit',
+    oils_i18n_gettext('credit.processor.stripe.secretkey',
         'Stripe secret key',
         'coust', 'label'),
-    oils_i18n_gettext('credit.processor.stripe.privatekey',
+    oils_i18n_gettext('credit.processor.stripe.secretkey',
         'Stripe secret key',
         'coust', 'description'),
     'string', null)
diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.data.stripe-payments.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.data.stripe-payments.sql
new file mode 100644 (file)
index 0000000..25a3a41
--- /dev/null
@@ -0,0 +1,51 @@
+BEGIN;
+
+
+-- SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
+
+
+-- cheat sheet for enabling Stripe payments:
+--  'credit.payments.allow' must be true, and among other things it drives the
+--      opac to render a payment form at all
+--  NEW 'credit.processor.stripe.enabled' must be true  (kind of redundant but
+--      my fault for setting the precedent with c.p.{authorizenet|paypal|payflowpro}.enabled)
+--  'credit.default.processor' must be 'Stripe'
+--  NEW 'credit.processor.stripe.pubkey' must be set
+--  NEW 'credit.processor.stripe.secretkey' must be set
+
+INSERT into config.org_unit_setting_type
+( name, grp, label, description, datatype, fm_class ) VALUES
+
+    ( 'credit.processor.stripe.enabled', 'credit',
+    oils_i18n_gettext('credit.processor.stripe.enabled',
+        'Enable Stripe payments',
+        'coust', 'label'),
+    oils_i18n_gettext('credit.processor.stripe.enabled',
+        'Enable Stripe payments',
+        'coust', 'description'),
+    'bool', null)
+
+,( 'credit.processor.stripe.pubkey', 'credit',
+    oils_i18n_gettext('credit.processor.stripe.pubkey',
+        'Stripe publishable key',
+        'coust', 'label'),
+    oils_i18n_gettext('credit.processor.stripe.pubkey',
+        'Stripe publishable key',
+        'coust', 'description'),
+    'string', null)
+
+,( 'credit.processor.stripe.secretkey', 'credit',
+    oils_i18n_gettext('credit.processor.stripe.secretkey',
+        'Stripe secret key',
+        'coust', 'label'),
+    oils_i18n_gettext('credit.processor.stripe.secretkey',
+        'Stripe secret key',
+        'coust', 'description'),
+    'string', null)
+;
+
+UPDATE config.org_unit_setting_type
+SET description = 'This might be "AuthorizeNet", "PayPal", "PayflowPro", or "Stripe".'
+WHERE name = 'credit.processor.default' AND description = 'This might be "AuthorizeNet", "PayPal", etc.'; -- don't clobber local edits or i18n
+
+COMMIT;
index e04e664..7d4740d 100644 (file)
@@ -5,7 +5,6 @@
     myopac_main_page = "payment_form";
 
     last_chance = CGI.param("last_chance");
-    use_stripe = ctx.get_org_setting(ctx.user.home_ou.id, 'opac.processor.stripe.enabled');
 %]
 <h3 class="sr-only">[% l('Pay Fines') %]</h3>
 [% IF ctx.fines.balance_owed <= 0 %]
@@ -29,7 +28,7 @@
     <form method="post" id="payment_form"
     [% IF use_stripe %]
     onsubmit="return stripe_onsubmit();"
-    [% ENDIF %]
+    [% END %]
     >
         <input type="hidden" name="last_chance" value="1" />
         [% FOR xact IN CGI.param('xact') %]
@@ -40,7 +39,7 @@
         [% END %]
         [% IF use_stripe %]
         <input type="hidden" name="stripe_token" id="stripe_token" />
-        [% ENDIF %]
+        [% END %]
 
         <table title="[% l('Billing Information') %]">
             <tbody>
                     data-stripe="number"
                     [% ELSE %]
                     name="number"
-                    [% ENDIF %]
+                    [% END %]
                     /></td>
                 </tr>
                 <tr>
                         data-stripe="cvc"
                         [% ELSE %]
                         name="cvv2"
-                        [% ENDIF %]
+                        [% END %]
                         /></td>
                 </tr>
                 <tr>
                         data-stripe="exp_month"
                         [% ELSE %]
                         name="expire_month"
-                        [% END IF %]
+                        [% END %]
                         >
                             <option value="01">[% l("January") %]</option>
                             <option value="02">[% l("February") %]</option>
                         data-stripe="exp_year"
                         [% ELSE %]
                         name="expire_year"
-                        [% ENDIF %]
+                        [% END %]
                         >
                         [% year = date.format(date.now, '%Y');
                         y = year;
index e857fff..feeba12 100644 (file)
@@ -1,5 +1,7 @@
 [%- PROCESS "opac/parts/header.tt2";
-    IF myopac_main_page == "payment_form" AND ctx.get_org_setting(ctx.user.home_ou.id, 'opac.processor.stripe.enabled')%]
+IF myopac_main_page == "payment_form" AND
+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';
+    use_stripe = 1; %]
 
         <script type="text/javascript" src="https://js.stripe.com/v2/"></script> <!-- use an ou setting for this url? -->
         <script type="text/javascript">