示例#1
0
 public function createAction()
 {
     if (isset($_POST['ajax']) && isset($_POST['getgateways'])) {
         $gatewayModel = new Gateway();
         $gateways = $gatewayModel->getGateways();
         AF::setJsonHeaders('json');
         Message::echoJsonSuccess(array('message' => $gateways));
     }
     $model = new CampaignGateway();
     $this->performAjaxValidation($model);
     if (isset($_POST['model']) && $_POST['model'] == 'Campgate') {
         $model->fillFromArray($_POST);
         if (isset($_POST['ajax'])) {
             if ($model->addGatewayById()) {
                 $link = AF::link(array('campgate' => 'view'), array('campaign_id' => $model->campaign_id));
                 Message::echoJson('success', array('redirect' => $link));
             } else {
                 Message::echoJsonError(__('campgate_not_created') . ' ' . $model->errors2string);
             }
             die;
         }
         $model->addGatewayById();
         $this->redirect();
     }
     $this->addToPageTitle('Create Campaign Gateway');
     $this->render('create', array('model' => $model));
 }
 function commit()
 {
     if (!parent::commit()) {
         return false;
     }
     $id = $this->get('id');
     if ($id === false) {
         return false;
     }
     $fields = array();
     $fields['field_id'] = $id;
     $fields['default_location'] = $this->get('default_location');
     if (!$fields['default_location']) {
         $fields['default_location'] = 'Brisbane, Australia';
     }
     include_once TOOLKIT . '/class.gateway.php';
     $ch = new Gateway();
     $ch->init();
     $ch->setopt('URL', 'http://maps.google.com/maps/geo?q=' . urlencode($fields['default_location']) . '&output=xml&key=' . $this->_engine->Configuration->get('google-api-key', 'map-location-field'));
     $response = $ch->exec();
     if (!preg_match('/<Placemark/i', $response)) {
         $fields['default_location'] = 'Brisbane, Australia';
         $fields['default_location_coords'] = '-27.46, 153.025';
     } else {
         $xml = new SimpleXMLElement($response);
         $coords = preg_split('/,/', $xml->Response->Placemark[0]->Point->coordinates, -1, PREG_SPLIT_NO_EMPTY);
         $fields['default_location_coords'] = $coords[1] . ',' . $coords[0];
     }
     $this->_engine->Database->query("DELETE FROM `tbl_fields_" . $this->handle() . "` WHERE `field_id` = '{$id}' LIMIT 1");
     return $this->_engine->Database->insert($fields, 'tbl_fields_' . $this->handle());
 }
示例#3
0
 public function create($aData)
 {
     $oConnection = Propel::getConnection(GatewayPeer::DATABASE_NAME);
     try {
         $sGatewayUID = G::generateUniqueID();
         $aData['GAT_UID'] = $sGatewayUID;
         $oGateway = new Gateway();
         $oGateway->fromArray($aData, BasePeer::TYPE_FIELDNAME);
         if ($oGateway->validate()) {
             $oConnection->begin();
             $iResult = $oGateway->save();
             $oConnection->commit();
             return $sGatewayUID;
         } else {
             $sMessage = '';
             $aValidationFailures = $oGateway->getValidationFailures();
             foreach ($aValidationFailures as $oValidationFailure) {
                 $sMessage .= $oValidationFailure->getMessage() . '<br />';
             }
             throw new Exception('The registry cannot be created!<br />' . $sMessage);
         }
     } catch (Exception $oError) {
         $oConnection->rollback();
         throw $oError;
     }
 }
 private function __geocodeAddress($address, $can_return_default = true)
 {
     $coordinates = null;
     $cache_id = md5('maplocationfield_' . $address);
     $cache = new Cacheable(Symphony::Database());
     $cachedData = $cache->check($cache_id);
     // no data has been cached
     if (!$cachedData) {
         include_once TOOLKIT . '/class.gateway.php';
         $ch = new Gateway();
         $ch->init();
         $ch->setopt('URL', '//maps.googleapis.com/maps/api/geocode/json?address=' . urlencode($address) . '&sensor=false&v=3.13');
         $response = json_decode($ch->exec());
         $coordinates = $response->results[0]->geometry->location;
         if ($coordinates && is_object($coordinates)) {
             $cache->write($cache_id, $coordinates->lat . ', ' . $coordinates->lng, $this->_geocode_cache_expire);
             // cache lifetime in minutes
         }
     } else {
         $coordinates = $cachedData['data'];
     }
     // coordinates is an array, split and return
     if ($coordinates && is_object($coordinates)) {
         return $coordinates->lat . ', ' . $coordinates->lng;
     } elseif ($coordinates) {
         return $coordinates;
     } elseif ($return_default) {
         return $this->_default_coordinates;
     }
 }
示例#5
0
 /**
  * @return Filter
  */
 protected function _getFilter()
 {
     if (is_null($this->filter)) {
         $this->filter = $this->gateway->createFilter();
     }
     return $this->filter;
 }
示例#6
0
 private function search()
 {
     $results = array();
     $url = "http://symphonyextensions.com/api/extensions/?keywords={$this->query}&type=&compatible-with={$this->compatibleVersion}&sort=updated&order=desc";
     // create the Gateway object
     $gateway = new Gateway();
     // set our url
     $gateway->init($url);
     // get the raw response, ignore errors
     $response = @$gateway->exec();
     if (!$response) {
         throw new Exception(__("Could not read from %s", array($url)));
     }
     // parse xml
     $xml = @simplexml_load_string($response);
     if (!$xml) {
         throw new Exception(__("Could not parse xml from %s", array($url)));
     }
     $extensions = $xml->xpath('/response/extensions/extension');
     foreach ($extensions as $index => $ext) {
         $name = $ext->xpath('name');
         $id = $ext->xpath('@id');
         $developer = $ext->xpath('developer/name');
         $version = $ext->xpath('version');
         $status = $ext->xpath('status');
         $compatible = $ext->xpath("compatibility/symphony[@version='{$this->version}']");
         $res = array('handle' => (string) $id[0], 'name' => (string) $name[0], 'by' => (string) $developer[0], 'version' => (string) $version[0], 'status' => (string) $status[0], 'compatible' => $compatible != null);
         $results[] = $res;
     }
     // set results array
     $this->_Result['results'] = $results;
 }
 function getValuesFromXML()
 {
     $xml_location = $this->get('xml_location');
     $cache_life = (int) $this->get('cache');
     require TOOLKIT . '/util.validators.php';
     // allow use of choice params in URL
     $xml_location = preg_replace('/{\\$root}/', URL, $xml_location);
     $xml_location = preg_replace('/{\\$workspace}/', WORKSPACE, $xml_location);
     $doc = new DOMDocument();
     if (preg_match($validators['URI'], $xml_location)) {
         // is a URL, check cache
         $cache_id = md5('xml_selectbox_' . $xml_location);
         $cache = new Cacheable($this->_Parent->_Parent->Database);
         $cachedData = $cache->check($cache_id);
         if (!$cachedData) {
             $ch = new Gateway();
             $ch->init();
             $ch->setopt('URL', $xml_location);
             $ch->setopt('TIMEOUT', 6);
             $xml = $ch->exec();
             $writeToCache = true;
             $cache->write($cache_id, $xml, $cache_life);
             // Cache life is in minutes not seconds e.g. 2 = 2 minutes
             $xml = trim($xml);
             if (empty($xml) && $cachedData) {
                 $xml = $cachedData['data'];
             }
         } else {
             $xml = $cachedData['data'];
         }
         $doc->loadXML($xml);
     } elseif (substr($xml_location, 0, 1) == '/') {
         // relative to DOCROOT
         $doc->load(DOCROOT . $this->get('xml_location'));
     } else {
         // in extension's /xml folder
         $doc->load(EXTENSIONS . '/xml_selectbox/xml/' . $this->get('xml_location'));
     }
     $xpath = new DOMXPath($doc);
     $options = array();
     foreach ($xpath->query($this->get('item_xpath')) as $item) {
         $option = array();
         $option['text'] = $this->run($xpath, $item, $this->get('text_xpath'));
         $option['value'] = $this->run($xpath, $item, $this->get('value_xpath'));
         if (is_null($option['value'])) {
             $option['value'] = $option['text'];
         }
         $options[] = $option;
         if ($item->hasChildNodes()) {
             foreach ($xpath->query('*', $item) as $child) {
                 $text = $this->run($xpath, $child, $this->get('text_xpath'));
                 $value = $this->run($xpath, $child, $this->get('value_xpath'));
                 $options[] = array('text' => $option['text'] . " / " . $text, 'value' => $option['value'] . "-" . (!is_null($value) ? $value : $text));
             }
         }
     }
     return $options;
 }
 function getValuesFromXML()
 {
     $xml_location = $this->get('xml_location');
     $cache_life = (int) $this->get('cache');
     require TOOLKIT . '/util.validators.php';
     // allow use of choice params in URL
     $xml_location = preg_replace('/{\\$root}/', URL, $xml_location);
     $xml_location = preg_replace('/{\\$workspace}/', WORKSPACE, $xml_location);
     if (preg_match($validators['URI'], $xml_location)) {
         // is a URL, check cache
         $cache_id = md5('xml_selectbox_' . $xml_location);
         $cache = new Cacheable($this->_Parent->_Parent->Database);
         $cachedData = $cache->check($cache_id);
         if (!$cachedData) {
             $ch = new Gateway();
             $ch->init();
             $ch->setopt('URL', $xml_location);
             $ch->setopt('TIMEOUT', 6);
             $xml = $ch->exec();
             $writeToCache = true;
             $cache->write($cache_id, $xml, $cache_life);
             // Cache life is in minutes not seconds e.g. 2 = 2 minutes
             $xml = trim($xml);
             if (empty($xml) && $cachedData) {
                 $xml = $cachedData['data'];
             }
         } else {
             $xml = $cachedData['data'];
         }
         $xml = simplexml_load_string($xml);
     } elseif (substr($xml_location, 0, 1) == '/') {
         // relative to DOCROOT
         $xml = simplexml_load_file(DOCROOT . $this->get('xml_location'));
     } else {
         // in extension's /xml folder
         $xml = simplexml_load_file(EXTENSIONS . '/xml_selectbox/xml/' . $this->get('xml_location'));
     }
     $options = array();
     if (!$xml) {
         return $options;
     }
     $items = $xml->xpath($this->get('item_xpath'));
     foreach ($items as $item) {
         $option = array();
         $text_xpath = $item->xpath($this->get('text_xpath'));
         $option['text'] = General::sanitize((string) $text_xpath[0]);
         if ($this->get('value_xpath') != '') {
             $value_xpath = $item->xpath($this->get('value_xpath'));
             $option['value'] = General::sanitize((string) $value_xpath[0]);
         }
         if ((string) $option['value'] == '') {
             $option['value'] = $option['text'];
         }
         $options[] = $option;
     }
     return $options;
 }
 function getValuesFromXML()
 {
     $xml_location = $this->get('xml_location');
     if (General::validateURL($xml_location) != '') {
         // is a URL, check cache
         $cache_id = md5($xml_location);
         $cache = new Cacheable($this->_Parent->_Parent->Database);
         $cachedData = $cache->check($cache_id);
         $creation = DateTimeObj::get('c');
         if (!$cachedData || time() - $cachedData['creation'] > 5 * 60) {
             if (Mutex::acquire($cache_id, 6, TMP)) {
                 $ch = new Gateway();
                 $ch->init();
                 $ch->setopt('URL', $xml_location);
                 $ch->setopt('TIMEOUT', 6);
                 $xml = $ch->exec();
                 $writeToCache = true;
                 Mutex::release($cache_id, TMP);
                 $xml = trim($xml);
                 if (empty($xml) && $cachedData) {
                     $xml = $cachedData['data'];
                 }
             } elseif ($cachedData) {
                 $xml = $cachedData['data'];
             }
         } else {
             $xml = $cachedData['data'];
         }
         $xml = simplexml_load_string($xml);
     } elseif (substr($xml_location, 0, 1) == '/') {
         // relative to DOCROOT
         $xml = simplexml_load_file(DOCROOT . $this->get('xml_location'));
     } else {
         // in extension's /xml folder
         $xml = simplexml_load_file(EXTENSIONS . '/xml_selectbox/xml/' . $this->get('xml_location'));
     }
     if (!$xml) {
         return;
     }
     $items = $xml->xpath($this->get('item_xpath'));
     $options = array();
     foreach ($items as $item) {
         $option = array();
         $text_xpath = $item->xpath($this->get('text_xpath'));
         $option['text'] = General::sanitize((string) $text_xpath[0]);
         if ($this->get('value_xpath') != '') {
             $value_xpath = $item->xpath($this->get('value_xpath'));
             $option['value'] = General::sanitize((string) $value_xpath[0]);
         }
         if ((string) $option['value'] == '') {
             $option['value'] = $option['text'];
         }
         $options[] = $option;
     }
     return $options;
 }
示例#10
0
 public function log($item_type, $item_id, $action_type, $user_id, $timestamp)
 {
     /**
      * Build author string for the fallback username. If we've got
      * a valid author, grab the full name. Otherwise, determine
      * whether it's an anonymous front-end user or a potentially
      * malicious person trying to access the back end. In the latter
      * case, output the IP or email we captured for reference. 
      */
     $author = AuthorManager::fetchByID($user_id);
     $members = $_SESSION['sym-members'];
     if ($author instanceof Author) {
         $username = $author->getFullName();
     } else {
         if (!empty($members)) {
             if ($members['members-section-id'] && $members['id']) {
                 $members_section = SectionManager::fetch($members['members-section-id'])->get('handle');
                 $members_link = SYMPHONY_URL . '/publish/' . $members_section . '/edit/' . $members['id'] . '/';
                 $username = __('The front-end member %s', array('<a href="' . $members_link . '">' . $members['username'] . '</a>'));
             } else {
                 $username = __('The front-end member %s', array($members['username']));
             }
         } else {
             if (is_numeric($item_type)) {
                 $username = __('A front-end user');
             } else {
                 $username = __('An unidentified user (%s)', array($item_id));
             }
         }
     }
     // Build the $data array for our table columns
     $data = array('item_type' => $item_type, 'item_id' => $item_id, 'action_type' => $action_type, 'user_id' => $user_id, 'timestamp' => $timestamp, 'fallback_username' => $username);
     /**
      * Build the fallback description. Used if the item gets deleted.
      * If the item type is numeric, we're dealing with an entry,
      * otherwise it's some other system element. They're formatted
      * differently.
      */
     if (is_numeric($item_type)) {
         $data['fallback_description'] = Tracker::formatEntryItem($data, TRUE);
     } else {
         $data['fallback_description'] = Tracker::formatElementItem($data, TRUE);
     }
     // Push it into the DB.
     Symphony::Database()->insert($data, 'tbl_tracker_activity');
     // Send the event to the URL if specificed
     $notify_url = Symphony::Configuration()->get('notify_url', 'tracker');
     $notify_urls_array = preg_split('/[\\s,]+/', $notify_url);
     foreach ($notify_urls_array as $url) {
         $gateway = new Gateway();
         $gateway->init($url . "?" . http_build_query($data));
         $gateway->exec();
     }
 }
 function notify($context)
 {
     var_dump($context);
     include_once TOOLKIT . '/class.gateway.php';
     $ch = new Gateway();
     $ch->init();
     $ch->setopt('URL', 'http://rpc.pingomatic.com/');
     $ch->setopt('POST', 1);
     $ch->setopt('CONTENTTYPE', 'text/xml');
     $ch->setopt('HTTPVERSION', '1.0');
     ##Create the XML request
     $xml = new XMLElement('methodCall');
     $xml->appendChild(new XMLElement('methodName', 'weblogUpdates.ping'));
     $params = new XMLElement('params');
     $param = new XMLElement('param');
     $param->appendChild(new XMLElement('value', $this->_Parent->Configuration->get('sitename', 'general')));
     $params->appendChild($param);
     $param = new XMLElement('param');
     $param->appendChild(new XMLElement('value', URL));
     $params->appendChild($param);
     $xml->appendChild($params);
     ####
     $ch->setopt('POSTFIELDS', $xml->generate(true, 0));
     //Attempt the ping
     $ch->exec(GATEWAY_FORCE_SOCKET);
 }
 public function __actionIndex()
 {
     // Use external data:
     if ($this->_fields['source']) {
         $gateway = new Gateway();
         $gateway->init();
         $gateway->setopt('URL', $this->_fields['source']);
         $gateway->setopt('TIMEOUT', 6);
         // Validate data:
         $this->_status = $this->_importer->validate($gateway->exec());
         if ($this->_status == Importer::__OK__) {
             $this->_importer->commit();
         }
     }
 }
 public function __construct($controller, $name, $order)
 {
     /* Store Settings Object */
     $conf = StoreSettings::get_settings();
     /* Comments Box, if enabled */
     if ($conf->CheckoutSettings_OrderComments) {
         $comments = TextareaField::create("CustomerComments", "Order Comments");
         $comments->setRightTitle("These comments will be seen by staff.");
     } else {
         $comments = HiddenField::create("CustomerComments", "");
     }
     /* Terms and Conditions, if enabled */
     if ($conf->CheckoutSettings_TermsAndConditions) {
         $terms = CheckboxField::create("Terms", "I agree to " . $conf->StoreSettings_StoreName . "'s " . "<a href=" . DataObject::get_by_id("SiteTree", $conf->CheckoutSettings_TermsAndConditionsSiteTree)->URLSegment . ">" . "Terms &amp; Conditions</a>.");
     } else {
         $terms = HiddenField::create("Terms", "");
     }
     /* Fields */
     $fields = FieldList::create($comments, OptionsetField::create("PaymentMethod", "Payment Method", Gateway::create()->getGateways($order)), $terms ? HeaderField::create("Terms and Conditions", 5) : HiddenField::create("TermsHeaderField", ""), $terms);
     /* Actions */
     $actions = FieldList::create(FormAction::create('payment', 'Place Order &amp; Continue to Payment'));
     /* Required Fields */
     $required = new RequiredFields(array("PaymentMethod", $terms ? "Terms" : null));
     /*
      * Now we create the actual form with our fields and actions defined 
      * within this class.
      */
     return parent::__construct($controller, $name, $fields, $actions, $required);
 }
示例#14
0
 /**
  * Creates a new customer transaction.
  *
  * @param Model_Customer_Paymentmethod $payment_method The payment method.
  * @param string                       $amount         The amount to transact.
  * @param array                        $data           Optional data.
  *
  * @return Model_Customer_Transaction
  */
 public static function create(Model_Customer_Paymentmethod $payment_method, $amount, array $data = array())
 {
     $gateway_instance = Gateway::instance($payment_method->gateway, $payment_method->customer);
     if ($gateway_instance) {
         $external_id = $gateway_instance->transaction()->create(array('payment_method' => $payment_method, 'amount' => $amount));
         if (!$external_id) {
             return false;
         }
     } else {
         $external_id = null;
     }
     $transaction = Model_Customer_Transaction::forge();
     $transaction->customer = $payment_method->customer;
     $transaction->gateway = $payment_method->gateway;
     $transaction->external_id = $external_id;
     $transaction->type = $payment_method->gateway->type;
     $transaction->provider = $payment_method->provider;
     $transaction->account = $payment_method->account;
     $transaction->amount = $amount;
     try {
         $transaction->save();
     } catch (FuelException $e) {
         Log::error($e);
         return false;
     }
     Service_Event::trigger('customer.transaction.create', $transaction->customer->seller, $transaction->to_array());
     return $transaction;
 }
示例#15
0
 function donations()
 {
     $donations = Donation::where('amount', '>=', '10')->orderBy('amount', 'desc')->lists('name');
     $gateways = Gateway::orderBy('name')->get();
     $this->stylesheet('assets/stylesheets/donations.css');
     $this->autoRender(compact('donations', 'gateways'), 'Donations');
 }
示例#16
0
 public function run()
 {
     $newGateways = Gateway::getNewGatewayEuisFromInflux();
     foreach ($newGateways as $newGateway) {
         $newGateway->save();
     }
     $lastEntry = Gateway::getLastEntry();
     Gateway::updateGatewayStatusFromInflux($lastEntry->last_seen);
 }
示例#17
0
文件: Akbank.php 项目: refo/payment
 protected function prepareRequest($endpointType = 'xml')
 {
     $endpoint = $this->config('endpoint');
     $this->endpoint = $endpoint[$endpointType];
     $this->request['Name'] = $this->config('username');
     $this->request['Password'] = $this->config('password');
     $this->request['ClientId'] = $this->config('merchant');
     parent::prepareRequest();
     $this->requestBody = 'data=' . urldecode($this->requestBody);
 }
 public function run()
 {
     Eloquent::unguard();
     $gateways = [['name' => 'BeanStream', 'provider' => 'BeanStream', 'payment_library_id' => 2], ['name' => 'Psigate', 'provider' => 'Psigate', 'payment_library_id' => 2], ['name' => 'moolah', 'provider' => 'AuthorizeNet_AIM', 'sort_order' => 1, 'recommended' => 1, 'site_url' => 'https://invoiceninja.mymoolah.com/', 'payment_library_id' => 1], ['name' => 'Alipay', 'provider' => 'Alipay_Express', 'payment_library_id' => 1], ['name' => 'Buckaroo', 'provider' => 'Buckaroo_CreditCard', 'payment_library_id' => 1], ['name' => 'Coinbase', 'provider' => 'Coinbase', 'payment_library_id' => 1], ['name' => 'DataCash', 'provider' => 'DataCash', 'payment_library_id' => 1], ['name' => 'Neteller', 'provider' => 'Neteller', 'payment_library_id' => 1], ['name' => 'Pacnet', 'provider' => 'Pacnet', 'payment_library_id' => 1], ['name' => 'PaymentSense', 'provider' => 'PaymentSense', 'payment_library_id' => 1], ['name' => 'Realex', 'provider' => 'Realex_Remote', 'payment_library_id' => 1], ['name' => 'Sisow', 'provider' => 'Sisow', 'payment_library_id' => 1], ['name' => 'Skrill', 'provider' => 'Skrill', 'payment_library_id' => 1]];
     foreach ($gateways as $gateway) {
         if (!DB::table('gateways')->where('name', '=', $gateway['name'])->get()) {
             Gateway::create($gateway);
         }
     }
 }
示例#19
0
 public static function deleteCode($companyId, $code)
 {
     Gateway::getOnlineStatus();
     $store = Store::instance('wymenu');
     $ret = $store->delete($companyId . $code);
     /*if(Yii::app()->params->has_cache)
       {
           $ccode = apc_delete($companyId.$code);                    
       }*/
 }
示例#20
0
 /**
  * Gets a new instance of gateway $class_name.
  *
  * @param Model_Gateway  $gateway    The gateway model to use for the driver.
  * @param Model_Customer $customer   The customer model to use for the driver.
  * @param string         $class_name The class name to call on the driver.
  *
  * @return Gateway_Model
  */
 public static function forge(Model_Gateway $gateway, Model_Customer $customer = null, $class_name)
 {
     $driver_name = str_replace('Gateway_', '', get_called_class());
     $driver_name = str_replace('_Driver', '', $driver_name);
     $class = 'Gateway_' . Str::ucwords(Inflector::denamespace($driver_name)) . '_' . Str::ucwords(Inflector::denamespace($class_name));
     if (!class_exists($class)) {
         throw new GatewayException('Call to undefined class ' . $class);
     }
     $driver = Gateway::instance($gateway, $customer);
     return new $class($driver);
 }
示例#21
0
 private function download()
 {
     // create the Gateway object
     $gateway = new Gateway();
     // set our url
     $gateway->init($this->downloadUrl);
     // get the raw response, ignore errors
     $response = @$gateway->exec();
     if (!$response) {
         throw new Exception(__("Could not read from %s", array($this->downloadUrl)));
     }
     // write the output
     $tmpFile = MANIFEST . '/tmp/' . Lang::createHandle($this->extensionHandle);
     if (!General::writeFile($tmpFile, $response)) {
         throw new Exception(__("Could not write file."));
     }
     // open the zip
     $zip = new ZipArchive();
     if (!$zip->open($tmpFile)) {
         General::deleteFile($tmpFile, true);
         throw new Exception(__("Could not open downloaded file."));
     }
     // get the directory name
     $dirname = $zip->getNameIndex(0);
     // extract
     $zip->extractTo(EXTENSIONS);
     $zip->close();
     // delete tarbal
     General::deleteFile($tmpFile, false);
     // prepare
     $curDir = EXTENSIONS . '/' . $dirname;
     $toDir = $this->getDestinationDirectory();
     // delete current version
     if (!General::deleteDirectory($toDir)) {
         throw new Exception(__('Could not delete %s', array($toDir)));
     }
     // rename extension folder
     if (!@rename($curDir, $toDir)) {
         throw new Exception(__('Could not rename %s to %s', array($curDir, $toDir)));
     }
 }
示例#22
0
 /**
  * Verifies an order against bank and user-defined validators
  *
  * @param Order $order
  *
  * @return bool Whetehr if the order is verified or not
  */
 private function verifyOrder(Order $order)
 {
     if (false === $this->gateway->verifyPayment($order)) {
         return false;
     }
     foreach ($this->orderValidators as $validator) {
         if (false === call_user_func($validator, $order)) {
             return false;
         }
     }
     return true;
 }
示例#23
0
 /**
  * Test the evaluation of all policies when no policy name is given
  */
 public function testAllPolicyEvaluateAllAny()
 {
     $set = PolicySet::instance()->add('policy1', Policy::instance()->hasUsername('ccornutt'));
     $user = (object) ['username' => 'ccornutt'];
     $subject = new Subject($user);
     $subject->setAuth(true);
     $context = new Context(['policies' => $set]);
     $gateway = new Gateway($subject, $context);
     // Evaluate the result of the policy above, true because they're:
     //  1. set correctly, 2. policy passes
     $result = $gateway->evaluate();
     $this->assertTrue($result);
 }
示例#24
0
 public static function getExtensionAsXML($handle)
 {
     $url = self::URL_ROOT . "extensions/{$handle}/";
     // create the Gateway object
     $gateway = new Gateway();
     // set our url
     $gateway->init($url);
     // get the raw response, ignore errors
     $response = @$gateway->exec();
     if (!$response) {
         throw new Exception(__("Could not read from %s", array($this->downloadUrl)));
     }
     // parse xml
     $xml = @simplexml_load_string($response);
     if (!$xml) {
         throw new Exception(__("Could not parse xml from %s", array($url)));
     }
     $extension = $xml->xpath('/response/extension');
     if (empty($extension)) {
         throw new Exception(__("Could not find extension %s", array($query)));
     }
     return $extension;
 }
 public function run()
 {
     Eloquent::unguard();
     $gateways = [array('name' => 'BeanStream', 'provider' => 'BeanStream', 'payment_library_id' => 2), array('name' => 'Psigate', 'provider' => 'Psigate', 'payment_library_id' => 2)];
     $updateProviders = array(0 => 'AuthorizeNet_AIM', 4 => 'PayPal_Pro', 5 => 'TwoCheckout');
     foreach ($gateways as $gateway) {
         Gateway::create($gateway);
     }
     Gateway::whereIn('provider', $updateProviders)->update(array('recommended' => 1));
     Gateway::where('provider', '=', 'AuthorizeNet_AIM')->update(array('sort_order' => 5, 'site_url' => 'http://reseller.authorize.net/application/?id=5560364'));
     //Gateway::where('provider', '=', 'BeanStream')->update(array('sort_order' => 10, 'site_url' => 'http://www.beanstream.com/'));
     //Gateway::where('provider', '=', 'FirstData_Connect')->update(array('sort_order' => 20, 'site_url' => 'https://www.firstdata.com/'));
     Gateway::where('provider', '=', 'PayPal_Pro')->update(array('sort_order' => 25, 'site_url' => 'https://www.paypal.com/'));
     Gateway::where('provider', '=', 'TwoCheckout')->update(array('sort_order' => 30, 'site_url' => 'https://www.2checkout.com/referral?r=2c37ac2298'));
 }
 /**
  * getCMSFields
  * Construct the FieldList used in the CMS. To provide a
  * smarter UI we don't use the scaffolding provided by
  * parent::getCMSFields.
  * 
  * @return FieldList
  */
 public function getCMSFields()
 {
     Requirements::css('torindul-silverstripe-shop/css/LeftAndMain.css');
     //Create the FieldList and push the Root TabSet on to it.
     $fields = FieldList::create($root = TabSet::create('Root', Tab::create("Main", HeaderField::create("Add/Edit Payment"))));
     /* 
      * If a Payment Gateway/Method hasn't been selected yet, prompt for one.
      * Otherwise, show the form fields for the database fields in the Order_Payment DataObject.
      */
     if (!$this->exists()) {
         $fields->addFieldsToTab("Root.Main", array(CompositeField::create(DropdownField::create("ClassName", "Payment Method", Gateway::create()->getGateways($this->Order(), true))->setRightTitle("Which payment method did the customer pay with?")->setEmptyString("(Select one)"))));
     } else {
         $fields->addFieldsToTab("Root.Main", array(CompositeField::create(DateField::create("Date", "Payment Date")->setConfig('dateformat', 'dd-MM-yyyy')->setConfig('showcalendar', true)->setRightTitle('To open a pop-up calendar click on the text field above.'), DropdownField::create("Status", "Payment Status", array("Pending" => "Pending", "Processing" => "Processing", "Denied" => "Denied", "Completed" => "Completed", "Refunded" => "Refunded")), FieldGroup::create("Amounts", NumericField::create("Amount", "Payment Amount")->setRightTitle("How much was paid?"), DropdownField::create("Currency", "Payment Currency", DataObject::get("StoreCurrency", "(`Enabled`=1)")->map("ID", "Code"))->setRightTitle("In which currency was the payment?")))));
     }
     return $fields;
 }
示例#27
0
文件: init.php 项目: alencarmo/OCF
 function initializeUserSettings()
 {
     global $jQueryLib, $gorumroll;
     $_S =& new AppSettings();
     $_S->initLanguageProperties();
     Init::initializeUserSettings();
     if (class_exists("gateway")) {
         Gateway::includeLanguageFiles();
     }
     $gorumroll->checkForPostMaxSizeError();
     $_S->initThemeProperties();
     // In case of the organize page, the 1.1.4 version of the jquery library must be loaded:
     //$jQueryLib = $gorumroll->method=="organize_form" ? "/jquery/interface/jquery.js" : "/jquery/jquery.js";
     $jQueryLib = "/jquery/jquery.js";
     if (file_exists(THEME_DIR . "/theme_config.php")) {
         include_once THEME_DIR . "/theme_config.php";
     }
 }
示例#28
0
 /**
  * Creates a new customer gateway relation.
  *
  * @param Model_Customer $customer The customer.
  * @param Model_Gateway  $gateway  The gateway.
  * @param array          $data     Optional data.
  *
  * @return Model_Customer
  */
 public static function create(Model_Customer $customer, Model_Gateway $gateway, array $data = array())
 {
     if (!($contact = Arr::get($data, 'contact'))) {
         $contact = current($customer->contacts);
     }
     $external_id = Gateway::instance($gateway)->customer()->create(array('customer' => $customer, 'contact' => $contact));
     if (!$external_id) {
         return false;
     }
     $customer_gateway = Model_Customer_Gateway::forge();
     $customer_gateway->customer_id = $customer->id;
     $customer_gateway->gateway_id = $gateway->id;
     $customer_gateway->external_id = $external_id;
     try {
         $customer_gateway->save();
     } catch (FuelException $e) {
         Log::error($e);
         return false;
     }
     return $customer_gateway;
 }
 function displayPublishPanel(&$wrapper, $data = NULL, $flagWithError = NULL, $fieldnamePrefix = NULL, $fieldnamePostfix = NULL)
 {
     if (!isset(Administration::instance()->Page)) {
         return;
     }
     // work out what page we are on, get portions of the URL
     $callback = Administration::instance()->getPageCallback();
     $entry_id = $callback['context']['entry_id'];
     // get an Entry object for this entry
     $entries = EntryManager::fetch($entry_id);
     if (is_array($entries)) {
         $entry = reset($entries);
     }
     // parse dynamic portions of the panel URL
     $url = $this->parseExpression($entry, $this->get('url_expression'));
     if (!preg_match('/^http/', $url)) {
         $url = URL . $url;
     }
     // create Symphony cookie to pass with each request
     $cookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
     session_write_close();
     $gateway = new Gateway();
     $gateway->init($url);
     $gateway->setopt('TIMEOUT', 10);
     $gateway->setopt(CURLOPT_COOKIE, $cookie);
     $gateway->setopt(CURLOPT_SSL_VERIFYPEER, FALSE);
     $result = $gateway->exec();
     // a unique name for this panel instance
     $instance_id = $callback['context']['section_handle'] . '_' . $this->get('element_name');
     $container = new XMLELement('div', $result);
     $container->setAttribute('id', $instance_id);
     $container->setAttribute('class', 'inline frame');
     $label = new XMLElement('label', $this->get('label'));
     $label->appendChild($container);
     $wrapper->appendChild($label);
     $asset_index = $this->get('id') * rand(10, 100);
     // add panel-specific styling
     $instance_css = '/html-panel/' . $instance_id . '.css';
     if (file_exists(WORKSPACE . $instance_css)) {
         Administration::instance()->Page->addStylesheetToHead(URL . '/workspace' . $instance_css, 'screen', $asset_index++);
     }
     // add panel-specific behaviour
     $instance_js = '/html-panel/' . $instance_id . '.js';
     if (file_exists(WORKSPACE . $instance_js)) {
         Administration::instance()->Page->addScriptToHead(URL . '/workspace' . $instance_js, $asset_index++);
     }
 }
示例#30
0
 public function notify($context)
 {
     include_once TOOLKIT . '/class.gateway.php';
     $ch = new Gateway();
     $ch->init();
     $ch->setopt('URL', 'http://rpc.pingomatic.com/');
     $ch->setopt('POST', 1);
     $ch->setopt('CONTENTTYPE', 'text/xml');
     $xml = new XMLElement('methodCall');
     $xml->appendChild(new XMLElement('methodName', 'weblogUpdates.ping'));
     $params = new XMLElement('params');
     $param = new XMLElement('param');
     $param->appendChild(new XMLElement('value', Symphony::Configuration()->get('sitename', 'general')));
     $params->appendChild($param);
     $param = new XMLElement('param');
     $param->appendChild(new XMLElement('value', URL));
     $params->appendChild($param);
     $xml->appendChild($params);
     $ch->setopt('POSTFIELDS', $xml->generate(true, 0));
     $ch->exec(GATEWAY_FORCE_SOCKET);
 }