/** * Process gateway */ public static function process_gateway() { if (filter_has_var(INPUT_POST, 'event_espresso_pronamic_ideal')) { $config_id = get_option(self::OPTION_CONFIG_ID); $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id); if ($gateway) { $payment_data = array('attendee_id' => apply_filters('filter_hook_espresso_transactions_get_attendee_id', '')); $data = new Pronamic_WP_Pay_Extensions_EventEspressoLegacy_PaymentData($payment_data); $payment = Pronamic_WP_Pay_Plugin::start($config_id, $gateway, $data); $error = $gateway->get_error(); if (is_wp_error($error)) { Pronamic_WP_Pay_Plugin::render_errors($error); } else { $gateway->redirect($payment); } } } }
/** * Initialize */ public function init() { global $pronamic_pay_errors; $pronamic_pay_errors = array(); if (filter_has_var(INPUT_POST, 'pronamic_pay_nonce')) { $nonce = filter_input(INPUT_POST, 'pronamic_pay_nonce', FILTER_SANITIZE_STRING); if (wp_verify_nonce($nonce, 'pronamic_pay')) { $id = filter_input(INPUT_POST, 'pronamic_pay_form_id', FILTER_VALIDATE_INT); $config_id = get_post_meta($id, '_pronamic_payment_form_config_id', true); $valid = $this->validate(); if ($valid) { $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id); if ($gateway) { $data = new Pronamic_WP_Pay_PaymentFormData(); $payment = Pronamic_WP_Pay_Plugin::start($config_id, $gateway, $data); $error = $gateway->get_error(); if (is_wp_error($error)) { Pronamic_WP_Pay_Plugin::render_errors($error); } else { // @see https://github.com/WordImpress/Give/blob/1.1/includes/payments/functions.php#L172-L178 // @see https://github.com/woothemes/woocommerce/blob/2.4.3/includes/wc-user-functions.php#L36-L118 $first_name = filter_input(INPUT_POST, 'pronamic_pay_first_name', FILTER_SANITIZE_STRING); $last_name = filter_input(INPUT_POST, 'pronamic_pay_last_name', FILTER_SANITIZE_STRING); $email = filter_input(INPUT_POST, 'pronamic_pay_email', FILTER_VALIDATE_EMAIL); $user = get_user_by('email', $email); if (!$user) { // Make a random string for password $password = wp_generate_password(10); // Make a user with the username as the email $user_id = wp_insert_user(array('user_login' => $email, 'user_pass' => $password, 'user_email' => $email, 'role' => 'payer', 'first_name' => $first_name, 'last_name' => $last_name)); // User $user = new WP_User($user_id); } wp_update_post(array('ID' => $payment->post->ID, 'post_author' => $user->ID)); $gateway->redirect($payment); } exit; } } } } }
/** * Submit to gateway */ public function submit() { $config_id = get_option(Pronamic_WP_Pay_Extensions_WPeCommerce_Extension::OPTION_IDEAL_CONFIG_ID); // Set process to 'order_received' (2) // @see http://plugins.trac.wordpress.org/browser/wp-e-commerce/tags/3.8.7.6.2/wpsc-includes/merchant.class.php#L301 // @see http://plugins.trac.wordpress.org/browser/wp-e-commerce/tags/3.8.7.6.2/wpsc-core/wpsc-functions.php#L115 $this->set_purchase_processed_by_purchid(Pronamic_WP_Pay_Extensions_WPeCommerce_WPeCommerce::PURCHASE_STATUS_ORDER_RECEIVED); $gateway = Pronamic_WP_Pay_Plugin::get_gateway($config_id); if ($gateway) { $data = new Pronamic_WP_Pay_Extensions_WPeCommerce_PaymentData($this); $payment_method = Pronamic_WP_Pay_PaymentMethods::IDEAL; $gateway->set_payment_method($payment_method); $payment = Pronamic_WP_Pay_Plugin::start($config_id, $gateway, $data, $payment_method); update_post_meta($payment->get_id(), '_pronamic_payment_wpsc_purchase_id', $data->get_purchase_id()); update_post_meta($payment->get_id(), '_pronamic_payment_wpsc_session_id', $data->get_session_id()); $error = $gateway->get_error(); if (is_wp_error($error)) { Pronamic_WP_Pay_Plugin::render_errors($error); } else { $gateway->redirect($payment); } } }
/** * Maybe test payment */ public function maybe_test_payment() { if (filter_has_var(INPUT_POST, 'test_pay_gateway') && check_admin_referer('test_pay_gateway', 'pronamic_pay_test_nonce')) { $id = filter_input(INPUT_POST, 'post_ID', FILTER_SANITIZE_NUMBER_INT); $gateway = Pronamic_WP_Pay_Plugin::get_gateway($id); if ($gateway) { $amount = filter_input(INPUT_POST, 'test_amount', FILTER_VALIDATE_FLOAT, array('flags' => FILTER_FLAG_ALLOW_THOUSAND, 'options' => array('decimal' => pronamic_pay_get_decimal_separator()))); $data = new Pronamic_WP_Pay_PaymentTestData(wp_get_current_user(), $amount); $payment = Pronamic_WP_Pay_Plugin::start($id, $gateway, $data); $error = $gateway->get_error(); if (is_wp_error($error)) { Pronamic_WP_Pay_Plugin::render_errors($error); } else { $gateway->redirect($payment); } exit; } } }
/** * Order success * * In Shopp version 1.1.9 the 'shopp_order_success' the purchase is given as first parameter, * in Shopp version 1.2+ the 'shopp_order_success' the purchase is not passed as parameter anymore */ public function order_success($purchase = null) { // Check if the purchases is passed as first parameter, if not we // will load the purchase from the global Shopp variable if (empty($purchase)) { global $Shopp; $purchase = $Shopp->Purchase; } // Check gateway $gateway = Pronamic_WP_Pay_Plugin::get_gateway($this->config_id); if ($gateway) { $gateway->set_payment_method($this->payment_method); $data = new Pronamic_WP_Pay_Extensions_Shopp_PaymentData($purchase, $this); $payment = Pronamic_WP_Pay_Plugin::start($this->config_id, $gateway, $data, $this->payment_method); $error = $gateway->get_error(); if (is_wp_error($error)) { Pronamic_WP_Pay_Plugin::render_errors($error); exit; } else { $gateway->redirect($payment); } } }
/** * Check if an iDEAL payment needs to be processed. */ public static function process_payment() { $do_process_payment = filter_input(INPUT_POST, 'pronamic_ideal_process_payment', FILTER_SANITIZE_STRING); if (strlen($do_process_payment) <= 0) { return; } // Prepare transaction data $unique_hash = it_exchange_create_unique_hash(); $current_customer = it_exchange_get_current_customer(); $transaction_object = it_exchange_generate_transaction_object(); if (!$transaction_object instanceof stdClass) { return; } it_exchange_add_transient_transaction(self::$slug, $unique_hash, $current_customer->ID, $transaction_object); $configuration_id = self::get_gateway_configuration_id(); $gateway = Pronamic_WP_Pay_Plugin::get_gateway($configuration_id); if ($gateway) { $data = new Pronamic_WP_Pay_Extensions_IThemesExchange_PaymentData($unique_hash, $transaction_object); $payment_method = self::get_gateway_payment_method(); $gateway->set_payment_method($payment_method); $payment = Pronamic_WP_Pay_Plugin::start($configuration_id, $gateway, $data, $payment_method); $error = $gateway->get_error(); if (is_wp_error($error)) { Pronamic_WP_Pay_Plugin::render_errors($error); } else { $gateway->redirect($payment); } exit; } }