function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     $order_id = $tc->generate_order_id();
     ${$payment_info} = array();
     $payment_info['currency'] = $tc->get_cart_currency();
     $payment_info = $this->save_payment_info($payment_info);
     $order = $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, false);
     wp_redirect($tc->get_confirmation_slug(true, $order_id));
     tc_js_redirect($tc->get_confirmation_slug(true, $order_id));
     exit;
 }
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     require_once $tc->plugin_dir . "/includes/gateways/netbanx/optimalpayments.php";
     $order_id = $tc->generate_order_id();
     $total = $this->total();
     $nb_api_key = $this->api_key_id;
     $nb_api_secret = $this->api_key_secret;
     $nb_acc_number = $this->account_number;
     if ('live' == $this->mode) {
         $client = new OptimalPayments\OptimalApiClient($nb_api_key, $nb_api_secret, OptimalPayments\Environment::LIVE, $nb_acc_number);
     } else {
         $client = new OptimalPayments\OptimalApiClient($nb_api_key, $nb_api_secret, OptimalPayments\Environment::TEST, $nb_acc_number);
     }
     $netbanx_params = array('merchantRefNum' => $order_id, 'amount' => $total * 100, 'settleWithAuth' => true, 'card' => array('cardNum' => $_POST['tc_nb_number'], 'cvv' => $_POST['tc_nb_cvc'], 'cardExpiry' => array('month' => (int) $_POST['tc_nb_month'], 'year' => 2000 + (int) $_POST['tc_nb_year'])), 'billingDetails' => array('zip' => $_POST['tc_nb_zip']));
     try {
         $auth = $client->cardPaymentService()->authorize(new OptimalPayments\CardPayments\Authorization($netbanx_params));
         $payment_info = array('total' => $total, 'currency' => $tc->get_cart_currency(), 'method' => __('Credit Card', 'tc'), 'transaction_id' => $auth->id);
         $payment_info = $this->save_payment_info();
         $order = $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, true);
         wp_redirect($tc->get_confirmation_slug(true, $order_id));
         tc_js_redirect($tc->get_confirmation_slug(true, $order_id));
         exit;
     } catch (OptimalPayments\NetbanxException $e) {
         $this->add_error(sprintf(__('There was an error processing your card - "%s".', 'tc'), $e->getMessage()));
         //'payment'
         return false;
         exit;
     }
 }
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     $payment = new TC_Gateway_Worker_AuthorizeNet_AIM($this->API_Endpoint, 'yes', ',', '', $this->get_option('api_user'), $this->get_option('api_key'), $this->get_option('mode', 'sandbox'));
     $payment->transaction($_POST['card_num']);
     $order_id = $tc->generate_order_id();
     if ($this->additional_fields == 'yes') {
         $payment->setParameter("x_address", $_POST['billing_address']);
         $payment->setParameter("x_state", $_POST['state']);
         $payment->setParameter("x_city", $_POST['city']);
         $payment->setParameter("x_zip", $_POST['zip']);
         $payment->setParameter("x_country", $_POST['country']);
         $payment->setParameter("x_phone", $_POST['phone_number']);
     }
     $payment->setParameter("x_card_code", $_POST['card_code']);
     $payment->setParameter("x_exp_date ", $_POST['exp_month'] . $_POST['exp_year']);
     $payment->setParameter("x_amount", $this->total());
     $payment->setParameter("x_currency_code", $this->currency);
     $payment->setParameter("x_description", $this->cart_items());
     $payment->setParameter("x_invoice_num", $order_id);
     if ($this->get_option('mode', 'sandbox') == 'sandbox') {
         $payment->setParameter("x_test_request", true);
     } else {
         $payment->setParameter("x_test_request", false);
     }
     $payment->setParameter("x_duplicate_window", 30);
     $address = $_POST['address1'];
     $payment->setParameter("x_first_name", $this->buyer_info('first_name'));
     $payment->setParameter("x_last_name", $this->buyer_info('last_name'));
     $payment->setParameter("x_email", $this->buyer_info('email'));
     $payment->setParameter("x_customer_ip", $_SERVER['REMOTE_ADDR']);
     $payment->process();
     if ($payment->isApproved()) {
         $payment_info = array();
         $payment_info['method'] = $payment->getMethod();
         $payment_info['transaction_id'] = $payment->getTransactionID();
         $payment_info = $this->save_payment_info($payment_info);
         $paid = true;
         $order = $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, $paid);
         wp_redirect($tc->get_confirmation_slug(true, $order_id));
         tc_js_redirect($tc->get_confirmation_slug(true, $order_id));
         exit;
     } else {
         $_SESSION['tc_gateway_error'] = $payment->getResponseText();
         wp_redirect($tc->get_payment_slug(true));
         tc_js_redirect($tc->get_payment_slug(true));
         exit;
     }
 }
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     $order_id = $tc->generate_order_id();
     require_once $tc->plugin_dir . "/includes/gateways/braintree/lib/Braintree.php";
     Braintree_Configuration::environment($this->environment);
     Braintree_Configuration::merchantId($this->merchant_key);
     Braintree_Configuration::publicKey($this->public_key);
     Braintree_Configuration::privateKey($this->private_key);
     $result = Braintree_Transaction::sale(array('amount' => $this->total(), 'orderId' => $order_id, 'creditCard' => array('number' => $_POST["number"], 'cvv' => $_POST["cvv"], 'expirationMonth' => $_POST["month"], 'expirationYear' => $_POST["year"], 'cardholderName' => $this->buyer_info('full_name')), 'customer' => array('firstName' => $this->buyer_info('first_name'), 'lastName' => $this->buyer_info('last_name'), 'email' => $this->buyer_info('email')), "options" => array("submitForSettlement" => apply_filters('tc_braintree_settle_payment', true))));
     if ($result->success) {
         //setup our payment details
         $payment_info = array();
         $payment_info['method'] = __('Credit Card');
         $payment_info['transaction_id'] = $result->transaction->id;
         $payment_info = $this->save_payment_info($payment_info);
         $paid = true;
         $order = $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, $paid);
         wp_redirect($tc->get_confirmation_slug(true, $order_id));
         tc_js_redirect($tc->get_confirmation_slug(true, $order_id));
         exit;
     } else {
         if ($result->transaction) {
             $_SESSION['tc_gateway_error'] = sprintf(__('Error processing transaction: "%s".', 'tc'), $result->message);
             wp_redirect($tc->get_payment_slug(true));
             tc_js_redirect($tc->get_payment_slug(true));
         } else {
             $_SESSION['tc_gateway_error'] = sprintf(__('Validation errors: "%s".', 'tc'), $result->message);
             //$result->errors->deepAll()
             wp_redirect($tc->get_payment_slug(true));
             tc_js_redirect($tc->get_payment_slug(true));
         }
     }
 }
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     $network_settings = get_site_option('tc_network_settings', array());
     $percent = isset($network_settings['gateways'][$this->plugin_name]['commision_rate']) && is_numeric($network_settings['gateways'][$this->plugin_name]['commision_rate']) ? $network_settings['gateways'][$this->plugin_name]['commision_rate'] : 0;
     $fixed = isset($network_settings['gateways'][$this->plugin_name]['commision_rate_fixed']) && is_numeric($network_settings['gateways'][$this->plugin_name]['commision_rate_fixed']) ? $network_settings['gateways'][$this->plugin_name]['commision_rate_fixed'] : 0;
     if ($percent > 100) {
         $percent = 100;
     }
     $_SESSION['stripeToken'] = $_POST['stripeToken'];
     if (!isset($_SESSION['stripeToken'])) {
         $tc->cart_checkout_error(__('The Stripe Token was not generated correctly. Please go back and try again.', 'tc'));
         return false;
     }
     if (!class_exists('Stripe')) {
         require_once $tc->plugin_dir . "/includes/gateways/stripe/lib/Stripe.php";
     }
     Stripe::setApiKey($this->private_key);
     $order_id = $tc->generate_order_id();
     try {
         $charge = Stripe_Charge::create(array("amount" => $this->total() * 100, "currency" => strtolower($this->currency), "source" => $_SESSION['stripeToken'], "description" => sprintf(__('%s Store Purchase - Order ID - %s, Email - %s', 'tc'), get_bloginfo('name'), $order_id, $this->buyer_info('email')), "application_fee" => round(($this->total() * $percent / 100 + $fixed) * 100)));
         if ($charge->paid == 'true') {
             $payment_info = array();
             $payment_info['method'] = sprintf(__('%1$s Card ending in %2$s - Expires %3$s', 'tc'), $charge->card->type, $charge->card->last4, $charge->card->exp_month . '/' . $charge->card->exp_year);
             $payment_info['transaction_id'] = $charge->id;
             $payment_info = $this->save_payment_info($payment_info);
             $paid = true;
             $order = $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, $paid);
             wp_redirect($tc->get_confirmation_slug(true, $order_id));
             tc_js_redirect($tc->get_confirmation_slug(true, $order_id));
             exit;
         }
     } catch (Exception $e) {
         unset($_SESSION['stripeToken']);
         $_SESSION['tc_gateway_error'] = sprintf(__('There was an error processing your card - "%s".', 'tc'), $e->getMessage());
         wp_redirect($tc->get_payment_slug(true));
         tc_js_redirect($tc->get_payment_slug(true));
         exit;
     }
     return false;
 }
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     include_once 'beanstream/Gateway.php';
     include_once 'beanstream/Exception.php';
     $order_id = $tc->generate_order_id();
     $total = $this->total();
     $beanstream = new \Beanstream\Gateway($this->merchant_id, $this->api_access, 'www', 'v1');
     $payment_data = array('order_number' => $order_id, 'amount' => $total, 'payment_method' => 'card', 'card' => array('name' => $this->buyer_info('full_name'), 'number' => $_POST[$this->plugin_name . '_cc_number'], 'expiry_month' => $_POST[$this->plugin_name . '_cc_month'], 'expiry_year' => $_POST[$this->plugin_name . '_cc_year'], 'cvd' => $_POST[$this->plugin_name . '_cc_cvc']));
     try {
         $result = $beanstream->payments()->makeCardPayment($payment_data, TRUE);
         //set to FALSE for Pre-Auth
         if ($result['approved']) {
             $payment_info = array('gateway_public_name' => $this->public_name, 'gateway_private_name' => $this->admin_name, 'total' => $total, 'currency' => $this->currency, 'method' => __('Credit Card', 'tc'), 'transaction_id' => $payment->id);
             $payment_info = $this->save_payment_info();
             $paid = true;
             $order = $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, $paid);
             wp_redirect($tc->get_confirmation_slug(true, $order_id));
             tc_js_redirect($tc->get_confirmation_slug(true, $order_id));
             exit;
         } else {
             $this->add_error('We\'re very sorry but the card you entered was not approved.');
             return false;
         }
     } catch (\Beanstream\Exception $e) {
         $this->add_error(sprintf(__('<li>There was an error processing your card: "%s".</li>', 'tc'), $e->getMessage()));
         return false;
     }
 }
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     if (isset($_POST['card_token'])) {
         $_SESSION['card_token'] = $_POST['card_token'];
     }
     if (!isset($_SESSION['card_token'])) {
         $_SESSION['tc_gateway_error'] = __('The PIN Token was not generated correctly.', 'tc');
         wp_redirect($tc->get_payment_slug(true));
         tc_js_redirect($tc->get_payment_slug(true));
         exit;
         return false;
     }
     if ($this->force_ssl) {
         define('PIN_API_CHARGE_URL', 'https://api.pin.net.au/1/charges');
     } else {
         define('PIN_API_CHARGE_URL', 'https://test-api.pin.net.au/1/charges');
     }
     define('PIN_API_KEY', $this->private_key);
     $token = $_SESSION['card_token'];
     if ($token) {
         $order_id = $tc->generate_order_id();
         try {
             $args = array('method' => 'POST', 'httpversion' => '1.1', 'timeout' => apply_filters('tc_http_request_timeout', 30), 'blocking' => true, 'compress' => true, 'headers' => array('Authorization' => 'Basic ' . base64_encode(PIN_API_KEY . ':' . '')), 'body' => array('amount' => (int) ($this->total() * 100), 'currency' => strtolower($this->currency), 'description' => $this->cart_items(), 'email' => $this->buyer_info('email'), 'ip_address' => $_SESSION['ip_address'], 'card_token' => $_SESSION['card_token']), 'cookies' => array());
             $charge = wp_remote_post(PIN_API_CHARGE_URL, $args);
             $charge = json_decode($charge['body'], true);
             $charge = $charge['response'];
             if ($charge['success'] == true) {
                 $payment_info = array();
                 $payment_info['method'] = sprintf(__('%1$s Card %2$s', 'tc'), ucfirst($charge['card']['scheme']), $charge['card']['display_number']);
                 $payment_info['transaction_id'] = $charge['token'];
                 $payment_info = $this->save_payment_info();
                 $paid = true;
                 $order = $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, $paid);
                 wp_redirect($tc->get_confirmation_slug(true, $order_id));
                 tc_js_redirect($tc->get_confirmation_slug(true, $order_id));
                 exit;
             } else {
                 unset($_SESSION['card_token']);
                 $_SESSION['tc_gateway_error'] = sprintf(__('There was an error processing your card.', 'tc'));
                 wp_redirect($tc->get_payment_slug(true));
                 tc_js_redirect($tc->get_payment_slug(true));
                 exit;
                 return false;
             }
         } catch (Exception $e) {
             unset($_SESSION['card_token']);
             $_SESSION['tc_gateway_error'] = sprintf(__('There was an error processing your card: "%s".', 'tc'), $e->getMessage());
             wp_redirect($tc->get_payment_slug(true));
             tc_js_redirect($tc->get_payment_slug(true));
             exit;
             return false;
         }
     }
 }
Esempio n. 8
0
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     if ($this->SandboxFlag == 'sandbox') {
         $url = 'https://www.2checkout.com/checkout/purchase';
     } else {
         $url = 'https://www.2checkout.com/checkout/purchase';
     }
     $order_id = $tc->generate_order_id();
     $params = array();
     $params['total'] = $this->total();
     $params['sid'] = $this->API_Username;
     $params['cart_order_id'] = $order_id;
     $params['merchant_order_id'] = $order_id;
     $params['return_url'] = $tc->get_confirmation_slug(true, $order_id);
     $params['x_receipt_link_url'] = $tc->get_confirmation_slug(true, $order_id);
     $params['skip_landing'] = '1';
     $params['fixed'] = 'Y';
     $params['currency_code'] = $this->currency;
     $params['mode'] = '2CO';
     $params['card_holder_name'] = $this->buyer_info('full_name');
     $params['email'] = $this->buyer_info('email');
     if ($this->SandboxFlag == 'sandbox') {
         $params['demo'] = 'Y';
     }
     $params["li_0_type"] = "product";
     $params["li_0_name"] = $this->cart_items();
     $params["li_0_price"] = $this->total();
     $params["li_0_tangible"] = 'N';
     $param_list = array();
     foreach ($params as $k => $v) {
         $param_list[] = "{$k}=" . rawurlencode($v);
     }
     $param_str = implode('&', $param_list);
     $paid = false;
     $payment_info = $this->save_payment_info();
     $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, $paid);
     wp_redirect("{$url}?{$param_str}");
     tc_js_redirect("{$url}?{$param_str}");
     exit(0);
 }
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     $order_id = $tc->generate_order_id();
     $request_params = array('METHOD' => 'DoDirectPayment', 'USER' => $this->api_username, 'PWD' => $this->api_password, 'SIGNATURE' => $this->api_signature, 'VERSION' => $this->api_version, 'PAYMENTACTION' => 'Sale', 'IPADDRESS' => $_SERVER['REMOTE_ADDR'], 'ACCT' => $_POST['ACCT'], 'EXPDATE' => $_POST['CARD_MONTH'] . $_POST['CARD_YEAR'], 'CVV2' => $_POST['CCV2'], 'FIRSTNAME' => $_POST['FIRSTNAME'], 'LASTNAME' => $_POST['LASTNAME'], 'STREET' => $_POST['STREET'], 'CITY' => $_POST['CITY'], 'STATE' => $_POST['STATE'], 'COUNTRYCODE' => $_POST['COUNTRYCODE'], 'ZIP' => $_POST['ZIP'], 'AMT' => $this->total(), 'CURRENCYCODE' => $_POST['CURRENCYCODE'], 'DESC' => $this->cart_items());
     $nvp_string = '';
     foreach ($request_params as $var => $val) {
         $nvp_string .= '&' . $var . '=' . urlencode($val);
     }
     $response = wp_remote_post($this->api_endpoint, array('timeout' => 120, 'httpversion' => '1.1', 'body' => $request_params, 'user-agent' => $tc->title, 'sslverify' => false));
     if (is_wp_error($response)) {
         $error_message = $response->get_error_message();
         $_SESSION['tc_gateway_error'] = __("Something went wrong:", 'tc') . $error_message;
         wp_redirect($tc->get_payment_slug(true));
         tc_js_redirect($tc->get_payment_slug(true));
         exit;
     } else {
         $nvp_response = $this->NVPToArray($response['body']);
         if ($nvp_response['ACK'] == 'Success' || $nvp_response['ACK'] == 'SuccessWithWarning') {
             //setup our payment details
             $payment_info = array();
             $payment_info['method'] = __('Credit Card', 'tc');
             $payment_info['transaction_id'] = $nvp_response['TRANSACTIONID'];
             $payment_info = $this->save_payment_info();
             $paid = true;
             $order = $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, $paid);
             wp_redirect($tc->get_confirmation_slug(true, $order_id));
             tc_js_redirect($tc->get_confirmation_slug(true, $order_id));
             exit;
         } else {
             $_SESSION['tc_gateway_error'] = $nvp_response['L_LONGMESSAGE0'];
             wp_redirect($tc->get_payment_slug(true));
             tc_js_redirect($tc->get_payment_slug(true));
             exit;
         }
     }
 }
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     $order_id = $tc->generate_order_id();
     $counter = 0;
     $cart_total = 0;
     $paid = false;
     $payment_info = $this->save_payment_info();
     /* PAY TABS SPECIFIC */
     $paytabs_payment_url = $this->get_paytabs_args($order_id, $this->buyer_info('first_name'), $this->buyer_info('last_name'), $this->buyer_info('email'), $this->total());
     $paytabs_adr = $paytabs_payment_url->payment_url;
     //check if api is wrong or dont get payment url
     if ($paytabs_adr == '' || $paytabs_payment_url->error_code == '0002') {
         $_SESSION['tc_gateway_error'] = sprintf(__('Transaction declined, Merchant information is wrong', 'tc'), $e->getMessage());
         wp_redirect($tc->get_payment_slug(true));
         tc_js_redirect($tc->get_payment_slug(true));
         exit;
     } else {
         $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, $paid);
         wp_redirect($paytabs_adr);
         tc_js_redirect($paytabs_adr);
         exit;
     }
     /* PAY TABS SPECIFIC */
 }
 function ipn()
 {
     global $tc;
     if (isset($_POST['transaction_id'])) {
         $transaction_id = $_POST['transaction_id'];
         if ($this->merchant_id == 'demo') {
             $json = wp_remote_get('https://voguepay.com/?v_transaction_id=' . $transaction_id . '&type=json&demo=true');
         } else {
             $json = wp_remote_get('https://voguepay.com/?v_transaction_id=' . $transaction_id . '&type=json');
         }
         $transaction = json_decode($json['body'], true);
         $transaction_id = $transaction['transaction_id'];
         $merchant_ref = $transaction['merchant_ref'];
         $order_id = tc_get_order_id_by_name($merchant_ref);
         //get order id from order name
         $order_id = $order_id->ID;
         $order = new TC_Order($order_id);
         $order_total = $order->details->tc_payment_info['total'];
         $amount_paid = $transaction['total'];
         if ($transaction['status'] == 'Approved') {
             if (round($amount_paid, 2) < round($order_total, 2)) {
                 $tc->update_order_status($order->ID, 'order_fraud');
                 //die('Fraud detected. Price paid ' . $amount_paid . ' and original price of ' . $order_total . ' do not match.');
                 $_SESSION['tc_gateway_error'] = sprintf(__('Something went wrong. Price paid %s and original price of %s do not match.', 'tc'), $amount_paid, $order_total);
                 wp_redirect($tc->get_payment_slug(true));
                 tc_js_redirect($tc->get_payment_slug(true));
                 exit;
             }
             $tc->update_order_payment_status($order_id, true);
             //die( 'IPN Processed OK. Payment for order successfull.' );
         } else {
             //die( 'IPN Processed OK. Payment Failed' );
         }
     }
 }
 function order_confirmation($order, $payment_info = '', $cart_info = '')
 {
     global $tc;
     $order = tc_get_order_id_by_name($order);
     if (isset($_GET['order_number'])) {
         $this->init_mijireh();
         try {
             $mj_order = new Mijireh_Order(esc_attr($_GET['order_number']));
             $payment_status = $mj_order->status;
             if ($payment_status == 'paid') {
                 $paid = true;
                 $tc->update_order_payment_status($order->ID, $paid);
             } else {
                 //do nothing, waiting for paid status
             }
         } catch (Mijireh_Exception $e) {
             $_SESSION['tc_gateway_error'] = __('Mijireh Error : ', 'tc') . $e->getMessage();
             wp_redirect($tc->get_payment_slug(true));
             tc_js_redirect($tc->get_payment_slug(true));
             exit;
         }
     }
 }
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     $payment_method = $_POST['komoju_payment_method'];
     $order_id = $tc->generate_order_id();
     $param_list = array();
     $paid = false;
     $total = number_format($this->total(), 2, '.', '');
     $start_point = $this->mode == 'sandbox' ? $this->sandbox_url : $this->live_url;
     $secret_key = $this->secret_key;
     $endpoint = "/" . $this->locale . "/api/" . $this->account_id . "/transactions/" . $payment_method . "/new";
     $params = array("transaction[amount]" => $this->total(), "transaction[currency]" => $this->currency, "transaction[customer][given_name]" => $this->buyer_info('first_name'), "transaction[customer][family_name]" => $this->buyer_info('last_name'), "transaction[customer][given_name_kana]" => $this->buyer_info('first_name'), "transaction[customer][family_name_kana]" => $this->buyer_info('last_name'), "transaction[external_order_num]" => $order_id, "transaction[return_url]" => $tc->get_confirmation_slug(true, $order_id), "transaction[cancel_url]" => $this->cancel_url, "transaction[callback_url]" => $this->ipn_url, "transaction[tax]" => "0", "timestamp" => time());
     $qs_params = array();
     foreach ($params as $key => $val) {
         $qs_params[] = urlencode($key) . '=' . urlencode($val);
     }
     sort($qs_params);
     $query_string = implode('&', $qs_params);
     $url = $endpoint . '?' . $query_string;
     $hmac = hash_hmac('sha256', $url, $secret_key);
     $payment_info = $this->save_payment_info();
     $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, $paid);
     wp_redirect($start_point . $url . '&hmac=' . $hmac);
     tc_js_redirect($start_point . $url . '&hmac=' . $hmac);
     exit;
 }
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     $this->init_mollie();
     $order_id = $tc->generate_order_id();
     try {
         $payment = $this->mollie->payments->create(array("amount" => $this->total(), "description" => __('Order: #', 'tc-mollie') . $order_id, "redirectUrl" => $tc->get_confirmation_slug(true, $order_id), "metadata" => array("order_id" => $order_id)));
         $payment_info = array();
         $payment_info['transaction_id'] = $payment->id;
         $payment_info = $this->save_payment_info($payment_info);
         $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, false);
         wp_redirect($payment->getPaymentUrl());
         tc_js_redirect($payment->getPaymentUrl());
         exit;
     } catch (Mollie_API_Exception $e) {
         $_SESSION['tc_gateway_error'] = __('API call failed: ', 'tc-mollie') . htmlspecialchars($e->getMessage());
         wp_redirect($tc->get_payment_slug(true));
         tc_js_redirect($tc->get_payment_slug(true));
         exit;
     }
 }
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     if (isset($_POST['simplify_payment_form']) && $_POST['simplify_payment_form'] == 'not_available') {
         $_SESSION['tc_gateway_error'] = __('The Simplify Commerce is not available at the moment. Please try another method or contact the admnistrator', 'tc-sc');
         wp_redirect($tc->get_payment_slug(true));
         tc_js_redirect($tc->get_payment_slug(true));
         return false;
     }
     if (!isset($_POST['simplifyToken'])) {
         $_SESSION['tc_gateway_error'] = __('The Simplify Commerce Token was not generated correctly. Please go back and try again.', 'tc');
         wp_redirect($tc->get_payment_slug(true));
         tc_js_redirect($tc->get_payment_slug(true));
         return false;
     }
     $_SESSION['simplifyToken'] = $_POST['simplifyToken'];
     require_once $tc->plugin_dir . "/includes/gateways/simplify/Simplify.php";
     //generate a tickera order id
     $order_id = $tc->generate_order_id();
     Simplify::$publicKey = $this->public_key;
     Simplify::$privateKey = $this->private_key;
     try {
         $payment = Simplify_Payment::createPayment(array('amount' => $this->total() * 100, 'token' => $_SESSION['simplifyToken'], 'description' => $this->cart_items(), 'reference' => $order_id, 'currency' => $this->currency));
         if ($payment->paymentStatus == 'APPROVED') {
             $payment_info = array();
             $payment_info['transaction_id'] = $payment->id;
             $payment_info = $this->save_payment_info();
             $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, true);
             wp_redirect($tc->get_confirmation_slug(true, $order_id));
             tc_js_redirect($tc->get_confirmation_slug(true));
             exit;
         } else {
             if ($payment->paymentStatus == 'DECLINED') {
                 //run if the card is declined etc.
                 //
                 $_SESSION['tc_gateway_error'] = apply_filters('tc_simplify_declined_card', __('We\'re very sorry but the card you entered was declined ', 'tc-sc'));
                 wp_redirect($tc->get_payment_slug(true));
                 tc_js_redirect($tc->get_payment_slug(true));
                 exit;
             }
         }
     } catch (Simplify_ApiException $e) {
         unset($_SESSION['simplifyToken']);
         $_SESSION['tc_gateway_error'] = sprintf(__('There was an error processing your card - "%s".', 'tc'), $e->getMessage());
         wp_redirect($tc->get_payment_slug(true));
         tc_js_redirect($tc->get_payment_slug(true));
         exit;
     }
     return false;
 }
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     if (isset($_POST['paymillToken'])) {
         $_SESSION['paymillToken'] = $_POST['paymillToken'];
     }
     if (!isset($_SESSION['paymillToken'])) {
         $_SESSION['tc_gateway_error'] = __('The Paymill Token was not generated correctly.', 'tc');
         wp_redirect($tc->get_payment_slug(true));
         tc_js_redirect($tc->get_payment_slug(true));
         exit;
         return false;
     }
     define('PAYMILL_API_HOST', 'https://api.paymill.com/v2/');
     define('PAYMILL_API_KEY', $this->get_option('private_key'));
     $token = $_SESSION['paymillToken'];
     if ($token) {
         require "paymill/lib/Services/Paymill/Transactions.php";
         $transactionsObject = new Services_Paymill_Transactions(PAYMILL_API_KEY, PAYMILL_API_HOST);
         $order_id = $tc->generate_order_id();
         try {
             $params = array('amount' => $this->total() * 100, 'currency' => strtolower($this->currency), 'token' => $token, 'description' => $this->cart_items());
             $charge = $transactionsObject->create($params);
             if ($charge['status'] == 'closed') {
                 //setup our payment details
                 $payment_info = array();
                 $payment_info['method'] = sprintf(__('%1$s Card ending in %2$s - Expires %3$s', 'tc'), ucfirst($charge['payment']['card_type']), $charge['payment']['last4'], $charge['payment']['expire_month'] . '/' . $charge['payment']['expire_year']);
                 $payment_info['transaction_id'] = $charge['id'];
                 $payment_info = $this->save_payment_info();
                 $paid = true;
                 $order = $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, $paid);
                 wp_redirect($tc->get_confirmation_slug(true, $order_id));
                 tc_js_redirect($tc->get_confirmation_slug(true, $order_id));
                 exit;
             }
         } catch (Exception $e) {
             unset($_SESSION['paymillToken']);
             $_SESSION['tc_gateway_error'] = sprintf(__('There was an error processing your card: "%s".', 'tc'), $e->getMessage());
             wp_redirect($tc->get_payment_slug(true));
             tc_js_redirect($tc->get_payment_slug(true));
             exit;
             return false;
         }
     }
 }
 function send_request($host, $data)
 {
     $response = wp_remote_post($host, array('method' => 'POST', 'body' => $data, 'timeout' => 70, 'sslverify' => false));
     if (is_wp_error($response)) {
         $_SESSION['tc_gateway_error'] = __('There was a problem connecting to the payment gateway.', 'tc');
         wp_redirect($tc->get_payment_slug(true));
         tc_js_redirect($tc->get_payment_slug(true));
         exit;
     }
     if (empty($response['body'])) {
         $_SESSION['tc_gateway_error'] = __('Empty PayUMoney response.', 'tc');
         wp_redirect($tc->get_payment_slug(true));
         tc_js_redirect($tc->get_payment_slug(true));
         exit;
     }
     $parsed_response = $response['body'];
     return $parsed_response;
 }
<?php

global $tc, $tc_gateway_plugins;
$cart_total = 0;
$cart_contents = $tc->get_cart_cookie();
if (!isset($_REQUEST['tc_choose_gateway'])) {
    _e('Something went wrong: Gateway is not selected.', 'tc');
}
$payment_class_name = $tc_gateway_plugins[$_REQUEST['tc_choose_gateway']][0];
$payment_gateway = new $payment_class_name();
if (!session_id()) {
    session_start();
}
$cart_total = $_SESSION['tc_cart_total'];
if ($tc->checkout_error == false) {
    $payment_gateway->process_payment($cart_contents);
    exit;
} else {
    wp_redirect($this->get_payment_slug(true));
    tc_js_redirect($this->get_payment_slug(true));
    exit;
}
 function order_confirmation($order, $payment_info = '', $cart_info = '')
 {
     global $tc;
     if (isset($_POST['ErrDesc']) && !empty($_POST['ErrDesc'])) {
         $_SESSION['tc_gateway_error'] = $_POST['ErrDesc'];
         wp_redirect($tc->get_payment_slug(true));
         tc_js_redirect($tc->get_payment_slug(true));
         exit;
     } else {
         $this->ipn();
     }
 }
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     $order_id = $tc->generate_order_id();
     $params = array();
     $params['no_shipping'] = '1';
     //do not prompt for an address
     $params['cmd'] = '_xclick';
     $params['business'] = $this->business;
     $params['currency_code'] = $this->currency;
     $params['item_name'] = $this->cart_items();
     $params['amount'] = $this->total();
     $params['custom'] = $order_id;
     $params['return'] = $tc->get_confirmation_slug(true, $order_id);
     $params['cancel_return'] = apply_filters('tc_paypal_standard_cancel_url', $this->cancel_url);
     $params['notify_url'] = $this->ipn_url;
     $params['charset'] = apply_filters('tc_paypal_standard_charset', 'UTF-8');
     $params['rm'] = '2';
     //the buyer's browser is redirected to the return URL by using the POST method, and all payment variables are included
     $params['lc'] = $this->locale;
     $params['email'] = $this->buyer_info('email');
     $params['first_name'] = $this->buyer_info('first_name');
     $params['last_name'] = $this->buyer_info('last_name');
     if ($this->SandboxFlag == 'live') {
         $url = 'https://www.paypal.com/cgi-bin/webscr';
     } else {
         $params['demo'] = 'Y';
         $url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
     }
     $param_list = array();
     foreach ($params as $k => $v) {
         $param_list[] = "{$k}=" . rawurlencode($v);
     }
     $param_str = implode('&', $param_list);
     $paid = false;
     $payment_info = $this->save_payment_info();
     $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, $paid);
     wp_redirect("{$url}?{$param_str}");
     tc_js_redirect("{$url}?{$param_str}");
     exit(0);
 }
 function process_payment($cart)
 {
     global $tc;
     $this->maybe_start_session();
     $this->save_cart_info();
     $_SESSION['stripeToken'] = $_POST['stripeToken'];
     if (!isset($_SESSION['stripeToken'])) {
         $tc->cart_checkout_error(__('The Stripe Token was not generated correctly. Please go back and try again.', 'tc'));
         return false;
     }
     if (!class_exists('Stripe')) {
         require_once $tc->plugin_dir . "/includes/gateways/stripe/lib/Stripe.php";
     }
     Stripe::setApiKey($this->private_key);
     $order_id = $tc->generate_order_id();
     try {
         $stripe_params = array("amount" => $this->total() * 100, "currency" => strtolower($this->currency), "card" => $_SESSION['stripeToken'], "description" => $this->cart_items());
         if ($this->send_receipt == '1') {
             $stripe_params["receipt_email"] = $this->buyer_info('email');
         }
         $charge = Stripe_Charge::create($stripe_params);
         if ($charge->paid == 'true') {
             $payment_info = array();
             $payment_info['method'] = sprintf(__('%1$s Card ending in %2$s - Expires %3$s', 'tc'), $charge->card->type, $charge->card->last4, $charge->card->exp_month . '/' . $charge->card->exp_year);
             $payment_info['transaction_id'] = $charge->id;
             $payment_info = $this->save_payment_info();
             $paid = true;
             $order = $tc->create_order($order_id, $this->cart_contents(), $this->cart_info(), $payment_info, $paid);
             wp_redirect($tc->get_confirmation_slug(true, $order_id));
             tc_js_redirect($tc->get_confirmation_slug(true, $order_id));
             exit;
         }
     } catch (Exception $e) {
         unset($_SESSION['stripeToken']);
         $_SESSION['tc_gateway_error'] = sprintf(__('There was an error processing your card - "%s".', 'tc'), $e->getMessage());
         wp_redirect($tc->get_payment_slug(true));
         tc_js_redirect($tc->get_payment_slug(true));
         exit;
     }
     return false;
 }