Updating front end renewal form.
case 'renewMembership':
$error = false;
$view = 'renewMembership';
- // $messages[] = '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
$member_invoice_id = $BillingSupport->getMembersInvoiceTypeByRefDest( $this->memberID );
if ( $member_invoice_id ) {
switch ( $payment_option ) {
case 'pay_by_credit_card':
// Do the Payment Processing.
- $errors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] );
- // echo '<pre>$errors: ' . print_r( $errors, true ) . '</pre>';
- if ( $errors ) {
- // $messages[] = '<pre>$errors: ' . print_r( $errors, true ) . '</pre>';
- if ( count( $errors ) > 0 ) {
+ $processErrors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] );
+ // echo '<pre>$processErrors: ' . print_r( $processErrors, true ) . '</pre>';
+ if ( $processErrors ) {
+ // $messages[] = '<pre>$processErrors: ' . print_r( $processErrors, true ) . '</pre>';
+ if ( count( $processErrors ) > 0 ) {
+ $error = true;
$BillingSupport->removeInvoiceById( $invoice_id );
- foreach ( $errors as $error ) {
+ foreach ( $processErrors as $error ) {
$messages[] = '<span style="color: red;">'.$error.'</span>';
}
}
break;
}
- // Now need to show the invoice.
- $view = 'viewInvoice';
+ // If there's no error reported then show the invoice
+ if ( !$error ) {
+ // Now need to show the invoice.
+ $view = 'viewInvoice';
- // Get the invoice.
- $invoiceHtml = $BillingSupport->viewInvoice( $invoice_id );
+ // Get the invoice.
+ $invoiceHtml = $BillingSupport->viewInvoice( $invoice_id );
+ }
}
case 'renewMembership':
$error = false;
$view = 'renewMembership';
- // $messages[] = '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
$member_invoice_id = $BillingSupport->getMembersInvoiceTypeByRefDest( $this->memberID );
if ( $member_invoice_id ) {
'due_date' => date( 'Y-m-d' ),
'member_invoice' => $member_invoice,
'employee_data' => $employees,
- 'employees' => $_REQUEST['employees']
+ 'employees' => isset( $_REQUEST['employees'] ) ? $_REQUEST['employees'] : array(),
);
if ( !$invoice_data ) {
$error = true;
// If there's any errors then re-show the form.
if ( $error ) {
- // TODO: Here we'll need to remove the invoice created if any.
+ // Remove the invoice created.
+ if ( $invoice_id ) {
+ $BillingSupport->removeInvoiceById( $invoice_id );
+ }
+
$view = 'renew';
// Get list of payable invoice_types
// Need to see if there's an account for this member.
$account = $Accounts->editEntry( $accountID );
} else {
- // Do the Payment Processing.
- $errors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] );
- // echo '<pre>$errors: ' . print_r( $errors, true ) . '</pre>';
+ // Look at the payment option given
+ $payment_option = filter_var( $_REQUEST['payment_option'], FILTER_SANITIZE_STRING );
+
+ switch ( $payment_option ) {
+ case 'pay_by_credit_card':
+ // Do the Payment Processing.
+ $processErrors = $BillingSupport->processMemberRenewal( $accountID, $invoice_id, $invoice_data['amount'], $invoice_data['employees'] );
+ // echo '<pre>$processErrors: ' . print_r( $processErrors, true ) . '</pre>';
+ if ( $processErrors ) {
+ // $messages[] = '<pre>$processErrors: ' . print_r( $processErrors, true ) . '</pre>';
+ if ( count( $processErrors ) > 0 ) {
+ $error = true;
+ $BillingSupport->removeInvoiceById( $invoice_id );
+ foreach ( $processErrors as $error ) {
+ $messages[] = '<span style="color: red;">'.$error.'</span>';
+ }
+ }
+ $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->getInvoiceTypeById( $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.
+ $account = $Accounts->editEntry( $accountID );
+ }
+ break;
+ case 'pay_by_check':
+ break;
+ }
+
+ // If there's no error reported then show the invoice
+ if ( !$error ) {
+ // Now need to show the invoice.
+ $view = 'viewInvoice';
+
+ // Get the invoice.
+ $invoiceHtml = $BillingSupport->viewInvoice( $invoice_id );
+ }
}
{if $employees}
<div class="glm-billing-field">
<div class="glm-billing-label">
- Employees to Renew
+ <strong>Associated Members/Employees</strong>
</div>
<div class="glm-billing-input">
{foreach $employees as $employee}
</div>
</div>
- <div class="glm-billing-field glm-billing-left-half">
- <div class="glm-billing-label glm-required">
- First Name
- </div>
- <div class="glm-billing-input">
- <input type="text" name="billing_fname" value="{$account.fieldData.billing_fname}" required />
- </div>
- </div>
- <div class="glm-billing-field glm-billing-right-half">
- <div class="glm-billing-label glm-required">
- Last Name
- </div>
- <div class="glm-billing-input">
- <input type="text" name="billing_lname" value="{$account.fieldData.billing_lname}" required />
- </div>
- </div>
- <div class="glm-billing-field">
- <div class="glm-billing-label glm-required">
- Address
- </div>
- <div class="glm-billing-input">
- <input type="text" name="billing_addr1" value="{$account.fieldData.billing_addr1}" required />
- </div>
- </div>
- <div class="glm-billing-field glm-billing-left-half">
- <div class="glm-billing-label glm-required">
- City
- </div>
- <div class="glm-billing-input">
- <input type="text" name="billing_city" value="{$account.fieldData.billing_city}" required />
- </div>
- </div>
- <div class="glm-billing-field glm-billing-right-half">
- <div class="glm-billing-label glm-required">
- State / Province
- </div>
- <div class="glm-billing-input">
- <select 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}>
- {$s.name}
- </option>
- {/foreach}
- </select>
- </div>
- </div>
- <div class="glm-billing-field">
- <div class="glm-billing-label glm-required">
- Zip
- </div>
- <div class="glm-billing-input">
- <input type="text" name="billing_zip" value="{$account.fieldData.billing_zip}" required />
- </div>
- </div>
-
- <div class="glm-billing-field">
- <div class="glm-billing-label glm-required">
- Name on Card
- </div>
- <div class="glm-billing-input">
- <input
- type="text"
- name="cc_name"
- required
- {if isset($smarty.request.cc_name) && $smarty.request.cc_name}value="{$smarty.request.cc_name}"{/if} />
- </div>
- </div>
- <div class="glm-billing-field glm-billing-left-half">
- <div class="glm-billing-label glm-required">
- Card Type
- </div>
- <div class="glm-billing-input">
- <select name="cc_type" required>
- <option value=""></option>
- {foreach $management.cc_accepts.names as $cardId => $cardName}
- <option value="{$cardId}"
- {if isset($smarty.request.cc_type) && $smarty.request.cc_type == $cardId} selected{/if}>{$cardName}</option>
- {/foreach}
- </select>
- </div>
- </div>
- <div class="glm-billing-field glm-billing-right-half">
- <div class="glm-billing-label glm-required">
- Card Number
- </div>
- <div class="glm-billing-input">
- <input
- type="text"
- placeholder="Numbers Only"
- name="cc_numb"
- required
- pattern="\d*"
- {if isset($smarty.request.cc_numb) && $smarty.request.cc_numb}value="{$smarty.request.cc_numb}"{/if} />
- </div>
- </div>
- <div class="glm-billing-field glm-billing-left-half">
- <div class="glm-billing-label glm-required">
- Card Expiration
- </div>
- <div class="glm-billing-input">
- <input
- type="text"
- placeholder="MM/YY"
- name="cc_exp"
- required
- pattern="{literal}\d{2}/\d{2}{/literal}"
- {if isset($smarty.request.cc_exp) && $smarty.request.cc_exp}value="{$smarty.request.cc_exp}"{/if} />
- </div>
- </div>
- <div class="glm-billing-field glm-billing-right-half">
- <div class="glm-billing-label glm-required">
- C V V
- </div>
- <div class="glm-billing-input">
- <input
- type="text"
- placeholder="3 or 4 digit security code on back of card"
- name="cc_cvv"
- required
- pattern="{literal}\d{3,4}{/literal}"
- {if isset($smarty.request.cc_cvv) && $smarty.request.cc_cvv}value="{$smarty.request.cc_cvv}"{/if} />
- </div>
- </div>
+{* Include the Payment Form template *}
+{include file='common/billing/paymentForm.html'}
<input class="button button-primary" type="submit" value="Renew">