if (!isset($_REQUEST['sa_metabox_payments_nonce'])) { self::ajax_fail('Forget something?'); } $nonce = $_REQUEST['sa_metabox_payments_nonce']; if (!wp_verify_nonce($nonce, SI_Controller::NONCE)) { self::ajax_fail('Not going to fall for it!'); } if (!isset($_REQUEST['sa_metabox_invoice_id'])) { self::ajax_fail('Forget something?'); } if (get_post_type($_REQUEST['sa_metabox_invoice_id']) != SI_Invoice::POST_TYPE) { self::ajax_fail('Error: Invoice PT mismatch.'); } $amount = isset($_REQUEST['sa_metabox_payment_amount']) ? $_REQUEST['sa_metabox_payment_amount'] : 0; $number = isset($_REQUEST['sa_metabox_payment_transaction_id']) ? $_REQUEST['sa_metabox_payment_transaction_id'] : ''; $date = isset($_REQUEST['sa_metabox_payment_date']) ? $_REQUEST['sa_metabox_payment_date'] : ''; $notes = isset($_REQUEST['sa_metabox_payment_notes']) ? $_REQUEST['sa_metabox_payment_notes'] : ''; if (!$amount) { self::ajax_fail('No payment amount set.'); } self::create_admin_payment($_REQUEST['sa_metabox_invoice_id'], $amount, $number, $date, $notes); header('Content-type: application/json'); if (self::DEBUG) { header('Access-Control-Allow-Origin: *'); } echo wp_json_encode(array('response' => si__('Payment Added'))); exit; } } SI_Admin_Payment::init(); // Since it's not a registered payment processor, init it when file is loaded.