Separate stripe js into stripe.tt2, add seed data for ou settings
authorJason Boyer <JBoyer1@library.in.gov>
Thu, 19 Sep 2013 13:45:25 +0000 (09:45 -0400)
committerDan Wells <dbw2@calvin.edu>
Thu, 20 Feb 2014 21:31:28 +0000 (16:31 -0500)
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/templates/opac/parts/base.tt2
Open-ILS/src/templates/opac/parts/stripe.tt2 [new file with mode: 0644]

index 2cfc7f8..964389c 100644 (file)
@@ -3855,6 +3855,33 @@ INSERT into config.org_unit_setting_type
         'coust', 'description'),
     'bool', null)
 
+    ( '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.privatekey', 'credit',
+    oils_i18n_gettext('credit.processor.stripe.privatekey',
+        'Stripe secret key',
+        'coust', 'label'),
+    oils_i18n_gettext('credit.processor.stripe.privatekey',
+        'Stripe secret key',
+        'coust', 'description'),
+    'string', null)
+
 ,( 'format.date', 'gui',
     oils_i18n_gettext('format.date',
         'Format Dates with this pattern.',
index ed82a3b..e596af0 100644 (file)
         </style>
         [% END %]
         [% INCLUDE 'opac/parts/goog_analytics.tt2' %]
-        [% IF myopac_main_page == "payment_form" AND ctx.get_org_setting(ctx.user.home_ou.id, 'opac.processor.stripe.enabled')%]
-        <script type="text/javascript" src="https://js.stripe.com/v2/"></script> <!-- use an ou setting for this url? -->
-        <script type="text/javascript">
-        // This script is only displayed when logged in, so ctx.user.home_ou is always available
-        Stripe.setPublishableKey('[% ctx.get_org_setting(ctx.user.home_ou.id, 'credit.processor.stripe.pubkey') %]');
+        [% INCLUDE 'opac/parts/stripe.tt2' %]
 
-        function stripe_onsubmit() {
-            var form = document.getElementById("stripe_form");
-            var button = document.getElementById("payment_submit");
-
-            button.disabled = true;
-
-            Stripe.card.createToken(form, stripe_callback);
-
-            return false;
-        }
-
-        function stripe_callback(status, response) {
-            var form = document.getElementById("payment_form");
-            var button = document.getElementById("payment_submit");
-            var stripe_token = document.getElementById("stripe_token");
-
-            if(response.error) {
-                alert(response.error.message);
-                button.disabled = false;
-                return;
-            }
-
-            stripe_token.value = response.id; // response.id is the token id, though there are more fields available if needed.
-            form.setAttribute("onsubmit","");
-            form.submit();
-        }
-        </script>
-        [% END %]
-
-        </head>
+    </head>
     <body[% IF want_dojo; ' class="tundra"'; END %]>
         <h1 class="sr-only">[% l('Catalog') %]</h1>
         [%#Each content page needs (at minimum) an <h2> describing the content%]
diff --git a/Open-ILS/src/templates/opac/parts/stripe.tt2 b/Open-ILS/src/templates/opac/parts/stripe.tt2
new file mode 100644 (file)
index 0000000..e857fff
--- /dev/null
@@ -0,0 +1,36 @@
+[%- 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')%]
+
+        <script type="text/javascript" src="https://js.stripe.com/v2/"></script> <!-- use an ou setting for this url? -->
+        <script type="text/javascript">
+        // This script is only displayed when logged in, so ctx.user.home_ou is always available
+        Stripe.setPublishableKey('[% ctx.get_org_setting(ctx.user.home_ou.id, 'credit.processor.stripe.pubkey') %]');
+
+        function stripe_onsubmit() {
+            var form = document.getElementById("stripe_form");
+            var button = document.getElementById("payment_submit");
+
+            button.disabled = true;
+
+            Stripe.card.createToken(form, stripe_callback);
+
+            return false;
+        }
+
+        function stripe_callback(status, response) {
+            var form = document.getElementById("payment_form");
+            var button = document.getElementById("payment_submit");
+            var stripe_token = document.getElementById("stripe_token");
+
+            if(response.error) {
+                alert(response.error.message);
+                button.disabled = false;
+                return;
+            }
+
+            stripe_token.value = response.id; // response.id is the token id, though there are more fields available if needed.
+            form.setAttribute("onsubmit","");
+            form.submit();
+        }
+        </script>
+[%- END %]