$invoice_row = JB_get_membership_invoice_row($_REQUEST['invoice_id']); $t_end = strtotime($invoice_row['member_end']); $t_next_month = mktime(date('H', $t_end), date('i', $t_end), date('s', $t_end), date('n', $t_end) - 1, date('j', $t_end), date('Y', $t_end)); $d_next_month = gmdate("Y-m-d H:i:s", $t_next_month); $sql = "UPDATE membership_invoices SET member_end='{$d_next_month}' WHERE invoice_id = '" . jb_escape_sql($_REQUEST['invoice_id']) . "' "; jb_mysql_query($sql); $JBMarkup->ok_msg('Subtracted 1 month'); } if ($_REQUEST['never_expire'] != '') { $sql = "UPDATE membership_invoices SET months_duration='0' WHERE invoice_id = '" . jb_escape_sql($_REQUEST['invoice_id']) . "' "; jb_mysql_query($sql); $JBMarkup->ok_msg('Set to never expire'); } if ($_REQUEST['expire'] != '') { $invoice_row = JB_get_membership_invoice_row($_REQUEST['invoice_id']); JB_expire_membership($invoice_row, $send_email = false); $JBMarkup->ok_msg('Subscription expired'); } if ($_REQUEST['reactivate'] != '') { $invoice_row = JB_get_membership_invoice_row($_REQUEST['invoice_id']); $now = gmdate("Y-m-d H:i:s"); $sql = "UPDATE membership_invoices SET `status`='Completed', `processed_date`='{$now}' WHERE invoice_id='" . jb_escape_sql($_REQUEST['invoice_id']) . "'"; $result = JB_mysql_query($sql) or JB_mail_error("[{$sql}]" . mysql_error()); JB_start_membership($invoice_row); $JBMarkup->ok_msg('Subscription reactivated'); } if ($_REQUEST['save'] != '') { $invoice_row = JB_get_membership_invoice_row($_REQUEST['invoice_id']); $sql = "UPDATE membership_invoices SET amount='" . jb_escape_sql($_REQUEST['amount']) . "', item_name='" . jb_escape_sql($_REQUEST['item_name']) . "', payment_method='" . jb_escape_sql($_REQUEST['payment_method']) . "' WHERE invoice_id='" . jb_escape_sql($_REQUEST['invoice_id']) . "'"; $result = JB_mysql_query($sql) or JB_mail_error("[{$sql}]" . mysql_error()); $JBMarkup->ok_msg('Subscription modified');
function JB_update_memberships() { // get all the expired invoices $now = gmdate("Y-m-d H:i:s"); // +3600 add 1 hour, this ads an additional hour to the membership so that PayPal IPN and other have a chance to renew the invoice. $sql = "SELECT * FROM membership_invoices WHERE ((`status`='Completed' ) OR ((`status`='Pending') AND `reason`='jb_credit_advanced')) AND (UNIX_TIMESTAMP(`member_end`)+3600 < UNIX_TIMESTAMP('{$now}')) AND months_duration > 0 "; $invoice_result = JB_mysql_query($sql) or JB_mail_error(mysql_error() . $sql); while ($invoice_row = mysql_fetch_array($invoice_result)) { JB_expire_membership($invoice_row); } }
JB_debit_transaction($invoice_id, $mc_gross, $mc_currency, $txn_id, $reason_code, "PayPal", $product_type, $_REQUEST['subscr_id']); } JBPLUG_do_callback('pay_trn_subscr_completed', $invoice_id, $product_type); } if ($txn_type == 'subscr_failed') { } if ($txn_type == 'subscr_eot') { if ($product_type == 'S') { // subscriptions to view resume $invoice_row = JB_get_subscription_invoice_row($invoice_id); JB_expire_subscription($invoice_row); } if ($product_type == 'M') { // Membership $invoice_row = JB_get_membership_invoice_row($invoice_id); JB_expire_membership($invoice_id); } } if ($txn_type == 'subscr_signup') { } if ($txn_type == 'web_accept' || $txn_type == '') { // transaction came from a button or straight from paypal switch ($payment_status) { case "Canceled_Reversal": break; case "Completed": if ($product_type == 'P') { pp_log_entry("complete package" . $invoice_id); JB_complete_package_invoice($invoice_id, 'PayPal'); } elseif ($product_type == 'S') { if (PAYPAL_MANUAL_APPROVE == 'Y') {