case 'mark_paid':
$_REQUEST['transaction_time'] = date( 'Y-m-d H:i:s' );
- $invoices = $BillingSupport->getUnPaidInvoicesByAccount( $account['fieldData']['id'] );
+ $nvoices = $BillingSupport->getUnPaidInvoicesByAccount( $account['fieldData']['id'] );
// Mark this invoice as paid
// Create new payment.
$payment_id = $BillingSupport->createPayment( $accountID, $_REQUEST['total_renew_amount'], 'Marked Paid' );
$accountUpdated = true;
}
if ( $this->ajaxSide ) {
- trigger_error( 'Account Ajax Hit', E_USER_NOTICE );
+ // trigger_error( 'Account Ajax Hit', E_USER_NOTICE );
header( 'Content-type:application/json;charset=utf-8', true );
echo json_encode( $account, true );
exit;
break;
case 'createMemberPayment':
+ // trigger_error( print_r( $_REQUEST['invoices'], true), E_USER_NOTICE );
$view = 'paymentProcess';
$account_id = filter_var( $_REQUEST['account_id'], FILTER_VALIDATE_INT );
$amount = filter_var( $_REQUEST['amount'], FILTER_VALIDATE_FLOAT );
$payment_data = filter_var( $_REQUEST['payment_data'], FILTER_SANITIZE_STRING );
$invoices = filter_var( $_REQUEST['invoices'], FILTER_VALIDATE_INT, array( 'flags' => FILTER_REQUIRE_ARRAY ) );
+ // trigger_error( print_r(
+ // array(
+ // 'account_id' => $account_id,
+ // 'amount' => $amount,
+ // 'payment_method' => $payment_method,
+ // 'payment_data' => $payment_data,
+ // 'invoices' => $invoices,
+ // ), true ), E_USER_NOTICE );
if ( $account_id && $amount && $payment_method && !empty( $invoices ) ) {
// Create new payment.
$payment_id = $BillingSupport->createPayment( $account_id, $amount, $payment_method, $payment_data );
+ // trigger_error( "payment_id: $payment_id", E_USER_NOTICE );
if ( $payment_id ) {
+ // trigger_error( "before recordPayment", E_USER_NOTICE );
// Record the payment.
$BillingSupport->recordPayment( $payment_id, $account_id, $amount, $invoices, $this->config['transaction_numb']['Payment'] );
+ // trigger_error( "after recordPayment", E_USER_NOTICE );
}
} else {
$payment_id = false;
}
+ // trigger_error( print_r( $this->ajaxSide, true), E_USER_NOTICE );
if ( $this->ajaxSide ) {
+ $invoiceData = $invoices;
if ( !empty( $invoices ) ) {
$invoiceData = array_map( array( $BillingSupport, 'getInvoiceById' ), $invoices );
}
'payment_id' => $payment_id,
'invoices' => $invoiceData
);
+ // trigger_error( print_r( $return, true), E_USER_NOTICE );
header( 'Content-type:application/json;charset=utf-8', true );
echo json_encode( $return, true );
exit;
+ // rsp: <h1>Error thrown</h1><p>Call to a member function remove_role() on boolean</p>
}
break;
if ( rsp ) {
var $sucessModal = $('#billingSuccess');
$sucessModal.foundation('open').trigger('resizeme.zp.reveal');
- if ( rsp.invoices.length > 0 ) {
+ if ( rsp.invoices != undefined && rsp.invoices.length > 0 ) {
// Loop over the invoices and update the ones if found on this page.
for ( var i in rsp.invoices ) {
// Update the balance due
$('#balance-' + rsp.invoices[i].id ).html( rsp.invoices[i].balance );
// If the invoices is marked 'Paid' then remove the make payment
// or pay invoices links and the send invoices line
- if ( rsp.invoices[i].paid ) {
+ if ( rsp.invoices.length && rsp.invoices[i].paid ) {
$('#make-a-payment-' + rsp.invoices[i].id).remove();
$('#pay-invoice-' + rsp.invoices[i].id).remove();
$('#send-invoice-' + rsp.invoices[i].id).remove();
+ } else {
+ //console.log('rsp: ', rsp);
}
}
+ } else {
+ //console.log('rsp: ', rsp);
}
return true;
} else {