function paypal_pro_process()
 {
     global $event_details, $cart_totals;
     $event_id = $event_details['ID'];
     if (is_null($event_id)) {
         return false;
     }
     $regis_id = $this->erm->get_regis_id();
     $post_ID = $this->erm->get_regis_post_id();
     $this->ecm->setup_event_details($event_id);
     $this->erm->calculate_cart_totals(true);
     $min_deposit = epl_get_element_m('min_deposit', 'money_totals', $cart_totals, 0);
     $min_deposit = $min_deposit > 0 && epl_get_element_m('pay_deposit', 'money_totals', $cart_totals, 0) == 1;
     $amount = $cart_totals['money_totals']['grand_total'];
     $tax = $min_deposit ? 0 : epl_get_element_m('surcharge', 'money_totals', $cart_totals, 0);
     $subtotal = $tax == 0 ? $amount : epl_get_element_m('subtotal', 'money_totals', $cart_totals, 0);
     $discount_amount = epl_get_element('discount_amount', $cart_totals['money_totals'], 0);
     //$subtotal = $discount_amount > 0 ? number_format( $subtotal - $discount_amount, 2 ) : $subtotal;
     $requestParams = array('IPADDRESS' => $_SERVER['REMOTE_ADDR'], 'PAYMENTACTION' => 'Sale');
     foreach ($_POST as $k => &$v) {
         trim(esc_attr($v));
     }
     $creditCardDetails = array('CREDITCARDTYPE' => $_POST['_epl_cc_card_type'], 'ACCT' => $_POST['_epl_cc_num'], 'EXPDATE' => date_i18n("mY", strtotime($_POST['_epl_cc_exp_month'] . $_POST['_epl_cc_exp_year'])), 'CVV2' => $_POST['_epl_cc_cvv']);
     $payerDetails = array('FIRSTNAME' => $_POST['_epl_cc_first_name'], 'LASTNAME' => $_POST['_epl_cc_last_name'], 'COUNTRYCODE' => $_POST['_epl_cc_country'], 'STATE' => $_POST['_epl_cc_state'], 'CITY' => $_POST['_epl_cc_city'], 'STREET' => $_POST['_epl_cc_address'], 'ZIP' => $_POST['_epl_cc_zip']);
     $orderParams = array('AMT' => epl_get_balance_due(), 'ITEMAMT' => $min_deposit ? epl_get_balance_due() : $subtotal, 'TAXAMT' => $tax, 'SHIPPINGAMT' => 0, 'CURRENCYCODE' => epl_nz(epl_get_general_setting('epl_currency_code'), 'USD'));
     $item = array('L_NAME0' => 'Event Registration', 'L_DESC0' => $event_details['post_title'], 'L_AMT0' => $min_deposit ? epl_get_balance_due() : $subtotal, 'L_QTY0' => '1');
     $this->epl->load_file('libraries/gateways/paypal/paypal.php');
     $paypal = new EPL_Paypal();
     $gateway_info = $this->erm->get_gateway_info();
     $paypal->_credentials = array('USER' => trim($gateway_info['_epl_user']), 'PWD' => trim($gateway_info['_epl_pwd']), 'SIGNATURE' => trim($gateway_info['_epl_sig']));
     $request = $requestParams + $creditCardDetails + $payerDetails + $orderParams + $item;
     $request = apply_filters('epl_paypal_pro_process_params', $request);
     $response = $paypal->request('DoDirectPayment', $request);
     if (is_array($response) && $response['ACK'] == 'Success') {
         // Payment successful
         // We'll fetch the transaction ID for internal bookkeeping
         $transactionId = $response['TRANSACTIONID'];
         $data['post_ID'] = $post_ID;
         $data['_epl_grand_total'] = $_totals['money_totals']['grand_total'];
         $data['_epl_payment_amount'] = $response['AMT'];
         $data['_epl_payment_date'] = current_time('mysql');
         $data['_epl_payment_method'] = $this->erm->get_payment_profile_id();
         $data['_epl_transaction_id'] = $response['TRANSACTIONID'];
         $data['_epl_prediscount_total'] = epl_get_element('pre_discount_total', $_totals['money_totals'], 0);
         $data['_epl_discount_amount'] = epl_get_element('discount_amount', $_totals['money_totals'], 0);
         //$data['_epl_payment_note'] = print_r($response,true);
         $data = apply_filters('epl_pp_pro_response_data', $data, $response);
         $this->erm->update_payment_data($data);
         return true;
         //echo "DONE";
     } else {
         $r = '<div class="epl_error">ERROR: ' . $response['L_SHORTMESSAGE0'] . '. ' . $response['L_LONGMESSAGE0'] . '</div>';
         if (isset($response['L_SHORTMESSAGE1'])) {
             $r .= '<div class="epl_error">ERROR: ' . $response['L_SHORTMESSAGE1'] . '. ' . $response['L_LONGMESSAGE1'] . '</div>';
         }
         return $r;
     }
 }
 function _exp_checkout_do_payment()
 {
     global $event_details;
     $event_id = $event_details['ID'];
     if (is_null($event_id)) {
         return false;
     }
     $regis_id = $this->erm->get_regis_id();
     $post_ID = $_SESSION['__epl']['post_ID'];
     $this->ecm->setup_event_details($event_id);
     $_totals = $this->erm->calculate_totals();
     $this->epl->load_file('libraries/gateways/paypal/paypal.php');
     $paypal = new EPL_Paypal();
     $requestParams = array('TOKEN' => $_GET['token'], 'PAYMENTACTION' => 'Sale', 'PAYERID' => $_GET['PayerID'], 'PAYMENTREQUEST_0_AMT' => $_totals['money_totals']['grand_total'], 'PAYMENTREQUEST_0_CURRENCYCODE' => epl_nz(epl_get_general_setting('epl_currency_code'), 'USD'));
     $response = $paypal->request('DoExpressCheckoutPayment', $requestParams);
     if (is_array($response) && $response['ACK'] == 'Success') {
         $data['post_ID'] = $post_ID;
         $data['_epl_regis_status'] = '5';
         $data['_epl_grand_total'] = $_totals['money_totals']['grand_total'];
         $data['_epl_payment_amount'] = $response['PAYMENTINFO_0_AMT'];
         $data['_epl_payment_date'] = current_time('mysql');
         $data['_epl_payment_method'] = '_pp_exp';
         $data['_epl_transaction_id'] = $response['PAYMENTINFO_0_TRANSACTIONID'];
         $data = apply_filters('epl_pp_exp_response_data', $data, $response);
         $this->erm->update_payment_data($data);
         return true;
         //echo "DONE";
     } else {
         //display error message
         return 'ERROR: ' . $response['L_SHORTMESSAGE0'] . '. ' . $response['L_LONGMESSAGE0'];
     }
 }