public function updateProfile($invoice_id) { $this->params['METHOD'] = "UpdateRecurringPaymentsProfile"; $invoice = new Web_Invoice_GetInfo($invoice_id); $user_id = $invoice->recipient('user_id'); if (get_option('web_invoice_pfp_authentication') == '3token' || get_option('web_invoice_pfp_authentication') == 'unipay') { $this->params['DESC'] = $invoice->display('subscription_name'); $this->params['PROFILESTARTDATE'] = date('c', strtotime($invoice->display('startDateM'))); $this->params['TOTALBILLINGCYCLES'] = $invoice->display('totalOccurrences'); $this->params['NOTE'] = "Related invoice was updated"; $this->params['PROFILEID'] = web_invoice_meta($invoice_id, 'subscription_id'); $this->params["FIRSTNAME"] = get_usermeta($user_id, 'first_name'); $this->params["LASTNAME"] = get_usermeta($user_id, 'last_name'); $this->params["STREET"] = get_usermeta($user_id, 'address'); $this->params["CITY"] = get_usermeta($user_id, 'city'); $this->params["STATE"] = get_usermeta($user_id, 'state'); $this->params["COUNTRYCODE"] = get_usermeta($user_id, 'country'); $this->params["ZIP"] = get_usermeta($user_id, 'zip'); $this->params["PHONENUM"] = get_usermeta($user_id, 'phonenumber'); if (get_option('web_invoice_pfp_shipping_details') == 'True') { //Shipping Info $this->params["SHIPTONAME"] = get_usermeta($user_id, 'shipto_first_name') . " " . get_usermeta($user_id, 'shipto_last_name'); $this->params["SHIPTOSTREET"] = get_usermeta($user_id, 'shipto_address'); $this->params["SHIPTOCITY"] = get_usermeta($user_id, 'shipto_city'); $this->params["SHIPTOSTATE"] = get_usermeta($user_id, 'shipto_state'); $this->params["SHIPTOCOUNTRY"] = get_usermeta($user_id, 'shipto_country'); $this->params["SHIPTOZIP"] = get_usermeta($user_id, 'shipto_zip'); $this->params["SHIPTOPHONENUM"] = get_usermeta($user_id, 'shipto_phonenumber'); } } else { $this->params['ACTION'] = "M"; $this->params['ORIGPROFILEID'] = web_invoice_meta($invoice_id, 'subscription_id'); $this->params['PROFILENAME'] = $invoice->display('subscription_name'); $this->params['START'] = date('mdY', strtotime($invoice->display('startDateM')) + 3600 * 24); $this->params['TERM'] = $invoice->display('totalOccurrences'); $this->params['PAYPERIOD'] = web_invoice_pfp_wpppe_convert_interval($invoice->display('interval_length'), $invoice->display('interval_unit')); $this->params["COMMENT1"] = get_usermeta($user_id, 'first_name') . " " . get_usermeta($user_id, 'last_name') . " " . $invoice->display('subscription_name') . " Recurring"; $this->params["FIRSTNAME"] = get_usermeta($user_id, 'first_name'); $this->params["LASTNAME"] = get_usermeta($user_id, 'last_name'); $this->params["STREET"] = get_usermeta($user_id, 'streetaddress'); $this->params["CITY"] = get_usermeta($user_id, 'city'); $this->params["STATE"] = get_usermeta($user_id, 'state'); $this->params["COUNTRY"] = get_usermeta($user_id, 'country'); $this->params["ZIP"] = get_usermeta($user_id, 'zip'); $this->params["PHONENUM"] = get_usermeta($user_id, 'phonenumber'); if (get_option('web_invoice_pfp_shipping_details') == 'True') { //Shipping Info $this->params["SHIPTONAME"] = get_usermeta($user_id, 'shipto_first_name') . " " . get_usermeta($user_id, 'shipto_last_name'); $this->params["SHIPTOSTREET"] = get_usermeta($user_id, 'shipto_streetaddress'); $this->params["SHIPTOCITY"] = get_usermeta($user_id, 'shipto_city'); $this->params["SHIPTOSTATE"] = get_usermeta($user_id, 'shipto_state'); $this->params["SHIPTOCOUNTRY"] = get_usermeta($user_id, 'shipto_country'); $this->params["SHIPTOZIP"] = get_usermeta($user_id, 'shipto_zip'); $this->params["SHIPTOPHONENUM"] = get_usermeta($user_id, 'shipto_phonenumber'); } } $this->params["AMT"] = $invoice->display('amount'); $this->params["CURRENCYCODE"] = $invoice->display('currency'); return $this->process(); }
function web_invoice_determine_currency($invoice_id) { //in class if (web_invoice_meta($invoice_id, 'web_invoice_currency_code') != '') { $currency_code = web_invoice_meta($invoice_id, 'web_invoice_currency_code'); } elseif (get_option('web_invoice_default_currency_code') != '') { $currency_code = get_option('web_invoice_default_currency_code'); } else { $currency_code = "USD"; } return $currency_code; }
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 web_invoice_show_recurring_info($invoice_id) { $invoice = new Web_Invoice_GetInfo($invoice_id); ?> <div id="recurring_info" class="clearfix"> <h2 id="web_invoice_welcome_message" class="invoice_page_subheading"><?php printf(__('Welcome, %s!', WEB_INVOICE_TRANS_DOMAIN), $invoice->recipient('callsign')); ?> </h2> <?php if ($invoice->display('description')) { ?> <p><?php echo $invoice->display('description'); ?> </p> <?php } ?> <p class="recurring_info_breakdown"><?php printf(__('This is a recurring invoice, id: <b>%s</b>.', WEB_INVOICE_TRANS_DOMAIN), $invoice->display('display_id')); ?> </p> <p><?php printf(__('You will be billed %1$s in the amount of %2$s ', WEB_INVOICE_TRANS_DOMAIN), $invoice->display('display_billing_rate'), $invoice->display('display_amount')); // Determine if starting now or t a set date if (web_invoice_meta($invoice_id, 'web_invoice_subscription_start_day') != '' && web_invoice_meta($invoice_id, 'web_invoice_subscription_start_month') != '' && web_invoice_meta($invoice_id, 'web_invoice_subscription_start_year' != '')) { echo web_invoice_meta($invoice_id, 'web_invoice_subscription_start_day') . ", " . web_invoice_meta($invoice_id, 'web_invoice_subscription_start_month') . ", " . web_invoice_meta($invoice_id, 'web_invoice_subscription_start_year'); } ?> .</p> <?php if ($invoice->display('invoice_date') && get_option('web_invoice_show_invoice_date', 'Hide') == 'Show') { ?> <p class="web_invoice_date"><?php printf(__('Invoice Date: %s', WEB_INVOICE_TRANS_DOMAIN), $invoice->display('invoice_date')); } if ($invoice->display('due_date')) { ?> <p class="web_invoice_due_date"><?php printf(__("Due Date: %s", WEB_INVOICE_TRANS_DOMAIN), $invoice->display('due_date')); ?> </p><?php } //Billing Business Address if (get_option('web_invoice_show_business_address') == 'yes') { web_invoice_show_business_address(); } if (get_option('web_invoice_show_billing_address') == 'yes') { web_invoice_show_billing_address($invoice_id); } echo web_invoice_draw_itemized_table($invoice_id); ?> </div> <?php }
function processRequest($ip, $request) { $this->ip = $ip; $this->ap_custemailaddress = $request['ap_custemailaddress']; $this->ap_custfirstname = $request['ap_custfirstname']; $this->ap_custlastname = $request['ap_custlastname']; $this->ap_custaddress = $request['ap_custaddress']; $this->ap_custcity = $request['ap_custcity']; $this->ap_custstate = $request['ap_custstate']; $this->ap_custcountry = $request['ap_custcountry']; $this->ap_custzip = $request['ap_custzip']; $this->ap_merchant = $request['ap_merchant']; $this->ap_referencenumber = $request['ap_referencenumber']; $this->ap_totalamount = $request['ap_totalamount']; $this->ap_currency = $request['ap_currency']; $this->ap_amount = $request['ap_amount']; $this->ap_itemname = $request['ap_itemname']; $this->ap_securitycode = $request['ap_securitycode']; $this->ap_status = $request['ap_status']; $this->ap_test = $request['ap_test']; if (!$this->_allowedIp()) { $this->_logFailure('Invalid IP'); 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->ap_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->ap_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); } if ($this->ap_merchant != get_option('web_invoice_alertpay_address')) { $this->_logFailure('Invalid pay_to_email'); header('HTTP/1.0 400 Bad Request'); header('Content-type: text/plain; charset=UTF-8'); print 'We were not expecting you. REF: AP2'; exit(0); } if ($this->ap_securitycode != get_option('web_invoice_alertpay_secret')) { $this->_logFailure('Invalid security code'); 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 (strtolower($this->ap_status) != "success") { $this->_logSuccess('Payment failed (status)'); header('HTTP/1.0 200 OK'); header('Content-type: text/plain; charset=UTF-8'); print 'Thank you very much for letting us know. REF: Not success'; exit(0); } if ($this->ap_test == 1) { if (get_option('web_invoice_alertpay_test_mode') == 'TRUE') { $this->_logFailure('Test payment'); $this->updateContactInfo(); } } else { $this->updateContactInfo(); web_invoice_mark_as_paid($this->invoice->id); } 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 display($what) { global $_web_invoice_clear_cache, $wpdb; if (!$this->_row_cache || $_web_invoice_clear_cache) { $this->_setRowCache($wpdb->get_row("SELECT * FROM " . Web_Invoice::tablename('main') . " WHERE invoice_num = '{$this->id}'")); $_web_invoice_clear_cache = false; } $invoice_info = $this->_row_cache; switch ($what) { case 'log_status': if ($status_update = $wpdb->get_row("SELECT * FROM " . Web_Invoice::tablename('log') . " WHERE invoice_id = " . $this->id . " ORDER BY `" . Web_Invoice::tablename('log') . "`.`time_stamp` DESC LIMIT 0 , 1")) { return $status_update->value . " - " . web_invoice_Date::convert($status_update->time_stamp, 'Y-m-d H', __('M d Y', WEB_INVOICE_TRANS_DOMAIN)); } break; case 'paid_date': $paid_date = $wpdb->get_var("SELECT time_stamp FROM " . Web_Invoice::tablename('log') . " WHERE action_type = 'paid' AND invoice_id = '" . $this->id . "' ORDER BY time_stamp DESC LIMIT 0, 1"); if ($paid_date) { return date(get_option('date_format', __('Y-m-d', WEB_INVOICE_TRANS_DOMAIN)), strtotime(web_invoice_Date::convert($paid_date, 'Y-m-d H', __('M d Y', WEB_INVOICE_TRANS_DOMAIN)))); } break; case 'paid_date_raw': $paid_date = $wpdb->get_var("SELECT time_stamp FROM " . Web_Invoice::tablename('log') . " WHERE action_type = 'paid' AND invoice_id = '" . $this->id . "' ORDER BY time_stamp DESC LIMIT 0, 1"); if ($paid_date) { return $paid_date; } break; case 'subscription_name': return web_invoice_meta($this->id, 'web_invoice_subscription_name'); break; case 'interval_length': return web_invoice_meta($this->id, 'web_invoice_subscription_length'); break; case 'interval_unit': return web_invoice_meta($this->id, 'web_invoice_subscription_unit'); break; case 'totalOccurrences': return web_invoice_meta($this->id, 'web_invoice_subscription_total_occurances'); break; case 'installment': return web_invoice_meta($this->id, 'installment', 0); break; case 'startDate': $web_invoice_subscription_start_day = web_invoice_meta($this->id, 'web_invoice_subscription_start_day'); $web_invoice_subscription_start_year = web_invoice_meta($this->id, 'web_invoice_subscription_start_year'); $web_invoice_subscription_start_month = web_invoice_meta($this->id, 'web_invoice_subscription_start_month'); if ($web_invoice_subscription_start_month && $web_invoice_subscription_start_year && $web_invoice_subscription_start_day && strtotime($web_invoice_subscription_start_year . "-" . $web_invoice_subscription_start_month . "-" . $web_invoice_subscription_start_day) > time()) { return date(get_option('date_format', __('Y-m-d', WEB_INVOICE_TRANS_DOMAIN)), strtotime($web_invoice_subscription_start_year . "-" . $web_invoice_subscription_start_month . "-" . $web_invoice_subscription_start_day)); } else { return date(get_option('date_format', __('Y-m-d', WEB_INVOICE_TRANS_DOMAIN)), time() + 1800); } break; case 'endDate': return date(get_option('date_format', __('Y-m-d', WEB_INVOICE_TRANS_DOMAIN)), strtotime("+" . $this->display('interval_length') * $this->display('totalOccurrences') . " " . $this->display('interval_unit'), strtotime($this->display('startDateM')))); break; case 'nextDate': if ($this->display('totalOccurrences') > $this->display('installment')) { if ($this->display('installment') == 0 && strtotime($this->display('startDateM')) >= strtotime($this->display('due_dateM'))) { $start_date = $this->display('due_dateM'); } else { $start_date = $this->display('startDateM'); } return date(get_option('date_format', __('Y-m-d', WEB_INVOICE_TRANS_DOMAIN)), strtotime("+" . $this->display('interval_length') * $this->display('installment') . " " . $this->display('interval_unit'), strtotime($start_date))); } return $this->display('endDate'); break; case 'startDateM': $web_invoice_subscription_start_day = web_invoice_meta($this->id, 'web_invoice_subscription_start_day'); $web_invoice_subscription_start_year = web_invoice_meta($this->id, 'web_invoice_subscription_start_year'); $web_invoice_subscription_start_month = web_invoice_meta($this->id, 'web_invoice_subscription_start_month'); if ($web_invoice_subscription_start_month && $web_invoice_subscription_start_year && $web_invoice_subscription_start_day && strtotime($web_invoice_subscription_start_year . "-" . $web_invoice_subscription_start_month . "-" . $web_invoice_subscription_start_day) > time()) { return date('Y-m-d', strtotime($web_invoice_subscription_start_year . "-" . $web_invoice_subscription_start_month . "-" . $web_invoice_subscription_start_day)); } else { return date('Y-m-d', time() + 1800); } break; case 'endDateM': return date('Y-m-d', strtotime("+" . $this->display('interval_length') * $this->display('totalOccurrences') . " " . $this->display('interval_unit'), strtotime($this->display('startDateM')))); break; case 'nextDateM': if ($this->display('totalOccurrences') > $this->display('installment')) { if ($this->display('installment') == 0 && strtotime($this->display('startDateM')) >= strtotime($this->display('due_dateM'))) { $start_date = $this->display('due_dateM'); } else { $start_date = $this->display('startDateM'); } return date('Y-m-d', strtotime("+" . $this->display('interval_length') * $this->display('installment') . " " . $this->display('interval_unit'), strtotime($start_date))); } return $this->display('endDate'); break; case 'profileEndDate': return date(get_option('date_format', __('Y-m-d', WEB_INVOICE_TRANS_DOMAIN)), strtotime("+" . $this->display('interval_length') * ($this->display('totalOccurrences') - 1) . " " . $this->display('interval_unit'), strtotime($this->display('startDate')) + 3600 * 24)); break; case 'archive_status': $result = $wpdb->get_col("SELECT action_type FROM " . Web_Invoice::tablename('log') . " WHERE invoice_id = '" . $this->id . "' ORDER BY time_stamp DESC"); foreach ($result as $event) { if ($event == 'unarchive') { return ''; break; } if ($event == 'archive') { return 'archive'; break; } } break; case 'display_billing_rate': $length = web_invoice_meta($this->id, 'web_invoice_subscription_length'); $unit = web_invoice_meta($this->id, 'web_invoice_subscription_unit'); $occurances = web_invoice_meta($this->id, 'web_invoice_subscription_total_occurances'); // days if ($unit == "days") { if ($length == '1') { return "daily for {$occurances} days"; } if ($length > '1') { return "every {$length} days for a total of {$occurances} billing cycles"; } } //months if ($unit == "months") { if ($length == '1') { return "monthly for {$occurances} months"; } if ($length > '1') { return "every {$length} months {$occurances} times"; } } if ($unit == "years") { if ($length == '1') { return "annually for {$occurances} years"; } if ($length > '1') { return "every {$length} years {$occurances} times"; } } break; case 'link': $link_to_page = get_permalink(get_option('web_invoice_web_invoice_page')); $hashed = md5($this->id); if (get_option("permalink_structure")) { return $link_to_page . "?invoice_id=" . $hashed; } else { return $link_to_page . "&invoice_id=" . $hashed; } break; case 'invoice_hash': return md5($this->id); break; case 'print_link': return $this->display('link') . '&print=1'; break; case 'hash': return md5($this->id); break; case 'currency': if (web_invoice_meta($this->id, 'web_invoice_currency_code') != '') { $currency_code = web_invoice_meta($this->id, 'web_invoice_currency_code'); } else { if (get_option('web_invoice_default_currency_code') != '') { $currency_code = get_option('web_invoice_default_currency_code'); } else { $currency_code = "USD"; } } return $currency_code; break; case 'display_id': $web_invoice_custom_invoice_id = web_invoice_meta($this->id, 'web_invoice_custom_invoice_id'); if (empty($web_invoice_custom_invoice_id)) { return $this->id; } else { return $web_invoice_custom_invoice_id; } break; case 'due_date': $web_invoice_due_date_month = web_invoice_meta($this->id, 'web_invoice_due_date_month'); $web_invoice_due_date_year = web_invoice_meta($this->id, 'web_invoice_due_date_year'); $web_invoice_due_date_day = web_invoice_meta($this->id, 'web_invoice_due_date_day'); if (!empty($web_invoice_due_date_month) && !empty($web_invoice_due_date_year) && !empty($web_invoice_due_date_day)) { return date(get_option('date_format', __('Y-m-d', WEB_INVOICE_TRANS_DOMAIN)), strtotime("{$web_invoice_due_date_year}-{$web_invoice_due_date_month}-{$web_invoice_due_date_day}")); } return date(get_option('date_format', __('Y-m-d', WEB_INVOICE_TRANS_DOMAIN))); break; case 'due_dateM': $web_invoice_due_date_month = web_invoice_meta($this->id, 'web_invoice_due_date_month'); $web_invoice_due_date_year = web_invoice_meta($this->id, 'web_invoice_due_date_year'); $web_invoice_due_date_day = web_invoice_meta($this->id, 'web_invoice_due_date_day'); if (!empty($web_invoice_due_date_month) && !empty($web_invoice_due_date_year) && !empty($web_invoice_due_date_day)) { return date('Y-m-d', strtotime("{$web_invoice_due_date_year}-{$web_invoice_due_date_month}-{$web_invoice_due_date_day}")); } return date('Y-m-d'); break; case 'invoice_date': if ($invoice_info && $invoice_info->invoice_date && !empty($invoice_info->invoice_date)) { date(get_option('date_format', __('Y-m-d', WEB_INVOICE_TRANS_DOMAIN)), strtotime($invoice_info->invoice_date)); } return date(get_option('date_format', __('Y-m-d', WEB_INVOICE_TRANS_DOMAIN))); break; case 'amount': return $invoice_info->amount; break; case 'due_amount': $payments = web_invoice_sum_payments($this->id); return max(0, $invoice_info->amount - $payments); break; case 'tax_percent': $_tax_values = unserialize(web_invoice_meta($this->id, 'tax_value')); if (is_array($_tax_values)) { $_tax_value = 0; foreach ($_tax_values as $_tax_valuex) { $_tax_value += $_tax_valuex; } } else { $_tax_value = $_tax_values; } return $_tax_value; break; case 'tax_total': $_tax_values = unserialize(web_invoice_meta($this->id, 'tax_value')); if (is_array($_tax_values)) { $_tax_value = 0; foreach ($_tax_values as $_tax_valuex) { $_tax_value += $_tax_valuex; } } else { $_tax_value = $_tax_values; } return $_tax_value * $invoice_info->amount; break; case 'subject': return $invoice_info->subject; break; case 'display_amount': return web_invoice_display_payment($this->display('currency'), $invoice_info->amount); break; case 'description': return str_replace("\n", "<br />", $invoice_info->description); break; case 'itemized': return unserialize(urldecode($invoice_info->itemized)); break; case 'status': return $invoice_info->status; break; case 'trx_id': return web_invoice_payment_register($this->id, $this->display('amount')); break; } }
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>"; }
function processRequest($ip, $request) { $this->ip = $ip; $this->pay_to_email = $request['pay_to_email']; $this->pay_from_email = $request['pay_from_email']; $this->merchant_id = $request['merchant_id']; $this->mb_transaction_id = $request['mb_transaction_id']; $this->transaction_id = $request['transaction_id']; $this->mb_amount = $request['mb_amount']; $this->mb_currency = $request['mb_currency']; $this->status = $request['status']; $this->md5sig = $request['md5sig']; $this->amount = $request['amount']; $this->currency = $request['currency']; if (isset($request['rec_payment_id'])) { $this->recurring_payment_id = $request['rec_payment_id']; } if (isset($request['rec_payment_type'])) { $this->recurring_payment_type = $request['rec_payment_type']; } if (!$this->_allowedIp()) { $this->_logFailure('Invalid IP'); 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->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: MB0'; exit(0); } if ($this->amount != $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: MB1'; exit(0); } if ($this->pay_to_email != get_option('web_invoice_moneybookers_address') && $this->pay_to_email != get_option('web_invoice_moneybookers_recurring_address')) { $this->_logFailure('Invalid pay_to_email'); header('HTTP/1.0 400 Bad Request'); header('Content-type: text/plain; charset=UTF-8'); print 'We were not expecting you. REF: MB2'; exit(0); } $secret_word = strtoupper(md5(get_option('web_invoice_moneybookers_secret'))); $our_signature = strtoupper(md5("{$this->merchant_id}{$this->transaction_id}{$secret_word}{$this->mb_amount}{$this->mb_currency}{$this->status}")); if ($this->md5sig != $our_signature) { $this->_logFailure('Invalid signature, we calculated ' . $our_signature); 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->status != 2) { if ($this->status == -2) { $this->_logSuccess('Payment failed (status)'); } if ($this->status == -1) { $this->_logSuccess('Payment cancelled (status)'); } if ($this->status == 0) { $this->_logSuccess('Payment pending (status)'); } header('HTTP/1.0 200 OK'); header('Content-type: text/plain; charset=UTF-8'); print 'Thank you very much for letting us know. REF: Pending'; exit(0); } $this->_logSuccess('Paid'); web_invoice_mark_as_paid($this->invoice->id); 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); }