/** * Setup the reference link in the referrals table * * @access public * @since 1.6 */ public function reference_link($reference = 0, $referral) { if (empty($referral->context) || $this->context != $referral->context) { return $reference; } $payment = SI_Payment::get_instance($reference); $invoice_id = $payment->get_invoice_id(); $url = get_edit_post_link($invoice_id); $reference = get_the_title($invoice_id); return '<a href="' . esc_url($url) . '">' . $reference . '</a>'; }
/** * Void a payment * @param integet $payment_id Payment ID * @return */ public static function void_payment($payment_id, $new_data = '') { // Mark as refunded and change the $payment = SI_Payment::get_instance($payment_id); if (!is_a($payment, 'SI_Payment')) { return; } $payment->set_status(SI_Payment::STATUS_VOID); $payment->set_payment_method(self::__('Admin Void')); // Merge old data with new updated message $new_data = wp_parse_args($payment->get_data(), array('void_notes' => $new_data, 'updated' => sprintf(self::__('Voided by User #%s on %s'), get_current_user_id(), date_i18n(get_option('date_format') . ' @ ' . get_option('time_format'))))); $payment->set_data($new_data); add_action('si_void_payment', $payment_id, $new_data); }
function test_add_payment() { $payment_total = $this->invoice->get_balance(); // create new payment $payment_id = SI_Payment::new_payment(array('payment_method' => SI_Paypal_EC::PAYMENT_METHOD, 'invoice' => $this->invoice->get_id(), 'amount' => $payment_total, 'data' => array('api_response' => array())), SI_Payment::STATUS_AUTHORIZED); if (!$payment_id) { return false; } $payment = SI_Payment::get_instance($payment_id); do_action('payment_authorized', $payment); // Complete and fire actions $payment->set_status(SI_Payment::STATUS_COMPLETE); do_action('payment_complete', $payment); $this->assertEquals($this->invoice->get_balance(), 0); }
public static function create_admin_payment($invoice_id = 0, $amount = '0.00', $number = '', $date = '', $notes = '') { if (did_action('si_new_payment') > 0) { // make sure this return; } $invoice = SI_Invoice::get_instance($invoice_id); // create new payment $payment_id = SI_Payment::new_payment(array('payment_method' => self::get_payment_method(), 'invoice' => $invoice_id, 'amount' => $amount, 'transaction_id' => $number, 'data' => array('amount' => $amount, 'check_number' => $number, 'date' => strtotime($date), 'notes' => $notes)), SI_Payment::STATUS_COMPLETE); if (!$payment_id) { return false; } $payment = SI_Payment::get_instance($payment_id); if ($date != '') { $payment->set_post_date(date('Y-m-d H:i:s', strtotime($date))); } do_action('admin_payment', $payment_id, $invoice); do_action('payment_complete', $payment); }
function build_test_payment($invoice_id, $total = 0, $date = false, $status = '') { $invoice = SI_Invoice::get_instance($invoice_id); // Randomize if no total is set. $payment_total = !$total ? rand(1, 300) : $total; $status = $status != '' ? $status : SI_Payment::STATUS_AUTHORIZED; // create new payment $payment_id = SI_Payment::new_payment(array('payment_method' => SI_Paypal_EC::PAYMENT_METHOD, 'invoice' => $invoice->get_id(), 'amount' => $payment_total, 'data' => array('api_response' => array())), $status); $this->payment_ids[] = $payment_id; $new_payment = SI_Payment::get_instance($payment_id); do_action('payment_authorized', $new_payment); if (!$date) { $date = time(); } if (!is_integer($date)) { $date = strtotime($date); } $new_payment->set_post_date(date('Y-m-d H:i:s', $date)); $this->assertTrue(in_array($payment_id, $this->payment_ids)); return $payment_id; }
public static function total_payment_data_by_date_segment($segment = 'weeks', $span = 6) { // Return cache if present. $cache = self::get_cache(__FUNCTION__ . $segment . $span); if ($cache) { return $cache; } // FUTURE charts should be dynamic based on selected segment. $weeks = self::walk_back_x_span($span, $segment); $year = date('Y', strtotime($span . ' weeks ago')); // Build data array, without a explicit build segments without posts will not show. $data = array(); foreach ($weeks as $week_num) { $data[$week_num] = array('payments' => 0, 'totals' => 0, 'status_pending' => 0, 'status_authorized' => 0, 'status_complete' => 0, 'status_partial' => 0, 'status_void' => 0); } $args = array('post_type' => SI_Payment::POST_TYPE, 'post_status' => 'any', 'posts_per_page' => -1, 'orderby' => 'date', 'fields' => 'ids', 'date_query' => array(array('after' => date('Y-m-d', strtotime($year . 'W' . array_shift($weeks))), 'inclusive' => true))); $payments = new WP_Query($args); foreach ($payments->posts as $payment_id) { $payment = SI_Payment::get_instance($payment_id); $week = get_the_time('W', $payment_id); $data[$week]['payments'] += 1; $data[$week]['totals'] += $payment->get_amount(); switch (get_post_status($payment_id)) { case SI_Payment::STATUS_PENDING: $data[$week]['status_pending'] += 1; break; case SI_Payment::STATUS_AUTHORIZED: $data[$week]['status_authorized'] += 1; break; case SI_Payment::STATUS_COMPLETE: $data[$week]['status_complete'] += 1; break; case SI_Payment::STATUS_PARTIAL: $data[$week]['status_partial'] += 1; break; case SI_Payment::STATUS_VOID: $data[$week]['status_void'] += 1; break; default: break; } } return self::set_cache(__FUNCTION__ . $segment . $span, $data, self::CACHE_TIMEOUT); }
public function get_payments_total($pending = true) { if (isset($this->payments_total)) { return $this->payments_total; } $payment_ids = self::get_payments(); $payment_total = 0; foreach ($payment_ids as $payment_id) { $payment = SI_Payment::get_instance($payment_id); if (!$pending && $payment->get_status() == SI_Payment::STATUS_PENDING) { continue; } if (!in_array($payment->get_status(), array(SI_Payment::STATUS_VOID, SI_Payment::STATUS_RECURRING, SI_Payment::STATUS_CANCELLED))) { $payment_total += $payment->get_amount(); } } $this->payment_total = $payment_total; return $payment_total; }
public static function payment($data = array()) { if (!isset($data['id'])) { $data['id'] = $_GET['id']; } $payment = SI_Payment::get_instance($data['id']); if (!is_a($payment, 'SI_Payment')) { return; } return self::payment_data($payment); }
function si_doc_history_records($doc_id = 0, $filtered = true) { if (!$doc_id) { $doc_id = get_the_ID(); } $returned_history = array(); switch (get_post_type($doc_id)) { case SI_Estimate::POST_TYPE: $estimate = SI_Estimate::get_instance($doc_id); $history = $estimate->get_history(); break; case SI_Invoice::POST_TYPE: $invoice = SI_Invoice::get_instance($doc_id); $history = array_merge($invoice->get_history(), $invoice->get_payments()); break; default: # code... break; } $history = apply_filters('si_doc_history_records_pre_sort', $history, $doc_id, $filtered); // Sort in ascending order asort($history, SORT_NUMERIC); foreach ($history as $item_id) { if (get_post_type($item_id) == SI_Record::POST_TYPE) { $record = SI_Record::get_instance($item_id); // If no type is set than just keep on moving. if ($record->get_type() == SI_Record::DEFAULT_TYPE) { continue; } // filter these types of records out. if ($filtered) { if (in_array($record->get_type(), array(SI_Controller::PRIVATE_NOTES_TYPE, SI_Estimates::VIEWED_STATUS_UPDATE, SI_Notifications::RECORD))) { continue; } } $r_post = $record->get_post(); switch ($record->get_type()) { case SI_Controller::PRIVATE_NOTES_TYPE: $returned_history[$item_id]['type'] = __('Private Note', 'sprout-invoices'); break; case SI_Estimates::HISTORY_UPDATE: $returned_history[$item_id]['type'] = __('Updated', 'sprout-invoices'); break; case SI_Estimates::VIEWED_STATUS_UPDATE: $returned_history[$item_id]['type'] = __('Viewed', 'sprout-invoices'); break; case SI_Notifications::RECORD: $returned_history[$item_id]['type'] = __('Notification', 'sprout-invoices'); break; case SI_Estimates::HISTORY_INVOICE_CREATED: $returned_history[$item_id]['type'] = __('Invoice Created', 'sprout-invoices'); break; case SI_Estimate_Submissions::SUBMISSION_UPDATE: $returned_history[$item_id]['type'] = __('Submitted', 'sprout-invoices'); break; case SI_Importer::RECORD: $returned_history[$item_id]['type'] = __('Imported', 'sprout-invoices'); break; case SI_Estimates::HISTORY_STATUS_UPDATE: default: $returned_history[$item_id]['type'] = __('Status Update', 'sprout-invoices'); break; } $returned_history[$item_id]['status_type'] = $record->get_type(); $returned_history[$item_id]['post_date'] = $r_post->post_date; $returned_history[$item_id]['update_title'] = $r_post->post_title; $returned_history[$item_id]['content'] = $r_post->post_content; } elseif (get_post_type($item_id) == SI_Payment::POST_TYPE) { $payment = SI_Payment::get_instance($item_id); $p_post = $payment->get_post(); $returned_history[$item_id]['type'] = __('Payment', 'sprout-invoices'); $returned_history[$item_id]['status_type'] = 'payment'; $returned_history[$item_id]['post_date'] = $p_post->post_date; $returned_history[$item_id]['update_title'] = $p_post->post_title; $returned_history[$item_id]['content'] = ''; $returned_history[$item_id]['content'] .= '<span>' . $payment->get_payment_method() . '</span><br/>'; $returned_history[$item_id]['content'] .= '<b>' . __('Payment Total', 'sprout-invoices') . ':</b> ' . sa_get_formatted_money($payment->get_amount(), $item_id); } else { if ($filtered) { $comment = get_comment($item_id); if (!is_wp_error($comment)) { $returned_history[$item_id]['type'] = $comment->comment_author; $returned_history[$item_id]['status_type'] = 'comment'; $returned_history[$item_id]['post_date'] = $comment->comment_date; $returned_history[$item_id]['content'] = get_comment_text($comment->comment_ID); $returned_history[$item_id]['comment_id'] = intval($comment->comment_ID); } } } } return $returned_history; }
public static function create_payment($payment = array()) { if (!isset($payment['Invoice ID'])) { do_action('si_error', 'No Invoice ID given within payment import', $payment); return; } // Find the associated invoice $invoices = SI_Post_Type::find_by_meta(SI_Invoice::POST_TYPE, array(self::CSV_ID => $payment['Invoice ID'])); // Can't assign a payment without an invoice if (empty($invoices)) { do_action('si_error', 'No invoice found for this payment', $payment['Payment ID']); return; } $invoice = SI_Invoice::get_instance($invoices[0]); if (!is_a($invoice, 'SI_Invoice')) { return; } $payment_id = SI_Payment::new_payment(array('payment_method' => isset($payment['Payment Method']) ? $payment['Payment Method'] : self::PAYMENT_METHOD, 'invoice' => $invoice->get_id(), 'amount' => round($payment['Amount'], 2), 'transaction_id' => isset($payment['Payment ID']) ? $payment['Payment ID'] : '', 'data' => array('api_response' => $payment))); $new_payment = SI_Payment::get_instance($payment_id); $new_payment->set_post_date(date('Y-m-d H:i:s', strtotime($payment['Date']))); return $new_payment; }
// Add a progress bar to show table record collection. echo '<tr class="odd" id="progress_row"><td valign="top" colspan="8" class="dataTables_empty"><div id="rows_progress" style="width:100%;border:1px solid #ccc;"></div> <div id="table_progress">' . __('Preparing rows...', 'sprout-invoices') . '</div></td></tr>'; $records = new WP_Query($args); $i = 0; while ($records->have_posts()) { $records->the_post(); // Calculate the percentage $i++; $percent = intval($i / $records->found_posts * 100) . "%"; // Javascript for updating the progress bar and information echo '<script language="javascript" id="progress_js"> document.getElementById("rows_progress").innerHTML="<div style=\\"width:' . $percent . ';background-color:#ddd;\\"> </div>"; document.getElementById("table_progress").innerHTML="' . sprintf(__('%o records(s) of %o added.', 'sprout-invoices'), $i, $records->found_posts) . '"; document.getElementById("progress_js").remove(); </script>'; $payment = SI_Payment::get_instance(get_the_ID()); $invoice_id = $payment->get_invoice_id(); if ($payment->get_status() == SI_Payment::STATUS_VOID) { $table_voided_payment_total += $payment->get_amount(); $payment_total = 0; $payment_void_total = $payment->get_amount(); } else { $table_payment_total += $payment->get_amount(); $payment_total = $payment->get_amount(); $payment_void_total = 0; } $payment_link = sprintf('<a class="payments_link" title="%s" href="%s&s=%s">#%s</a>', __('Payment', 'sprout-invoices'), get_admin_url('', '/edit.php?post_type=sa_invoice&page=sprout-apps/invoice_payments'), get_the_ID(), get_the_ID()); $payments_link = sprintf('<a class="payments_link" title="%s" href="%s&s=%s">%s</a>', __('Invoice Payments', 'sprout-invoices'), get_admin_url('', '/edit.php?post_type=sa_invoice&page=sprout-apps/invoice_payments'), $invoice_id, sa_get_formatted_money(si_get_invoice_payments_total($invoice_id))); $invoice_name = $invoice_id ? sprintf('<a href="%s">%s</a>', get_edit_post_link($invoice_id), get_the_title($invoice_id)) : __('N/A', 'sprout-invoices'); $client_name = si_get_invoice_client_id($invoice_id) ? sprintf('<a href="%s">%s</a>', get_edit_post_link(si_get_invoice_client_id($invoice_id)), get_the_title(si_get_invoice_client_id($invoice_id))) : __('N/A', 'sprout-invoices'); ?>
/** * Process a payment * * @param SI_Checkouts $checkout * @param SI_Invoice $invoice * @return SI_Payment|bool false if the payment failed, otherwise a Payment object */ public function process_payment(SI_Checkouts $checkout, SI_Invoice $invoice) { $amount = isset($_POST['sa_checks_amount']) ? $_POST['sa_checks_amount'] : false; $number = isset($_POST['sa_checks_check_number']) ? $_POST['sa_checks_check_number'] : false; $date = isset($_POST['sa_checks_mailed']) ? $_POST['sa_checks_mailed'] : false; $notes = isset($_POST['sa_checks_notes']) ? $_POST['sa_checks_notes'] : ''; if (!isset($_POST['sa_checks_nonce']) || !wp_verify_nonce($_POST['sa_checks_nonce'], self::NONCE)) { return false; } if (!$amount) { return false; } // create new payment $payment_id = SI_Payment::new_payment(array('payment_method' => self::get_payment_method(), 'invoice' => $invoice->get_id(), 'amount' => $amount, 'transaction_id' => $number, 'data' => array('amount' => $amount, 'check_number' => $number, 'date' => strtotime($date), 'notes' => $notes)), SI_Payment::STATUS_PENDING); if (!$payment_id) { return false; } $payment = SI_Payment::get_instance($payment_id); if ($date != '') { $payment->set_post_date(date('Y-m-d H:i:s', strtotime($date))); } do_action('payment_pending', $payment); return $payment; }
/** * Process a payment * * @param SI_Checkouts $checkout * @param SI_Invoice $invoice * @return SI_Payment|bool false if the payment failed, otherwise a Payment object */ public function process_payment(SI_Checkouts $checkout, SI_Invoice $invoice) { $post_data = $this->nvp_data($checkout, $invoice); do_action('si_log', __CLASS__ . '::' . __FUNCTION__ . ' - PayPal WPP post_data', $post_data); $response = wp_safe_remote_post($this->get_api_url(), array('httpversion' => '1.1', 'body' => $post_data, 'timeout' => apply_filters('http_request_timeout', 30), 'sslverify' => false)); do_action('si_log', __CLASS__ . '::' . __FUNCTION__ . ' - PayPal WPP $response', $response); if (is_wp_error($response)) { return false; } if ($response['response']['code'] != '200') { return false; } $response = wp_parse_args(wp_remote_retrieve_body($response)); do_action('si_log', __CLASS__ . '::' . __FUNCTION__ . ' - PayPal EC Authorization Response (Parsed)', $response); if (strpos($response['ACK'], 'Success') !== 0) { $this->set_error_messages($response); return false; } if (strpos($response['ACK'], 'SuccessWithWarning') === 0) { $this->set_error_messages($response); } $payment_id = SI_Payment::new_payment(array('payment_method' => $this->get_payment_method(), 'invoice' => $invoice->get_id(), 'amount' => $response['AMT'], 'data' => array('live' => self::$api_mode == self::MODE_LIVE, 'api_response' => $response)), SI_Payment::STATUS_AUTHORIZED); if (!$payment_id) { return false; } $payment = SI_Payment::get_instance($payment_id); do_action('payment_authorized', $payment); $this->maybe_create_recurring_payment_profiles($checkout, $invoice, $payment); return $payment; }
public static function create_invoice_payment($payment = array(), SI_Invoice $invoice) { $possible_dups = SI_Post_Type::find_by_meta(SI_Payment::POST_TYPE, array(self::WPINVOICE_ID => $payment['ID'])); // Don't create a duplicate if this was already imported. if (!empty($possible_dups)) { do_action('si_error', 'Invoice imported already', $payment['ID']); return; } $payment_id = SI_Payment::new_payment(array('payment_method' => isset($payment['action']) ? self::PAYMENT_METHOD . ' :: ' . $payment['action'] : self::PAYMENT_METHOD, 'invoice' => $invoice->get_id(), 'amount' => $payment['value'], 'transaction_id' => isset($payment['ID']) ? $payment['object_id'] . '::' . $payment['ID'] : '', 'data' => array('api_response' => $payment))); $new_payment = SI_Payment::get_instance($payment_id); $new_payment->set_post_date(date('Y-m-d H:i:s', $payment['time'])); return $new_payment; }
public static function create_invoice_payment(Harvest_Payment $payment, SI_Invoice $invoice) { $possible_dups = SI_Post_Type::find_by_meta(SI_Payment::POST_TYPE, array(self::HARVEST_ID => $payment->id)); // Don't create a duplicate if this was already imported. if (!empty($possible_dups)) { do_action('si_error', 'Invoice imported already', $payment->id); return; } $payment_id = SI_Payment::new_payment(array('payment_method' => isset($payment->recorded_by) ? $payment->recorded_by : self::PAYMENT_METHOD, 'invoice' => $invoice->get_ID(), 'amount' => $payment->amount, 'transaction_id' => isset($payment->pay_pal_transaction_id) ? $payment->pay_pal_transaction_id : '', 'data' => array('api_response' => array('amount' => $payment->amount, 'authorization' => $payment->authorization, 'created_at' => $payment->created_at, 'id' => $payment->id, 'invoice_id' => $payment->invoice_id, 'paid_at' => $payment->paid_at, 'paypal_transaction_id' => $payment->pay_pal_transaction_id, 'payment_gateway_id' => $payment->payment_gateway_id, 'recorded_by' => $payment->recorded_by, 'recorded_by_email' => $payment->recorded_by_email, 'updated_at' => $payment->updated_at)))); $new_payment = SI_Payment::get_instance($payment_id); $new_payment->set_post_date(date('Y-m-d H:i:s', strtotime($payment->created_at))); return $new_payment; }
/** * Mark payment complete * * @return */ public static function manually_mark_complete() { if (!isset($_REQUEST['complete_payment_nonce'])) { self::ajax_fail('Forget something?'); } $nonce = $_REQUEST['complete_payment_nonce']; if (!wp_verify_nonce($nonce, self::AJAX_NONCE)) { self::ajax_fail('Not going to fall for it!'); } if (!current_user_can('manage_sprout_invoices_payments')) { return; } $payment_id = $_REQUEST['payment_id']; $payment = SI_Payment::get_instance($payment_id); $status = $payment->get_status(); if (!is_a($payment, 'SI_Payment')) { self::ajax_fail('Payment ID Error.'); } $payment->set_status(SI_Payment::STATUS_COMPLETE); if ($payment->get_status() != $status) { header('Content-type: application/json'); echo wp_json_encode(array('response' => si__('Payment status updated.'))); exit; } else { self::ajax_fail('Failed payment capture.'); } }
?> <?php if ($inv_payments = $invoice->get_payments()) { ?> <div class="si_payment_history"> <strong><?php _e('Payment History', 'sprout-invoices'); ?> </strong> <?php foreach ($inv_payments as $payment_id) { ?> <?php $payment = SI_Payment::get_instance($payment_id); $method = strpos(strtolower($payment->get_payment_method()), 'credit') !== false ? __('Credit Card', 'sprout-invoices') : $payment->get_payment_method(); ?> <small><?php printf(__('<b>%s:</b> %s', 'sprout-invoices'), $method, sa_get_formatted_money($payment->get_amount(), $invoice_id)); ?> </small> <?php } ?> </div> <?php } ?>
public static function send_client($client_id = 0, $event = '') { if ($event == '') { return; } $client = SI_Payment::get_instance($client_id); if (!is_a($client, 'SI_Client')) { return; } $zaps = self::get_zaps_by_event($event); if (empty($zaps)) { return; } $data = self::client_data($client); Zapier_API::send_zaps($zaps, $data); }
function column_data($item) { $payment_id = $item->ID; $payment = SI_Payment::get_instance($payment_id); $method = $payment->get_payment_method(); $data = $payment->get_data(); $detail = ''; if (is_array($data)) { foreach ($data as $key => $value) { if (is_array($value)) { $value = sprintf('<pre id="payment_detail_%s" style="width="500px"; white-space:pre-wrap; text-align: left; font: normal normal 11px/1.4 menlo, monaco, monospaced; padding: 5px;">%s</pre>', $payment_id, print_r($value, true)); } if (is_string($value)) { $detail .= '<dl> <dt><b>' . ucfirst(str_replace('_', ' ', $key)) . '</b></dt> <dd>' . $value . '</dd> </dl>'; } } } //Build row actions $actions = array('detail' => sprintf('<a href="#TB_inline?width=900&height=600&inlineId=data_id_%s" class="thickbox button" title="' . __('Transaction Data', 'sprout-invoices') . '">' . __('Transaction Data', 'sprout-invoices') . '</a><div id="data_id_%s" style="display:none;">%s</div>', $payment_id, $payment_id, $detail)); //Return the title contents return sprintf('%1$s %2$s', $method, $this->row_actions($actions)); }
public static function create_payment($payment) { $possible_dups = SI_Post_Type::find_by_meta(SI_Payment::POST_TYPE, array(self::FRESHBOOKS_ID => $payment['payment_id'])); // Don't create a duplicate if this was already imported. if (!empty($possible_dups)) { do_action('si_error', 'Invoice imported already', $payment['payment_id']); return; } // Find the associated invoice $invoices = SI_Post_Type::find_by_meta(SI_Invoice::POST_TYPE, array(self::FRESHBOOKS_ID => $payment['invoice_id'])); $invoice = SI_Invoice::get_instance($invoices[0]); $invoice_id = is_a($invoice, 'SI_Invoice') ? $invoice->get_id() : 0; // Can't assign a payment without an invoice if (!$invoice_id) { do_action('si_error', 'No invoice found for this payment', $payment['payment_id']); return; } $payment_id = SI_Payment::new_payment(array('payment_method' => isset($payment['type']) && !is_array($payment['type']) ? $payment['type'] : self::PAYMENT_METHOD, 'invoice' => $invoice_id, 'amount' => round($payment['amount'], 2), 'transaction_id' => isset($payment['payment_id']) ? $payment['payment_id'] : '', 'data' => array('api_response' => $payment))); $new_payment = SI_Payment::get_instance($payment_id); $new_payment->set_post_date(date('Y-m-d H:i:s', strtotime($payment['date']))); return $new_payment; }
/** * Process a payment * * @param SI_Checkouts $checkout * @param SI_Invoice $invoice * @return SI_Payment|bool FALSE if the payment failed, otherwise a Payment object */ public function process_payment(SI_Checkouts $checkout, SI_Invoice $invoice) { // Recurring if (si_is_invoice_recurring($invoice)) { $this->create_recurring_payment_plan($checkout, $invoice); $charge_reciept = $this->add_customer_to_plan($checkout, $invoice); } else { // default $charge_reciept = $this->charge_stripe($checkout, $invoice); } do_action('si_log', __CLASS__ . '::' . __FUNCTION__ . ' - Stripe Response', $charge_reciept); if (!$charge_reciept) { return false; } $payment_id = SI_Payment::new_payment(array('payment_method' => self::PAYMENT_METHOD, 'invoice' => $invoice->get_id(), 'amount' => self::convert_cents_to_money($charge_reciept['amount']), 'data' => array('live' => self::$api_mode == self::MODE_LIVE, 'api_response' => $charge_reciept)), SI_Payment::STATUS_AUTHORIZED); if (!$payment_id) { return false; } // Go through the routine and do the authorized actions and then complete. $payment = SI_Payment::get_instance($payment_id); do_action('payment_authorized', $payment); $payment->set_status(SI_Payment::STATUS_COMPLETE); do_action('payment_complete', $payment); // Return the payment return $payment; }