public function processRequest($ip) { $this->ip = $ip; $parts = preg_split('/&/', $this->response); foreach ($parts as $part) { $p = preg_split('/=/', $part, 2); $this->results[$p[0]] = $p[1]; } $this->invoice = new Web_Invoice_GetInfo(web_invoice_get_invoice_id_by_payment($this->results['VendorTxCode'])); if (!$this->invoice) { return; } if ($this->results['Status'] == 'OK' && intval($this->results['Amount']) == intval($this->invoice->display('amount'))) { $this->approved = true; web_invoice_mark_as_paid($this->invoice->id); $this->_logSuccess($this->results['VPSTxId']); web_invoice_update_invoice_meta($this->invoice->id, 'transaction_id', $this->results['VPSTxId']); web_invoice_update_invoice_meta($this->invoice->id, 'auth_code', $this->results['TxAuthNo']); } else { if ($this->results['Status'] == 'NOTAUTHED') { $this->declined = true; $this->_logFailure($this->results['VPSTxId']); web_invoice_update_invoice_meta($this->invoice->id, 'transaction_id', $this->results['VPSTxId']); } else { $this->error = true; $this->_logFailure($this->results['VPSTxId']); web_invoice_update_invoice_meta($this->invoice->id, 'transaction_id', $this->results['VPSTxId']); } } wp_redirect(web_invoice_build_invoice_link($this->invoice->id)); }
function _processNewRequest($ip, $request) { $this->ip = $ip; $this->gc_custemailaddress = $request['buyer-billing-address_email']; $_names = preg_split('/ /', $request['buyer-billing-address_contact-name']); $this->gc_custlastname = array_pop($_names); $this->gc_custfirstname = join(' ', $_names); $this->gc_custaddress = "{$request['buyer-billing-address_address1']}\n {$request['buyer-billing-address_address2']}"; $this->gc_custcity = $request['buyer-billing-address_city']; $this->gc_custstate = $request['buyer-billing-address_region']; $this->gc_custcountry = $request['buyer-billing-address_country-code']; $this->gc_custzip = $request['buyer-billing-address_postal-code']; $this->gc_referencenumber = $request['google-order-number']; $this->gc_totalamount = $request['order-total']; $this->gc_currency = $request['order-total_currency']; $this->gc_status = $request['financial-order-state']; if (!$this->_allowed()) { $this->_logFailure('Invalid user'); header('HTTP/1.0 403 Forbidden'); header('Content-type: text/plain; charset=UTF-8'); print 'We were unable to authenticate the request'; exit(0); } if (!$this->invoice->id) { $this->_logFailure('Invoice not found'); header('HTTP/1.0 404 Not Found'); header('Content-type: text/plain; charset=UTF-8'); print 'Invoice not found'; exit(0); } if ($this->gc_currency != web_invoice_meta($this->invoice->id, 'web_invoice_currency_code')) { $this->_logFailure('Invalid currency'); header('HTTP/1.0 400 Bad Request'); header('Content-type: text/plain; charset=UTF-8'); print 'We were not expecting you. REF: AP0'; exit(0); } if ($this->gc_totalamount != $this->invoice->display('amount')) { $this->_logFailure('Invalid amount'); header('HTTP/1.0 400 Bad Request'); header('Content-type: text/plain; charset=UTF-8'); print 'We were not expecting you. REF: AP1'; exit(0); } web_invoice_update_invoice_meta($this->invoice->id, 'gc_serial_number', $request['google-order-number']); $this->_logSuccess('New payment serial ' . $request['google-order-number']); $this->updateContactInfo(); header('HTTP/1.0 200 OK'); header('Content-type: text/plain; charset=UTF-8'); print 'Thank you very much for letting us know'; exit(0); }
function processRequest($ip, $request) { $this->ip = $ip; if ($request['RESULT'] == 0) { $this->emailaddress = $request['EMAIL']; $_names = preg_split('/ /', $request['NAME']); $this->lastname = array_pop($_names); $this->firstname = join(' ', $_names); $this->address = $request['ADDRESS']; $this->city = $request['CITY']; $this->state = $request['STATE']; $this->country = $request['COUNTRY']; $this->zip = $request['ZIP']; $this->result = $request['RESULT']; $this->respmsg = $request['RESPMSG']; if (isset($request['AUTHCODE'])) { $this->auth_code = $request['AUTHCODE']; } $this->avs_data = $request['AVSDATA']; if (isset($request['HOSTCODE'])) { $this->host_code = $request['HOSTCODE']; } $this->pnref = $request['PNREF']; if ($this->respmsg == 'AVSDECLINED' || $this->respmsg == 'CSCDECLINED') { $this->_processCancellation($ip, $request); } else { $this->_processPayment($ip, $request); } $this->updateContactInfo(); web_invoice_update_invoice_meta($this->invoice->id, 'payflow_pnref', $this->pnref); } else { $this->_logFailure($this->respmsg); header('HTTP/1.0 200 OK'); header('Content-type: text/plain; charset=UTF-8'); print 'Thank you very much for letting us know. REF: Failure'; } exit(0); }
function web_invoice_update_recurring_start_date($invoice_id, $date) { web_invoice_update_invoice_meta($invoice_id, 'web_invoice_subscription_start_day', date('d', $date)); web_invoice_update_invoice_meta($invoice_id, 'web_invoice_subscription_start_year', date('Y', $date)); web_invoice_update_invoice_meta($invoice_id, 'web_invoice_subscription_start_month', date('m', $date)); }
function install() { global $wpdb; require_once ABSPATH . 'wp-admin/includes/upgrade.php'; if (!empty($wpdb->charset)) { $charset_collate = "DEFAULT CHARACTER SET {$wpdb->charset}"; } if (!empty($wpdb->collate)) { $charset_collate .= " COLLATE {$wpdb->collate}"; } //change old table name to new one if ($wpdb->get_var("SHOW TABLES LIKE 'web_invoice'")) { global $table_prefix; $sql_update = "RENAME TABLE " . $table_prefix . "invoice TO " . Web_Invoice::tablename('main') . ""; $wpdb->query($sql_update); } if ($wpdb->get_var("SHOW TABLES LIKE '" . Web_Invoice::tablename('main') . "'") != Web_Invoice::tablename('main')) { $sql_main = "CREATE TABLE IF NOT EXISTS " . Web_Invoice::tablename('main') . " (\r\n\t\t\t\tid int(11) NOT NULL auto_increment,\r\n\t\t\t\tinvoice_date timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,\r\n\t\t\t\tamount double default '0',\r\n\t\t\t\tdescription text NOT NULL,\r\n\t\t\t\tinvoice_num varchar(45) NOT NULL default '',\r\n\t\t\t\tuser_id varchar(20) NOT NULL default '',\r\n\t\t\t\tsubject text NOT NULL,\r\n\t\t\t\titemized text NOT NULL,\r\n\t\t\t\tstatus int(11) NOT NULL,\r\n\t\t\t\tPRIMARY KEY (id),\r\n\t\t\t\tUNIQUE KEY invoice_num (invoice_num)\r\n\t\t\t ) {$charset_collate};"; dbDelta($sql_main); } else { if ($wpdb->get_var("SHOW COLUMNS FROM " . Web_Invoice::tablename('main') . " LIKE 'invoice_date'") != 'invoice_date') { $wpdb->query("ALTER TABLE " . Web_Invoice::tablename('main') . " ADD invoice_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP AFTER id;"); $all_invoices = $wpdb->get_results("SELECT DISTINCT invoice_id, time_stamp FROM " . Web_Invoice::tablename('log') . " WHERE action_type = 'created'"); foreach ($all_invoices as $invoice_log) { $wpdb->query("UPDATE " . Web_Invoice::tablename('main') . " SET invoice_date = '{$invoice_log->time_stamp}' WHERE invoice_date = '0000-00-00 00:00:00' AND invoice_num = '{$invoice_log->invoice_id}'"); } } } if (preg_match('/^4\\.0.*/', $wpdb->get_var("SELECT version()")) > 0) { $sql_log = "CREATE TABLE IF NOT EXISTS " . Web_Invoice::tablename('log') . " (\r\n\t\t\t\tid bigint(20) NOT NULL auto_increment,\r\n\t\t\t\tinvoice_id int(11) NOT NULL default '0',\r\n\t\t\t\taction_type varchar(255) NOT NULL,\r\n\t\t\t\t`value` longtext NOT NULL,\r\n\t\t\t\ttime_stamp timestamp NOT NULL,\r\n\t\t\t\tPRIMARY KEY (id)\r\n\t\t\t ) {$charset_collate};"; dbDelta($sql_log); } else { $sql_log = "CREATE TABLE IF NOT EXISTS " . Web_Invoice::tablename('log') . " (\r\n\t\t\t\tid bigint(20) NOT NULL auto_increment,\r\n\t\t\t\tinvoice_id int(11) NOT NULL default '0',\r\n\t\t\t\taction_type varchar(255) NOT NULL,\r\n\t\t\t\t`value` longtext NOT NULL,\r\n\t\t\t\ttime_stamp timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\r\n\t\t\t\tPRIMARY KEY (id)\r\n\t\t\t ) {$charset_collate};"; dbDelta($sql_log); } $sql_meta = "CREATE TABLE IF NOT EXISTS `" . Web_Invoice::tablename('meta') . "` (\r\n\t\t\t `meta_id` bigint(20) NOT NULL auto_increment,\r\n\t\t\t `invoice_id` bigint(20) NOT NULL default '0',\r\n\t\t\t `meta_key` varchar(255) default NULL,\r\n\t\t\t `meta_value` longtext,\r\n\t\t\t PRIMARY KEY (`meta_id`),\r\n\t\t\t KEY `invoice_id` (`invoice_id`),\r\n\t\t\t KEY `meta_key` (`meta_key`)\r\n\t\t\t) {$charset_collate};"; dbDelta($sql_meta); if ($wpdb->get_var("SHOW TABLES LIKE '" . Web_Invoice::tablename('payment') . "'") != Web_Invoice::tablename('payment')) { $sql_payment = "CREATE TABLE IF NOT EXISTS " . Web_Invoice::tablename('payment') . " (\r\n\t\t\t\t payment_id int(20) NOT NULL auto_increment,\r\n\t\t\t\t amount double default '0',\r\n\t\t\t\t invoice_id int(20) NOT NULL,\r\n\t\t\t\t user_id int(20) NOT NULL,\r\n\t\t\t\t status int(11) NOT NULL,\r\n\t\t\t\t PRIMARY KEY (payment_id)\r\n\t\t\t\t) {$charset_collate};"; dbDelta($sql_payment); } else { if ($wpdb->get_var("SHOW COLUMNS FROM " . Web_Invoice::tablename('payment') . " LIKE 'invoice_id'") != 'invoice_id') { $wpdb->query("ALTER TABLE " . Web_Invoice::tablename('payment') . " ADD `invoice_id` INT( 20 ) NOT NULL AFTER `amount`;"); $wpdb->query("ALTER TABLE " . Web_Invoice::tablename('payment') . " CHANGE `user_id` `user_id` INT( 20 ) NOT NULL;"); $wpdb->query("ALTER TABLE " . Web_Invoice::tablename('payment') . " CHANGE `payment_id` `payment_id` INT( 20 ) NOT NULL;"); } if ($wpdb->get_var("SHOW COLUMNS FROM " . Web_Invoice::tablename('payment') . " LIKE 'trx_id'") != 'trx_id') { $wpdb->query("TRUNCATE TABLE " . Web_Invoice::tablename('payment') . ";"); $wpdb->query("ALTER TABLE " . Web_Invoice::tablename('payment') . " CHANGE `payment_id` `payment_id` INT( 20 ) NOT NULL AUTO_INCREMENT;"); $wpdb->query("ALTER TABLE " . Web_Invoice::tablename('payment') . " ADD `trx_id` VARCHAR( 25 ) NOT NULL AFTER `invoice_id`, ADD UNIQUE ( `trx_id` );"); } } $sql_payment_meta = "CREATE TABLE IF NOT EXISTS `" . Web_Invoice::tablename('payment_meta') . "` (\r\n\t\t\t\t `payment_meta_id` int(20) NOT NULL auto_increment,\r\n\t\t\t\t `payment_id` int(20) NOT NULL default '0',\r\n\t\t\t\t `meta_key` varchar(255) default NULL,\r\n\t\t\t\t `meta_value` longtext,\r\n\t\t\t\t PRIMARY KEY (`payment_meta_id`),\r\n\t\t\t\t KEY `payment_id` (`payment_id`),\r\n\t\t\t\t KEY `meta_key` (`meta_key`)\r\n\t\t\t\t) {$charset_collate};"; dbDelta($sql_payment_meta); // Fix Paid Statuses from Old Version where they were kept in main table $all_invoices = $wpdb->get_results("SELECT invoice_num FROM " . Web_Invoice::tablename('main') . " WHERE status ='1'"); if (!empty($all_invoices)) { foreach ($all_invoices as $invoice) { web_invoice_update_invoice_meta($invoice->invoice_num, 'paid_status', 'paid'); } } // Fix old phone_number and street_address to be without the dash $all_users_with_meta = $wpdb->get_col("SELECT DISTINCT user_id FROM {$wpdb->usermeta}"); if (!empty($all_users_with_meta)) { foreach ($all_users_with_meta as $user) { if (get_usermeta($user, 'company_name')) { update_usermeta($user, 'company_name', get_usermeta($user, 'company_name')); } if (get_usermeta($user, 'tax_id')) { update_usermeta($user, 'tax_id', get_usermeta($user, 'tax_id')); } if (get_usermeta($user, 'street_address')) { update_usermeta($user, 'streetaddress', get_usermeta($user, 'street_address')); } if (get_usermeta($user, 'phone_number')) { update_usermeta($user, 'phonenumber', get_usermeta($user, 'phone_number')); } if (get_usermeta($user, 'country')) { update_usermeta($user, 'country', get_usermeta($user, 'country')); } } } add_option('web_invoice_version', WEB_INVOICE_SCHEDULER_VERSION_NUM); add_option('web_invoice_email_address', get_bloginfo('admin_email')); add_option('web_invoice_business_name', get_bloginfo('blogname')); add_option('web_invoice_business_address', ''); add_option('web_invoice_show_billing_address', 'no'); add_option('web_invoice_show_business_address', 'no'); add_option('web_invoice_payment_method', ''); add_option('web_invoice_protocol', 'http'); add_option('web_invoice_user_level', array('administrator')); $current_role = get_option('web_invoice_user_level'); if (!is_array($current_role) || in_array('level_8', $current_role)) { $current_role = array('administrator'); update_option('web_invoice_user_level', $current_role); } $ro = new WP_Roles(); foreach ($ro->role_objects as $role) { if (in_array($role->name, $current_role)) { $role->add_cap('manage_web_invoice', true); } } add_option('web_invoice_web_invoice_page', ''); add_option('web_invoice_redirect_after_user_add', 'no'); add_option('web_invoice_self_generate_from_template', 'no'); add_option('web_invoice_partial_payments', 'no'); add_option('web_invoice_default_currency_code', 'USD'); add_option('web_invoice_show_quantities', 'Hide'); add_option('web_invoice_show_invoice_date', 'Hide'); add_option('web_invoice_use_css', 'yes'); add_option('web_invoice_force_https', 'false'); add_option('web_invoice_send_thank_you_email', 'no'); add_option('web_invoice_cc_thank_you_email', 'no'); add_option('web_invoice_tax_count', '1'); add_option('web_invoice_tax_name', serialize(array())); //Authorize.net Gateway Settings add_option('web_invoice_gateway_username', ''); add_option('web_invoice_gateway_tran_key', ''); add_option('web_invoice_gateway_delim_char', ','); add_option('web_invoice_gateway_encap_char', ''); add_option('web_invoice_gateway_merchant_email', get_bloginfo('admin_email')); add_option('web_invoice_gateway_header_email_receipt', 'Thanks for your payment!'); add_option('web_invoice_recurring_gateway_url', 'https://api.authorize.net/xml/v1/request.api'); add_option('web_invoice_gateway_url', 'https://gateway.merchantplus.com/cgi-bin/PAWebClient.cgi'); add_option('web_invoice_gateway_MD5Hash', ''); add_option('web_invoice_gateway_test_mode', 'FALSE'); add_option('web_invoice_gateway_delim_data', 'TRUE'); add_option('web_invoice_gateway_relay_response', 'FALSE'); add_option('web_invoice_gateway_email_customer', 'FALSE'); // PayPal add_option('web_invoice_paypal_button', ''); add_option('web_invoice_paypal_subscribe_button', ''); add_option('web_invoice_paypal_address', ''); add_option('web_invoice_paypal_only_button', 'False'); // Payflow add_option('web_invoice_payflow_button', ''); add_option('web_invoice_payflow_login', ''); add_option('web_invoice_payflow_partner', ''); add_option('web_invoice_payflow_only_button', 'False'); add_option('web_invoice_payflow_shipping_details', 'True'); add_option('web_invoice_payflow_silent_post', 'False'); // Payflow Pro add_option('web_invoice_pfp_partner', ''); add_option('web_invoice_pfp_env', 'live'); add_option('web_invoice_pfp_authentication', ''); add_option('web_invoice_pfp_username', ''); add_option('web_invoice_pfp_password', ''); add_option('web_invoice_pfp_signature', ''); add_option('web_invoice_pfp_wpppe_vendor', ''); add_option('web_invoice_pfp_wpppe_username', ''); add_option('web_invoice_pfp_wpppe_password', ''); add_option('web_invoice_pfp_3rdparty_email', ''); add_option('web_invoice_pfp_shipping_details', 'True'); // Other add_option('web_invoice_other_details', ''); // Moneybookers add_option('web_invoice_moneybookers_button', ''); add_option('web_invoice_moneybookers_address', ''); add_option('web_invoice_moneybookers_recurring_address', ''); add_option('web_invoice_moneybookers_merchant', 'False'); add_option('web_invoice_moneybookers_secret', uniqid()); add_option('web_invoice_moneybookers_ip', '83.220.158.0-83.220.158.31,213.129.75.193-213.129.75.206,91.208.28.0-91.208.28.255,193.105.47.0-193.105.47.255'); // AlertPay add_option('web_invoice_alertpay_button', ''); add_option('web_invoice_alertpay_address', ''); add_option('web_invoice_alertpay_merchant', 'False'); add_option('web_invoice_alertpay_secret', uniqid()); add_option('web_invoice_alertpay_test_mode', 'FALSE'); add_option('web_invoice_alertpay_ip', '67.205.87.225-67.205.87.226,67.205.87.235'); // 2CO add_option('web_invoice_2co_button', ''); add_option('web_invoice_2co_sid', ''); add_option('web_invoice_2co_secret_word', uniqid()); add_option('web_invoice_2co_demo_mode', 'FALSE'); // Google Checkout add_option('web_invoice_google_checkout_button', ''); add_option('web_invoice_google_checkout_env', 'live'); add_option('web_invoice_google_checkout_merchant_id', ''); add_option('web_invoice_google_checkout_level2', 'False'); add_option('web_invoice_google_checkout_merchant_key', ''); add_option('web_invoice_google_checkout_tax_state', 'NY'); // Sage Pay add_option('web_invoice_sagepay_button', ''); add_option('web_invoice_sagepay_env', 'live'); add_option('web_invoice_sagepay_vendor_name', ''); add_option('web_invoice_sagepay_vendor_key', ''); add_option('web_invoice_sagepay_shipping_details', 'True'); // Send invoice add_option('web_invoice_email_send_invoice_subject', '%subject'); add_option('web_invoice_email_send_invoice_content', "Dear %call_sign,\r\n\r\n%business_name has sent you a %recurring\r\nweb invoice in the amount of %amount.\r\n\r\n%description\r\n\r\nYou may pay, view and print the invoice online by visiting the following link: \r\n%link\r\n\r\nBest regards,\r\n%business_name ( %business_email )"); // Send reminder (past due date) add_option('web_invoice_email_send_reminder_subject', '[Reminder] %subject'); add_option('web_invoice_email_send_reminder_content', "Dear %call_sign, \r\n\r\n%business_name has sent you a reminder for the %recurring\r\nweb invoice in the amount of %amount.\r\n\r\n%description\r\n\r\nYou may pay, view and print the invoice online by visiting the following link: \r\n%link.\r\n\r\nBest regards,\r\n%business_name ( %business_email )"); // Send reminder (Due in future) add_option('web_invoice_email_send_reminder_pre_due_subject', '[Reminder] %subject due on %due_date'); add_option('web_invoice_email_send_reminder_pre_due_content', "Dear %call_sign, \r\n\r\n%business_name has sent you a friendly reminder for the %recurring\r\nweb invoice in the amount of %amount due on %due_date.\r\n\r\n%description\r\n\r\nYou may pay, view and print the invoice online by visiting the following link: \r\n%link.\r\n\r\nBest regards,\r\n%business_name ( %business_email )"); // Send receipt add_option('web_invoice_email_send_receipt_subject', 'Receipt for %subject'); add_option('web_invoice_email_send_receipt_content', "Dear %call_sign, \r\n\r\n%business_name has received your payment for the %recurring\r\nweb invoice in the amount of %amount.\r\n\r\nThank you very much for your patronage.\r\n\r\nBest regards,\r\n%business_name ( %business_email )"); add_option('web_invoice_pdf_content', "<html>\r\n <head>\r\n\t<title>Invoice</title>\r\n\t<meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />\r\n </head>\r\n <body>\r\n\t<div id='invoice_page' class='clearfix'>\r\n\t <img style='float: right;' src='" . $this->the_path . "/images/logo_small_padding.gif' style='width:420px; height: 110px;' />\r\n\t <h1>Invoice</h1>\r\n\t %content\r\n\t</div>\r\n </body>\r\n</html>"); add_option('web_invoice_html_content', '<div id="invoice_page" class="clearfix"> <div class="noprint"><p>%print_message</p></div> %content </div>'); add_option('web_invoice_allowed_currencies', array('EUR', 'USD')); add_option('web_invoice_installed', WEB_INVOICE_VERSION_NUM); }
function Web_Invoice_Decider($web_invoice_action = null) { global $wpdb, $web_invoice_memory_head_room; if (26214400 > $web_invoice_memory_head_room) { $this->message = sprintf(__("Less than 25MB of memory available for Web Invoice, please set <code>memory_limit = %s</code> in your" . "<code>php.ini</code> if Web Invoice crashes unexpectedly", WEB_INVOICE_TRANS_DOMAIN), web_invoice_return_bytes_nice(web_invoice_return_bytes(ini_get('memory_limit')) + 27000000)); } $web_invoice_action = !empty($_REQUEST['web_invoice_action']) ? $_REQUEST['web_invoice_action'] : $web_invoice_action; $invoice_id = $_REQUEST['invoice_id']; if (!$invoice_id) { $invoice_id = $_REQUEST['multiple_invoices'][0]; } $web_invoice_recurring_billing = web_invoice_meta($invoice_id, 'web_invoice_recurring_billing'); //echo "do this: " . $web_invoice_action; echo "<div class='wrap'>"; switch ($web_invoice_action) { case "save_and_preview": if (empty($invoice_id)) { web_invoice_show_message("Error - invoice id was not passed."); } else { web_invoice_show_message(web_invoice_process_invoice_update($invoice_id), 'updated fade'); if (web_invoice_meta($invoice_id, 'subscription_id') && web_invoice_meta($invoice_id, 'recurring_transaction_id')) { require_once 'gateways/payflowpro.class.php'; $pfp = new Web_Invoice_PayflowProRecurring(); if (web_invoice_meta($invoice_id, 'web_invoice_recurring_billing')) { $pfp->updateProfile($invoice_id); web_invoice_update_log($invoice_id, 'pfp_subscription_update', "Subscription updated. REF: " . $pfp->getRef()); } else { if ($pfp->deleteProfile(web_invoice_meta($invoice_id, 'subscription_id'))) { web_invoice_update_log($invoice_id, 'pfp_subscription_update', "Subscription cancelled. REF: " . $pfp->getRef()); web_invoice_update_invoice_meta($invoice_id, 'pfp_status', 'cancelled'); web_invoice_delete_invoice_meta($invoice_id, 'subscription_id'); } } } web_invoice_saved_preview($invoice_id); do_action('web_invoice_invoice_save', $invoice_id); } break; case "clear_log": web_invoice_show_message(web_invoice_clear_invoice_status($invoice_id), 'updated fade'); web_invoice_options_manageInvoice($invoice_id); break; case "doPausePfp": if (web_invoice_meta($invoice_id, 'subscription_id') && web_invoice_meta($invoice_id, 'recurring_transaction_id')) { require_once 'gateways/payflowpro.class.php'; $pfp = new Web_Invoice_PayflowProRecurring(); if (web_invoice_meta($invoice_id, 'web_invoice_recurring_billing')) { $profile_id = web_invoice_meta($invoice_id, 'subscription_id'); if ($pfp->pauseProfile($profile_id)) { web_invoice_update_log($invoice_id, 'pfp_subscription_update', "Subscription paused. REF: " . $pfp->getRef()); web_invoice_update_invoice_meta($invoice_id, 'pfp_status', 'paused'); web_invoice_delete_invoice_meta($invoice_id, 'subscription_id'); do_action('web_invoice_invoice_pause_recurring', $invoice_id); $message = 'Paused subscription.'; } else { $message = 'Failed to pause subscription.'; } $message .= " <a href='admin.php?page=new_web_invoice&web_invoice_action=doInvoice&invoice_id=" . $invoice_id . "'>Continue editing</a>"; web_invoice_show_message($message, 'updated fade'); } } if ($web_invoice_recurring_billing) { web_invoice_recurring_overview(); } else { web_invoice_default(); } break; case "doRestartRecurringPfp": if (web_invoice_meta($invoice_id, 'recurring_transaction_id')) { require_once 'gateways/payflowpro.class.php'; $pfp = new Web_Invoice_PayflowProRecurring(); if (web_invoice_meta($invoice_id, 'web_invoice_recurring_billing')) { $profile_id = web_invoice_meta($invoice_id, 'recurring_transaction_id'); if ($pfp->reactivateProfile($profile_id, $invoice_id)) { web_invoice_update_log($invoice_id, 'pfp_subscription_update', "Subscription reactivated. REF: " . $pfp->getRef()); web_invoice_update_invoice_meta($invoice_id, 'pfp_status', 'active'); web_invoice_update_invoice_meta($invoice_id, 'subscription_id', $profile_id); do_action('web_invoice_invoice_restart_recurring', $invoice_id); $message = 'Reactivated subscription.'; } else { $message = 'Failed to reactivate subscription.'; } $message .= " <a href='admin.php?page=new_web_invoice&web_invoice_action=doInvoice&invoice_id=" . $invoice_id . "'>Continue editing</a>"; web_invoice_show_message($message, 'updated fade'); } } if ($web_invoice_recurring_billing) { web_invoice_recurring_overview(); } else { web_invoice_default(); } break; case "complete_removal": web_invoice_complete_removal(); web_invoice_show_settings(); break; case "doInvoice": if (isset($invoice_id)) { web_invoice_options_manageInvoice($invoice_id); } else { web_invoice_options_manageInvoice(); } break; case "overview": web_invoice_default(); break; case "user_overview": web_invoice_user_default(); break; case "web_invoice_show_welcome_message": web_invoice_show_welcome_message(); break; case "web_invoice_recurring_billing": web_invoice_recurring_overview(); break; case "send_now": web_invoice_show_message(web_invoice_send_email($invoice_id)); if ($web_invoice_recurring_billing) { web_invoice_recurring_overview(); } else { web_invoice_default(); } break; case "first_setup": if (isset($_POST['web_invoice_web_invoice_page'])) { update_option('web_invoice_web_invoice_page', $_POST['web_invoice_web_invoice_page']); } if (isset($_POST['web_invoice_payment_method'])) { update_option('web_invoice_payment_method', join($_POST['web_invoice_payment_method'], ',')); } if (isset($_POST['web_invoice_gateway_username'])) { update_option('web_invoice_gateway_username', $_POST['web_invoice_gateway_username']); } if (isset($_POST['web_invoice_gateway_tran_key'])) { update_option('web_invoice_gateway_tran_key', $_POST['web_invoice_gateway_tran_key']); } if (isset($_POST['web_invoice_gateway_merchant_email'])) { update_option('web_invoice_gateway_merchant_email', $_POST['web_invoice_gateway_merchant_email']); } // PayPal if (isset($_POST['web_invoice_paypal_address'])) { update_option('web_invoice_paypal_address', $_POST['web_invoice_paypal_address']); } if (isset($_POST['web_invoice_paypal_only_button'])) { update_option('web_invoice_paypal_only_button', $_POST['web_invoice_paypal_only_button']); } if (isset($_POST['web_invoice_paypal_sandbox'])) { update_option('web_invoice_paypal_sandbox', $_POST['web_invoice_paypal_sandbox']); } // Payflow if (isset($_POST['web_invoice_payflow_login'])) { update_option('web_invoice_payflow_login', $_POST['web_invoice_payflow_login']); } if (isset($_POST['web_invoice_payflow_partner'])) { update_option('web_invoice_payflow_partner', $_POST['web_invoice_payflow_partner']); } if (isset($_POST['web_invoice_payflow_only_button'])) { update_option('web_invoice_payflow_only_button', $_POST['web_invoice_payflow_only_button']); } if (isset($_POST['web_invoice_payflow_silent_post'])) { update_option('web_invoice_payflow_silent_post', $_POST['web_invoice_payflow_silent_post']); } // Other/Bank if (isset($_POST['web_invoice_other_details'])) { update_option('web_invoice_other_details', $_POST['web_invoice_other_details']); } // Moneybookers if (isset($_POST['web_invoice_moneybookers_address'])) { update_option('web_invoice_moneybookers_address', $_POST['web_invoice_moneybookers_address']); } if (isset($_POST['web_invoice_moneybookers_recurring_address'])) { update_option('web_invoice_moneybookers_recurring_address', $_POST['web_invoice_moneybookers_recurring_address']); } if (isset($_POST['web_invoice_moneybookers_merchant'])) { update_option('web_invoice_moneybookers_merchant', $_POST['web_invoice_moneybookers_merchant']); } if (isset($_POST['web_invoice_moneybookers_secret'])) { update_option('web_invoice_moneybookers_secret', $_POST['web_invoice_moneybookers_secret']); } if (isset($_POST['web_invoice_moneybookers_ip'])) { update_option('web_invoice_moneybookers_ip', $_POST['web_invoice_moneybookers_ip']); } // AlertPay if (isset($_POST['web_invoice_alertpay_address'])) { update_option('web_invoice_alertpay_address', $_POST['web_invoice_alertpay_address']); } if (isset($_POST['web_invoice_alertpay_merchant'])) { update_option('web_invoice_alertpay_merchant', $_POST['web_invoice_alertpay_merchant']); } if (isset($_POST['web_invoice_alertpay_secret'])) { update_option('web_invoice_alertpay_secret', $_POST['web_invoice_alertpay_secret']); } web_invoice_options_manageInvoice(); break; case "web_invoice_settings": web_invoice_process_settings(); web_invoice_show_settings(); break; case "web_invoice_email_templates": web_invoice_process_email_templates(); web_invoice_show_email_templates(); break; case "delete_invoice": web_invoice_show_message(web_invoice_delete($_REQUEST['multiple_invoices'])); if ($web_invoice_recurring_billing) { web_invoice_recurring_overview(); } else { web_invoice_default(); } break; case "send_invoice": if (empty($_REQUEST['multiple_invoices'])) { web_invoice_show_message("No invoices selected, nothing sent."); } else { web_invoice_show_message(web_invoice_send_email($_REQUEST['multiple_invoices']), 'updated fade'); } if ($web_invoice_recurring_billing) { web_invoice_recurring_overview(); } else { web_invoice_default(); } break; case "send_reminder": if (empty($_REQUEST['multiple_invoices'])) { web_invoice_show_message("No invoices selected, no reminder sent."); } else { web_invoice_show_message(web_invoice_send_email($_REQUEST['multiple_invoices'], 'reminder'), 'updated fade'); } if ($web_invoice_recurring_billing) { web_invoice_recurring_overview(); } else { web_invoice_default(); } break; case "archive_invoice": if (empty($_REQUEST['multiple_invoices'])) { web_invoice_show_message("No invoices selected, nothing archived."); } else { web_invoice_show_message(web_invoice_archive($_REQUEST['multiple_invoices']), 'updated fade'); } if ($web_invoice_recurring_billing) { web_invoice_recurring_overview(); } else { web_invoice_default(); } break; case "unarchive_invoice": if (empty($_REQUEST['multiple_invoices'])) { web_invoice_show_message("No invoices selected, nothing un-archived."); } else { web_invoice_show_message(web_invoice_unarchive($_REQUEST['multiple_invoices']), 'updated fade'); } if ($web_invoice_recurring_billing) { web_invoice_recurring_overview(); } else { web_invoice_default(); } break; case "mark_as_paid": if (empty($_REQUEST['multiple_invoices'])) { web_invoice_show_message("No invoices selected, nothing marked as paid."); } else { web_invoice_show_message(web_invoice_mark_as_paid($_REQUEST['multiple_invoices']), 'updated fade'); } if ($web_invoice_recurring_billing) { web_invoice_recurring_overview(); } else { web_invoice_default(); } break; case "mark_as_sent": if (empty($_REQUEST['multiple_invoices'])) { web_invoice_show_message("No invoices selected, nothing marked as sent.."); } else { web_invoice_show_message(web_invoice_mark_as_sent($_REQUEST['multiple_invoices']), 'updated fade'); } if ($web_invoice_recurring_billing) { web_invoice_recurring_overview(); } else { web_invoice_default(); } break; case "save_not_send": // Already saved, this just shows a message $web_invoice_custom_invoice_id = web_invoice_meta($invoice_id, 'web_invoice_custom_invoice_id'); if ($web_invoice_custom_invoice_id) { $message = "Invoice <b>{$web_invoice_custom_invoice_id}</b> saved."; } else { $message = "Invoice <b>#" . $invoice_id . "</b> saved."; } $message .= " <a href=" . web_invoice_build_invoice_link($invoice_id) . ">View Web Invoice</a>"; web_invoice_show_message($message, ' updated fade'); if ($web_invoice_recurring_billing) { web_invoice_recurring_overview(); } else { web_invoice_default(); } break; default: if ($web_invoice_recurring_billing) { web_invoice_recurring_overview(); } else { web_invoice_default(); } break; } echo "</div>"; }