function espresso_display_2checkout($payment_data) { extract($payment_data); // Setup class include_once '2checkout.php'; echo '<!-- Event Espresso 2checkout Gateway Version ' . $twocheckout_gateway_version . '-->'; $my2checkout = new TwoCo(); // initiate an instance of the class global $org_options, $wpdb; //global $attendee_id; $twocheckout_settings = get_option('event_espresso_2checkout_settings'); $twocheckout_id = empty($twocheckout_settings['2checkout_id']) ? 0 : $twocheckout_settings['2checkout_id']; $twocheckout_username = empty($twocheckout_settings['2checkout_username']) ? '' : $twocheckout_settings['2checkout_username']; //$image_url = $2checkout_settings['button_url']; $twocheckout_cur = empty($twocheckout_settings['currency_format']) ? 'USD' : $twocheckout_settings['currency_format']; $no_shipping = empty($twocheckout_settings['no_shipping']) ? '' : $twocheckout_settings['no_shipping']; $use_sandbox = empty($twocheckout_settings['use_sandbox']) ? false : true; if ($use_sandbox) { // Enable test mode if needed $my2checkout->enableTestMode(); } $session_id = $wpdb->get_var("SELECT attendee_session FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id='" . $attendee_id . "'"); $sql = "SELECT ed.id, ed.event_name, ed.event_desc, ac.cost, ac.quantity FROM " . EVENTS_DETAIL_TABLE . " ed "; $sql .= " JOIN " . EVENTS_ATTENDEE_TABLE . " a ON ed.id=a.event_id "; $sql .= " JOIN " . EVENTS_ATTENDEE_COST_TABLE . " ac ON a.id=ac.attendee_id "; $sql .= " WHERE a.attendee_session='{$session_id}'"; $tickets = $wpdb->get_results($sql, ARRAY_A); $item_num = 1; foreach ($tickets as $ticket) { $my2checkout->addField('c_prod_' . $item_num, $ticket['id'] . ',' . $ticket['quantity']); $my2checkout->addField('c_name_' . $item_num, $ticket['event_name']); $my2checkout->addField('c_description_' . $item_num, ''); $my2checkout->addField('c_price_' . $item_num, $ticket['cost']); $item_num++; } $my2checkout->addField('id_type', '1'); $my2checkout->addField('sid', $twocheckout_id); $my2checkout->addField('cart_order_id', rand(1, 100)); if ($twocheckout_settings['force_ssl_return']) { $home = str_replace('http:', 'https:', home_url()); } else { $home = home_url(); } $my2checkout->addField('x_Receipt_Link_URL', str_replace('http:', 'https:', $home . '/?page_id=' . $org_options['return_url'] . '&id=' . $attendee_id . '®istration_id=' . $registration_id . '&event_id=' . $event_id . '&attendee_action=post_payment&form_action=payment&type=2co')); $my2checkout->addField('total', number_format($event_cost, 2, '.', '')); $my2checkout->addField('tco_currency', $twocheckout_cur); //Enable this function if you want to send payment notification before the person has paid. //This function is copied on the payment processing page //event_espresso_send_payment_notification($attendee_id, $txn_id, $amount_pd); //Decide if you want to auto redirect to your payment website or display a payment button. if (!empty($twocheckout_settings['bypass_payment_page']) && $twocheckout_settings['bypass_payment_page'] == 'Y') { $my2checkout->submitPayment(); //Enable auto redirect to payment site } else { if (empty($twocheckout_settings['button_url'])) { if (file_exists(EVENT_ESPRESSO_GATEWAY_DIR . "2checkout/logo.png")) { $button_url = EVENT_ESPRESSO_GATEWAY_URL . "2checkout/logo.png"; } else { $button_url = EVENT_ESPRESSO_PLUGINFULLURL . "gateways/2checkout/logo.png"; } } elseif (file_exists($twocheckout_settings['button_url'])) { $button_url = $twocheckout_settings['button_url']; } else { //If no other buttons exist, then use the default location $button_url = EVENT_ESPRESSO_PLUGINFULLURL . "gateways/2checkout/logo.png"; } $my2checkout->submitButton($button_url, '2checkout'); //Display payment button wp_deregister_script('jquery.validate.pack'); } if ($use_sandbox) { echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __(' 2checkout.com Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $my2checkout->dump_fields(); // for debugging, output a table of all the fields } }
// product/plan id $total = $_POST['amount'] + $_POST['tax']; // cost + taxes = total cost $tco_currency = $_POST['currency_code']; // currency $custom = $_POST['custom']; // transaction id for daloradius $item_name = $_POST['item_name']; // name of the product that is puchased $quantity = $_POST['quantity']; // quantity $product_id = $_POST['product_id']; // Include the 2checkout library include_once 'include/merchant/TwoCo.php'; // Create an instance of the authorize.net library $my2CO = new TwoCo(); // Specify your 2CheckOut vendor id $my2CO->addField('sid', $sid); // Specify the order information $my2CO->addField('cart_order_id', $cart_order_id); $my2CO->addField('total', $total); $my2CO->addField('tco_currency', $tco_currency); $my2CO->addField('custom', $custom); $my2CO->addField('x_email_merchant', 'true'); $my2CO->addField('c_name_1', $item_name); $my2CO->addField('product_id', $product_id); $my2CO->addField('c_prod1', $product_id); $my2CO->addField('quantity1', $quantity); // Specify the url where authorize.net will send the IPN $my2CO->addField('x_Receipt_Link_URL', $configValues['CONFIG_MERCHANT_IPN_URL_ROOT'] . "/" . $configValues['CONFIG_MERCHANT_IPN_URL_RELATIVE_DIR']); // Enable test mode if needed
/** * User::pay_new() * * New payment * * @access public * @param int $id User ID * @param int $gate_id Gateway ID * @return void */ public function pay_new($id = '', $gate_id = '') { if (intval($id) == 0 or intval($gate_id) == 0) { show_404(); } $user = $this->db->get_where('users', array('id' => $id))->row(); if (!$user or $user->status != 0) { show_404(); } $group = $this->db->get_where('groups', array('id' => $user->group))->row(); if (!$group) { show_404(); } $gate = $this->db->get_where('gateways', array('id' => $gate_id))->row(); if (!$gate) { show_404(); } // get payment gateway settings $gate_conf = unserialize($gate->settings); // load payment libs include_once APPPATH . 'libraries/payment/PaymentGateway.php'; // which payment system to use? if ($gate->name == 'paypal') { // Include the paypal library include_once APPPATH . 'libraries/payment/Paypal.php'; // Create an instance of the paypal library $my_paypal = new Paypal(); // Specify your paypal email $my_paypal->add_field('business', $gate_conf['email']); // Specify the currency $my_paypal->add_field('currency_code', $gate_conf['currency']); // Specify the url where paypal will send the user on success/failure $my_paypal->add_field('return', site_url('user/pay_complete')); $my_paypal->add_field('cancel_return', site_url('user/pay_cancel')); // Specify the url where paypal will send the IPN $my_paypal->add_field('notify_url', site_url('payment/ipn/paypal')); // Specify the product information $my_paypal->add_field('item_name', $this->startup->site_config->sitename . ' ' . lang('Account Registration')); $my_paypal->add_field('amount', $group->price); $my_paypal->add_field('item_number', rand(1, 1000) . '-' . $user->id); // Specify any custom value $my_paypal->add_field('custom', base64_encode(json_encode(array('user_id' => $user->id, 'type' => 'reg')))); // Enable test mode if needed if (defined('XUDEBUG') and XUDEBUG == true) { $my_paypal->enable_test_mode(); } // Let's start the train! $data['form'] = $my_paypal->submit_payment(lang('If you are not automatically redirected to payment website within 5 seconds,<br> click \'Make Payment\' below to begin the payment procedure.')); } else { if ($gate->name == 'authorize') { // Include the paypal library include_once APPPATH . 'libraries/payment/Authorize.php'; // Create an instance of the authorize.net library $my_authorize = new Authorize(); // Specify your authorize.net login and secret $my_authorize->set_user_info($gate_conf['login'], $gate_conf['secret']); // Specify the url where authorize.net will send the user on success/failure $my_authorize->add_field('x_Receipt_Link_URL', site_url('user/pay_complete')); // Specify the url where authorize.net will send the IPN $my_authorize->add_field('x_Relay_URL', site_url('payment/ipn/authorize')); // Specify the product information $my_authorize->add_field('x_Description', $this->startup->site_config->sitename . ' ' . lang('Account Registration')); $my_authorize->add_field('x_Amount', $group->price); $my_authorize->add_field('x_Invoice_num', rand(1, 1000) . '-' . $user->id); $my_authorize->add_field('x_Cust_ID', base64_encode(json_encode(array('user_id' => $user->id, 'type' => 'reg')))); // Enable test mode if needed if (defined('XUDEBUG') and XUDEBUG == true) { $my_authorize->enable_test_mode(); } // Let's start the train! $data['form'] = $my_authorize->submit_payment(lang('If you are not automatically redirected to payment website within 5 seconds,<br> click \'Make Payment\' below to begin the payment procedure.')); } else { if ($gate->name = '2co') { // Include the paypal library include_once APPPATH . 'libraries/payment/TwoCo.php'; // Create an instance of the authorize.net library $my2_co = new TwoCo(); // Specify your 2CheckOut vendor id $my2_co->add_field('sid', $gate_conf['vendor_id']); // Specify the order information $my2_co->add_field('cart_order_id', rand(1, 1000) . '-' . $user->id); $my2_co->add_field('total', $group->price); // Specify the url where authorize.net will send the IPN $my2_co->add_field('x_Receipt_Link_URL', site_url('payment/ipn/two_checkout')); $my2_co->add_field('tco_currency', $gate_conf['currency']); $my2_co->add_field('custom', base64_encode(json_encode(array('user_id' => $user->id, 'type' => 'reg')))); // Enable test mode if needed if (defined('XUDEBUG') and XUDEBUG == true) { $my2_co->enable_test_mode(); } // Let's start the train! $data['form'] = $my2_co->submit_payment(lang('If you are not automatically redirected to payment website within 5 seconds,<br> click \'Make Payment\' below to begin the payment procedure.')); } } } $this->load->view($this->startup->skin . '/header', array('header_title' => lang('Make Payment'))); $this->load->view($this->startup->skin . '/user/register/pay_new', array('ammount' => $group, 'user' => $id, 'form' => $data['form'])); $this->load->view($this->startup->skin . '/footer'); }
/** * Ipn::two_checkout() * * Validate Two Checkout payments * * @access public * @return void */ public function two_checkout() { // Include the paypal library include_once APPPATH . 'libraries/payment/TwoCo.php'; $this->_gateway = 3; $gate = $this->db->get_where('gateways', array('name' => 'twoco'))->row(); $gate_conf = json_decode($gate->settings); // Create an instance of the authorize.net library $my2_co = new TwoCo(); // Log the IPN results // $my2_co->ipn_log = TRUE; // Specify your authorize login and secret $my2_co->set_secret($gate_conf['secret_id']); // Enable test mode if needed $my2_co->enable_test_mode(); // Check validity and write down it if ($my2_co->validate_ipn()) { $settings = json_decode(base64_decode($my2_co->ipn_data['custom'])); if ($settings['type'] == 'reg') { $this->_new_user_payment($settings['user_id'], $my2_co->ipn_data['total']); redirect('/user/pay_complete'); } redirect('/user/pay_cancel'); } else { $this->_log_error($my2_co->ipn_data); redirect('/user/pay_cancel'); } }
* You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ********************************************************************************************************* * * Authors: Liran Tal <*****@*****.**> * ********************************************************************************************************* */ // Include the 2checkout library include_once 'include/merchant/TwoCo.php'; include_once 'include/common/common.php'; include 'library/config_read.php'; // Create an instance of the 2Checkout library $my2CO = new TwoCo(); // Log the IPN results // $my2CO->ipnLog = TRUE; // Specify your 2Checkout login and secret $my2CO->setSecret($configValues['CONFIG_MERCHANT_IPN_SECRET']); // Enable test mode if needed $my2CO->enableTestMode(); // Check validity and write it down. if ($my2CO->validateIpn()) { $logFile = $configValues['CONFIG_LOG_MERCHANT_IPN_FILENAME']; logToFile("\n", $logFile); saveToDb($my2CO->ipnData, "Completed"); include 'library/opendb.php'; require_once 'include/common/provisionUser.php'; // the payment is valid, we activate the user by adding him to freeradius's set of tables (radcheck etc) // get transaction id from 2checkout ipn POST
<?php // Include the paypal library include_once 'TwoCo.php'; // Create an instance of the authorize.net library $my2CO = new TwoCo(); // Log the IPN results $my2CO->ipnLog = TRUE; // Specify your authorize login and secret $my2CO->setSecret('YOUR_SECRET_KEY'); // Enable test mode if needed $my2CO->enableTestMode(); // Check validity and write down it if ($my2CO->validateIpn()) { file_put_contents('2co.txt', 'SUCCESS'); } else { file_put_contents('2co.txt', "FAILURE\n\n" . $my2CO->ipnData); }
<?php // Include the paypal library include_once 'TwoCo.php'; // Create an instance of the authorize.net library $my2CO = new TwoCo(); // Log the IPN results $my2CO->ipnLog = TRUE; // Specify your authorize login and secret $my2CO->setSecret('tango'); // Enable test mode if needed $my2CO->enableTestMode(); // Check validity and write down it if ($my2CO->validateIpn()) { file_put_contents('2co.txt', 'SUCCESS'); } else { file_put_contents('2co.txt', "FAILURE\n\n" . $my2CO->ipnData); }
<?php include_once '../../../wp-load.php'; include_once 'lib/gateway/TwoCo.php'; include_once 'eStore_process_payment_data.php'; $my2CO = new TwoCo(); // Log the INS results $debug_on = get_option('eStore_cart_enable_debug'); if ($debug_on) { $my2CO->ipnLog = TRUE; } // Specify your 2co login and secret $tco_secret_word = get_option('eStore_2co_secret_word'); $my2CO->setSecret($tco_secret_word); // Enable test mode if needed if (get_option('eStore_cart_enable_sandbox')) { $my2CO->enableTestMode(); } // Check validity and write down it if ($my2CO->validateIpn()) { $txn_id = $my2CO->ipnData['invoice_id']; if (eStore_txn_prcoessed($txn_id)) { eStore_do_thank_you_page_display_tasks_with_txn_id($txn_id); } else { handle_payment_data($my2CO->ipnData, "2co"); } } else { handle_payment_data($my2CO->ipnData, "2co"); }
<?php // Include the paypal library include_once 'TwoCo.php'; // Create an instance of the authorize.net library $my2CO = new TwoCo(); // Specify your 2CheckOut vendor id $my2CO->addField('sid', '1234'); // Specify the order information $my2CO->addField('cart_order_id', rand(1, 100)); $my2CO->addField('total', '9.99'); // Specify the url where authorize.net will send the IPN $my2CO->addField('x_Receipt_Link_URL', 'https://localhost/signup-paypal/paypal-ipn.php'); $my2CO->addField('tco_currency', 'USD'); $my2CO->addField('custom', 'muri'); // Enable test mode if needed $my2CO->enableTestMode(); // Let's start the train! $my2CO->submitPayment();
function submit_to_2co() { $eStore_default_currency = get_option('cart_payment_currency'); $eStore_return_url = get_option('cart_return_from_paypal_url'); $eStore_sandbox_enabled = get_option('eStore_cart_enable_sandbox'); $my2CO = new TwoCo(); // Specify your 2CheckOut vendor id $vendor_id = get_option('eStore_2co_vendor_id'); $my2CO->addField('sid', $vendor_id); if (!empty($eStore_default_currency)) { $tco_currency = $eStore_default_currency; } else { $tco_currency = 'USD'; } $my2CO->addField('tco_currency', $tco_currency); //use list_currency // Save the order details $uniqueId = uniqid(); eStore_save_order_details($uniqueId); // Specify the order information $my2CO->addField('id_type', '1'); $my2CO->addField('cart_order_id', $uniqueId); // ======================= global $wpdb; $products_table_name = WP_ESTORE_PRODUCTS_TABLE_NAME; $count = 1; $total = 0; foreach ($_SESSION['eStore_cart'] as $item) { $id = $item['item_number']; $ret_product = $wpdb->get_row("SELECT * FROM {$products_table_name} WHERE id = '{$id}'", OBJECT); $rounded_price = round($item['price'], 2); $my2CO->addField("c_name_{$count}", htmlspecialchars($item['name'])); $my2CO->addField("c_description_{$count}", htmlspecialchars($item['name'])); $my2CO->addField("c_price_{$count}", $rounded_price); //$my2CO->addField("quantity_$count", $item['quantity']); //$my2CO->addField("c_prod_$count", $item['item_number']); $my2CO->addField("c_prod_{$count}", $item['item_number'] . ',' . $item['quantity']); if (empty($item['shipping'])) { $my2CO->addField("c_tangible_{$count}", 'N'); } else { $my2CO->addField("c_tangible_{$count}", 'Y'); } $total += $rounded_price * $item['quantity']; $count++; } //Specify the url where 2CO will return the custoemr after payment $total_items_in_cart = count($_SESSION['eStore_cart']); if ($total_items_in_cart == 1 && !empty($ret_product->return_url)) { $my2CO->addField('return_url', $ret_product->return_url); } else { if (!empty($eStore_return_url)) { $my2CO->addField('return_url', $eStore_return_url); } } if ($_SESSION['eStore_cart_postage_cost'] > 0) { $rounded_shipping = round($_SESSION['eStore_cart_postage_cost'], 2); $my2CO->addField("c_name_{$count}", "Shipping"); $my2CO->addField("c_description_{$count}", "Shipping"); $my2CO->addField("c_price_{$count}", $rounded_shipping); $my2CO->addField("c_prod_{$count}", "SHIPPING" . ',' . "1"); } $grand_total = $total + $rounded_shipping + $_SESSION['eStore_cart_total_tax']; $grand_total = round($grand_total, 2); $my2CO->addField('total', $grand_total); //$my2CO->addField('sh_cost', $_SESSION['eStore_cart_postage_cost']); //======================== //$my2CO->addField('pay_method', "CC"); //$my2CO->addField('skip_landing', "1"); //======================== if (get_option('eStore_auto_product_delivery') != '') { $notify = WP_ESTORE_URL . '/eStore_2co_ipn.php'; $my2CO->addField('x_Receipt_Link_URL', $notify); } $custom_field_val = eStore_get_custom_field_value(); $my2CO->addField('custom', $custom_field_val); // Enable test mode if needed if ($eStore_sandbox_enabled) { $my2CO->enableTestMode(); } // Lets clear the cart reset_eStore_cart(); $my2CO->submitPayment2(WP_ESTORE_CLICK_HERE); }
<?php // Include the paypal library include_once 'TwoCo.php'; // Create an instance of the authorize.net library $my2CO = new TwoCo(); // Specify your 2CheckOut vendor id $my2CO->addField('sid', 'YOUR_VENDOR_ID'); // Specify the order information $my2CO->addField('cart_order_id', rand(1, 100)); $my2CO->addField('total', '9.99'); // Specify the url where authorize.net will send the IPN $my2CO->addField('x_Receipt_Link_URL', 'http://YOUR_HOST/payment/twoco_ipn.php'); $my2CO->addField('tco_currency', 'USD'); $my2CO->addField('custom', 'muri'); // Enable test mode if needed $my2CO->enableTestMode(); // Let's start the train! $my2CO->submitPayment();