Update for Square payment
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 10 Jul 2019 13:04:53 +0000 (09:04 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 10 Jul 2019 13:04:53 +0000 (09:04 -0400)
Build data to send to square payment

js/sq-payment-form.js
views/common/billing/paymentForm.html
views/common/billing/squarePaymentForm.html
views/front/billing/paymentForm.html

index 83d3a34..58091e0 100644 (file)
@@ -106,38 +106,50 @@ var paymentForm = new SqPaymentForm({
          */
         createPaymentRequest: function () {
 
+            var lname  = $('#billing_lname').val();
+            var fname  = $('#billing_fname').val();
+            var addr1  = $('#billing_addr1').val();
+            var city   = $('#billing_city').val();
+            var state  = $('#billing_state').val();
+            var zip    = $('#billing_zip').val();
+            var email  = $('#billing_email').val();
+            var amount = $('#total_amount').val();
+
+
             var paymentRequestJson = {
                 requestShippingAddress: false,
                 requestBillingInfo: true,
                 shippingContact: {
-                    familyName: "CUSTOMER LAST NAME",
-                    givenName: "CUSTOMER FIRST NAME",
-                    email: "mycustomer@example.com",
+                    familyName: lname,
+                    givenName: fname,
+                    email: email,
                     country: "USA",
-                    region: "CA",
-                    city: "San Francisco",
+                    region: state,
+                    city: city,
                     addressLines: [
-                        "1455 Market St #600"
+                        addr1
                     ],
-                    postalCode: "94103",
-                    phone:"14255551212"
+                    postalCode: zip,
+                    phone:""
                 },
                 currencyCode: "USD",
                 countryCode: "US",
                 total: {
-                    label: "MERCHANT NAME",
-                    amount: "1.00",
+                    label: window.merchantName,
+                    amount: amount,
                     pending: false
                 },
                 lineItems: [
                     {
                         label: "Subtotal",
-                        amount: "1.00",
+                        amount: amount,
                         pending: false
                     }
                 ]
             };
 
+            console.log(paymentRequestJson);
+
             return paymentRequestJson;
         },
 
index 93f5ea5..a330b08 100644 (file)
@@ -16,7 +16,7 @@
                 First Name
             </div>
             <div class="glm-billing-input">
-                <input type="text" name="billing_fname" value="{$account.fieldData.billing_fname}" required />
+                <input type="text" id="billing_fname" name="billing_fname" value="{$account.fieldData.billing_fname}" required />
             </div>
         </div>
         <div class="glm-billing-field glm-billing-right-half">
@@ -24,7 +24,7 @@
                 Last Name
             </div>
             <div class="glm-billing-input">
-                <input type="text" name="billing_lname" value="{$account.fieldData.billing_lname}" required />
+                <input type="text" id="billing_lname" name="billing_lname" value="{$account.fieldData.billing_lname}" required />
             </div>
         </div>
     {/if}
@@ -33,7 +33,7 @@
             Address
         </div>
         <div class="glm-billing-input">
-            <input type="text" name="billing_addr1" value="{$account.fieldData.billing_addr1}" required />
+            <input type="text" id="billing_addr1" name="billing_addr1" value="{$account.fieldData.billing_addr1}" required />
         </div>
     </div>
     <div class="glm-billing-field glm-billing-left-half">
@@ -41,7 +41,7 @@
             City
         </div>
         <div class="glm-billing-input">
-            <input type="text" name="billing_city" value="{$account.fieldData.billing_city}" required />
+            <input type="text" id="billing_city" name="billing_city" value="{$account.fieldData.billing_city}" required />
         </div>
     </div>
     <div class="glm-billing-field glm-billing-right-half">
@@ -49,7 +49,7 @@
             State / Province
         </div>
         <div class="glm-billing-input">
-            <select name="billing_state" required>
+            <select id="billing_state" name="billing_state" required>
                 <option value=""></option>
                 {foreach $account.fieldData.billing_state.list as $s}
                     <option value="{$s.value}"{if $account.fieldData.billing_state.value == $s.value} selected="selected"{/if}>
@@ -64,7 +64,7 @@
             Zip
         </div>
         <div class="glm-billing-input">
-            <input type="text" name="billing_zip" value="{$account.fieldData.billing_zip}" required />
+            <input type="text" id="billing_zip" name="billing_zip" value="{$account.fieldData.billing_zip}" required />
         </div>
     </div>
     <div class="glm-billing-field">
@@ -72,7 +72,7 @@
             Email Address
         </div>
         <div class="glm-billing-input">
-            <input type="text" name="email" value="{$account.fieldData.email}" required />
+            <input type="text" id="billing_email" name="email" value="{$account.fieldData.email}" required />
         </div>
     </div>
 
index 05b3467..f4ac88b 100644 (file)
@@ -3,7 +3,8 @@
 <script src="https://js.squareup.com/v2/paymentform"></script>
 <script>
 window.applicationId = '{if $billing_settings.square_use_prod}{$billing_settings.square_prod_app_id}{else}{$billing_settings.square_sandbox_app_id}{/if}';
-window.locationId = '{if $billing_settings.square_use_prod}{$billing_settings.square_prod_location_id}{else}{$billing_settings.square_sandbox_location_id}{/if}';
+window.locationId    = '{if $billing_settings.square_use_prod}{$billing_settings.square_prod_location_id}{else}{$billing_settings.square_sandbox_location_id}{/if}';
+window.merchantName  = '{$billing_settings.company_name}';
 </script>
 
 {* link to the local SqPaymentForm initialization *}
index 6c04421..2697026 100644 (file)
@@ -17,7 +17,7 @@
         <input type="hidden" name="option" value="paymentProcess" />
         <input type="hidden" id="member_id" name="member" value="{$memberId}" />
         <input type="hidden" id="account_id" name="account_id" value="{$accountId}" />
-        <input type="hidden" id="total_renew_amount" name="total_renew_amount" value="" />
+        <input type="hidden" id="total_amount" name="total_renew_amount" value="" />
 
         <input type="hidden" id="member_renewing" name="member_renewing" data-amount="" value="" />
 
@@ -172,7 +172,7 @@ jQuery(document).ready(function($){
         }
 
         $('#renew_total').html( formatter.format( member_renewing_amount ) );
-        $('#total_renew_amount').val( member_renewing_amount );
+        $('#total_amount').val( member_renewing_amount );
 
     }