function espresso_display_worldpay($payment_data) { extract($payment_data); include_once 'Worldpay.php'; global $wpdb, $org_options; $myworldpay = new Espresso_Worldpay(); // initiate an instance of the class echo '<!-- Event Espresso WorldPay Gateway Version ' . $myworldpay->worldpay_gateway_version . '-->'; $worldpay_settings = get_option('event_espresso_worldpay_settings'); $use_sandbox = $worldpay_settings['use_sandbox']; if ($use_sandbox) { $myworldpay->enableTestMode(); } if ($use_sandbox) { // Enable test mode if needed $myworldpay->addField('testMode', '100'); } $myworldpay->addField('instId', $worldpay_settings['worldpay_id']); $myworldpay->addField('cartId', 'wp-' . event_espresso_session_id()); $myworldpay->addField('amount', $event_cost); $myworldpay->addField('MC_id', $attendee_id); $myworldpay->addField('MC_registration_id', $registration_id); //$myworldpay->addField('MC_session_id', session_id()); $myworldpay->addField('MC_type', 'worldpay'); $myworldpay->addField('currency', $worldpay_settings['currency_format']); $myworldpay->addField('MC_callback', get_permalink($org_options['return_url'])); if (!empty($worldpay_settings['bypass_payment_page'])) { $myworldpay->submitPayment(); //Enable auto redirect to payment site } else { $button_url = espresso_select_button_for_display($worldpay_settings['button_url'], "worldpay/worldpay-logo.png"); $myworldpay->submitButton($button_url, 'worldpay'); //Display payment button } if ($use_sandbox) { echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('WorldPay Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $myworldpay->dump_fields(); // for debugging, output a table of all the fields } }
function espresso_display_paypal($payment_data) { global $wpdb; extract($payment_data); include_once 'Paypal.php'; $myPaypal = new EE_Paypal(); echo '<!-- Event Espresso PayPal Gateway Version ' . $myPaypal->gateway_version . '-->'; global $org_options; $paypal_settings = get_option('event_espresso_paypal_settings'); //Check for an alternate PayPal email address if (isset($event_meta['paypal_email']) && !empty($event_meta['paypal_email']) && filter_var($event_meta['paypal_email'], FILTER_VALIDATE_EMAIL) != FALSE) { //Alternate PayPal email - using the paypal meta key field. $paypal_id = $event_meta['paypal_email']; } else { $paypal_id = empty($paypal_settings['paypal_id']) ? '' : $paypal_settings['paypal_id']; } $paypal_cur = empty($paypal_settings['currency_format']) ? '' : $paypal_settings['currency_format']; $no_shipping = isset($paypal_settings['no_shipping']) ? $paypal_settings['no_shipping'] : '0'; $use_sandbox = $paypal_settings['use_sandbox']; if ($use_sandbox) { $myPaypal->enableTestMode(); } do_action('action_hook_espresso_use_add_on_functions'); // get attendee_session $SQL = "SELECT attendee_session FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id=%d"; $session_id = $wpdb->get_var($wpdb->prepare($SQL, $attendee_id)); // now get all registrations for that session $SQL = "SELECT a.final_price, a.orig_price, a.quantity, ed.event_name, a.price_option, a.fname, a.lname "; $SQL .= " FROM " . EVENTS_ATTENDEE_TABLE . " a "; $SQL .= " JOIN " . EVENTS_DETAIL_TABLE . " ed ON a.event_id=ed.id "; $SQL .= " WHERE attendee_session=%s ORDER BY a.id ASC"; $items = $wpdb->get_results($wpdb->prepare($SQL, $session_id)); //printr( $items, '$items <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); foreach ($items as $key => $item) { $item_num = $key + 1; $myPaypal->addField('item_name_' . $item_num, $item->price_option . ' for ' . $item->event_name . '. Attendee: ' . $item->fname . ' ' . $item->lname); $myPaypal->addField('quantity_' . $item_num, absint($item->quantity)); if ($item->final_price < $item->orig_price) { $adjustment = abs($item->orig_price - $item->final_price); if (absint($item->quantity) > 1) { $adjustment = $adjustment * absint($item->quantity); } $myPaypal->addField('amount_' . $item_num, $item->orig_price); $myPaypal->addField('discount_amount_' . $item_num, $adjustment); //$myPaypal->addField('discount_amount2_' . $item_num, $adjustment);//Not sure this line is needed. } else { $myPaypal->addField('amount_' . $item_num, $item->final_price); } if (isset($paypal_settings['tax_override']) && $paypal_settings['tax_override'] == true) { $myPaypal->addField('tax_' . $item_num, '0.00'); } if (isset($paypal_settings['shipping_override']) && $paypal_settings['shipping_override'] == true) { $myPaypal->addField('shipping_' . $item_num, '0.00'); } } //printr( $myPaypal, '$myPaypal <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' ); $myPaypal->addField('business', $paypal_id); if ($paypal_settings['force_ssl_return']) { $home = str_replace("http://", "https://", home_url()); } else { $home = home_url(); } $myPaypal->addField('charset', "utf-8"); $myPaypal->addField('return', $home . '/?page_id=' . $org_options['return_url'] . '&r_id=' . $registration_id . '&type=paypal'); $myPaypal->addField('cancel_return', $home . '/?page_id=' . $org_options['cancel_return']); $myPaypal->addField('notify_url', $home . '/?page_id=' . $org_options['notify_url'] . '&id=' . $attendee_id . '&r_id=' . $registration_id . '&event_id=' . $event_id . '&attendee_action=post_payment&form_action=payment&type=paypal'); $event_name = $wpdb->get_var('SELECT event_name FROM ' . EVENTS_DETAIL_TABLE . " WHERE id='" . $event_id . "'"); $myPaypal->addField('cmd', '_cart'); $myPaypal->addField('upload', '1'); $myPaypal->addField('currency_code', $paypal_cur); $myPaypal->addField('image_url', empty($paypal_settings['image_url']) ? '' : $paypal_settings['image_url']); $myPaypal->addField('no_shipping ', $no_shipping); $myPaypal->addField('first_name', $fname); $myPaypal->addField('last_name', $lname); $myPaypal->addField('email', $attendee_email); $myPaypal->addField('address1', $address); $myPaypal->addField('city', $city); $myPaypal->addField('state', $state); $myPaypal->addField('zip', $zip); if (!empty($paypal_settings['bypass_payment_page']) && $paypal_settings['bypass_payment_page'] == 'Y') { $myPaypal->submitPayment(); } else { $button_url = espresso_select_button_for_display($paypal_settings['button_url'], "paypal/btn_stdCheckout2.gif"); $myPaypal->submitButton($button_url, 'paypal'); } if ($use_sandbox) { echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('PayPal Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $myPaypal->dump_fields(); } }
function espresso_display_exact($payment_data) { extract($payment_data); // Setup class include_once 'Exact.php'; global $org_options; $myExact = new Espresso_Exact(); // initiate an instance of the class echo '<!--Event Espresso Exact.com Gateway Version ' . $myExact->gateway_version . '-->'; $exact_settings = get_option('event_espresso_exact_settings'); $exact_login_id = empty($exact_settings['exact_login_id']) ? '' : $exact_settings['exact_login_id']; $exact_transaction_key = empty($exact_settings['exact_transaction_key']) ? '' : $exact_settings['exact_transaction_key']; $button_type = empty($exact_settings['button_type']) ? '' : $exact_settings['button_type']; //$button_url = $exact_settings['button_url']; $image_url = empty($exact_settings['image_url']) ? '' : $exact_settings['image_url']; $use_sandbox = $exact_settings['use_sandbox']; $use_testmode = $exact_settings['test_transactions']; if ($use_testmode == true) { // Enable test mode if needed $myExact->enableTestMode(); } if ($use_sandbox) { // Enable test mode if needed $myExact->useTestServer(); } $quantity = isset($quantity) && $quantity > 0 ? $quantity : espresso_count_attendees_for_registration($attendee_id); $myExact->setUserInfo($exact_login_id, $exact_transaction_key); $myExact->addField('x_amount', number_format($event_cost, 2)); $myExact->addField('x_show_form', 'PAYMENT_FORM'); $myExact->addField('registration_id', $registration_id); $myExact->addField('x_relay_response', 'TRUE'); if ($exact_settings['force_ssl_return']) { $home = str_replace("http://", "https://", home_url()); } else { $home = home_url(); } $myExact->addField('x_relay_url', $home . '/?type=exact&page_id=' . $org_options['return_url']); $myExact->addField('x_description', stripslashes_deep($event_name) . ' | ' . __('Reg. ID:', 'event_espresso') . ' ' . $attendee_id . ' | ' . __('Name:', 'event_espresso') . ' ' . stripslashes_deep($fname . ' ' . $lname) . ' | ' . __('Total Registrants:', 'event_espresso') . ' ' . $quantity); $myExact->addField('x_logo_url', $image_url); $myExact->addField('x_invoice_num', event_espresso_session_id()); //Post variables $myExact->addField('x_cust_id', $attendee_id); $myExact->addField('x_first_name', $fname); $myExact->addField('x_last_name', $lname); $myExact->addField('x_email', $attendee_email); $myExact->addField('x_address', $address); $myExact->addField('x_city', $city); $myExact->addField('x_state', $state); $myExact->addField('x_zip', $zip); $myExact->addField('x_fp_sequence', $attendee_id); //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($exact_settings['bypass_payment_page']) && $exact_settings['bypass_payment_page'] == 'Y') { $myExact->submitPayment(); //Enable auto redirect to payment site } else { $button_url = espresso_select_button_for_display($exact_settings['button_url'], "exact/exact-logo.png"); $myExact->submitButton($button_url, 'exact'); //Display payment button } if ($use_sandbox) { echo '<p>Test credit card # 4007000000027</p>'; echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $myExact->dump_fields(); // for debugging, output a table of all the fields } }
function espresso_display_luottokunta($payment_data) { global $org_options; $payment_data['payment_status'] = 'Incomplete'; $payment_data['txn_type'] = 'Luottokunta'; //$payment_data = apply_filters('filter_hook_espresso_prepare_event_link', $payment_data); $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data); global $wpdb, $org_options; $luottokunta_settings = get_option('event_espresso_luottokunta_settings'); $currency_code = 978; //for now luottokuna only supports Euros, which have currency cod e978$luottokunta_settings['currency_code']; $merchant_number = $luottokunta_settings['luottokunta_id']; $mac_key = $luottokunta_settings['luottokunta_mac_key']; //it would be good to use this $total_cost_in_cents = $payment_data['total_cost'] * 100; $description = $payment_data['event_name']; $bypass_payment_page = $luottokunta_settings['bypass_payment_page'] == 'Y' ? true : false; $button_url = $luottokunta_settings['button_url']; //generate a unique key which must be unique for every request to luottokunta $order_id = wp_generate_password(9, false); $base_return_url = add_query_arg(array('r_id' => $payment_data['registration_id'], 'type' => 'luottokunta', 'order_id' => $order_id), get_permalink($org_options['return_url'])); $success_url = add_query_arg('success', true, $base_return_url); $failure_url = add_query_arg('success', 0, $base_return_url); $cancel_url = get_permalink($org_options['cancel_return']); if ($luottokunta_settings['force_ssl_return']) { $success_url = str_replace("http://", "https://", $success_url); $failure_url = str_replace("http://", "https://", $failure_url); $cancel_url = str_replace("http://", "https://", $cancel_url); } $server_url = "https://dmp2.luottokunta.fi/dmp/html_payments"; $user_ip = $_SERVER["REMOTE_ADDR"] != '::1' ? $_SERVER['REMOTE_ADDR'] : '127.0.0.1'; $button_url = espresso_select_button_for_display($luottokunta_settings['button_url'], "luottokunta/luottokunta.gif"); $submit_html = "<input type='image' class='payment-option-lnk allow-leave-page' src='{$button_url}'/>"; if ($bypass_payment_page) { $bypass_payment_page_js = "<script>document.getElementById('luottokunta_form').submit();</script>"; } else { $bypass_payment_page_js = ""; } $transaction_type = "0"; $authentication_mac_unhashed = $mac_check_in_form = implode("&", array($merchant_number, $order_id, $total_cost_in_cents, $currency_code, $transaction_type, $mac_key)); //echo "authentication mac unhasehd:".$authentication_mac_unhashed; //note: order is essential. see luottokunta's "html form interface v1.3 section 4.2.1 $authentication_mac = hash('sha256', $authentication_mac_unhashed); $external_link_img = EVENT_ESPRESSO_PLUGINFULLURL . '/images/icons/external-link.png'; $formhtml = <<<HEREDOC \t\t <div id="luottokunta-payment-option-dv" class="off-site-payment-gateway payment-option-dv"> \t\t\t<img class="off-site-payment-gateway-img" width="16" height="16" src="{$external_link_img}" alt="click to visit this payment gateway"> \t \t\t\t<form action="{$server_url}" method="post" id='luottokunta_form'> \t\t\t\t<input type="hidden" name="Merchant_Number" value="{$merchant_number}"> \t\t\t\t \t\t\t\t<input type="hidden" name="Card_Details_Transmit" value="0"> \t\t\t\t<input type="hidden" name="Language" value="{$luottokunta_settings['luottokunta_payment_page_language']}"> \t\t\t\t<input type="hidden" name="Device_Category" value="1"> \t\t\t\t<input type="hidden" name="Order_ID" value="{$order_id}"> \t\t\t\t<input type="hidden" name="Customer_ID" value="{$payment_data['attendee_id']}"> \t\t\t\t<input type="hidden" name="Amount" value="{$total_cost_in_cents}"> \t\t\t\t<input type="hidden" name="Currency_Code" value="{$currency_code}"> \t\t\t\t<input type="hidden" name="Order_Description" value="{$description}"> \t\t\t\t<input type="hidden" name="Success_Url" value="{$success_url}"> \t\t\t\t<input type="hidden" name="Failure_Url" value="{$failure_url}"> \t\t\t\t<input type="hidden" name="Cancel_Url" value="{$cancel_url}"> \t\t\t\t<input type="hidden" name="Transaction_Type" value="{$transaction_type}"> \t\t\t\t<input type='hidden' name='Authentication_Mac' value='{$authentication_mac}'> \t\t\t\t<input type="hidden" name="Customer_IP_Address" value="{$user_ip}"> \t\t\t\t{$submit_html} \t\t\t\t</form> \t\t\t</div> {$bypass_payment_page_js} HEREDOC; /* other fields from demo <input type="text" name="Authentication_Mac" value="{$mac_key}"> <input type="text" name="Dossier_ID" value="Dossier123"> <input type="TEXT" name="OrderID" value="{$payment_data['registration_id']}">OrderID<br> <input type="TEXT" name="Sname" value="John Smith">Sname<br> <input type="TEXT" name="Saddress1" value="123 Main St.">Saddress1<br> <input type="TEXT" name="Saddress2" value="Apt 6">Saddress2<br> <input type="TEXT" name="Scity" value="Toronto">Scity<br> <input type="TEXT" name="Sprovince" value="Ontario">Sprovince<br> <input type="TEXT" name="Spostalcode" value="L5N2B3">Spostalcode<br> <input type="TEXT" name="Scountry" value="Canada">Scountry<br> <input type="TEXT" name="Scompany" value="Luottokunta">Scompany<br> <input type="TEXT" name="Bcompany" value="Luottokunta">Bcompany<br> <input type="TEXT" name="CustomerRefNo" value="123456789">CustomerRefNo<br> <input type="TEXT" name="TestResult" value="">TestResult<br> <input type="TEXT" name="UserID" value="User1">UserID<br> <input type="TEXT" name="Comments" value="No comments today">Comments<br> <input type="TEXT" name="CardNumber" value="">CardNumber<br> <input type="TEXT" name="CardExpMonth" value="">CardExpMonth<br> <input type="TEXT" name="CardExpYear" value="">CardExpYear<br> <input type="TEXT" name="TransRefNumber" value="">TransRefNumber<br> <input type="TEXT" name="CardAuthNumber" value="">CardAuthNumber<br> <input type="TEXT" name="Fax" value="416-555-2091">Fax<br> <input type="TEXT" name="Tax1" value="1">Tax1<br> <input type="TEXT" name="Tax2" value="2">Tax2<br> <input type="TEXT" name="Tax3" value="3">Tax3<br> <input type="TEXT" name="Tax4" value="4">Tax4<br> <input type="TEXT" name="Tax5" value="5">Tax5<br> <input type="TEXT" name="ShippingTotal" value="6">ShippingTotal<br> <input type="TEXT" name="CardIDNumber" value="">CardIDNumber<br> <input type="TEXT" name="CardXID" value="">CardXID<br> <input type="TEXT" name="CardECI" value="">CardECI<br> <input type="TEXT" name="CardCavv" value="">CardCavv<br> <input type="TEXT" name="CardLevel2PO" value="">CardLevel2PO<br> <input type="TEXT" name="CardLevel2Tax" value="">CardLevel2Tax<br> <input type="TEXT" name="CardLevel2TaxExempt" value="">CardLevel2TaxExempt<br> <input type="TEXT" name="CardLevel2ShiptoZip" value="">CardLevel2ShiptoZip<br> <input type="TEXT" name="AuthorizationNumber" value="">AuthorizationNumber<br> <input type="TEXT" name="CardRefNumber" value="">CardRefNumber<br><input type="TEXT" name="ItemID01" value="apple">ItemID01 <input type="TEXT" name="Description01" value="delicious apple">Description01 <input type="TEXT" name="Quantity01" value="2">Quantity01 <input type="TEXT" name="Price01" value="15">Price01<br><input type="TEXT" name="OptionName0101" value="Color0101"><input type="TEXT" name="OptionValue0101" value="Red01">Option01 <input type="TEXT" name="OptionName0102" value="Color0102"><input type="TEXT" name="OptionValue0102" value="Green01">Option02<br><input type="TEXT" name="OptionName0103" value="Color0103"><input type="TEXT" name="OptionValue0103" value="Yellow01">Option03 <input type="TEXT" name="OptionName0104" value="Color0104"><input type="TEXT" name="OptionValue0104" value="Black01">Option04<br><input type="TEXT" name="OptionName0105" value="Color0105"><input type="TEXT" name="OptionValue0105" value="White01">Option05<br><input type="TEXT" name="ItemID02" value="book">ItemID02 <input type="TEXT" name="Description02" value="good book">Description02 <input type="TEXT" name="Quantity02" value="3">Quantity02 <input type="TEXT" name="Price02" value="25">Price02<br><input type="TEXT" name="OptionName0201" value="Color0201"><input type="TEXT" name="OptionValue0201" value="Red02">Option01 <input type="TEXT" name="OptionName0202" value="Color0202"><input type="TEXT" name="OptionValue0202" value="Green02">Option02<br><input type="TEXT" name="OptionName0203" value="Color0203"><input type="TEXT" name="OptionValue0203" value="Yellow02">Option03 <input type="TEXT" name="OptionName0204" value="Color0204"><input type="TEXT" name="OptionValue0204" value="Black02">Option04<br><input type="TEXT" name="OptionName0205" value="Color0205"><input type="TEXT" name="OptionValue0205" value="White02">Option05<br><input type="TEXT" name="ItemID03" value="computer">ItemID03 <input type="TEXT" name="Description03" value="IBM computer">Description03 <input type="TEXT" name="Quantity03" value="1">Quantity03 <input type="TEXT" name="Price03" value="1200">Price03<br><input type="TEXT" name="OptionName0301" value="Color0301"><input type="TEXT" name="OptionValue0301" value="Red03">Option01 <input type="TEXT" name="OptionName0302" value="Color0302"><input type="TEXT" name="OptionValue0302" value="Green03">Option02<br><input type="TEXT" name="OptionName0303" value="Color0303"><input type="TEXT" name="OptionValue0303" value="Yellow03">Option03 <input type="TEXT" name="OptionName0304" value="Color0304"><input type="TEXT" name="OptionValue0304" value="Black03">Option04<br><input type="TEXT" name="OptionName0305" value="Color0305"><input type="TEXT" name="OptionValue0305" value="White03">Option05<br><input type="TEXT" name="ItemID04" value="">ItemID04 <input type="TEXT" name="Description04" value="">Description04 <input type="TEXT" name="Quantity04" value="">Quantity04 <input type="TEXT" name="Price04" value="">Price04<br><input type="TEXT" name="OptionName0401" value="Color0401"><input type="TEXT" name="OptionValue0401" value="Red04">Option01 <input type="TEXT" name="OptionName0402" value="Color0402"><input type="TEXT" name="OptionValue0402" value="Green04">Option02<br><input type="TEXT" name="OptionName0403" value="Color0403"><input type="TEXT" name="OptionValue0403" value="Yellow04">Option03 <input type="TEXT" name="OptionName0404" value="Color0404"><input type="TEXT" name="OptionValue0404" value="Black04">Option04<br><input type="TEXT" name="OptionName0405" value="Color0405"><input type="TEXT" name="OptionValue0405" value="White04">Option05<br><input type="TEXT" name="ItemID05" value="">ItemID05 <input type="TEXT" name="Description05" value="">Description05 <input type="TEXT" name="Quantity05" value="">Quantity05 <input type="TEXT" name="Price05" value="">Price05<br><input type="TEXT" name="OptionName0501" value="Color0501"><input type="TEXT" name="OptionValue0501" value="Red05">Option01 <input type="TEXT" name="OptionName0502" value="Color0502"><input type="TEXT" name="OptionValue0502" value="Green05">Option02<br><input type="TEXT" name="OptionName0503" value="Color0503"><input type="TEXT" name="OptionValue0503" value="Yellow05">Option03 <input type="TEXT" name="OptionName0504" value="Color0504"><input type="TEXT" name="OptionValue0504" value="Black05">Option04<br><input type="TEXT" name="OptionName0505" value="Color0505"><input type="TEXT" name="OptionValue0505" value="White05">Option05<br><input type="SUBMIT" value="Buy Now"><table> -->*/ echo $formhtml; return $payment_data; }
function espresso_display_mwarrior($payment_data) { extract($payment_data); // Setup class include_once 'Mwarrior.php'; $mwarrior = new Espresso_Mwarrior(); // initiate an instance of the class echo '<!--Event Espresso Merchant Warrior Gateway Version ' . $mwarrior->gateway_version . '-->'; global $org_options; //global $attendee_id; $mwarrior_settings = get_option('event_espresso_mwarrior_settings'); $mwarrior_id = empty($mwarrior_settings['mwarrior_id']) ? '' : $mwarrior_settings['mwarrior_id']; $mwarrior_apikey = empty($mwarrior_settings['mwarrior_apikey']) ? '' : $mwarrior_settings['mwarrior_apikey']; $mwarrior_passphrase = empty($mwarrior_settings['mwarrior_passphrase']) ? '' : $mwarrior_settings['mwarrior_passphrase']; $mwarrior_cur = empty($mwarrior_settings['currency_format']) ? '' : $mwarrior_settings['currency_format']; $logo_url = empty($mwarrior_settings['image_url']) ? '' : $mwarrior_settings['image_url']; $use_sandbox = $mwarrior_settings['use_sandbox']; if ($use_sandbox) { // Enable test mode if needed $mwarrior->enableTestMode(); } $salt = $mwarrior->_generateHashSalt(); $mwarrior->setMerchantInfo($mwarrior_id, $mwarrior_apikey, $mwarrior_passphrase); //Post variables $mwarrior->addField('method', 'processCard'); $mwarrior->addField('merchantUUID', $mwarrior_id); $mwarrior->addField('apiKey', $mwarrior_apikey); $mwarrior->addField('customerName', $fname . " " . $lname); $mwarrior->addField('customerEmail', $attendee_email); $mwarrior->addField('customerAddress', $address); $mwarrior->addField('customerCity', $city); $mwarrior->addField('customerPostCode', $zip); $mwarrior->addField('customerState', $state); $mwarrior->addField('customerCountry', empty($country) ? '' : $country); $mwarrior->addField('customerPhone', $phone); $mwarrior->addField('transactionProduct', stripslashes_deep($event_name)); $mwarrior->addField('transactionAmount', number_format($event_cost, 2, '.', '')); $mwarrior->addField('transactionCurrency', $mwarrior_cur); $mwarrior->addField('logoURL', $logo_url); $returnURL = add_query_arg(array('id' => $attendee_id, 'r_id' => $registration_id, 'event_id' => $event_id, 'attendee_action' => 'post_payment', 'form_action' => 'payment', 'type' => 'mwarrior'), get_permalink($org_options['return_url'])); //notify is the thank yuo page... is that right? mike july 19 2013, editing code... $notifyURL = add_query_arg(array('id' => $attendee_id, 'r_id' => $registration_id, 'event_id' => $event_id, 'attendee_action' => 'post_payment', 'form_action' => 'payment', 'type' => 'mwarrior'), get_permalink($org_options['return_url'])); if ($mwarrior_settings['force_ssl_return']) { $returnURL = str_replace("http://", "https://", $returnURL); $notifyURL = str_replace("http://", "https://", $notifyURL); } $mwarrior->addField('returnURL', $returnURL); $mwarrior->addField('notifyURL', $notifyURL); // $mwarrior->addField('returnURL', $home . '/?page_id=' . $org_options['return_url'] . '&id=' . $attendee_id . '&r_id=' . $registration_id . '&event_id=' . $event_id . '&attendee_action=post_payment&form_action=payment&type=mwarrior'); //$mwarrior->addField('cancel_return', $home.'/?page_id='.$org_options['cancel_return']); // $mwarrior->addField('notifyURL', $home . '/?page_id=' . $org_options['return_url'] . '&id=' . $attendee_id . '&r_id=' . $registration_id . '&event_id=' . $event_id . '&attendee_action=post_payment&form_action=payment&type=mwarrior'); $mwarrior->addField('urlHash', $mwarrior->_calculateHash($mwarrior->fields, "url")); $mwarrior->addField('hash', $mwarrior->_calculateHash($mwarrior->fields, "transaction")); $mwarrior->addField('hashSalt', $salt); //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($mwarrior_settings['bypass_payment_page']) && $mwarrior_settings['bypass_payment_page'] == 'Y') { $mwarrior->submitPayment(); //Enable auto redirect to payment site } else { $button_url = espresso_select_button_for_display($mwarrior_settings['button_url'], "mwarrior/mwarrior-logo.png"); $mwarrior->submitButton($button_url, 'mwarrior'); //Display payment button } // Store the salt temporarily in the database $mwarrior->_storeHashSalt($salt, espresso_registration_id($attendee_id)); if ($use_sandbox) { echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $mwarrior->dump_fields(); // for debugging, output a table of all the fields } }
function espresso_display_authnet($payment_data) { extract($payment_data); // Setup class include_once 'Authorize.php'; global $org_options, $wpdb; $myAuthorize = new Espresso_Authorize(); // initiate an instance of the class echo '<!--Event Espresso Authorize.net Gateway Version ' . $myAuthorize->gateway_version . '-->'; $authnet_settings = get_option('event_espresso_authnet_settings'); $authnet_login_id = empty($authnet_settings['authnet_login_id']) ? '' : $authnet_settings['authnet_login_id']; $authnet_transaction_key = empty($authnet_settings['authnet_transaction_key']) ? '' : $authnet_settings['authnet_transaction_key']; $image_url = empty($authnet_settings['image_url']) ? '' : $authnet_settings['image_url']; $use_sandbox = $authnet_settings['use_sandbox']; $use_testmode = $authnet_settings['test_transactions']; if ($use_testmode) { // Enable test mode if needed $myAuthorize->enableTestMode(); } if ($use_sandbox) { // Enable test mode if needed $myAuthorize->useTestServer(); } $quantity = !empty($quantity) ? $quantity : espresso_count_attendees_for_registration($attendee_id); $myAuthorize->setUserInfo($authnet_login_id, $authnet_transaction_key); $myAuthorize->addField('x_Relay_URL', espresso_build_gateway_url('return_url', $payment_data, 'authnet')); $myAuthorize->addField('x_Description', stripslashes_deep($event_name) . ' | ' . __('Reg. ID:', 'event_espresso') . ' ' . $attendee_id . ' | ' . __('Name:', 'event_espresso') . ' ' . stripslashes_deep($fname . ' ' . $lname) . ' | ' . __('Total Registrants:', 'event_espresso') . ' ' . $quantity); $myAuthorize->addField('x_Amount', number_format($event_cost, 2)); $myAuthorize->addField('x_Logo_URL', $image_url); $myAuthorize->addField('x_Invoice_num', 'au-' . event_espresso_session_id()); //Post variables $myAuthorize->addField('x_cust_id', $attendee_id); $myAuthorize->addField('x_first_name', $fname); $myAuthorize->addField('x_last_name', $lname); $myAuthorize->addField('x_Email', $attendee_email); $myAuthorize->addField('x_Address', $address); $myAuthorize->addField('x_City', $city); $myAuthorize->addField('x_State', $state); $myAuthorize->addField('x_Zip', $zip); $sql = "SELECT attendee_session FROM " . EVENTS_ATTENDEE_TABLE . " WHERE id='" . $attendee_id . "'"; $session_id = $wpdb->get_var($sql); $sql = "SELECT a.final_price, a.quantity, ed.event_name, a.price_option, a.fname, a.lname FROM " . EVENTS_ATTENDEE_TABLE . " a JOIN " . EVENTS_DETAIL_TABLE . " ed ON a.event_id=ed.id "; $sql .= " WHERE attendee_session='" . $session_id . "' ORDER BY a.id ASC"; $items = $wpdb->get_results($sql); foreach ($items as $key => $item) { $item_num = $key + 1; $myAuthorize->addLineItem($item_num, strlen($item->event_name) > 30 ? substr_replace($item->event_name, '', 30) : $item->event_name, substr_replace($item->price_option . ' for ' . $item->event_name . '. Attendee: ' . $item->fname . ' ' . $item->lname, '', 255), $item->quantity, $item->final_price, FALSE); } //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($authnet_settings['bypass_payment_page']) && $authnet_settings['bypass_payment_page'] == 'Y') { $myAuthorize->submitPayment(); //Enable auto redirect to payment site } else { $button_url = espresso_select_button_for_display($authnet_settings['button_url'], "authnet/btn_cc_vmad.gif"); $myAuthorize->submitButton($button_url, 'authnet'); //Display payment button } if ($use_sandbox) { echo '<p>Test credit card # 4007000000027</p>'; echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $myAuthorize->dump_fields(); // for debugging, output a table of all the fields } }
function espresso_display_anz($payment_data) { global $wpdb; $payment_data['payment_status'] = 'Incomplete'; $payment_data['txn_type'] = 'ANZ'; //$payment_data = apply_filters('filter_hook_espresso_prepare_event_link', $payment_data); $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data); global $wpdb, $org_options; $anz_settings = get_option('event_espresso_anz_settings'); $merchant_id = $anz_settings['anz_id']; $access_code = $anz_settings['anz_access_code']; $secure_secret = $anz_settings['anz_secure_secret']; $bypass_payment_page = $anz_settings['bypass_payment_page'] == 'Y' ? true : false; $button_url = $anz_settings['button_url']; if ($anz_settings['force_ssl_return']) { $home = str_replace("http://", "https://", home_url()); } else { $home = home_url(); } $return_url = $home . '/?page_id=' . $org_options['return_url'] . '&r_id=' . $payment_data['registration_id'] . '&type=anz'; $server_url = "https://migs.mastercard.com.au/vpcpay"; $button_url = espresso_select_button_for_display($anz_settings['button_url'], "anz/anz.gif"); if (!empty($button_url)) { $submit_html = "<img class='payment-option-lnk allow-leave-page' src='{$button_url}'/>"; } //http://localhost/eetrunk31/?page_id=5&r_id=42-5150cf9c1f748&type=anz&Title=PHP+VPC+3-Party&vpc_3DSECI=01&vpc_3DSXID=7S%2BXbvLUbBrsxTkYaXJMxjx0yhM%3D&vpc_3DSenrolled=Y&vpc_3DSstatus=A&vpc_AVSResultCode=Unsupported&vpc_AcqAVSRespCode=Unsupported&vpc_AcqCSCRespCode=N&vpc_AcqResponseCode=04&vpc_Amount=1000&vpc_BatchNo=20130326&vpc_CSCResultCode=N&vpc_Card=MC&vpc_Command=pay&vpc_Locale=en&vpc_MerchTxnRef=425150cf9c1f748&vpc_Merchant=ANZCAZALYS&vpc_Message=Expired+Card&vpc_OrderInfo=VPC+Example2&vpc_ReceiptNo=130326378001&vpc_SecureHash=329FC69DA1F03B3F7B896C97BF488E45&vpc_TransactionNo=2000000187&vpc_TxnResponseCode=4&vpc_VerSecurityLevel=06&vpc_VerStatus=M&vpc_VerToken=how5CsZD%2BBZwCAEAAAJ1AhUAAAA%3D&vpc_VerType=3DS&vpc_Version=1 $txn_id = str_replace("-", "", $payment_data['registration_id']); $amount_in_cents = $payment_data['total_cost'] * 100; //as per eGate Virtual Payment Clietn Guide Rev 1.2.0, all inputs must be hashed, in ascending alphabetical order $hash_data = array('01_secret_must_come_first' => $secure_secret, 'vpc_AccessCode' => $access_code, 'vpc_Amount' => $amount_in_cents, 'vpc_Command' => 'pay', 'vpc_Locale' => 'en', 'vpc_Merchant' => $merchant_id, 'vpc_MerchTxnRef' => $txn_id, 'vpc_OrderInfo' => 'VPC Example2', 'vpc_ReturnURL' => $return_url, 'Title' => 'PHP VPC 3-Party', 'vpc_Version' => 1); $success = ksort($hash_data); $url_encoded_hash_values = array(); foreach ($hash_data as $field_name => $field_value) { $url_encoded_hash_values[urlencode($field_name)] = urlencode($field_value); } $md5_data = implode("", $hash_data); $hash_string = strtoupper(md5($md5_data)); // echo "fields used in hash:".implode( "", $hash_fields ); //remove our super-secret thing from the list, because we're about to //send each of them as a GET parameter to ANZ unset($url_encoded_hash_values['01_secret_must_come_first']); unset($hash_data['01_secret_must_come_first']); $full_url = add_query_arg(array('vpc_SecureHash' => $hash_string), add_query_arg($url_encoded_hash_values, $server_url)); ?> <div id="anz-payment-option-dv" class="off-site-payment-gateway payment-option-dv"> <img class="off-site-payment-gateway-img" width="16" height="16" src="<?php echo EVENT_ESPRESSO_PLUGINFULLURL; ?> /images/icons/external-link.png" alt="click to visit this payment gateway"> <a href="<?php echo $full_url; ?> " class="payment-option-lnk allow-leave-page"><?php echo $submit_html; ?> </a> </div> <?php //only redirect immediately if they didnt jsut return from ANZ //otherwise, we want them to see the error message if ($bypass_payment_page && !array_key_exists('vpc_Message', $_GET)) { echo "<form>\n"; echo "<input type=\"hidden\" id=\"bypass_payment_page\" name=\"bypass_payment_page\" value=\"true\"/>\n"; echo "</form>\n"; echo "<script>window.location = '{$full_url}';</script>"; } return $payment_data; }
function espresso_display_psigate($payment_data) { global $wpdb; $payment_data['payment_status'] = 'Incomplete'; $payment_data['txn_type'] = 'PSiGate'; //$payment_data = apply_filters('filter_hook_espresso_prepare_event_link', $payment_data); $payment_data = apply_filters('filter_hook_espresso_get_total_cost', $payment_data); global $wpdb, $org_options; $psigate_settings = get_option('event_espresso_psigate_settings'); $currency_format = $psigate_settings['currency_format']; $event_meta = $wpdb->get_var($wpdb->prepare("SELECT event_meta from {$wpdb->prefix}events_detail WHERE id=%s", $payment_data['event_id'])); $event_meta = maybe_unserialize($event_meta); if (array_key_exists('event_currency', $event_meta)) { $currency_format = $event_meta['event_currency']; } if ('USD' == $currency_format) { $storekey = $psigate_settings['psigate_id_us']; } else { $storekey = $psigate_settings['psigate_id_can']; } $bypass_payment_page = $psigate_settings['bypass_payment_page'] == 'Y' ? true : false; $button_url = $psigate_settings['button_url']; if ($psigate_settings['force_ssl_return']) { $home = str_replace("http://", "https://", home_url()); } else { $home = home_url(); } $return_url = $home . '/?page_id=' . $org_options['return_url'] . '&r_id=' . $payment_data['registration_id'] . '&type=psigate'; $server_url = $psigate_settings['use_sandbox'] ? "https://devcheckout.psigate.com/HTMLPost/HTMLMessenger" : 'https://checkout.psigate.com/HTMLPost/HTMLMessenger'; /* @var $items StdClass[] array of attendees inner join with event on teh current purhcase*/ //$items=espresso_get_items_being_purchased($payment_data['attendee_id']); //get payment's details //get country of user. default to Canada, as this gateway is canadian $country = array_key_exists('country', $payment_data) ? $payment_data['country'] : ''; $address2 = array_key_exists('address2', $payment_data) ? $payment_data['address2'] : ''; $user_ip = $_SERVER["REMOTE_ADDR"]; $button_url = espresso_select_button_for_display($psigate_settings['button_url'], "psigate/psigate.gif"); $submit_html = "<input class='allow-leave-page payment-option-lnk' type='image' src='{$button_url}'/>"; if ($bypass_payment_page) { $bypass_payment_page_js = "<script>document.getElementById('psigate_form').submit();</script>"; } else { $bypass_payment_page_js = ""; } $external_link_img = EVENT_ESPRESSO_PLUGINFULLURL . '/images/icons/external-link.png'; $formhtml = <<<HEREDOC \t\t <div id="luottokunta-payment-option-dv" class="off-site-payment-gateway payment-option-dv"> \t\t\t<img class="off-site-payment-gateway-img" width="16" height="16" src="{$external_link_img}" alt="click to visit this payment gateway"> \t \t\t\t<form action="{$server_url}" id='psigate_form' method="post"> \t\t\t<input type="HIDDEN" name="MerchantID" value="{$storekey}"> \t\t\t<input type='HIDDEN' name='ThanksURL' value='{$return_url}'> \t\t\t<input type='HIDDEN' name='NoThanksURL' value='{$return_url}'> \t\t\t<input type="HIDDEN" name="PaymentType" value="CC"> \t\t\t<input type="HIDDEN" name="Bname" value="{$payment_data['fname']} {$payment_data['lname']}"> \t\t\t<input type="HIDDEN" name="Baddress1" value="{$payment_data['address']}"> \t\t\t<input type="HIDDEN" name="Baddress2" value="{$address2}"> \t\t\t<input type="HIDDEN" name="Bcity" value="{$payment_data['city']}"> \t\t\t<input type="HIDDEN" name="Bprovince" value="{$payment_data['state']}"> \t\t\t<input type="HIDDEN" name="Bpostalcode" value="{$payment_data['zip']}"> \t\t\t<input type="HIDDEN" name="Bcountry" value="{$country}"> \t\t\t<input type="HIDDEN" name="Phone" value="{$payment_data['phone']}"> \t\t\t<input type="HIDDEN" name="Email" value="{$payment_data['attendee_email']}"> \t\t\t<input type="HIDDEN" name="SubTotal" value="{$payment_data['total_cost']}"> \t\t\t<input type="HIDDEN" name="CardAction" value="0"> \t\t\t<input type="HIDDEN" name="CustomerIP" value="{$user_ip}"> \t\t\t{$submit_html} \t\t\t</form> \t\t\t</div> {$bypass_payment_page_js} HEREDOC; /* other fields from demo <input type="TEXT" name="OrderID" value="{$payment_data['registration_id']}">OrderID<br> <input type="TEXT" name="Sname" value="John Smith">Sname<br> <input type="TEXT" name="Saddress1" value="123 Main St.">Saddress1<br> <input type="TEXT" name="Saddress2" value="Apt 6">Saddress2<br> <input type="TEXT" name="Scity" value="Toronto">Scity<br> <input type="TEXT" name="Sprovince" value="Ontario">Sprovince<br> <input type="TEXT" name="Spostalcode" value="L5N2B3">Spostalcode<br> <input type="TEXT" name="Scountry" value="Canada">Scountry<br> <input type="TEXT" name="Scompany" value="PSiGate">Scompany<br> <input type="TEXT" name="Bcompany" value="PSiGate">Bcompany<br> <input type="TEXT" name="CustomerRefNo" value="123456789">CustomerRefNo<br> <input type="TEXT" name="TestResult" value="">TestResult<br> <input type="TEXT" name="UserID" value="User1">UserID<br> <input type="TEXT" name="Comments" value="No comments today">Comments<br> <input type="TEXT" name="CardNumber" value="">CardNumber<br> <input type="TEXT" name="CardExpMonth" value="">CardExpMonth<br> <input type="TEXT" name="CardExpYear" value="">CardExpYear<br> <input type="TEXT" name="TransRefNumber" value="">TransRefNumber<br> <input type="TEXT" name="CardAuthNumber" value="">CardAuthNumber<br> <input type="TEXT" name="Fax" value="416-555-2091">Fax<br> <input type="TEXT" name="Tax1" value="1">Tax1<br> <input type="TEXT" name="Tax2" value="2">Tax2<br> <input type="TEXT" name="Tax3" value="3">Tax3<br> <input type="TEXT" name="Tax4" value="4">Tax4<br> <input type="TEXT" name="Tax5" value="5">Tax5<br> <input type="TEXT" name="ShippingTotal" value="6">ShippingTotal<br> <input type="TEXT" name="CardIDNumber" value="">CardIDNumber<br> <input type="TEXT" name="CardXID" value="">CardXID<br> <input type="TEXT" name="CardECI" value="">CardECI<br> <input type="TEXT" name="CardCavv" value="">CardCavv<br> <input type="TEXT" name="CardLevel2PO" value="">CardLevel2PO<br> <input type="TEXT" name="CardLevel2Tax" value="">CardLevel2Tax<br> <input type="TEXT" name="CardLevel2TaxExempt" value="">CardLevel2TaxExempt<br> <input type="TEXT" name="CardLevel2ShiptoZip" value="">CardLevel2ShiptoZip<br> <input type="TEXT" name="AuthorizationNumber" value="">AuthorizationNumber<br> <input type="TEXT" name="CardRefNumber" value="">CardRefNumber<br><input type="TEXT" name="ItemID01" value="apple">ItemID01 <input type="TEXT" name="Description01" value="delicious apple">Description01 <input type="TEXT" name="Quantity01" value="2">Quantity01 <input type="TEXT" name="Price01" value="15">Price01<br><input type="TEXT" name="OptionName0101" value="Color0101"><input type="TEXT" name="OptionValue0101" value="Red01">Option01 <input type="TEXT" name="OptionName0102" value="Color0102"><input type="TEXT" name="OptionValue0102" value="Green01">Option02<br><input type="TEXT" name="OptionName0103" value="Color0103"><input type="TEXT" name="OptionValue0103" value="Yellow01">Option03 <input type="TEXT" name="OptionName0104" value="Color0104"><input type="TEXT" name="OptionValue0104" value="Black01">Option04<br><input type="TEXT" name="OptionName0105" value="Color0105"><input type="TEXT" name="OptionValue0105" value="White01">Option05<br><input type="TEXT" name="ItemID02" value="book">ItemID02 <input type="TEXT" name="Description02" value="good book">Description02 <input type="TEXT" name="Quantity02" value="3">Quantity02 <input type="TEXT" name="Price02" value="25">Price02<br><input type="TEXT" name="OptionName0201" value="Color0201"><input type="TEXT" name="OptionValue0201" value="Red02">Option01 <input type="TEXT" name="OptionName0202" value="Color0202"><input type="TEXT" name="OptionValue0202" value="Green02">Option02<br><input type="TEXT" name="OptionName0203" value="Color0203"><input type="TEXT" name="OptionValue0203" value="Yellow02">Option03 <input type="TEXT" name="OptionName0204" value="Color0204"><input type="TEXT" name="OptionValue0204" value="Black02">Option04<br><input type="TEXT" name="OptionName0205" value="Color0205"><input type="TEXT" name="OptionValue0205" value="White02">Option05<br><input type="TEXT" name="ItemID03" value="computer">ItemID03 <input type="TEXT" name="Description03" value="IBM computer">Description03 <input type="TEXT" name="Quantity03" value="1">Quantity03 <input type="TEXT" name="Price03" value="1200">Price03<br><input type="TEXT" name="OptionName0301" value="Color0301"><input type="TEXT" name="OptionValue0301" value="Red03">Option01 <input type="TEXT" name="OptionName0302" value="Color0302"><input type="TEXT" name="OptionValue0302" value="Green03">Option02<br><input type="TEXT" name="OptionName0303" value="Color0303"><input type="TEXT" name="OptionValue0303" value="Yellow03">Option03 <input type="TEXT" name="OptionName0304" value="Color0304"><input type="TEXT" name="OptionValue0304" value="Black03">Option04<br><input type="TEXT" name="OptionName0305" value="Color0305"><input type="TEXT" name="OptionValue0305" value="White03">Option05<br><input type="TEXT" name="ItemID04" value="">ItemID04 <input type="TEXT" name="Description04" value="">Description04 <input type="TEXT" name="Quantity04" value="">Quantity04 <input type="TEXT" name="Price04" value="">Price04<br><input type="TEXT" name="OptionName0401" value="Color0401"><input type="TEXT" name="OptionValue0401" value="Red04">Option01 <input type="TEXT" name="OptionName0402" value="Color0402"><input type="TEXT" name="OptionValue0402" value="Green04">Option02<br><input type="TEXT" name="OptionName0403" value="Color0403"><input type="TEXT" name="OptionValue0403" value="Yellow04">Option03 <input type="TEXT" name="OptionName0404" value="Color0404"><input type="TEXT" name="OptionValue0404" value="Black04">Option04<br><input type="TEXT" name="OptionName0405" value="Color0405"><input type="TEXT" name="OptionValue0405" value="White04">Option05<br><input type="TEXT" name="ItemID05" value="">ItemID05 <input type="TEXT" name="Description05" value="">Description05 <input type="TEXT" name="Quantity05" value="">Quantity05 <input type="TEXT" name="Price05" value="">Price05<br><input type="TEXT" name="OptionName0501" value="Color0501"><input type="TEXT" name="OptionValue0501" value="Red05">Option01 <input type="TEXT" name="OptionName0502" value="Color0502"><input type="TEXT" name="OptionValue0502" value="Green05">Option02<br><input type="TEXT" name="OptionName0503" value="Color0503"><input type="TEXT" name="OptionValue0503" value="Yellow05">Option03 <input type="TEXT" name="OptionName0504" value="Color0504"><input type="TEXT" name="OptionValue0504" value="Black05">Option04<br><input type="TEXT" name="OptionName0505" value="Color0505"><input type="TEXT" name="OptionValue0505" value="White05">Option05<br><input type="SUBMIT" value="Buy Now"><table> -->*/ echo $formhtml; return $payment_data; }
function espresso_display_eway($payment_data) { extract($payment_data); // Setup class include_once 'Eway.php'; echo '<!-- Event Espresso eWay Gateway Version ' . $eway_gateway_version . '-->'; echo ' <div id="eway-payment-option-dv" class="off-site-payment-gateway payment-option-dv"> <img class="off-site-payment-gateway-img" width="16" height="16" src="' . EVENT_ESPRESSO_PLUGINFULLURL . '/images/icons/external-link.png" alt="click to visit this payment gateway">'; $myeway = new Espresso_Eway(); // initiate an instance of the class global $org_options; //global $attendee_id; $eway_settings = get_option('event_espresso_eway_settings'); $eway_id = $eway_settings['eway_id']; $eway_username = $eway_settings['eway_username']; //$image_url = $eway_settings['button_url']; $eway_cur = $eway_settings['currency_format']; $use_sandbox = $eway_settings['use_sandbox']; $quantity = isset($quantity) && $quantity > 0 ? $quantity : espresso_count_attendees_for_registration($attendee_id); if ($use_sandbox) { // Enable test mode if needed $myeway->enableTestMode(); $myeway->addField('CustomerID', '87654321'); $myeway->addField('UserName', 'TestAccount'); } else { $myeway->addField('CustomerID', $eway_id); $myeway->addField('UserName', $eway_username); } $myeway->addField('Amount', number_format($event_cost, 2, '.', '')); $myeway->addField('Currency', $eway_cur); $myeway->addField('PageTitle', ''); $myeway->addField('PageDescription', ''); $myeway->addField('PageFooter', ''); $myeway->addField('Language', ''); $myeway->addField('CompanyName', str_replace("&", "%26", $org_options['organization'])); $myeway->addField('CustomerFirstName', $fname); $myeway->addField('CustomerLastName', $lname); $myeway->addField('CustomerAddress', $address); $myeway->addField('CustomerCity', $city); $myeway->addField('CustomerState', $state); $myeway->addField('CustomerPostCode', $zip); $myeway->addField('CustomerCountry', ''); $myeway->addField('CustomerEmail', $attendee_email); $myeway->addField('CustomerPhone', $phone); $myeway->addField('InvoiceDescription', stripslashes_deep($event_name) . ' | ' . __('Name:', 'event_espresso') . ' ' . stripslashes_deep($fname . ' ' . $lname) . ' | ' . __('Registrant Email:', 'event_espresso') . ' ' . $attendee_email . ' | ' . __('Total Registrants:', 'event_espresso') . ' ' . $quantity); $myeway->addField('CancelURL', str_replace("&", "%26", home_url() . '/?page_id=' . $org_options['cancel_return'])); if ($eway_settings['force_ssl_return']) { $home = str_replace("http://", "https://", home_url()); } else { $home = home_url(); } $return_url = str_replace("&", "%26", $home . '/?page_id=' . $org_options['return_url'] . '&id=' . $attendee_id . '&r_id=' . $registration_id . '&event_id=' . $event_id . '&attendee_action=post_payment&form_action=payment&type=eway'); $myeway->addField('ReturnURL', $return_url); $myeway->addField('CompanyLogo', $eway_settings['image_url']); $myeway->addField('PageBanner', ''); $myeway->addField('MerchantReference', ''); $myeway->addField('MerchantInvoice', ''); $myeway->addField('MerchantOption1', ''); $myeway->addField('MerchantOption2', ''); $myeway->addField('MerchantOption3', ''); $myeway->addField('ModifiableCustomerDetails', 'false'); if ($eway_settings['bypass_payment_page'] == 'Y') { $myeway->submitPayment(); //Enable auto redirect to payment site } else { $button_url = espresso_select_button_for_display($eway_settings['button_url'], "eway/eway-logo.png"); $myeway->submitButton($button_url, 'eway'); //Display payment button wp_deregister_script('jquery.validate.pack'); } if ($use_sandbox) { echo '<h3 style="color:#ff0000;" title="Payments will not be processed">' . __('Debug Mode Is Turned On', 'event_espresso') . '</h3>'; $myeway->dump_fields(); // for debugging, output a table of all the fields } echo ' </div>'; }
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 Espresso_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, a.final_price, a.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['final_price']); $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', $home . '/?page_id=' . $org_options['return_url'] . '&id=' . $attendee_id . '&r_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 { $button_url = espresso_select_button_for_display($twocheckout_settings['button_url'], "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 } }