From 0cf348414d4b00cb5541af4f853cc88b582beb70 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 27 Mar 2018 16:41:31 -0400 Subject: [PATCH] WIP renewal payment processing. Create the invoice, Process Payment, mark invoice paid and add payment. --- classes/billingSupport.php | 199 +++++++++++++++++++++-- css/admin.css | 20 +++ models/admin/member/billing.php | 271 ++++++++++---------------------- views/admin/billing/renew.html | 201 ++++++++++++++++++++--- 4 files changed, 465 insertions(+), 226 deletions(-) diff --git a/classes/billingSupport.php b/classes/billingSupport.php index 353aab3..dbe3dc8 100644 --- a/classes/billingSupport.php +++ b/classes/billingSupport.php @@ -769,6 +769,19 @@ class GlmBillingSupport ); } + public function getAllPayableInvoiceTypes() + { + return $this->wpdb->get_results( + "SELECT * + FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "invoice_types + WHERE amount > 0 + AND recurring + AND recurrence = 20 + ORDER BY name", + ARRAY_A + ); + } + public function getListOfAccountEmployees( $member_id ) { $accounts = array(); @@ -782,7 +795,7 @@ class GlmBillingSupport if ( $invoice_type_id ) { $invoice = $this->getInvoicTypeById( $invoice_type_id ); } - $accounts[] = array( + $accounts[$billing_account['id']] = array( 'id' => $billing_account['id'], 'ref_dest' => $billing_account['ref_dest'], 'ref_name' => $billing_account['ref_name'], @@ -797,6 +810,7 @@ class GlmBillingSupport { // Make sure the required parts of $invoice_data exists. if ( !isset( $invoice_data['account_id'] ) + || !isset( $invoice_data['renew_type_id'] ) || !isset( $invoice_data['amount'] ) || !isset( $invoice_data['due_date'] ) || !isset( $invoice_data['member_invoice'] ) @@ -834,25 +848,41 @@ class GlmBillingSupport ); $invoice_id = $this->wpdb->insert_id; // Add the line item for from the member invoice + // First get this invoice_type + $new_member_invoice_type = $this->getInvoicTypeById( $renew_type_id ); $this->createLineItemForInvoice( array( 'invoice_id' => $invoice_id, - 'line_item_type' => $member_invoice['id'], - 'name' => $member_invoice['name'], - 'amount' => $member_invoice['amount'], + 'line_item_type' => $new_member_invoice_type['id'], + 'name' => $new_member_invoice_type['name'], + 'amount' => $new_member_invoice_type['amount'], 'due_date' => $due_date, - 'recurring' => $recurring, - 'recurrence' => $recurrence, + 'recurring' => $new_member_invoice_type['recurring'], + 'recurrence' => $new_member_invoice_type['recurrence'], ) ); + // echo '
$invoice_id: ' . print_r( $invoice_id, true ) . '
'; if ( $invoice_id ) { // Add line items for each employee. - foreach ( $employees as $ref_dest ) { - // Get the account from the ref_dest. - $line_account_id = $this->getAccountByRefDest( $ref_dest ); - + foreach ( $employees as $account_id ) { + if ( $employee_data[$account_id]['invoice'] ) { + $this->createLineItemForInvoice( + array( + 'invoice_id' => $invoice_id, + 'line_item_type' => $employee_data[(int)$account_id]['invoice']['id'], + 'name' => $employee_data[(int)$account_id]['invoice']['name'], + 'amount' => $employee_data[(int)$account_id]['invoice']['amount'], + 'due_date' => $due_date, + 'recurring' => $employee_data[(int)$account_id]['invoice']['recurring'], + 'recurrence' => $employee_data[(int)$account_id]['invoice']['recurrence'], + ) + ); + } } } + // Calling the support class to save the invoice to transaction table. + $this->recordInvoice( $invoice_id, $account_id, $amount ); + return $invoice_id; } public function createLineItemForInvoice( $data ) @@ -895,11 +925,158 @@ class GlmBillingSupport '%s', // created '%s', // first_due_date '%s', // next_due_date - '%d', // recurring + '%s', // recurring '%d', // recurrence ) ); } + public function processMemberRenewal( $account_id, $invoice_id, $amount ) + { + $errors = array(); + // Get the selected credit card processor type + $ccProcessor = $this->config['billing_settings']['proc_methods']; + + // Setup the required account information for the selected payment processor + switch ($ccProcessor) { + + case $this->config['proc_method_numb']['Authorize.net']: + + // Get account data + $account = array( + 'login' => $this->config['billing_settings']['authorize_net_login'], + 'key' => $this->config['billing_settings']['authorize_net_key'], + 'test' => $this->config['billing_settings']['authorize_net_test'], + 'conf' => $this->config['billing_settings']['authorize_net_conf'], + 'email' => $this->config['billing_settings']['authorize_net_merchant_email'] + ); + + break; + + case $this->config['proc_method_numb']['MerchantSolutions']: + + // Get account data + $account = array( + 'acctid' => $this->config['billing_settings']['merchant_solutions_acctid'], + 'merchantpin' => $this->config['billing_settings']['merchant_solutions_merchantpin'], + 'test' => $this->config['billing_settings']['merchant_solutions_test'], + 'conf' => $this->config['billing_settings']['merchant_solutions_conf'], + 'email' => $this->config['billing_settings']['merchant_solutions_merchant_email'] + ); + + break; + + // These don't require account data + case $this->config['proc_method_numb']['Merchant']: + case $this->config['proc_method_numb']['TestAlwaysGood']: + case $this->config['proc_method_numb']['TestByCardNumber']: + default: + $account = array(); + break; + + } + + // Get the credit card input + $cardData = filter_var_array( + $_REQUEST, + array( + 'cc_type' => FILTER_SANITIZE_STRING, + 'cc_name' => FILTER_SANITIZE_STRING, + 'cc_numb' => FILTER_SANITIZE_NUMBER_INT, + 'cc_exp' => FILTER_SANITIZE_STRING, + 'cc_cvv' => FILTER_SANITIZE_NUMBER_INT, + ) + ); + + $paymentData = filter_var_array( + $_REQUEST, + array( + 'billing_fname' => FILTER_SANITIZE_STRING, + 'billing_lname' => FILTER_SANITIZE_STRING, + 'billing_addr1' => FILTER_SANITIZE_STRING, + 'billing_addr2' => FILTER_SANITIZE_STRING, + 'billing_city' => FILTER_SANITIZE_STRING, + 'billing_state' => FILTER_SANITIZE_STRING, + 'billing_zip' => FILTER_SANITIZE_STRING, + 'billing_phone' => FILTER_SANITIZE_STRING, + 'email' => FILTER_SANITIZE_STRING, + ) + ); + + // Add billing information to billing array + $billing = array( + 'fname' => $paymentData['billing_fname'], + 'lname' => $paymentData['billing_lname'], + 'addr1' => $paymentData['billing_addr1'], + 'addr2' => $paymentData['billing_addr2'], + 'city' => $paymentData['billing_city'], + 'state' => $paymentData['billing_state'], + 'zip' => $paymentData['billing_zip'], + 'phone' => $paymentData['billing_phone'], + 'email' => $paymentData['email'] + ); + $cardMatch = $this->config['credit_card_match']; + + // Check all credit card input + if ( $cardData['cc_type'] && $cardData['cc_type'] > 0 + && $cardData['cc_name'] && $cardData['cc_name'] != '' + && $cardData['cc_numb'] && $cardData['cc_numb'] > 0 + && $cardData['cc_exp'] && $cardData['cc_exp'] != '' + && $cardData['cc_cvv'] && $cardData['cc_cvv'] > 0 + ) { + if (!isset($this->config['credit_card_match'][$cardData['cc_type']]) || + !preg_match($this->config['credit_card_match'][$cardData['cc_type']], $cardData['cc_numb']) + ) { + $errors[] = 'The credit card number you entered does not match the selected type of credit card.'; + } + + } else { + $errors[] = 'You did not supply all required credit card information correctly.'; + } + + if (count($errors) == 0) { + + // Determine the directory of the payment processor to load and instantiate it. + if ($ccProcessor && isset($this->config['proc_dir'][$ccProcessor])) { + require_once GLM_MEMBERS_BILLING_PLUGIN_LIB_PATH.'/paymentProcessors/'.$this->config['proc_dir'][$ccProcessor].'/paymentGateway.php'; + $CcProcessor = new PaymentGateway($account); + } + + $payment = array( + 'name' => $this->config['settings']['company_name'], // Company Name + 'charge' => $amount, // Total charges + 'cctype' => $cardData['cc_type'], // Card Type + 'ccname' => $cardData['cc_name'], // Name on Card + 'ccnumb' => $cardData['cc_numb'], // Card Number + 'ccexp' => $cardData['cc_exp'], // Expiration Date + 'cccode' => $cardData['cc_cvv'], // CCV - security code + 'invoice' => 'billing-'.$paymentData['invoice_id'] // Invoice # is "reg-" plus cart ID + ); + + // Now try to run the card processor + $ccResult = $CcProcessor->processPayment($payment, $billing); + + // If successful submission - say we're complete + if (is_array($ccResult) && isset($ccResult['status']) && $ccResult['status'] == 1) { + // Need to record the payment + + // Set transaction_time to current time. + $_REQUEST['transaction_time'] = date('Y-m-d H:i:s'); + // Create new payment. + $payment_id = $this->createPayment( $account_id, $amount ); + // Record the payment. + $this->recordPayment( $payment_id, $account_id, $amount, $invoice_id ); + + $errors[] = $ccResult['statusText']; + $errors[] = $ccResult['description']; + + } + + } + + return $errors; + + } + } diff --git a/css/admin.css b/css/admin.css index a39ce51..192bd16 100644 --- a/css/admin.css +++ b/css/admin.css @@ -23,3 +23,23 @@ border-radius: 5px; padding: 20px; } + +/* glm-billing-form */ +.glm-billing-form { + max-width: 750px; +} +.glm-billing-field { + width: 100%; +} +.glm-billing-label { + font-size: 1rem; + padding: 7px 0 3px; +} +.glm-billing-input { + font-size: 1rem; + padding: 3px 0; +} +.glm-billing-input label { + width: 100%; + display: block; +} diff --git a/models/admin/member/billing.php b/models/admin/member/billing.php index 4e35163..afa64b4 100644 --- a/models/admin/member/billing.php +++ b/models/admin/member/billing.php @@ -122,6 +122,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling $hasBillingAccount = false; $employees = false; $member_invoice = false; + $payable_types = false; // For lockedToMember. $lockedToMember = false; @@ -180,44 +181,112 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling case 'renew': $view = 'renew'; + // Get list of payable invoice_types + $payable_types = $BillingSupport->getAllPayableInvoiceTypes(); + // echo '
$payable_types: ' . print_r( $payable_types, true ) . '
'; + $member_invoice_id = $BillingSupport->getMembersInvoiceTypeByRefDest( $this->memberID ); - // echo '
$member_invoice_id: ' . print_r( $member_invoice_id, true ) . '
'; if ( $member_invoice_id ) { $member_invoice = $BillingSupport->getInvoicTypeById( $member_invoice_id ); } - // echo '
$member_invoice: ' . print_r( $member_invoice, true ) . '
'; - $employees = $BillingSupport->getListOfAccountEmployees( $this->memberID ); - // echo '
$employees: ' . print_r( $employees, true ) . '
'; // Get a list of this accounts employees. If they have any. + $employees = $BillingSupport->getListOfAccountEmployees( $this->memberID ); + + // Load DataClass for Management. + require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataManagement.php'; + $Management = new GlmDataBillingManagement( $this->wpdb, $this->config ); + $management = $Management->getEntry( 1 ); + + // Need to see if there's an account for this member. + require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php'; + $Accounts = new GlmDataAccounts( $this->wpdb, $this->config ); + $accountID = $this->wpdb->get_var( + $this->wpdb->prepare( + "SELECT id + FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts + WHERE ref_dest = %d", + $this->memberID + ) + ); + $account = $Accounts->editEntry( $accountID ); break; case 'renewMembership': - $view = 'renewMembership'; + $error = false; + $view = 'renewMembership'; $messages[] = '
$_REQUEST: ' . print_r( $_REQUEST, true ) . '
'; $member_invoice_id = $BillingSupport->getMembersInvoiceTypeByRefDest( $this->memberID ); if ( $member_invoice_id ) { $member_invoice = $BillingSupport->getInvoicTypeById( $member_invoice_id ); + } else { + $error = true; } - $messages[] = '
$member_invoice: ' . print_r( $member_invoice, true ) . '
'; $employees = $BillingSupport->getListOfAccountEmployees( $this->memberID ); - $messages[] = '
$employees: ' . print_r( $employees, true ) . '
'; $invoice_data = array( 'account_id' => filter_var( $_REQUEST['account_id'], FILTER_VALIDATE_INT ), - 'amount' => filter_var( $_REQUEST['total_renew_amount'], FILTER_VALIDATE_STRING ), + 'renew_type_id' => filter_var( $_REQUEST['member_renewing'], FILTER_VALIDATE_INT ), + 'amount' => $_REQUEST['total_renew_amount'], 'due_date' => date( 'Y-m-d' ), 'member_invoice' => $member_invoice, 'employee_data' => $employees, 'employees' => $_REQUEST['employees'] ); - $messages[] = '
$invoice_data: ' . print_r( $invoice_data, true ) . '
'; + if ( !$invoice_data ) { + $error = true; + } // Create the invoice for this member. + $invoice_id = $BillingSupport->createMemberInvoiceWithEmployees( $invoice_data ); + if ( !$invoice_id ) { + $error = true; + } + + // Now that the invoice is created. Do payment Processing. + + // If there's any errors then re-show the form. + if ( $error ) { + // TODO: Here we'll need to remove the invoice created if any. + $view = 'renew'; + + // Get list of payable invoice_types + $payable_types = $BillingSupport->getAllPayableInvoiceTypes(); + + $member_invoice_id = $BillingSupport->getMembersInvoiceTypeByRefDest( $this->memberID ); + if ( $member_invoice_id ) { + $member_invoice = $BillingSupport->getInvoicTypeById( $member_invoice_id ); + } + + // Get a list of this accounts employees. If they have any. + $employees = $BillingSupport->getListOfAccountEmployees( $this->memberID ); + + // Load DataClass for Management. + require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataManagement.php'; + $Management = new GlmDataBillingManagement( $this->wpdb, $this->config ); + $management = $Management->getEntry( 1 ); + + // Need to see if there's an account for this member. + require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php'; + $Accounts = new GlmDataAccounts( $this->wpdb, $this->config ); + $accountID = $this->wpdb->get_var( + $this->wpdb->prepare( + "SELECT id + FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts + WHERE ref_dest = %d", + $this->memberID + ) + ); + $account = $Accounts->editEntry( $accountID ); + } else { + // Do the Payment Processing. + $errors = $BillingSupport->processMemberRenewal( $invoice_data['account_id'], $invoice_id, $invoice_data['amount'] ); + echo '
$errors: ' . print_r( $errors, true ) . '
'; + } break; @@ -288,189 +357,12 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling $view = 'paymentProcess'; - // Get the selected credit card processor type - $ccProcessor = $this->config['billing_settings']['proc_methods']; - - // Setup the required account information for the selected payment processor - switch ($ccProcessor) { - - case $this->config['proc_method_numb']['Authorize.net']: - - // Get account data - $account = array( - 'login' => $this->config['billing_settings']['authorize_net_login'], - 'key' => $this->config['billing_settings']['authorize_net_key'], - 'test' => $this->config['billing_settings']['authorize_net_test'], - 'conf' => $this->config['billing_settings']['authorize_net_conf'], - 'email' => $this->config['billing_settings']['authorize_net_merchant_email'] - ); + // MOVING TO billing support class + // $payment_status = $BillingSupport->processMemberRenewal(); - break; + // if error - case $this->config['proc_method_numb']['MerchantSolutions']: - // Get account data - $account = array( - 'acctid' => $this->config['billing_settings']['merchant_solutions_acctid'], - 'merchantpin' => $this->config['billing_settings']['merchant_solutions_merchantpin'], - 'test' => $this->config['billing_settings']['merchant_solutions_test'], - 'conf' => $this->config['billing_settings']['merchant_solutions_conf'], - 'email' => $this->config['billing_settings']['merchant_solutions_merchant_email'] - ); - - break; - - // These don't require account data - case $this->config['proc_method_numb']['Merchant']: - case $this->config['proc_method_numb']['TestAlwaysGood']: - case $this->config['proc_method_numb']['TestByCardNumber']: - default: - $account = array(); - break; - - } - - // Get the credit card input - $cardData = filter_var_array( - $_REQUEST, - array( - 'cc_type' => FILTER_SANITIZE_STRING, - 'cc_name' => FILTER_SANITIZE_STRING, - 'cc_numb' => FILTER_SANITIZE_NUMBER_INT, - 'cc_exp' => FILTER_SANITIZE_STRING, - 'cc_cvv' => FILTER_SANITIZE_NUMBER_INT, - ) - ); - - $paymentData = filter_var_array( - $_REQUEST, - array( - 'account_id' => FILTER_SANITIZE_NUMBER_INT, - 'invoice_id' => FILTER_SANITIZE_NUMBER_INT, - 'member' => FILTER_SANITIZE_NUMBER_INT, - 'amount' => array( - 'filter' => FILTER_SANITIZE_NUMBER_FLOAT, - 'flags' => FILTER_FLAG_ALLOW_FRACTION, - ), - 'billing_fname' => FILTER_SANITIZE_STRING, - 'billing_lname' => FILTER_SANITIZE_STRING, - 'billing_addr1' => FILTER_SANITIZE_STRING, - 'billing_addr2' => FILTER_SANITIZE_STRING, - 'billing_city' => FILTER_SANITIZE_STRING, - 'billing_state' => FILTER_SANITIZE_STRING, - 'billing_zip' => FILTER_SANITIZE_STRING, - 'billing_phone' => FILTER_SANITIZE_STRING, - 'email' => FILTER_SANITIZE_STRING, - ) - ); - - // Add billing information to billing array - $billing = array( - 'fname' => $paymentData['billing_fname'], - 'lname' => $paymentData['billing_lname'], - 'addr1' => $paymentData['billing_addr1'], - 'addr2' => $paymentData['billing_addr2'], - 'city' => $paymentData['billing_city'], - 'state' => $paymentData['billing_state'], - 'zip' => $paymentData['billing_zip'], - 'phone' => $paymentData['billing_phone'], - 'email' => $paymentData['email'] - ); - $cardMatch = $this->config['credit_card_match']; - - // Check all credit card input - if ( $cardData['cc_type'] && $cardData['cc_type'] > 0 - && $cardData['cc_name'] && $cardData['cc_name'] != '' - && $cardData['cc_numb'] && $cardData['cc_numb'] > 0 - && $cardData['cc_exp'] && $cardData['cc_exp'] != '' - && $cardData['cc_cvv'] && $cardData['cc_cvv'] > 0 - ) { - if (!isset($this->config['credit_card_match'][$cardData['cc_type']]) || - !preg_match($this->config['credit_card_match'][$cardData['cc_type']], $cardData['cc_numb']) - ) { - $messages[] = 'The credit card number you entered does not match the selected type of credit card.'; - } - - } else { - $messages[] = 'You did not supply all required credit card information correctly.'; - } - - if (count($messages) == 0) { - $paymentSuccess = true; - - // Determine the directory of the payment processor to load and instatiate it. - if ($ccProcessor && isset($this->config['proc_dir'][$ccProcessor])) { - require_once GLM_MEMBERS_BILLING_PLUGIN_LIB_PATH.'/paymentProcessors/'.$this->config['proc_dir'][$ccProcessor].'/paymentGateway.php'; - $CcProcessor = new PaymentGateway($account); - } - - $payment = array( - 'name' => $this->config['settings']['company_name'], // Company Name - 'charge' => $paymentData['amount'], // Total charges - 'cctype' => $cardData['cc_type'], // Card Type - 'ccname' => $cardData['cc_name'], // Name on Card - 'ccnumb' => $cardData['cc_numb'], // Card Number - 'ccexp' => $cardData['cc_exp'], // Expiration Date - 'cccode' => $cardData['cc_cvv'], // CCV - security code - 'invoice' => 'billing-'.$paymentData['invoice_id'] // Invoice # is "reg-" plus cart ID - ); - - // Now try to run the card processor - $ccResult = $CcProcessor->processPayment($payment, $billing); - - // If successful submission - say we're complete - if (is_array($ccResult) && isset($ccResult['status']) && $ccResult['status'] == 1) { - // Need to record the payment - - // Set transaction_time to current time. - $_REQUEST['transaction_time'] = date('Y-m-d H:i:s'); - // Create new payment. - $payment_id = $BillingSupport->createPayment( $paymentData['account_id'], $paymentData['amount'] ); - // Record the payment. - $BillingSupport->recordPayment( $payment_id, $paymentData['account_id'], $paymentData['amount'], $paymentData['invoice_id'] ); - - $messages[] = $ccResult['statusText']; - $messages[] = $ccResult['description']; - - } - - } else { - $paymentError = true; - // Load DataClass for accounts. - require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataAccounts.php'; - $Accounts = new GlmDataAccounts( $this->wpdb, $this->config ); - - // Load DataClass for Management. - require_once GLM_MEMBERS_BILLING_PLUGIN_CLASS_PATH . '/data/dataManagement.php'; - $Management = new GlmDataBillingManagement( $this->wpdb, $this->config ); - $management = $Management->getEntry( 1 ); - - // Need to see if there's an account for this member. - $accountID = $this->wpdb->get_var( - $this->wpdb->prepare( - "SELECT id - FROM " . GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . "accounts - WHERE ref_dest = %d", - $this->memberID - ) - ); - $account = $Accounts->editEntry( $accountID ); - - // Get unpaid invoices - $invoices = $BillingSupport->getUnPaidInvoicesByAccount( $account['fieldData']['id'] ); - if ( !empty( $invoices ) ) { - foreach ( $invoices as &$invoice ) { - $invoice['due_date'] = date( 'n/d/Y', strtotime( $invoice['due_date'] ) ); - } - } - - $cc_accepts = $this->config['billing_settings']['cc_accepts']; - - // Set the file name for the view file. - $view = 'makePayment'; - - // TODO: make sure the existing field data get setup in the form. - } break; @@ -558,6 +450,7 @@ class GlmMembersAdmin_member_billing // extends GlmDataBilling 'hasBillingAccount' => $hasBillingAccount, 'employees' => $employees, 'member_invoice' => $member_invoice, + 'payable_types' => $payable_types, ); // Return status, any suggested view, and any data to controller. diff --git a/views/admin/billing/renew.html b/views/admin/billing/renew.html index ab4f35c..c769e90 100644 --- a/views/admin/billing/renew.html +++ b/views/admin/billing/renew.html @@ -1,7 +1,8 @@ {include file='admin/member/header.html'} {include file='admin/billing/memberBillingSubHeader.html'} -
+

Membership Renewal

+
{if $paymentSuccess}Payment Completed{/if} {if $paymentError}Error With Payment{/if} @@ -11,9 +12,8 @@
{$message}
{/foreach} {/if} -

Renew membership

-
+ @@ -21,37 +21,181 @@ -

Employees:

{if $member_invoice} -
- +
+
+ Member Renewing +
+
+ +
{/if} - {foreach $employees as $employee} -
- + {if $employees} +
+
+ Employees to Renew +
+
+ {foreach $employees as $employee} + + {/foreach} +
- {/foreach} + {/if} + +
+
+ Total Due +
+
+
+
+
+
+ +
+
+ First Name +
+
+ +
+
+
+
+ Last Name +
+
+ +
+
+
+
+ Address +
+
+ +
+
+
+
+ City +
+
+ +
+
+
+
+ State / Province +
+
+ +
+
+
+
+ Zip +
+
+ +
+
-
+
+
+ Name on Card +
+
+ +
+
+
+
+ Card Type +
+
+ +
+
+
+
+ Card Number +
+
+ +
+
+
+
+ Card Expiration +
+
+ +
+
+
+
+ C V V +
+
+ +
- +
@@ -68,7 +212,7 @@ jQuery(document).ready(function($){ // Calculate the total for this page. // Get the member_renewing amount. - var member_renewing_amount = parseFloat( $('input[name=member_renewing]').data('amount') ); + var member_renewing_amount = parseFloat( $('input[name=member_renewing]:checked').data('amount') ); // Get each employee and add their amounts. $('input[name^=employees]').each(function(){ @@ -84,6 +228,11 @@ jQuery(document).ready(function($){ getPageTotal(); + // trigger total if changing Membership + $('input[name=member_renewing]').change(function(){ + getPageTotal(); + }); + // trigger total if changing employees $('input[name^=employees]').change(function(){ getPageTotal(); -- 2.17.1