Example #1
0
 function execute($pid, $script)
 {
     $s = new Stop();
     $s->Execute($pid, $script);
     $s = new Start();
     $s->Execute($pid, $script);
 }
Example #2
0
 public function execute_new_xml_load()
 {
     $pss = new PSS();
     $start = new Start();
     if (isset($_POST['url'])) {
         $json = $start->request($_POST['url']);
         $data = json_decode($json);
         $_SESSION['error'] = $pss->load_patterns2db($data);
         header("Location:?q=config");
         exit;
     }
     return array();
 }
Example #3
0
 /**
  * 取得模板引擎实例
  *
  * @return obj
  * @access  public 
  * @static
  */
 public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new Start();
     }
     return self::$instance;
 }
Example #4
0
 /**
  * List all created charges
  *
  * @return array list of transactions
  * @throws Start_Error_Parameters if any of the parameters is invalid
  * @throws Start_Error_Authentication if the API Key is invalid
  * @throws Start_Error if there is a general error in the API endpoint
  * @throws Exception for any other errors
  */
 public static function all()
 {
     $url = Start::getEndPoint('charge_list');
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_CAINFO, Start::getCaPath());
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_USERPWD, Start::getApiKey() . ':');
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_USERAGENT, 'Start/PHP/' . Start::VERSION);
     $result = json_decode(curl_exec($ch), true);
     // Check for errors and such.
     $info = curl_getinfo($ch);
     $errno = curl_errno($ch);
     if ($result === false || $errno != 0) {
         // Do error checking
         throw new Exception(curl_error($ch));
     } else {
         if ($info['http_code'] < 200 || $info['http_code'] > 299) {
             // Got a non-200 error code.
             Start::handleErrors($result, $info['http_code']);
         }
     }
     curl_close($ch);
     return $result;
 }
 function setUp()
 {
     Start::$fallback = false;
     Start::setApiKey('test_sec_k_2b99b969196bece8fa7fd');
     if (getenv("CURL") == "1") {
         Start::$useCurl = true;
     }
 }
Example #6
0
 public static function createToken($card)
 {
     $api_key_to_restore = Start::getApiKey();
     Start::setApiKey(self::$open_api_key);
     $token = Start_Token::create($card);
     Start::setApiKey($api_key_to_restore);
     return $token;
 }
 function setUp()
 {
     Start::setApiKey('test_sec_k_2b99b969196bece8fa7fd');
     Start::$fallback = false;
     if (getenv("CURL") == "1") {
         Start::$useCurl = true;
     }
     // Data for a successful customer
     $this->success_data = array("name" => "Test Customer", "email" => "*****@*****.**", "description" => "Signed up at the fair", "card" => array("number" => "4242424242424242", "exp_month" => 11, "exp_year" => 2016, "cvc" => "123"));
 }
Example #8
0
 public static function make_request($path, $data = array(), $method = '')
 {
     $url = Start::getBaseURL() . $path;
     try {
         return Start::$useCurl ? Start_Net_Curl::make_request($url, $data, $method) : Start_Net_Stream::make_request($url, $data, $method);
     } catch (Start_Error_SSLError $e) {
         // fallback to opposite method
         if (Start::$fallback) {
             return Start::$useCurl ? Start_Net_Stream::make_request($url, $data, $method) : Start_Net_Curl::make_request($url, $data, $method);
         } else {
             throw $e;
         }
     }
 }
Example #9
0
 /**
  * "Start" the application:
  * Analyze the URL elements and calls the according controller/method or the fallback
  */
 public function __construct()
 {
     // create array with URL parts in $url
     $this->splitUrl();
     // check for controller: does such a controller exist ?
     if (file_exists('./application/controller/' . $this->url_controller . '.php')) {
         // if so, then load this file and create this controller
         // example: if controller would be "car", then this line would translate into: $this->car = new car();
         require './application/controller/' . $this->url_controller . '.php';
         $this->url_controller = new $this->url_controller();
         // check for method: does such a method exist in the controller ?
         if (method_exists($this->url_controller, $this->url_action)) {
             // call the method and pass the arguments to it
             if (isset($this->url_parameter_3)) {
                 // will translate to something like $this->home->method($param_1, $param_2, $param_3);
                 $this->url_controller->{$this->url_action}($this->url_parameter_1, $this->url_parameter_2, $this->url_parameter_3);
             } elseif (isset($this->url_parameter_2)) {
                 // will translate to something like $this->home->method($param_1, $param_2);
                 $this->url_controller->{$this->url_action}($this->url_parameter_1, $this->url_parameter_2);
             } elseif (isset($this->url_parameter_1)) {
                 // will translate to something like $this->home->method($param_1);
                 $this->url_controller->{$this->url_action}($this->url_parameter_1);
             } else {
                 // if no parameters given, just call the method without parameters, like $this->home->method();
                 $this->url_controller->{$this->url_action}();
             }
         } else {
             // default/fallback: call the index() method of a selected controller
             $this->url_controller->index();
         }
     } else {
         // invalid URL, so simply show start/index
         require './application/controller/start.php';
         $start = new Start();
         $start->index();
     }
 }
Example #10
0
 public static function make_request($url, $data = array(), $method = '')
 {
     if (!defined('CURL_SSLVERSION_TLSv1_2')) {
         define('CURL_SSLVERSION_TLSv1_2', 6);
     }
     $ch = curl_init();
     if (Start::getUserAgent() != "") {
         $userAgent = Start::getUserAgent() . ' / StartPHP CURL ' . Start::VERSION;
     } else {
         $userAgent = 'StartPHP CURL' . Start::VERSION;
     }
     curl_setopt($ch, CURLOPT_CAINFO, Start::getCaPath());
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_USERPWD, Start::getApiKey() . ':');
     curl_setopt($ch, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1_2);
     if (!empty($data)) {
         if ($method == 'PUT' || $method == 'GET') {
             curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
         }
         curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
         curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen(json_encode($data))));
     }
     curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $result = json_decode(curl_exec($ch), true);
     // Check for errors and such.
     $info = curl_getinfo($ch);
     $errno = curl_errno($ch);
     if ($result === false || $errno != 0) {
         // Do error checking
         $curl_error = curl_error($ch);
         if ($errno == '1' || $errno == '35' || $errno == '51' || $errno == '60') {
             $exception_message = "You weren’t able to make API request due to SSL/TLS error. " . "  Here you can read how to solve this: https://docs.start.payfort.com/help/php/ssl#error_" . $errno . " Curl error: " . $curl_error;
         } else {
             $exception_message = "Curl error: " . $curl_error;
         }
         throw new Start_Error_SSLError($exception_message);
     } else {
         if ($info['http_code'] < 200 || $info['http_code'] > 299) {
             // Got a non-200 error code.
             Start::handleErrors($result, $info['http_code']);
         }
     }
     curl_close($ch);
     return $result;
 }
Example #11
0
 public static function make_request($url, $data = array(), $method)
 {
     $api_key = Start::getApiKey();
     $headers = array('Connection: close', "Authorization: Basic " . base64_encode("{$api_key}:"));
     if (!empty($data)) {
         if ($method == '') {
             $method = 'POST';
         }
         $content = json_encode($data);
         array_push($headers, 'Content-Type: application/json');
         array_push($headers, 'Content-Length: ' . strlen($content));
     } else {
         $method = 'GET';
         $content = '';
     }
     if (Start::getUserAgent() != "") {
         $user_agent = Start::getUserAgent() . ' / StartPHP Stream ' . Start::VERSION;
     } else {
         $user_agent = 'StartPHP Stream' . Start::VERSION;
     }
     $opts = array('http' => array('method' => $method, 'content' => $content, 'header' => $headers, 'timeout' => 20, 'ignore_errors' => true, 'user_agent' => $user_agent), 'ssl' => array('verify_peer' => true, 'cafile' => Start::getCaPath()));
     $context = stream_context_create($opts);
     $response = "{}";
     $exception_message = "";
     try {
         $response = file_get_contents($url, false, $context);
     } catch (Exception $e) {
         $exception_message = "You weren’t able to make API request due to SSL/TLS connection error. " . "Here you can read how to solve this: https://docs.start.payfort.com/help/php/ssl. " . "Error details: " . $e->getMessage();
         throw new Start_Error_SSLError($exception_message);
     }
     $result = json_decode($response, true);
     $headers = self::parseHeaders($http_response_header);
     if ($headers['http_code'] < 200 || $headers['http_code'] > 299) {
         Start::handleErrors($result, $headers['http_code']);
     } else {
         return $result;
     }
 }
 public function send()
 {
     require_once './vendor/autoload.php';
     if ($this->config->get('payfort_start_transaction')) {
         $capture = FALSE;
     } else {
         $capture = TRUE;
     }
     if ($this->config->get('payfort_start_test')) {
         $payfort_start_secret_api = $this->config->get('payfort_start_entry_test_secret_key');
     } else {
         $payfort_start_secret_api = $this->config->get('payfort_start_entry_live_secret_key');
     }
     $token = $_POST['payment_token'];
     $email = $_POST['payment_email'];
     $this->load->model('checkout/order');
     $order_id = $this->session->data['order_id'];
     $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
     $order_description = "Charge for order";
     $amount = $order_info['total'];
     $amount_in_cents = $amount * 100;
     $charge_args = array('description' => $order_description . ': ' . $order_id, 'card' => $token, 'currency' => $order_info['currency_code'], 'email' => $email, 'ip' => $_SERVER["REMOTE_ADDR"], 'amount' => $amount_in_cents, 'capture' => $capture);
     Start::setApiKey($payfort_start_secret_api);
     $json = array();
     try {
         $charge = Start_Charge::create($charge_args);
         $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
         $this->model_checkout_order->update($order_id, $this->config->get('payfort_start_order_status_id'), 'Charge added: ' . $order_id, false);
         $json['success'] = $this->url->link('checkout/success');
     } catch (Start_Error_Banking $e) {
         if ($e->getErrorCode() == "card_declined") {
             $json['error'] = "Card declined. Please use another card";
         } else {
             $json['error'] = $e->getMessage();
         }
     }
     $this->response->setOutput(json_encode($json));
 }
Example #13
0
<?php

include_once 'FC/class/User.class.php';
include_once 'start.class.php';
$myStart = new Start();
?>

<div class="col-md-7">
    <form method="post" action="accueil.php?link=start">
        <?php 
if (!empty($_POST) && $_POST['typeConvoi'] != -1) {
    $myStart->setNewConvoi();
    header("Location: accueil.php?link=accueil");
} else {
    include "start.html.php";
}
?>
    </form>
</div>
Example #14
0
<?php

/**
*Ajax engine - P.W.S.M.
*Author Roman Shneer romanshneer@gmail.com
*1.02.2012
*changed 01.11.2015
*/
include_once "lib/start.inc.php";
include_once "lib/pss.inc.php";
$start = new Start();
$start->chk_installation_login();
//$ajax=new _Ajax;
$pss = new PSS();
switch ($_GET['act']) {
    case 'request_reason':
        $template = 'request_reason';
        break;
    case 'chg_status':
        $template = 'chg_status';
        break;
    case 'chg_method':
        $template = 'chg_method';
        break;
    case 'chg_url':
        $template = 'chg_url';
        break;
    case 'chg_query_string':
        $template = 'chg_query_string';
        break;
    case 'chg_remote_ip':
Example #15
0
<?php

/**
*Installator - P.W.S.M.
*Author Roman Shneer romanshneer@gmail.com
*1.02.2012
*changed 01.11.2015
*/
include_once "../lib/start.inc.php";
include_once "../lib/wisard.inc.php";
$start = new Start();
$wisard = new Wisard();
$step = isset($_GET['step']) ? $_GET['step'] : 0;
### wellcome2 installer ###
if ($wisard->chk_configfile() == true && $step != 7) {
    $step = 1000;
}
switch ($step) {
    case 0:
        $template = 'window_wellcome';
        break;
    case 1:
        $template = 'window_create_config_file';
        break;
    case 2:
        $template = 'check_before_install';
        break;
    case 3:
        $template = 'install_db';
        break;
    case 4:
Example #16
0
 /**
  * sets API Key
  *
  * @param string $userAgent UserAgent
  */
 public static function setUserAgent($userAgent)
 {
     self::$userAgent = $userAgent;
 }
Example #17
0
 function setUp()
 {
     Start::setApiKey('test_sec_k_2b99b969196bece8fa7fd');
 }
 /**
  * @expectedException Start_Error_Request
  */
 function testCardException()
 {
     Start::setApiKey('test_sec_k_2b99b969196bece8fa7fd');
     $data = array("amount" => 1050, "currency" => "usd", "card" => array("number" => "4141414141414141", "exp_month" => 11, "exp_year" => 2016, "cvc" => "123"), "description" => "Charge for test@example.com");
     Start_Charge::create($data);
 }
 function setUp()
 {
     Start::setApiKey('test_sec_k_2b99b969196bece8fa7fd');
     // Data for a successful customer
     $this->success_data = array("name" => "Test Customer", "email" => "*****@*****.**", "description" => "Signed up at the fair", "card" => array("number" => "4242424242424242", "exp_month" => 11, "exp_year" => 2016, "cvc" => "123"));
 }
Example #20
0
}
return;
if (!class_exists('Raptor\\Raptor', false)) {
    $rpt_autoload = true;
} else {
    $rpt_autoload = false;
}
if (!class_exists('Raptor\\autoload', false)) {
    require __DIR__ . '/../../../../lib/autoload.php';
}
\Raptor\autoload::register();
\Raptor\RaptorDB::registerAutoload();
\Raptor\Bundle\BundleAutoload::register();
if (!defined("USER_LOCAL")) {
    define("USER_LOCAL", 305);
}
if (!defined("USER_REMOTE")) {
    define("USER_REMOTE", 306);
}
if (!defined("USER_PUBLIC")) {
    define("USER_PUBLIC", 307);
}
if (!class_exists('Start', false)) {
    require __DIR__ . '/../../../../app/Start.php';
}
$start = new \Start();
$start->onConfig();
if ($rpt_autoload) {
    $sessionhandler = new System\SessionHandlerBundle\Controller\DefaultController();
    $sessionhandler->indexAction();
}
Example #21
0
 public function send()
 {
     require_once './vendor/autoload.php';
     if ($this->config->get('payfort_start_transaction')) {
         $capture = FALSE;
     } else {
         $capture = TRUE;
     }
     if ($this->config->get('payfort_start_test')) {
         $payfort_start_secret_api = $this->config->get('payfort_start_entry_test_secret_key');
     } else {
         $payfort_start_secret_api = $this->config->get('payfort_start_entry_live_secret_key');
     }
     $token = $_POST['payment_token'];
     $email = $_POST['payment_email'];
     $this->load->model('checkout/order');
     $order_id = $this->session->data['order_id'];
     $order = $this->model_checkout_order->getOrder($this->session->data['order_id']);
     $order_description = "Charge for order";
     $amount = $order['total'];
     if (file_exists(DIR_SYSTEM . '../data/currencies.json')) {
         $currency_json_data = json_decode(file_get_contents(HTTP_SERVER . 'data/currencies.json'), 1);
         $currency_multiplier = $currency_json_data[$order['currency_code']];
     } else {
         $currency_multiplier = 100;
     }
     $amount_in_cents = $amount * $currency_multiplier;
     $version = "0.2";
     $billing_address = array("first_name" => $order['payment_firstname'], "last_name" => $order['payment_lastname'], "country" => $order['payment_country'], "city" => $order['payment_city'], "address_1" => $order['payment_address_1'], "address_2" => $order['payment_address_2'], "phone" => $order['telephone'], "postcode" => $order['payment_postcode']);
     if ($this->cart->hasShipping()) {
         $shipping_address = array("first_name" => $order['shipping_firstname'], "last_name" => $order['shipping_lastname'], "country" => $order['shipping_country'], "city" => $order['shipping_city'], "address_1" => $order['shipping_address_1'], "address_2" => $order['shipping_address_2'], "phone" => $order['telephone'], "postcode" => $order['shipping_postcode']);
     } else {
         $shipping_address = $billing_address;
     }
     if ($order['customer_id'] != 0) {
         $this->load->model('account/customer');
         $customer_info = $this->model_account_customer->getCustomer($this->customer->getId());
     }
     $user_name = $order['customer_id'] == 0 ? "guest" : $customer_info['firstname'];
     $registered_at = $order['customer_id'] == 0 ? date(DATE_ISO8601, strtotime(date("Y-m-d H:i:s"))) : date(DATE_ISO8601, strtotime($customer_info['date_added']));
     $products = $this->cart->getProducts();
     $order_items_array_full = array();
     foreach ($products as $key => $items) {
         $order_items_array['title'] = $items['name'];
         $order_items_array['amount'] = $items['price'];
         $order_items_array['quantity'] = $items['quantity'];
         array_push($order_items_array_full, $order_items_array);
     }
     $shopping_cart_array = array('user_name' => $user_name, 'registered_at' => $registered_at, 'items' => $order_items_array_full, 'billing_address' => $billing_address, 'shipping_address' => $shipping_address);
     $userAgent = 'Opencart ' . VERSION . ' / Start Plugin ' . $version;
     Start::setUserAgent($userAgent);
     Start::setApiKey($payfort_start_secret_api);
     $json = array();
     try {
         $charge_args = array('description' => $order_description . ': ' . $order_id, 'card' => $token, 'currency' => $order['currency_code'], 'email' => $email, 'ip' => $_SERVER["REMOTE_ADDR"], 'amount' => $amount_in_cents, 'capture' => $capture, 'shopping_cart' => $shopping_cart_array, 'metadata' => array('reference_id' => $order_id));
         $charge = Start_Charge::create($charge_args);
         $this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
         $this->model_checkout_order->update($order_id, $this->config->get('payfort_start_order_status_id'), 'Charge added: ' . $order_id, false);
         $json['success'] = $this->url->link('checkout/success');
     } catch (Start_Error_Banking $e) {
         if ($e->getErrorCode() == "card_declined") {
             $json['error'] = "Card declined. Please use another card";
         } else {
             $json['error'] = $e->getMessage();
         }
     }
     $this->response->setOutput(json_encode($json));
 }
Example #22
0
 function testEndPoints()
 {
     $this->assertEquals('https://api.start.payfort.com/charges/', Start::getEndPoint('charge'));
     $this->assertEquals('https://api.start.payfort.com/charges/', Start::getEndPoint('charge_list'));
 }
Example #23
0
<?php

require_once "config.php";
# Read the fields that were automatically submitted by beautiful.js
$token = $_POST["startToken"];
$email = $_POST["startEmail"];
# Setup the Start object with your private API key
Start::setApiKey($api_keys["secret_key"]);
# Process the charge
try {
    $charge = Start_Charge::create(array("amount" => $amount_in_cents, "currency" => $currency, "card" => $token, "email" => $email, "ip" => $_SERVER["REMOTE_ADDR"], "description" => "Charge Description"));
    echo "<h1>Successfully charged 10.00 AED</h1>";
    echo "<p>Charge ID: " . $charge["id"] . "</p>";
    echo "<p>Charge State: " . $charge["state"] . "</p>";
} catch (Start_Error $e) {
    $error_code = $e->getErrorCode();
    $error_message = $e->getMessage();
    /* depending on $error_code we can show different messages */
    if ($error_code === "card_declined") {
        echo "<h1>Charge was declined</h1>";
    } else {
        echo "<h1>Charge was not processed</h1>";
    }
    echo "<p>" . $error_message . "</p>";
}
?>

<a href="index.php">Try Again!</a>
Example #24
0
<?php

/**
*Main - P.W.S.M.
*Author Roman Shneer romanshneer@gmail.com
*1.02.2012
*changed 01.11.2015
*/
ini_set("display_errors", 1);
include_once "lib/start.inc.php";
include_once "lib/pss.inc.php";
#die("<hr>");
$start = new Start();
$start->chk_installation_login();
$pss = new PSS();
$contents[] = $start->letter_from_past();
#$headers['header']= $pss->draw_menu();
$headers['footer'] = '<author>Copiright 2012-' . date('Y') . ',PHP Web Security Monitor 2.0  <a href="mailto:romanshneer@gmail.com">Author</a>&nbsp;<a href="http://romanshneer.info/pwsm/contacts.php">Contact Us</a></author>';
if (!isset($_GET['q'])) {
    $_GET['q'] = null;
}
$data = array();
switch ($_GET['q']) {
    case 'new_agent':
        $template = 'new_agent';
        #$contents[]=$pss->wisard_new_agent();
        $headers['title'] = 'Patching new monitored object';
        break;
    case 'view_file':
        $template = 'view_file';
        $headers['title'] = 'View File Source';
Example #25
0
 public function collectPayment(\Mage_Payment_Model_Info $payment, $amount, $capture = true)
 {
     $Currency = Mage::app()->getStore()->getBaseCurrencyCode();
     require_once MAGENTO_ROOT . '/lib/Start/autoload.php';
     # At the top of your PHP file
     $token = isset($_POST['payfortToken']) ? $_POST['payfortToken'] : false;
     $email = isset($_POST['payfortEmail']) ? $_POST['payfortEmail'] : false;
     if (!$token || !$email) {
         //this block will be executed if the order was authorized earlier and now trying to capture amount
         $token_array = $payment->getAdditionalInformation('token');
         $token = $token_array['token'];
         $email = $token_array['email'];
     }
     if (!$token || !$email) {
         Mage::throwException('Invalid Token');
     }
     $currency = !isset($Currency) ? 'AED' : $Currency;
     if (file_exists(MAGENTO_ROOT . '/data/currencies.json')) {
         $currency_json_data = json_decode(file_get_contents(MAGENTO_ROOT . '/data/currencies.json'), 1);
         $currency_multiplier = $currency_json_data[$currency];
     } else {
         $currency_multiplier = 100;
     }
     $amount_in_cents = $amount * $currency_multiplier;
     $order = $payment->getOrder();
     $order_items_array_full = array();
     foreach ($order->getAllVisibleItems() as $value) {
         $order_items_array['title'] = $value->getName();
         $order_items_array['amount'] = round($value->getPrice(), 2) * $currency_multiplier;
         $order_items_array['quantity'] = $value->getQtyOrdered();
         array_push($order_items_array_full, $order_items_array);
     }
     $shipping_amount = $order->getShippingAmount();
     $shipping_amount = $shipping_amount * $currency_multiplier;
     if (Mage::getSingleton('customer/session')->isLoggedIn()) {
         $customer = Mage::getSingleton('customer/session')->getCustomer();
         $username = $customer->getName();
         $registered_at = date(DATE_ISO8601, strtotime($customer->getCreatedAt()));
     } else {
         $username = "******";
         $registered_at = date(DATE_ISO8601, strtotime(date("Y-m-d H:i:s")));
     }
     $billing_data = $order->getBillingAddress()->getData();
     if (is_object($order->getShippingAddress())) {
         $shipping_data = $order->getShippingAddress()->getData();
         $shipping_address = array("first_name" => $shipping_data['firstname'], "last_name" => $shipping_data['lastname'], "country" => $shipping_data['country_id'], "city" => $shipping_data['city'], "address" => $shipping_data['customer_address'], "phone" => $shipping_data['telephone'], "postcode" => $shipping_data['postcode']);
     } else {
         $shipping_address = array();
     }
     $billing_address = array("first_name" => $billing_data['firstname'], "last_name" => $billing_data['lastname'], "country" => $billing_data['country_id'], "city" => $billing_data['city'], "address" => $billing_data['customer_address'], "phone" => $billing_data['telephone'], "postcode" => $billing_data['postcode']);
     $shopping_cart_array = array('user_name' => $username, 'registered_at' => $registered_at, 'items' => $order_items_array_full, 'billing_address' => $billing_address, 'shipping_address' => $shipping_address);
     $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
     $charge_args = array('description' => "Magento charge for " . $email, 'card' => $token, 'currency' => $currency, 'email' => $email, 'ip' => $_SERVER['REMOTE_ADDR'], 'amount' => $amount_in_cents, 'capture' => $capture, 'shipping_amount' => $shipping_amount, 'shopping_cart' => $shopping_cart_array, 'metadata' => array('reference_id' => $orderId));
     $ver = new Mage();
     $version = $ver->getVersion();
     $userAgent = 'Magento ' . $version . ' / Start Plugin ' . self::PLUGIN_VERSION;
     Start::setUserAgent($userAgent);
     $method = $payment->getMethodInstance();
     if ($method->getConfigData('test_mode') == 1) {
         Start::setApiKey($method->getConfigData('test_secret_key'));
     } else {
         Start::setApiKey($method->getConfigData('live_secret_key'));
     }
     try {
         // Charge the token
         $charge = Start_Charge::create($charge_args);
         //need to process charge as success or failed
         $payment->setTransactionId($charge["id"]);
         if ($capture) {
             $payment->setIsTransactionClosed(1);
         } else {
             $payment->setIsTransactionClosed(0);
         }
     } catch (Start_Error $e) {
         $error_code = $e->getErrorCode();
         if ($error_code === "card_declined") {
             $errorMsg = 'Charge was declined. Please, contact you bank for more information or use a different card.';
         } else {
             $errorMsg = $e->getMessage();
         }
         throw new Mage_Payment_Model_Info_Exception($errorMsg);
     }
     //need to process charge as success or failed
 }
Example #26
0
 public function __construct($arrayConfig = array())
 {
     parent::__construct($arrayConfig + $this->arrayConfig);
 }
Example #27
0
<?php

/**
*Login - P.W.S.M.
*Author Roman Shneer romanshneer@gmail.com
*1.02.2012
*changed 01.11.2015
*/
include_once "../lib/start.inc.php";
$start = new Start();
$start->chk_installation();
if (!$start->chk_user()) {
    if (isset($_GET['act']) && $_GET['act'] == 'restore') {
        $template = 'restore_form';
    } elseif (isset($_GET['act']) && $_GET['act'] == 'restorenow' && isset($_GET['key'])) {
        $template = 'restorenow_form';
    } else {
        $template = 'login_form';
    }
} else {
    header("Location:" . substr($_SERVER['REQUEST_URI'], 0, strlen($_SERVER['REQUEST_URI']) - 6));
    exit;
}
$headers['footer'] = 'Copiright 2012-' . date('Y') . ',PHP Web Security Monitor 2.0,Roman Shneer   <a href="mailto:romanshneer@gmail.com">Contact</a>';
$headers['title'] = 'Authorisation';
$headers['description'] = 'PHP Web Security Monitor 2.0 is a security filter and monitor of REQUEST PHP variables for webmaster.';
$headers['keywords'] = 'PHP, Security, hacked site, hackers';
$headers['type'] = 'login';
#print $start->template_html($headers,$html);
include_once "../actions/actions.class.php";
$Actions = new Actions();
Example #28
0
 /**
  * sets API Key
  *
  * @param string $apiKey API key
  */
 public static function setApiKey($apiKey)
 {
     self::$apiKey = $apiKey;
 }
 /**
  * Process the payment and return the result
  *
  * @access public
  * @param int $order_id
  * @return array
  */
 function process_payment($order_id)
 {
     global $woocommerce;
     $order = new WC_Order($order_id);
     $token = $_POST['payfortToken'];
     try {
         if (empty($token)) {
             $error_msg = __('Please make sure your card details have been entered correctly.', 'woocommerce');
             throw new Start_Error($error_msg);
         }
         $charge_description = $order->id . ": WooCommerce charge for " . $order->billing_email;
         $order_items = $order->get_items();
         $order_items_array_full = array();
         $user_info = wp_get_current_user();
         $user_name = $user_info->user_login;
         $udata = get_userdata($user_info->ID);
         if (isset($udata->user_registered)) {
             $registered_at = date(DATE_ISO8601, strtotime($udata->user_registered));
         } else {
             $registered_at = date(DATE_ISO8601, strtotime(date("Y-m-d H:i:s")));
         }
         foreach ($order_items as $key => $items) {
             $itemClass = new WC_Product($items['product_id']);
             $order_items_array['title'] = $items['name'];
             $order_items_array['amount'] = round($itemClass->get_price(), 2) * $this->currency_multiplier[get_woocommerce_currency()];
             $order_items_array['quantity'] = $items['qty'];
             array_push($order_items_array_full, $order_items_array);
         }
         $billing_address = array("first_name" => $order->billing_first_name, "last_name" => $order->billing_last_name, "country" => $order->billing_country, "city" => $order->billing_city, "address_1" => $order->billing_address_1, "address_2" => $order->billing_address_2, "phone" => $order->billing_phone, "postcode" => $order->billing_postcode);
         $shipping_address = array("first_name" => $order->shipping_first_name, "last_name" => $order->shipping_last_name, "country" => $order->shipping_country, "city" => $order->shipping_city, "address_1" => $order->shipping_address_1, "address_2" => $order->shipping_address_2, "phone" => $order->shipping_phone, "postcode" => $order->shipping_postcode);
         $shopping_cart_array = array('user_name' => $user_name, 'registered_at' => $registered_at, 'items' => $order_items_array_full, 'billing_address' => $billing_address, 'shipping_address' => $shipping_address);
         $charge_args = array('description' => $charge_description, 'card' => $token, 'currency' => strtoupper(get_woocommerce_currency()), 'email' => $order->billing_email, 'ip' => $_SERVER['REMOTE_ADDR'], 'amount' => $order->get_total() * $this->currency_multiplier[get_woocommerce_currency()], 'shopping_cart' => $shopping_cart_array, 'shipping_amount' => round($order->get_total_shipping(), 2) * $this->currency_multiplier[get_woocommerce_currency()], 'metadata' => array('reference_id' => $order_id));
         if ($this->test_mode == 'yes') {
             Start::setApiKey($this->test_secret_key);
         } else {
             Start::setApiKey($this->live_secret_key);
         }
         $start_plugin_data = get_file_data('wp-content/plugins/payfort/woocommerce-payfort.php', array('Version'), 'plugin');
         $woo_plugin_data = get_file_data('wp-content/plugins/woocommerce/woocommerce.php', array('Version'), 'plugin');
         $userAgent = 'WooCommerce ' . $woo_plugin_data['0'] . ' / Start Plugin ' . $start_plugin_data['0'];
         Start::setUserAgent($userAgent);
         $charge = Start_Charge::create($charge_args);
         // No exceptions? Yaay, all done!
         $order->payment_complete();
         return array('result' => 'success', 'redirect' => $this->get_return_url($order));
     } catch (Start_Error $e) {
         // TODO: Can we get the extra params (so the error is more apparent)?
         // e.g. Instead of "request params are invalid", we get
         // "extras":{"amount":["minimum amount (in the smallest currency unit) is 185 for AED"]
         $error_code = $e->getErrorCode();
         if ($error_code === "card_declined") {
             $message = __('Error: ', 'woothemes') . $e->getMessage() . " Please, try with another card";
         } else {
             $message = __('Error: ', 'woothemes') . $e->getMessage();
         }
         // If function should we use?
         if (function_exists("wc_add_notice")) {
             // Use the new version of the add_error method
             wc_add_notice($message, 'error');
         } else {
             // Use the old version
             $woocommerce->add_error($message);
         }
         // we raise 'update_checkout' event for javscript
         // to remove card token
         WC()->session->set('refresh_totals', true);
         return array('result' => 'fail', 'redirect' => '');
     }
 }
    $start_payments_secret_api = Tools::safeOutput(Configuration::get('PAYFORT_START_TEST_SECRET_KEY'));
} else {
    $start_payments_secret_api = Tools::safeOutput(Configuration::get('PAYFORT_START_LIVE_SECRET_KEY'));
}
if (Tools::safeOutput(Configuration::get('PAYFORT_START_CAPTURE'))) {
    $capture = 0;
} else {
    $capture = 1;
}
$order_description = "Charge for order";
$order_id = $_POST['x_invoice_num'];
$email = $_POST['payment_email'];
$amount = $_POST['amount'];
$charge_args = array('description' => $order_description . ': ' . $order_id, 'card' => $_POST['payment_token'], 'currency' => $currency->iso_code, 'email' => $email, 'ip' => $_SERVER["REMOTE_ADDR"], 'amount' => $amount * 100, 'capture' => $capture);
include dirname(__FILE__) . '/vendor/payfort/start/Start.php';
Start::setApiKey($start_payments_secret_api);
$json = array();
try {
    $charge = Start_Charge::create($charge_args);
    $url = 'index.php?controller=order-confirmation&';
    if (_PS_VERSION_ < '1.5') {
        $url = 'order-confirmation.php?';
    }
    $payfortstart->validateOrder((int) $cart->id, Configuration::get('PAYFORT_START_HOLD_REVIEW_OS'), (double) $amount, "payfort start", "message", NULL, NULL, false, $customer->secure_key);
    $auth_order = new Order($payfortstart->currentOrder);
    Tools::redirect($url . 'id_module=' . (int) $payfortstart->id . '&id_cart=' . (int) $cart->id . '&key=' . $auth_order->secure_key);
} catch (Start_Error_Banking $e) {
    if ($e->getErrorCode() == "card_declined") {
        $error_message = "Card declined. Please use another card";
    } else {
        $error_message = $e->getMessage();