Example #1
0
 public static function add_attempt($sType)
 {
     global $database;
     $sUserIP = $_SERVER['REMOTE_ADDR'];
     $sTime = time();
     $sAttempt = new Attempt(0);
     $sAttempt->uType = $sType;
     $sAttempt->uIPAddress = $sUserIP;
     $sAttempt->uTimestamp = $sTime;
     $sAttempt->InsertIntoDatabase();
     return true;
 }
Example #2
0
 /**
  * Find an open port in a given range, trying several times.
  * Return FALSE if no open port is found after a timeout (1 second by default)
  *
  * @param  string  $host
  * @param  integer $range_start
  * @param  integer $range_end
  * @param  integer $timeout
  * @return integer|boolean
  */
 public static function ephimeral_port($host, $range_start = 1000, $range_end = 5000, $timeout = 1000)
 {
     return Attempt::make(function () use($host, $range_start, $range_end) {
         $port = rand($range_start, $range_end);
         return Network::is_port_open($host, $port) ? $port : FALSE;
     }, $timeout);
 }
Example #3
0
 private function attempt()
 {
     if (null === $this->attempt) {
         return $this->attempt = Attempt::call($this->callable, $this->arguments);
     }
     return $this->attempt;
 }
Example #4
0
 public function ordersAction()
 {
     $from = AF::get($this->params, 'from', false);
     $clearArray = array();
     $this->filter($clearArray);
     if (!isset($this->params['r_dates'])) {
         $today = date("d.m.Y");
         $this->params['r_dates'] = $today . '-' . $today;
     }
     $pagination = new Pagination(array('action' => $this->action, 'controller' => $this->controller, 'params' => $this->params, 'ajax' => true));
     $models = AFActiveDataProvider::models('Attempt', $this->params, $pagination);
     $dataProvider = $models->getDeclineOrdersReport();
     $filterFields = Attempt::$FilterFields = $models->getoutFilterFields($clearArray, array('r_dates'));
     $fields = array('order_formatted', 'type_formatted', 'status_note', 'created_formatted');
     $gateways = $models->getDSearchGateways();
     $reasons = $models->getDSearchReasons();
     // set ajax table
     if (AF::isAjaxRequestModels()) {
         $this->view->includeFile('_orders_table', array('application', 'views', 'declinedreports'), array('access' => $this->access, 'controller' => $this->controller, 'dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields, 'fields' => $fields, 'gateways' => $gateways, 'reasons' => $reasons));
         die;
     }
     Assets::css('jquery-ui');
     Assets::js('//code.jquery.com/ui/1.10.3/jquery-ui.js');
     Assets::js('dateRange/jquery.daterange');
     Assets::js('ajax_table');
     $this->render('orders', array('dataProvider' => $dataProvider, 'pagination' => $pagination, 'filterFields' => $filterFields, 'fields' => $fields, 'gateways' => $gateways, 'reasons' => $reasons, 'from' => $from));
 }
Example #5
0
 public static function seoURL($attempt_id, $lang = '')
 {
     $attempt = Attempt::find($attempt_id);
     $clean_chars = function ($string) {
         $string = str_replace(' ', '-', $string);
         // Replaces all spaces with hyphens.
         $string = preg_replace('/[^A-Za-z0-9\\-]/', '', $string);
         // Removes special chars.
         return preg_replace('/-+/', '-', strtolower($string));
         // Replaces multiple hyphens with single one.
     };
     $name = Domain::formatDiacritics($clean_chars($attempt->name));
     if (empty($lang)) {
         $lang = LaravelLocalization::getCurrentLocale();
     }
     return URL::route('attempt.details', ['id' => $attempt->id]);
 }
Example #6
0
 public function attemptAdd($attempt_id)
 {
     $attempt = Attempt::find($attempt_id);
     $categories = Category::getCategories();
     return View::make('admin.attempt_add')->with(compact('attempt', 'categories'));
 }
Example #7
0
 public function createByOrder(Order $order)
 {
     $modelAttempt = new Attempt();
     $modelAttempt->getLastOrderAttempt($order->order_id, Attempt::CREDIT_TYPE);
     //fb($order);
     $xmlArr = self::$_xmlContainer;
     $xmlArr['inkasso']['auftraggebernummer'] = 1088;
     $xmlArr['inkasso']['erstellungsdatum'] = date("d.m.Y");
     //$xmlArr['inkasso']['schuldner']['kundennummer']='';//2325
     $xmlArr['inkasso']['schuldner']['vorname'] = $order->customer->fname;
     $xmlArr['inkasso']['schuldner']['name'] = $order->customer->lname;
     //$xmlArr['inkasso']['schuldner']['anrede']='';
     //$xmlArr['inkasso']['schuldner']['geburtsdatum']='';
     //$xmlArr['inkasso']['schuldner']['familienstand']='';
     $xmlArr['inkasso']['schuldner']['gewerblich'] = 0;
     $xmlArr['inkasso']['schuldner']['rechtsform'] = 'Privat';
     //??
     //$xmlArr['inkasso']['schuldner']['arbeitgeber']['arbeitgeber-name1']='';
     //$xmlArr['inkasso']['schuldner']['arbeitgeber']['arbeitgeber-strasse']='';
     //$xmlArr['inkasso']['schuldner']['arbeitgeber']['arbeitgeber-plz']='';
     //$xmlArr['inkasso']['schuldner']['arbeitgeber']['arbeitgeber-ort']='';
     $xmlArr['inkasso']['schuldner']['adresse']['strasse'] = $order->address->fullAddress;
     $xmlArr['inkasso']['schuldner']['adresse']['plz'] = $order->address->zip;
     $xmlArr['inkasso']['schuldner']['adresse']['ort'] = $order->address->city;
     $xmlArr['inkasso']['schuldner']['adresse']['land'] = $order->address->country->country_name;
     //$xmlArr['inkasso']['schuldner']['adresse']['zusatz']='';
     $xmlArr['inkasso']['schuldner']['telefon']['telefonnr'] = $order->address->phone;
     $xmlArr['inkasso']['schuldner']['telefon']['typ'] = 'Telefon';
     //or Mobil
     $xmlArr['inkasso']['schuldner']['telefon']['zusatz'] = 'Zuhause';
     //?? Zuhause, Arbeit, Partner, Eltern
     $xmlArr['inkasso']['schuldner']['email']['emailadresse'] = $order->customer->email;
     //$xmlArr['inkasso']['schuldner']['bankverbindung']['kontoinhaber']='';
     $xmlArr['inkasso']['schuldner']['bankverbindung']['kontonr'] = strlen($order->payment->bank_code) <= 10 ? $order->payment->bank_code : null;
     $xmlArr['inkasso']['schuldner']['bankverbindung']['blz'] = strlen($order->payment->bank_code) == 8 ? $order->payment->bank_code : null;
     //$xmlArr['inkasso']['schuldner']['bankverbindung']['bankname']='';//??
     $xmlArr['inkasso']['inkassofall']['bestelldatum'] = HelperFormatted::date_euro_format($order->created);
     $xmlArr['inkasso']['inkassofall']['bestellzeit'] = HelperFormatted::time_format($order->created);
     $xmlArr['inkasso']['inkassofall']['mandatenreferenz'] = $order->campaign->order_url;
     $xmlArr['inkasso']['inkassofall']['zusatzinfo1'] = $order->ip_formatted;
     //$xmlArr['inkasso']['inkassofall']['zusatzinfo2']='';
     //$xmlArr['inkasso']['inkassofall']['zusatzinfo3']='';
     //$xmlArr['inkasso']['inkassofall']['sachbearbeiter']='';
     //$xmlArr['inkasso']['inkassofall']['telsach']='';
     $xmlArr['inkasso']['inkassofall']['forderung']['rechnungsnr'] = $modelAttempt->attempt_id;
     $xmlArr['inkasso']['inkassofall']['forderung']['rechnungstext'] = $modelAttempt->status_note;
     $xmlArr['inkasso']['inkassofall']['forderung']['betrag'] = $modelAttempt->amount * 100;
     $xmlArr['inkasso']['inkassofall']['forderung']['rech-datum'] = HelperFormatted::date_euro_format($modelAttempt->created);
     //$xmlArr['inkasso']['inkassofall']['forderung']['datumerstemahn']='';
     //$xmlArr['inkasso']['inkassofall']['forderung']['mahngebuehrengesamt']='';
     $xmlArr['inkasso']['inkassofall']['forderung']['zins-datum'] = HelperFormatted::date_euro_format($modelAttempt->created);
     //$xmlArr['inkasso']['inkassofall']['forderung']['katalog-nr']='';
     //$xmlArr['inkasso']['inkassofall']['forderung']['ruecklaeufergebuehr']='';
     //$xmlArr['inkasso']['inkassofall']['forderung']['datumruecklaeufergebuehr']='';
     //$xmlArr['inkasso']['inkassofall']['forderung']['waehrung']='';
     $xmlRequest = HelperFormatted::array2xml($xmlArr, false);
     /*
     header("Content-type:text/xml; charset=utf-8");
     echo $xmlRequest;
     die;
     */
     $xmlResponse = $this->request($xmlRequest, self::METHOD_INKASSOFAL_EINTRAGEN);
     $responseModel = simplexml_load_string($xmlResponse);
     $responseModel = (array) $responseModel;
     $responseItem = false;
     echo '<pre>';
     print_r($responseModel);
     echo '</pre>';
     die;
     foreach ($responseModel as $item) {
         ///*
         header("Content-type:text/xml; charset=utf-8");
         echo $item;
         die;
         //*/
         $responseItem = simplexml_load_string($item);
         return;
     }
     if ($responseItem && $responseItem->Code == 'OK') {
     } else {
     }
 }
Example #8
0
 public function bsReturn($attempt_id = null, $status = null)
 {
     // We only want to process CHARGE and DECLINE at the moment
     if (!$attempt_id || !$status || !in_array($status, array('CHARGE', 'DECLINE'))) {
         return false;
     }
     //get Attempt
     $attemptModel = Attempt::model()->with('order.status')->findByPk($attempt_id);
     if (!$attemptModel) {
         return false;
     }
     // set attempt status
     $attemptModel->status = $status == 'CHARGE' ? Attempt::SUCCESS_STATUS : Attempt::DECLINED_STATUS;
     $attemptModel->status_note = $status == 'CHARGE' ? 'Approved' : $attemptModel->status_note;
     $attemptModel->save();
     $this->order = clone $attemptModel->order;
     if ($status == 'CHARGE') {
         $this->order->status = 'ok';
         $this->order->removeFlags('salvage');
         $this->order->addFlags('paid');
         $this->order->payment_total = $this->order->amount_product + $this->order->amount_shipping;
         $this->order->save();
         if ($this->order->billing_cycle == 0) {
             $this->finalizeOrder();
         }
         OrderLog::createLog(0, $this->order->order_id, 22, $this->order->payment_total . ' ' . $this->order->campaign->currency_id);
     } else {
         $this->declinedOrder();
     }
 }
Example #9
0
 private function updateUser($shopperID)
 {
     // Update Shopper Add Credit Card
     $xmlArray = array('shopper' => array('web-info' => $this->requestArray('web-info'), 'shopper-info' => array('seller-shopper-id' => $this->customerModel->customer_id, 'shopper-currency' => $this->campaignModel->currency_id, 'store-id' => $this->_paymentOptions['store-id'], 'shopper-contact-info' => $this->requestArray('shopper-contact-info'), 'invoice-contacts-info' => array('invoice-contact-info' => $this->requestArray('invoice-contact-info')), 'payment-info' => array('credit-cards-info' => array('credit-card-info' => array('billing-contact-info' => $this->requestArray('billing-contact-info'), 'credit-card' => $this->requestArray('credit-card')))))));
     // if there is no cc_encrypt present
     if (!$this->paymentModel->cc_number_encrypt) {
         unset($xmlArray['shopper']['shopper-info']['payment-info']);
     }
     try {
         //Send request
         $response = $this->send($xmlArray, 'shoppers/' . $shopperID, 'shopper', true, true);
         fb($response);
     } catch (Exception $e) {
         //Change Attempt Status to unknown
         Attempt::setAttemptStatus($this->attemptModel, Attempt::UNKNOWN_STATUS);
         $this->_paymetnResponse->addError('error_processing_request');
         $this->_paymetnResponse->addAlert('error_processing_your_request');
         $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS;
         return false;
     }
     // add
     //if($response)
     return true;
 }
Example #10
0
 private function voidAttempt($attemptID = null)
 {
     if ($attemptID !== null) {
         $this->attemptModel = Attempt::model()->findByPk($attemptID);
     }
     if (!$this->attemptModel) {
         $this->_paymetnResponse->status = 'error';
         $this->_paymetnResponse->addError('no_attempt');
         return false;
     }
     $this->_ps->void();
 }
Example #11
0
 protected function beforePay()
 {
     $profileMethod = ProfileMethod::model()->findByPk(array('profile_id' => $this->campaignModel->profile->profile_id, 'method_id' => $this->paymentMethod->method_id));
     if ($profileMethod && $profileMethod->isFlag(ProfileMethod::FLAG_FILTER) && $this->paymentModel->cc_number) {
         if (!Bin::verificationCreditCard($this->paymentModel->cc_number)) {
             Attempt::setAttemptStatus($this->attemptModel, Attempt::FRAUD_STATUS);
             $this->_paymetnResponse->addError('error_processing_request');
             $this->_paymetnResponse->addAlert('please_use_a_different_card');
             $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS;
             // log prepaid card attempt
             OrderLog::createLog(0, $this->orderModel->order_id, 28, 'Prepaid Card');
             return false;
         }
     }
     return true;
 }
Example #12
0
 public function voidCreditCard()
 {
     $successAttemptModel = Attempt::getSuccessAttempt($this->orderModel->order_id);
     $successAttemptCustomData = json_decode($successAttemptModel->custom_data, true);
     if (self::$isTest) {
         //Approved / Successful Action
         //$successAttemptCustomData['tracking_number'] = '44444444-1D500CFBC1CAEA888888-00000001';
         //Declined / Forbidden Action
         //$successAttemptCustomData['tracking_number'] = '44444444-1D500CFBC1CAEA888888-00000002';
         //Error (general error)
         //$successAttemptCustomData['tracking_number'] = '44444444-1D500CFBC1CAEA888888-00000003';
     }
     $transaction = new AldraPay(array('merchantID' => $this->gatewayModel->username, 'passCode' => $this->gatewayModel->shared_secret));
     $transaction->set('transactionID', $successAttemptCustomData['tracking_number']);
     $transaction->void();
     try {
         $result = $transaction->execute();
         fb($result);
     } catch (Exception $e) {
         $aErrors = array('Error processing your request');
         $this->attemptError($aErrors);
         return false;
     }
     if (!$result) {
         // payment server errors
         $aErrors = array('Error processing your request');
         $this->attemptError($aErrors);
         return false;
     }
     // if not approved
     if (!isset($result['responseCode']) || !in_array($result['responseCode'], array(1, 7))) {
         //decline error
         $error = isset($result['reasonCodeString']) ? $result['reasonCodeString'] : 'Error processing your request';
         if (isset($result['transaction']['transactionID'])) {
             $this->attemptModel->custom_data = json_encode(array('tracking_number' => $result['transaction']['transactionID']));
         }
         $this->attemptError(array($error));
         return false;
     }
     switch ($result['responseCode']) {
         case '1':
             $this->attemptModel->status = Attempt::SUCCESS_STATUS;
             break;
         case '7':
             $this->attemptModel->status = Attempt::SUBMITED_STATUS;
             break;
     }
     if (isset($result['transaction']['transactionID'])) {
         //the field tracking_number DECIMAL(16,0)
         $this->attemptModel->custom_data = json_encode(array('tracking_number' => $result['transaction']['transactionID']));
     }
     $this->attemptModel->status_note = '';
     if ($result['responseCodeString']) {
         $this->attemptModel->status_note .= $result['responseCodeString'];
     }
     if ($result['reasonCodeString']) {
         $this->attemptModel->status_note .= ' (' . $result['reasonCodeString'] . ')';
     }
     $this->attemptModel->save();
     //Set success status to response
     $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS;
     $this->_paymetnResponse->attemptModel = $this->attemptModel;
     $this->_paymetnResponse->paymentModel = $this->paymentModel;
     OrderLog::createLog(0, $this->orderModel->order_id, 13, $this->attemptModel->amount . ' ' . $this->campaignModel->currency_id);
     return true;
 }
Example #13
0
$modelOrder = new Order();
$modelAttempt = new Attempt();
if ($attemptID) {
    $sql = "SELECT `order_id`\n            FROM `attempts`\n            WHERE `attempt_id`=?i\n            ORDER BY `attempt_number`";
    $result = $msql->getRow($sql, $attemptID);
    if ($result) {
        $orderID = $result['order_id'];
    }
    $attempts = false;
}
if ($orderID) {
    $sql = "SELECT *\n            FROM `attempts`\n            WHERE `order_id`=?i";
    $attempts = $msql->getAll($sql, $orderID);
}
if ($checkAttemptID) {
    $modelAttempt = Attempt::model()->with('order.gateway')->findByPk($checkAttemptID);
    $pacnetOptions = $modelAttempt->order->gateway->getAttributes();
    $pacnetOptions['isTest'] = false;
    $pymtReq = new RavenRequest('response', $pacnetOptions);
    $pymtReq->set('RequestID', $modelAttempt->attempt_id);
    try {
        $response = $pymtReq->send();
    } catch (Exception $e) {
        $response = false;
    }
    /*
    $payment=new PaymentAPI();
    $payment->updateStatusAttempt($modelAttempt, false);
    $response=$payment->getPaymetnResponse();
    */
}
Example #14
0
 /**
  * Reset Login Attempts
  * Resets login attempts increment value
  * in the database for a particular IP address.
  * 
  * @param mixed $ip_address
  */
 public function reset_login_attempts($ip_address = NULL)
 {
     if (is_null($ip_address)) {
         $ip_address = $this->ip_address;
     }
     $a = new Attempt();
     $a->where('ip_address', $ip_address)->get();
     if ($a->exists()) {
         $a->delete();
     }
 }
Example #15
0
 public function getReturnAttempt()
 {
     $attemptID = (int) $_GET['txnid'];
     $this->attemptModel = Attempt::model()->with('order.gateway', 'order.gateway', 'order.customer', 'order.address')->findByPk($attemptID);
     return $this->attemptModel;
 }
Example #16
0
<?php

@(include_once '../settings/autoload.php');
$msql = SafeMySQL::getInstance();
$text = '';
$attemptIDs = array('119456');
if (isset($_POST['refund'])) {
    foreach ($attemptIDs as $attemptID) {
        $sql = "SELECT g.system_code, p.method_id, a.order_id\n                FROM attempts as a\n                JOIN gateways as g USING(`gateway_id`)\n                JOIN orders as o USING(`order_id`)\n                JOIN payments as p USING(`payment_id`)\n                WHERE a.attempt_id=?i\n                ";
        $result = $msql->getRow($sql, $attemptID);
        if ($result) {
            $modelOrder = Order::model()->with('gateway')->findByPk($result['order_id']);
            $modelAttempt = Attempt::model()->findByPk($attemptID);
            $ps = PaymentSystem::getPaymentSystem($result['system_code'], $result['method_id']);
            $ps->setModel($modelOrder);
            $ps->setModel($modelAttempt);
            $ps->setModel($modelOrder->gateway);
            $ps->paymetnResponse = new PaymentAPIResponse();
            $response = $ps->refund();
            $text .= 'Attempt ID: ' . $attemptID . ' OrderID: ' . $modelOrder->order_id . '<br>';
            $text .= 'Status: ' . $response->status . '<br>';
            $text .= 'Errors: ' . $response->errors2string . '<br>';
            $text .= '<hr>';
        }
    }
}
?>

<!DOCTYPE html>
<html lang="en-US" class=" "><head>
    <meta charset="UTF-8">
Example #17
0
 public function voidCreditCard()
 {
     $successAttemptModel = Attempt::getSuccessAttempt($this->orderModel->order_id);
     $transaction = new NmiDirectPost(array('nmi_user' => $this->gatewayModel->username, 'nmi_password' => $this->gatewayModel->shared_secret));
     $transaction->void($successAttemptModel->tracking_number);
     $result = $transaction->execute();
     fb($result);
     // if error
     if ($result['response'] != 1 || !isset($result['response_code']) || $result['response_code'] != 100) {
         $aErrors = array('Response: ' . $result['responsetext'], ' Code: ' . $result['response_code']);
         if (isset(Nmi::$responseCodes[$result['response_code']])) {
             array_push($aErrors, ' Text:' . Nmi::$responseCodes[$result['response_code']]);
         }
         $this->attemptError($aErrors);
         return false;
     }
     // Fill and save attempt Model
     $this->attemptModel->status = Attempt::SUCCESS_STATUS;
     if (isset($result['transactionid']) && $result['transactionid']) {
         $this->attemptModel->tracking_number = $result['transactionid'];
     }
     $this->attemptModel->status_note = 'Response: ' . $result['responsetext'] . ', Code: ' . $result['response_code'];
     if (isset(Nmi::$responseCodes[$result['response_code']])) {
         $this->attemptModel->status_note .= ' Text:' . Nmi::$responseCodes[$result['response_code']];
     }
     if (isset($result['authcode']) && $result['authcode']) {
         $this->attemptModel->custom_data = json_encode(array('authcode' => $result['authcode']));
     }
     $this->attemptModel->save();
     //Set success status to response
     $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS;
     $this->_paymetnResponse->attemptModel = $this->attemptModel;
     $this->_paymetnResponse->paymentModel = $this->paymentModel;
     OrderLog::createLog(0, $this->orderModel->order_id, 3, $this->attemptModel->amount . ' ' . $this->campaignModel->currency_id);
     return true;
 }
Example #18
0
 public function getReturnAttempt()
 {
     $mac = isset($_GET['RETURNMAC']) ? $_GET['RETURNMAC'] : null;
     $ref = isset($_GET['REF']) ? $_GET['REF'] : null;
     if (!$mac || !$ref) {
         return null;
     }
     $attemptModel = Attempt::model()->with('return', 'order.campaign', 'order.customer', 'order.address')->find('`return_code`=:return_code', array(':return_code' => $ref . $mac));
     return $attemptModel;
 }
Example #19
0
 public static function getSuccessAttempt($orderID)
 {
     $attemptModel = Attempt::model();
     if ($orderID) {
         $sql = "SELECT *\n              FROM ?n\n              WHERE `order_id`=?i AND `status`='success'";
         $result = self::$_msql->getRow($sql, $attemptModel->tableName(), $orderID);
         if ($result) {
             $attemptModel->fillFromArray($result);
             $attemptModel->IsNewRecord = false;
         }
     }
     return $attemptModel;
 }
Example #20
0
Breadcrumbs::register('domain.edit', function ($breadcrumbs) {
    $breadcrumbs->parent('home');
    $breadcrumbs->push(trans('directory.edit_domain'), route('domain.edit'));
});
Breadcrumbs::register('domain.approve', function ($breadcrumbs) {
    $breadcrumbs->parent('home');
    $breadcrumbs->push('Aprobari domenii', route('domain.approve'));
});
//attempts
Breadcrumbs::register('domains-attempts', function ($breadcrumbs) {
    $breadcrumbs->parent('home');
    $breadcrumbs->push('Attempts', route('domains-attempts'));
});
Breadcrumbs::register('attempt.details', function ($breadcrumbs, $id) {
    $breadcrumbs->parent('domains-attempts');
    $attempt = Attempt::find($id);
    if (!empty($attempt)) {
        $breadcrumbs->push($attempt->name, route('attempt.details'));
    }
});
Breadcrumbs::register('attempt.add', function ($breadcrumbs) {
    $breadcrumbs->parent('home');
    $breadcrumbs->push('Add Attempt', route('attempt.add'));
});
Breadcrumbs::register('attempt.delete', function ($breadcrumbs) {
    $breadcrumbs->parent('home');
    $breadcrumbs->push('Delete Attempt', route('attempt.delete'));
});
// comments
Breadcrumbs::register('comments-all', function ($breadcrumbs) {
    $breadcrumbs->parent('home');
Example #21
0
 public function voidCreditCard()
 {
     fb('PayPal void');
     Attempt::setAttemptStatus($this->attemptModel, Attempt::INPROGRESS_STATUS);
     $successAttemptModel = Attempt::getSuccessAttempt($this->orderModel->order_id);
     $successAttemptCustomData = json_decode($successAttemptModel->custom_data, true);
     $options = array('username' => $this->gatewayModel->username, 'password' => $this->gatewayModel->routing_number, 'signature' => $this->gatewayModel->shared_secret);
     $transaction = new PayPal($options);
     if (self::$isTest) {
         $transaction->setIsProduction(false);
     }
     $transaction->set('TRANSACTIONID', $successAttemptCustomData['tracking_number']);
     $transaction->void();
     try {
         $response = $transaction->execute();
         fb($response);
     } catch (Exception $e) {
         $aErrors = array('Error processing your request');
         $this->attemptError($aErrors);
         return false;
     }
     if (!is_array($response) || !isset($response['ACK'])) {
         // payment server errors
         $aErrors = array('Error processing your request');
         $this->attemptError($aErrors);
         return false;
     }
     if (in_array($response['ACK'], array(Paypal::STATUS_SUCCESS, Paypal::STATUS_SUCCESS_WITH_WARNING))) {
         $this->attemptModel->status = Attempt::SUCCESS_STATUS;
         $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS;
     } else {
         $this->attemptModel->status = Attempt::DECLINED_STATUS;
         $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS;
     }
     //Save custom data
     $customData = array();
     if (isset($response['TRANSACTIONID'])) {
         $customData['tracking_number'] = $response['REFUNDTRANSACTIONID'];
     }
     if (isset($response['CORRELATIONID'])) {
         $customData['correlation_id'] = $response['CORRELATIONID'];
     }
     if (isset($response['REFUNDSTATUS'])) {
         $customData['refund_status'] = $response['REFUNDSTATUS'];
     }
     if (isset($response['PENDINGREASON'])) {
         $customData['pending_reason'] = $response['PENDINGREASON'];
     }
     if ($customData) {
         $this->attemptModel->custom_data = json_encode($customData);
     }
     //Save status_note
     $errors = array();
     if (isset($response['L_ERRORCODE0'])) {
         $errors[] = 'Code: ' . $response['L_ERRORCODE0'];
     }
     if (isset($response['L_LONGMESSAGE0'])) {
         $errors[] = 'Message: ' . $response['L_LONGMESSAGE0'];
     }
     if ($errors) {
         $this->attemptModel->status_note = implode('. ', $errors);
     }
     $this->attemptModel->save();
     //Set success status to response
     $this->_paymetnResponse->attemptModel = $this->attemptModel;
     $this->_paymetnResponse->paymentModel = $this->paymentModel;
     OrderLog::createLog(0, $this->orderModel->order_id, 13, $this->attemptModel->amount . ' ' . $this->campaignModel->currency_id);
     return true;
 }
Example #22
0
 public function voidCreditCard()
 {
     $successAttemptModel = Attempt::getSuccessAttempt($this->orderModel->order_id);
     if (!$successAttemptModel) {
         //it need to test
         Attempt::setAttemptStatus($this->attemptModel, Attempt::UNKNOWN_STATUS);
         $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS;
         return false;
     }
     $pacnetOptions = $this->gatewayModel->getAttributes();
     //$pacnetOptions['currency_id']=$this->campaignModel->currency_id;
     $pacnetOptions['isTest'] = self::$isTest;
     // Create and populate a request object
     $pymtReq = new RavenRequest('void', $pacnetOptions);
     $pymtReq->set('RequestID', $this->attemptModel->getrequest_id('pn'));
     $pymtReq->set('TrackingNumber', $successAttemptModel->tracking_number);
     $pymtReq->set('PymtType', self::CC_DEBIT);
     Attempt::setAttemptStatus($this->attemptModel, Attempt::INPROGRESS_STATUS);
     // Submit the request
     try {
         //Send request
         $pymtResp = $pymtReq->send();
     } catch (Exception $e) {
         //Change Attempt Status to unknown
         Attempt::setAttemptStatus($this->attemptModel, Attempt::UNKNOWN_STATUS);
         $this->_paymetnResponse->addError('error_processing_request');
         $this->_paymetnResponse->addAlert('error_processing_your_request');
         $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS;
         return false;
     }
     $errors = array();
     if ($pymtResp->get('httpStatus') == 'timeout') {
         $respReq = new RavenRequest('response', $this->gatewayModel->getAttributes());
         $respReq->set('RequestID', $pymtReq->get('RequestID'));
         $pymtResp = $respReq->send();
     }
     if ($pymtResp->get('httpStatus') != 200) {
         $this->_paymetnResponse->addAlert('error_processing_your_request');
         $errors['httpStatus'] = $pymtResp->get('httpStatus');
     }
     if ($pymtResp->get('ErrorCode')) {
         $errorCode = strtolower($pymtResp->get('ErrorCode'));
         $this->_paymetnResponse->addAlert($pymtResp->get('Message'));
         if (!in_array($errorCode, $errors)) {
             $errors['ErrorCode'] = $errorCode;
         }
     }
     if ($errors) {
         //Change Attempt Status to decline
         Attempt::setAttemptStatus($this->attemptModel, Attempt::DECLINED_STATUS);
         foreach ($errors as $key => $error) {
             $this->_paymetnResponse->addError($key, $error);
         }
         $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS;
         OrderLog::createLog(0, $this->orderModel->order_id, 21, implode(',', $errors));
         return false;
     }
     // Fill and save attempt Model
     $this->attemptModel->status = Attempt::SUCCESS_STATUS;
     $this->attemptModel->tracking_number = $pymtResp->get('TrackingNumber');
     $this->attemptModel->status_note = $pymtResp->get('Status') ? $pymtResp->get('Status') : '';
     $this->attemptModel->amount = $pymtResp->get('FormattedAmount');
     $this->attemptModel->save();
     //Set success status to response
     $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS;
     return true;
 }
Example #23
0
 /**
  * Perform a custom request on the phantomjs server, using curl
  * @param  string $command
  * @param  array  $options
  * @return mixed
  */
 protected function call($command, array $options = array())
 {
     $curl = curl_init();
     $options[CURLOPT_URL] = $this->command_url($command);
     $options[CURLOPT_RETURNTRANSFER] = TRUE;
     $options[CURLOPT_FOLLOWLOCATION] = TRUE;
     curl_setopt_array($curl, $options);
     $raw = '';
     Attempt::make(function () use($curl, &$raw) {
         $raw = trim(curl_exec($curl));
         return curl_getinfo($curl, CURLINFO_HTTP_CODE) == 200;
     });
     $error = curl_error($curl);
     $code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
     curl_close($curl);
     if ($error) {
         throw new Exception_Driver('Curl ":command" throws exception :error', array(':command' => $command, ':error' => $error));
     }
     if ($code != 200) {
         throw new Exception_Driver('Unexpected response from the panthomjs for :command: :code', array(':command' => $command, ':code' => $code));
     }
     $result = json_decode($raw, TRUE);
     return $result;
 }
Example #24
0
<?php

@(include_once 'settings/autoload.php');
/*
$r='FBiv4rtILU3NbVeyWhOb5oiHEYXW1jWSpyYjspWAI3XMqcl5oszQ5wIR9qBgVHOPgqojNugZcay/lRtjn0sdTIcJJZKutwYKXGDxOh4mBwm0rsIvzgi/bycHrP1kQ3cVrWjgtBDbZ58zdP2EqRjWbrsFu0VrarGL+YKv';
$t=NoteBase64::decode($r);
echo $t;
die;
*/
$payment = new PaymentAPI();
// Create new order
//$modelOrder=Order::model()->findByPk(2155137);
//$modelOrder=WebService::createTestOrder();
//$request=$payment->payOrder($modelOrder->order_id, $modelOrder->payment_total);
// Refund order
//$modelOrder=Order::model()->findByPk('2155336');
//$request=$payment->refundOrder($modelOrder, '1.00');
//void
//$modelOrder=Order::model()->findByPk('2155336');
//$request=$payment->voidOrder($modelOrder);
//attempt
$attemptModel = Attempt::model()->findByPk('119822');
$request = $payment->updateStatusAttempt($attemptModel);
echo '<pre>';
print_r($request);
echo '</pre>';
die;
//echo '<a target="_blank" href="'.$request->redirectUrl.'">link</a>';
//http://test.dragonpay.ph/Pay.aspx?txnid=79123&amount=11000&ccy=USD&description=Dragonpay&email=3561_email%40gmail.com&digest=6a8083fe136fe93fad96c6c0c6746ac0621e3070
//https://gw.dragonpay.ph/Pay.aspx?merchantid=ABC&txnid=12345678&amount=1000.00& ccy=PHP&description=Box+of+Chocolates&digest=a4b3d08462......
Example #25
0
 public static function finalizeOrder($orderID)
 {
     $modelOrder = Order::model()->findByPk((int) $orderID);
     if (!$modelOrder) {
         return false;
     }
     //Check status
     $modelAttempt = new Attempt();
     $modelAttempt->getLastOrderAttempt($modelOrder->order_id, Attempt::DEBIT_TYPE);
     if (in_array($modelAttempt->status, array(Attempt::SUCCESS_STATUS, Attempt::DECLINED_STATUS))) {
         return true;
     }
     $payment = new PaymentAPI();
     $response = $payment->updateStatusAttempt($modelAttempt);
     if ($response->attemptStatus == 'success') {
         $modelOrder->status = Order::STATUS_OK;
         $modelOrder->removeFlags(Order::FlAG_PAY);
         $modelOrder->addFlags(Order::FlAG_PAID);
         $modelOrder->payment_total = $modelAttempt->amount;
         $modelOrder->save();
         Event::setEvents($modelOrder->order_id, 8, false);
         //update recurring_next
         $sql = "UPDATE `orders_products`\n                JOIN `products` USING(`product_id`)\n                SET `orders_products`.`recurring_next` = DATE_ADD(NOW(), INTERVAL `products`.`subscription_days` DAY)\n                WHERE FIND_IN_SET('recurring', `orders_products`.`flags`)>0\n                AND `orders_products`.`order_id`=?i";
         self::$_msql->query($sql, $modelOrder->order_id);
         if ($modelOrder->billing_cycle == 0) {
             // Delete order prospect
             Prospects::deleteProspectOkOrder($modelOrder->order_id);
             Orders::createAttachedOrders($modelOrder);
             // Fire Pixel
             $cloneOrder = clone $modelOrder;
             Pixel::firePixelPb($cloneOrder);
             unset($cloneOrder);
         }
     } elseif ($response->attemptStatus == 'declined') {
         $modelOrder->status = Order::STATUS_ERROR;
         $modelOrder->removeFlags(Order::FlAG_PAY);
         $modelOrder->save();
         // Delete order prospect
         Prospects::deleteProspectOkOrder($modelOrder->order_id);
     }
 }
Example #26
0
 function __construct($result, $code, $data = array())
 {
     if ($code == static::USER_NOT_VERIFIED || $code == static::WRONG_PASSWORD || $code == static::OK || $code == static::DENIED) {
         $this->id = $data;
     } else {
         if ($code == static::USER_DOES_NOT_EXIST) {
             $this->email = $data;
         }
     }
     parent::__construct($result, $code, $data);
 }
 public function createHandle()
 {
     $pr = DirectoryHelpers::getPagerank(e(Input::get('url')));
     $valid_domain = function ($domain_name) {
         return preg_match("/^([a-z\\d](-*[a-z\\d])*)(\\.([a-z\\d](-*[a-z\\d])*))*\$/i", $domain_name) && preg_match("/^.{1,253}\$/", $domain_name) && preg_match("/^[^\\.]{1,63}(\\.[^\\.]{1,63})*\$/", $domain_name);
         //length of each label
     };
     $format_url = rtrim(str_replace(['http://', 'https://'], '', e(Input::get('url'))), '/');
     if (!$valid_domain($format_url)) {
         Session::put('category_id', e(Input::get('category_id')));
         return Redirect::back()->with('url_error', trans('directory.invalid_url'))->withInput();
     }
     $url_details = parse_url(e(Input::get('url')));
     $final_url = isset($url_details['scheme']) ? $url_details['scheme'] . '://' . $format_url : 'http://' . $format_url;
     Input::merge(array('url' => $final_url));
     $nice_input_names = ['category_id' => trans('directory.select_category'), 'name' => trans('directory.name'), 'url' => trans('directory.url'), 'format_url' => trans('directory.url'), 'description' => trans('directory.description'), 'keywords' => trans('directory.keywords')];
     $rules = ['category_id' => 'not_in:"0"', 'name' => 'required|between:6,260', 'url' => 'required|url|between:6,100|unique:domains', 'description' => 'required|between:200,1000', 'keywords' => 'between:5,255'];
     if (!Auth::check()) {
         $nice_input_names['g-recaptcha-response'] = 'captcha';
         $rules['g-recaptcha-response'] = 'required|recaptcha';
     }
     $coma_replace = function ($string) {
         return str_replace(',', ', ', $string);
     };
     if (strlen(str_replace(' ', '', e(Input::get('description')))) < 200 && Auth::user()->type != User::ADMIN_USER) {
         $attempt = new Attempt();
         $attempt->user_id = Auth::check() ? Auth::user()->id : null;
         $attempt->category_id = (int) e(Input::get('category_id'));
         $attempt->url = 'http://' . $format_url;
         $attempt->name = e(Input::get('name'));
         $attempt->description = $coma_replace(DirectoryHelpers::correctText(e(Input::get('description')), '.'));
         $attempt->keywords = $coma_replace(e(Input::get('keywords')));
         $attempt->save();
         return Redirect::back()->with('error', 'Descrierea este prea scurt&#259;')->withInput();
     }
     $validator = Validator::make(array_map('trim', Input::all()), $rules, [], $nice_input_names);
     if ($validator->fails()) {
         Session::put('category_id', e(Input::get('category_id')));
         return Redirect::back()->withErrors($validator)->withInput();
     }
     $status = Acl::isSuperAdmin() ? 1 : 0;
     $domain = new Domain();
     $domain->category_id = (int) e(Input::get('category_id'));
     $domain->status = $status;
     $domain->name = $coma_replace(e(Input::get('name')));
     $domain->url = 'http://' . $format_url;
     $domain->page_rank = $pr;
     $domain->description = $coma_replace(DirectoryHelpers::correctText(e(Input::get('description')), '.'));
     $domain->keywords = $coma_replace(e(Input::get('keywords')));
     try {
         $domain->thumb = DirectoryHelpers::generateThumb($domain->url);
     } catch (Exception $ex) {
         Log::error($ex->getMessage());
     }
     if ($domain->save()) {
         Acl::addAdmin($domain);
         return Redirect::route('domain.create')->with('success', trans('directory.domain_added'));
     }
     return Redirect::back()->with('error', trans('directory.domain_add_error'));
 }
Example #28
0
 public function refundCreditCard()
 {
     fb('refundCreditCard');
     $successAttemptModel = Attempt::getSuccessAttempt($this->orderModel->order_id);
     $customData = json_decode($successAttemptModel->custom_data);
     $options = $this->gatewayModel->getAttributes();
     $options['url'] = $this->_paymentOptions['refundUrl'];
     if (self::$isTest) {
         /*
         $options['url']='http://pinnaclecrm.com/lj3/scripts/core/pbsapitest.php';
         $options ['username']= '******';
         $options ['shared_secret']= 'ZFksGze8o7URmtfRqBl3';
         $options ['routing_number']= '15132';
         */
     }
     $transaction = new PBS($options);
     $refundType = $successAttemptModel->amount > $this->attemptModel->amount ? 2 : 1;
     $transaction->set('tradeNo', $customData->tradeNo);
     $transaction->set('refundType', $refundType);
     $transaction->set('tradeAmount', number_format($successAttemptModel->amount, 2));
     $transaction->set('refundAmount', number_format($this->attemptModel->amount, 2));
     $transaction->set('currency', $this->campaignModel->currency_id);
     $transaction->set('refundReason', 'Refund');
     $transaction->set('remark', '');
     $transaction->refund();
     fb($transaction);
     $response = $transaction->execute();
     fb($response);
     $xml = new DOMDocument();
     $xml->loadXML($response);
     //some
     if (!$xml->getElementsByTagName("batchNo")->item(0)->nodeValue) {
         $this->_paymetnResponse->addAlert('An error occurred');
         $this->attemptError(array('error' => 'no batchNo'));
         return false;
     }
     // Fill and save attempt Model
     $this->attemptModel->status = Attempt::SUCCESS_STATUS;
     $this->attemptModel->custom_data = json_encode(array('batchNo' => $xml->getElementsByTagName("batchNo")->item(0)->nodeValue));
     $this->attemptModel->tracking_number = substr($xml->getElementsByTagName("tradeNo")->item(0)->nodeValue, 15);
     $this->attemptModel->status_note = $xml->getElementsByTagName("description")->item(0)->nodeValu;
     $this->attemptModel->save();
     //Set success status to response
     $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS;
     return true;
 }
Example #29
0
 public function voidCreditCard()
 {
     fb('Argus void');
     $options = $this->gatewayModel->getAttributes();
     $options['url'] = $this->_paymentOptions['curlUrl'];
     $successAttemptModel = Attempt::getSuccessAttempt($this->orderModel->order_id);
     $successCustomData = json_decode($successAttemptModel->custom_data, true);
     if (self::$isTest) {
         $options['username'] = '******';
         $options['shared_secret'] = 'ZFksGze8o7URmtfRqBl3';
         $options['routing_number'] = '16724';
     }
     $transaction = new Argus($options);
     if (isset($successCustomData['po_id'])) {
         $transaction->set('request_ref_po_id', $successCustomData['po_id']);
     }
     $transaction->void();
     $response = $transaction->execute();
     $aResponse = $response['response'];
     fb($transaction);
     fb($response);
     if (!isset($aResponse['TRANS_STATUS_NAME']) || $aResponse['TRANS_STATUS_NAME'] != self::STATUS_APPROVED) {
         $aErrors = array();
         $rFields = array('SERVICE_RESPONSE', 'SERVICE_ADVICE', 'PROCESSOR_RESPONSE', 'PROCESSOR_ADVICE', 'INDUSTRY_RESPONSE', 'INDUSTRY_ADVICE');
         foreach ($rFields as $itemField) {
             if (isset($aResponse[$itemField]) && $aResponse[$itemField]) {
                 $aErrors[$itemField] = $aResponse[$itemField];
             }
         }
         fb($aErrors);
         $this->attemptError($aErrors);
         return false;
     }
     // Fill and save attempt Model
     $this->attemptModel->status = Attempt::SUCCESS_STATUS;
     if (isset($aResponse['TRANS_ID']) && $aResponse['TRANS_ID']) {
         $this->attemptModel->tracking_number = $aResponse['TRANS_ID'];
     }
     if (isset($aResponse['PROC_NAME'])) {
         $this->attemptModel->status_note = 'Response: ' . $aResponse['PROC_NAME'];
     }
     $customDate = array();
     $cFields = array('PO_ID', 'BATCH_ID', 'PMT_L4', 'PMT_ID', 'PO_LI_ID_1', 'PO_LI_PROD_ID_1');
     foreach ($cFields as $itemcField) {
         if (isset($aResponse[$itemcField]) && $aResponse[$itemcField]) {
             $customDate[$itemcField] = $aResponse[$itemcField];
         }
     }
     if ($customDate) {
         $this->attemptModel->custom_data = json_encode($customDate);
     }
     $this->attemptModel->save();
     //Set success status to response
     $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS;
     $this->_paymetnResponse->attemptModel = $this->attemptModel;
     $this->_paymetnResponse->paymentModel = $this->paymentModel;
     OrderLog::createLog(0, $this->orderModel->order_id, 3, $this->attemptModel->amount . ' ' . $this->campaignModel->currency_id);
     return true;
 }
Example #30
0
 function printAction()
 {
     $id = AF::get($this->params, 'id', FALSE);
     if (!$id) {
         throw new AFHttpException(0, 'no_id');
     }
     $orderArray = Order::getPrintFields($id);
     if (!$orderArray) {
         throw new AFHttpException(0, 'incorrect_id');
     }
     $orderModel = new Order();
     $orderModel->order_id = $id;
     $lables = $orderModel->attributeLabels();
     $orderInfo = array('full_order_id' => $orderArray['order_id'], 'created' => $orderArray['created'], 'status' => $orderArray['status'], 'campaign_name' => $orderArray['campaign_id'], 'amount_product' => Currency::getSingPrice($orderArray['amount_product'], $orderArray['currency_id']), 'amount_shipping' => Currency::getSingPrice($orderArray['amount_shipping'], $orderArray['currency_id']));
     if ($orderArray['amount_refunded']) {
         $orderInfo['amount_refunded'] = Currency::getSingPrice($orderArray['amount_refunded'], $orderArray['currency_id']);
     }
     $modelAttempt = new Attempt();
     $modelAttempt->getLastOrderAttempt($id, Attempt::DEBIT_TYPE);
     $orderInfo2 = array('payment_total' => Currency::getSingPrice($orderArray['payment_total'], $orderArray['currency_id']), 'AFID' => $orderArray['aff_id'], 'SID' => $orderArray['sid'], 'c1' => $orderArray['c1'], 'c2' => $orderArray['c2'], 'c3' => $orderArray['c3'], 'billing_cycle' => $orderArray['billing_cycle'], 'tracking_number' => $modelAttempt->tracking_number ? $modelAttempt->tracking_number : __('no'));
     $orderInfo2['rma_code'] = $orderArray['rma_code'] ? $orderArray['rma_code'] : __('no');
     $orderInfo2['gateway_name'] = $orderArray['gateway_name'];
     $orderInfo = array_merge($orderInfo, $orderInfo2);
     $customerInfo = array('order_customer_name' => $orderArray['fname'] . ' ' . $orderArray['lname'], 'email' => $orderArray['email'], 'ip' => long2ip($orderArray['ip']), 'phone' => $orderArray['phone'], 'order_address1' => $orderArray['address1'], 'order_address2' => $orderArray['address2'], 'order_city' => $orderArray['city'], 'order_state' => $orderArray['state_name'], 'order_country' => $orderArray['country_name'], 'order_zip' => $orderArray['zip'], 'order_billing_fname' => $orderArray['billing_country_id'] ? $orderArray['billing_fname'] : $orderArray['fname'], 'order_billing_lname' => $orderArray['billing_country_id'] ? $orderArray['billing_lname'] : $orderArray['lname'], 'order_billing_address1' => $orderArray['billing_country_id'] ? $orderArray['billing_address1'] : $orderArray['address1'], 'order_billing_address2' => $orderArray['billing_country_id'] ? $orderArray['billing_address2'] : $orderArray['address2'], 'order_billing_city' => $orderArray['billing_country_id'] ? $orderArray['billing_city'] : $orderArray['city'], 'order_billing_state' => $orderArray['billing_country_id'] ? $orderArray['billing_state_name'] : $orderArray['state_name'], 'order_billing_country' => $orderArray['billing_country_id'] ? $orderArray['billing_country_name'] : $orderArray['country_name'], 'order_billing_zip' => $orderArray['billing_country_id'] ? $orderArray['billing_zip'] : $orderArray['zip']);
     $paymentModel = new Payment();
     $paymentModel->fillFromArray($orderArray);
     $paymentInfo = array('payment_type' => $orderArray['payment_type']);
     if ($orderArray['payment_type'] == 'pn') {
         $addPaymentInfo = array('order_payment_status' => $modelAttempt->status, 'order_cc_number' => $paymentModel->cc_number_formatted, 'order_expiry_date' => $paymentModel->exp_date_formatted, 'order_transaction_id' => $modelAttempt->tracking_number ? $modelAttempt->tracking_number : __('no'));
         $paymentInfo = array_merge($paymentInfo, $addPaymentInfo);
     }
     $orderProducts = $orderModel->getOrderProducts();
     $this->layout = array('layouts', 'main_print');
     $this->render('print', array('order' => $orderArray, 'lables' => $lables, 'orderInfo' => $orderInfo, 'customerInfo' => $customerInfo, 'paymentInfo' => $paymentInfo, 'orderProducts' => $orderProducts));
 }