示例#1
0
 public function payEmail()
 {
     $options = self::getOptions();
     $options['merchant'] = $this->gatewayModel->username;
     $options['passwd'] = $this->gatewayModel->shared_secret;
     $dp = new DragonpayRequest($options);
     $dp->set('txnid', $this->attemptModel->attempt_id);
     $dp->set('amount', number_format($this->attemptModel->amount, 2, '.', ''));
     $dp->set('ccy', 'PHP');
     //$this->campaignModel->currency_id);
     $dp->set('description', $this->campaignModel->profile->descriptor_name);
     $dp->set('email', $this->customerModel->email);
     $dp->set('param1', $this->attemptModel->attempt_id);
     //$dp->set('mode', '1');
     //Change Attempt Status to inprogress
     Attempt::setAttemptStatus($this->attemptModel, Attempt::INPROGRESS_STATUS);
     //or submitted?
     $this->_paymetnResponse->redirectUrl = $dp->redirectUrl();
     //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, 22, $this->attemptModel->amount . ' ' . $this->campaignModel->currency_id);
     return true;
 }
示例#2
0
 public function packageSent()
 {
     //$dt = new DateTime();
     $this->sent = 'NOW():sql';
     //$dt->format('Y-m-d H:i:s');//?
     $this->update();
     // update order status
     foreach ($this->orders as $o) {
         $o->status = 'sent';
         $o->update();
         OrderLog::createLog(0, $o->order_id, 19);
     }
 }
示例#3
0
 private static function parserCsvFiles($downloadFilePath)
 {
     $header = NULL;
     $data = array();
     if (($handle = fopen($downloadFilePath, 'r')) !== FALSE) {
         while (($row = fgetcsv($handle, 1000, ',')) !== FALSE) {
             if (!$header) {
                 $header = $row;
             } else {
                 $data[] = array_combine($header, $row);
             }
         }
         fclose($handle);
     }
     $db = SafeMySQL::getInstance();
     echo '<pre>';
     print_r($db->getConn());
     echo '</pre>';
     foreach ($data as $orderArray) {
         if (isset($orderArray['Tracking Number']) && isset($orderArray['Order Id'])) {
             /*
              * Old query
             $sql = "UPDATE `orders` SET `tracking_number`=?s, `status`='shipped'
                     WHERE (`order_id`=?i OR `ship_with`=?i) AND `status` = 'sent'";
             */
             $sql = "UPDATE `packages_orders` AS `po`\n                    JOIN `packages` AS `p` USING (`package_id`)\n                    LEFT JOIN `orders` AS `o` ON `o`.`order_id` = `po`.`order_id` AND `o`.`status` IN ('ok', 'sent')\n                    SET `p`.`tracking_number` = ?s, `o`.`status` = 'shipped'\n                    WHERE `package_id` =\n                    (SELECT `package_id` FROM `packages_orders` AS `p1` WHERE `p1`.`order_id`=?i LIMIT 1)";
             $orderID = (int) $orderArray['Order Id'];
             echo $sql . '<hr>';
             $db->query($sql, $orderArray['Tracking Number'], $orderID);
             if ($db->affectedRows() > 0) {
                 Event::setEvents($orderID, 9);
                 OrderLog::createLog(0, $orderID, 20);
             }
         }
     }
 }
示例#4
0
 protected function attemptError($errors)
 {
     //Change Attempt Status to decline and save status note
     $this->attemptModel->status = Attempt::DECLINED_STATUS;
     $this->attemptModel->status_note = implode(',', $errors);
     $this->attemptModel->save();
     foreach ($errors as $key => $error) {
         $this->_paymetnResponse->addError($key, $error);
     }
     //$this->_paymetnResponse->addAlert('error_processing_your_request');
     $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS;
     $this->_paymetnResponse->attemptModel = $this->attemptModel;
     $this->_paymetnResponse->paymentModel = $this->paymentModel;
     OrderLog::createLog(0, $this->orderModel->order_id, 21, implode(',', $errors));
 }
示例#5
0
 public function cancelRetries($user_id = 0)
 {
     $this->removeFlags(Order::FlAG_RETRY);
     $this->model_uset_id = $user_id;
     if ($this->save(false)) {
         OrderLog::createLog($user_id, $this->order_id, 23);
         return true;
     }
     return false;
 }
示例#6
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;
 }
示例#7
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;
 }
示例#8
0
 public function payCreditCard()
 {
     fb('PSPaymentBillsService');
     $options = $this->gatewayModel->getAttributes();
     $options['url'] = $this->_paymentOptions['payUrl'];
     if (self::$isTest) {
         /* $options ['username']= '******';
            $options ['shared_secret']= 'ZFksGze8o7URmtfRqBl3';
            $options ['routing_number']= '15132';*/
     }
     if (strlen($this->billingAddressModel->fullAddress) < 2) {
         $this->billingAddressModel->fullAddress = 'Address: ' . $this->billingAddressModel->fullAddress;
     }
     if (strlen($this->shippingAddressModel->phone) < 2) {
         $this->shippingAddressModel->phone = '0' . $this->shippingAddressModel->phone;
     }
     $transaction = new PBS($options);
     $transaction->set('orderNo', $this->attemptModel->getrequest_id('pb'));
     $transaction->set('orderCurrency', $this->campaignModel->currency_id);
     $transaction->set('orderAmount', number_format($this->attemptModel->amount, 2));
     $transaction->set('paymentMethod', 'Credit Card');
     $transaction->set('cardNo', $this->paymentModel->cc_number);
     $transaction->set('cardExpireMonth', $this->paymentModel->exp_date_month_formatted);
     $transaction->set('cardExpireYear', $this->paymentModel->exp_date_year_formatted);
     // send cvv if the billing circle = 0
     if ($this->orderModel->billing_cycle == 0) {
         $transaction->set('cardSecurityCode', $this->paymentModel->cc_cvv);
     }
     $transaction->set('issuingBank', 'Bank');
     $transaction->set('customerID', 'HLTH' . $this->attemptModel->attempt_id);
     $transaction->set('firstName', $this->billingAddressModel->fname);
     $transaction->set('lastName', $this->billingAddressModel->lname);
     $transaction->set('email', $this->customerModel->email);
     $transaction->set('ip', $this->orderModel->ip_formatted);
     $transaction->set('phone', $this->shippingAddressModel->phone);
     $transaction->set('country', strtoupper($this->billingAddressModel->country_id));
     $transaction->set('state', $this->billingAddressModel->state_id);
     $transaction->set('city', $this->billingAddressModel->city);
     $transaction->set('address', $this->billingAddressModel->fullAddress);
     $transaction->set('zip', $this->billingAddressModel->zip);
     $transaction->set('remark', '');
     //$signsrc = htmlspecialchars($transaction->merNo.$transaction->gatewayNo.$transaction->orderNo.$transaction->orderCurrency.$transaction->orderAmount.$transaction->customerID.$transaction->firstName.$transaction->lastName.$transaction->cardNo.$transaction->cardExpireYear.$transaction->cardExpireMonth.$transaction->cardSecurityCode.$transaction->email.$transaction->signkey);
     //$transaction->set('signInfo',hash('sha256',$signsrc));
     $transaction->sale();
     fb($transaction);
     // Submit the request
     try {
         $response = $transaction->execute();
     } catch (Exception $e) {
         $this->attemptError(array('error_processing_request'));
         return false;
     }
     fb($response);
     $xml = new DOMDocument();
     $xml->loadXML($response);
     fb($xml);
     // properly formed response?
     if (!$xml->getElementsByTagName("orderStatus")->item(0)) {
         $this->_paymetnResponse->addAlert('An error occurred');
         $this->attemptError(array('error' => 'unknown error'));
         return false;
     }
     // Fill and save attempt Model
     if ($xml->getElementsByTagName("tradeNo")->item(0) && $xml->getElementsByTagName("tradeNo")->item(0)->nodeValue) {
         //$this->attemptModel->tracking_number = (self::$isTest) ? substr($xml->getElementsByTagName("tradeNo")->item(0)->nodeValue,1) : $xml->getElementsByTagName("tradeNo")->item(0)->nodeValue;
         $this->attemptModel->custom_data = json_encode(array('tradeNo' => $xml->getElementsByTagName("tradeNo")->item(0)->nodeValue));
         $this->attemptModel->tracking_number = substr($xml->getElementsByTagName("tradeNo")->item(0)->nodeValue, 15);
     }
     $this->attemptModel->status_note = $xml->getElementsByTagName("orderInfo")->item(0)->nodeValue;
     //Transaction status:
     /*-2 => 'To be confirmed',
     		-1 => 'Pending',
     		 0 => 'Failure',
     		 1 => 'Success',*/
     $status = $xml->getElementsByTagName("orderStatus")->item(0)->nodeValue;
     //fb($status);
     // Check the status
     switch ($status) {
         case 1:
             $this->attemptModel->status = Attempt::SUCCESS_STATUS;
             $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS;
             break;
         case -2:
         case -1:
             $this->attemptModel->status = Attempt::SUBMITED_STATUS;
             $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS;
             break;
         case 0:
             fb('its been declined!!!');
             $this->attemptModel->status = Attempt::DECLINED_STATUS;
             $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS;
             $this->_paymetnResponse->addAlert($xml->getElementsByTagName("orderInfo")->item(0)->nodeValue);
             $this->attemptError(array('error' => $xml->getElementsByTagName("orderInfo")->item(0)->nodeValue));
             return false;
             break;
         default:
             $this->attemptModel->status = Attempt::DECLINED_STATUS;
             $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS;
             $this->_paymetnResponse->addAlert($xml->getElementsByTagName("orderInfo")->item(0)->nodeValue);
             $this->attemptError(array('error' => $xml->getElementsByTagName("orderInfo")->item(0)->nodeValue));
             return false;
             break;
     }
     if (!$this->attemptModel->save()) {
         fb('attempt save failed');
         fb($this->attemptModel->getErrors());
         fb($this->attemptModel->tracking_number);
     }
     //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, 22, $this->attemptModel->amount . ' ' . $this->campaignModel->currency_id);
     return true;
 }
示例#9
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;
 }
示例#10
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;
 }
示例#11
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;
 }
示例#12
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();
     }
 }
示例#13
0
 function deleteAction()
 {
     $id = AF::get($_POST, 'id', 0);
     $modelsID = explode(',', $id);
     $errors = FALSE;
     foreach ($modelsID as $id) {
         $model = new Order();
         if ($model->fillFromDbPk($id)) {
             $orderDeleteModel = new OrderDelete();
             $orderDeleteModel->fillFromArray($model->getAttributes());
             if ($orderDeleteModel->save()) {
                 if (!$model->delete()) {
                     $errors = true;
                 }
             } else {
                 $errors = true;
             }
             OrderLog::createLog($this->user->user_id, $id, 25);
         } else {
             $errors = TRUE;
         }
         if ($model->getErrors()) {
             $errors = TRUE;
         }
         unset($model);
     }
     if (isset($_POST['ajax'])) {
         AF::setJsonHeaders('json');
         if ($errors) {
             Message::echoJsonError(__('order_no_deleted'));
         } else {
             Message::echoJsonSuccess(__('order_deleted'));
         }
     }
 }
示例#14
0
     @(include_once '../../ws/class/ipayment.class.php');
     @(include_once '../../ws/class/payment.class.php');
     @(include_once '../../ws/class/raven_config_demo.php');
     @(include_once '../../ws/class/ravenrequest.class.php');
     @(include_once '../../ws/class/payment_' . $orderModel->payment_type . '.class.php');
     $paymentSystem = Payment::getPaymentSystem($orderModel);
     try {
         if ($paymentSystem->setRefund($countRefunded)) {
             $jobModel->done();
             $saveOrder = new Order();
             $saveOrder->order_id = $jobModel->order_id;
             $saveOrder->payment_total = $orderModel->payment_total - $countRefunded;
             echo $saveOrder->payment_total . '<br>';
             $saveOrder->setIsNewRecord(false);
             $saveOrder->save(false);
             OrderLog::createLog(0, $jobModel->order_id, 13, $countRefunded);
         } else {
             $jobModel->setStatusError(json_encode($paymentSystem->geterrors()));
         }
     } catch (Exception $e) {
         $jobModel->setStatusError($e->getMessage());
     }
     break;
 case 'mail':
     $mailArray = unserialize($jobModel->content);
     $smtpModel = new Smtp();
     $smtpModel->fillFromDbPk((int) $mailArray['smtp_id']);
     $mail = new PHPMailer();
     $mail->IsSMTP();
     $mail->IsHTML(true);
     $mail->CharSet = 'UTF-8';
示例#15
0
<?php

include_once '../settings/autoload.php';
$msql = SafeMySQL::getInstance();
$sql = "SELECT *\n        FROM `fulfillments` as f\n        WHERE f.`active` = 1";
$setFulfillment = $msql->getAll($sql);
if (!$setFulfillment) {
    die;
}
foreach ($setFulfillment as $fulfillment) {
    $fulfillmentModel = new Fulfillment();
    $fulfillmentModel->fillFromArray($fulfillment);
    $sql = "(\n                SELECT o.*, o.`created` as 'order_created', p.*, s.*, sc.`shipcat_code`, sc.`shipcat_name`, g.`gateway_id`, g.`alias`, opn.`card_number`, opn.`expiry_date`, `countries1`.`country_name` AS `country_name`, `countries2`.`country_name` AS `billing_country_name`, `states1`.`state_name` AS `state_name`, `states2`.`state_name` AS `billing_state_name`\n                FROM `orders` AS o\n                JOIN `campaigns` AS c ON o.`campaign_id` = c.`campaign_id`\n                JOIN `orders_pn` AS opn ON o.`order_id` = opn.`order_id`\n                JOIN `products` AS p ON o.`product_id` = p.`product_id`\n                LEFT JOIN `shipping` AS s ON o.`shipping_id` = s.`shipping_id`\n                LEFT JOIN `shipcat` AS sc ON s.`shipcat_id` = sc.`shipcat_id`\n                LEFT JOIN `gateways` AS g ON c.`gateway_id` = g.`gateway_id`\n                LEFT JOIN `countries` AS `countries1` ON o.`country_id` = `countries1`.`country_id`\n                LEFT JOIN `countries` AS `countries2` ON o.`billing_country_id` = `countries2`.`country_id`\n                LEFT JOIN `states` AS `states1` ON o.`country_id` = `states1`.`country_id` AND o.`state_id` = `states1`.`state_code`\n                LEFT JOIN `states` AS `states2` ON o.`billing_country_id` = `states2`.`country_id` AND o.`billing_state_id` = `states2`.`state_code`\n                WHERE o.`status` = 'ok' AND c.`fulfillment_id` = ?i)\n                UNION\n                (\n                    SELECT o.*, o.`created` as 'order_created', p.*, s.*, sc.`shipcat_code`, sc.`shipcat_name`, NULL, NULL, NULL, NULL, `countries1`.`country_name` AS `country_name`, `countries2`.`country_name` AS `billing_country_name`, `states1`.`state_name` AS `state_name`, `states2`.`state_name` AS `billing_state_name`\n                    FROM `orders` AS o\n                    JOIN `campaigns` AS c ON o.`campaign_id` = c.`campaign_id`\n                    JOIN `products` AS p ON o.`product_id` = p.`product_id`\n                    LEFT JOIN `shipping` AS s ON o.`shipping_id` = s.`shipping_id`\n                    LEFT JOIN `shipcat` AS sc ON s.`shipcat_id` = sc.`shipcat_id`\n                    LEFT JOIN `countries` AS `countries1` ON o.`country_id` = `countries1`.`country_id`\n                    LEFT JOIN `countries` AS `countries2` ON o.`billing_country_id` = `countries2`.`country_id`\n                    LEFT JOIN `states` AS `states1` ON o.`country_id` = `states1`.`country_id` AND o.`state_id` = `states1`.`state_code`\n                    LEFT JOIN `states` AS `states2` ON o.`billing_country_id` = `states2`.`country_id` AND o.`billing_state_id` = `states2`.`state_code`\n                    WHERE `status` = 'upsell' AND `ship_with` IN (\n                    SELECT `order_id`\n                    FROM `orders` AS o\n                    WHERE o.`status` = 'ok' AND c.`fulfillment_id` = ?i\n                )\n            )\n            ORDER BY `order_id`";
    $orders = $msql->getInd('order_id', $sql, $fulfillmentModel->fulfillment_id, $fulfillmentModel->fulfillment_id);
    if (!$orders) {
        continue;
    }
    $filePath = OrderFTP::createFtpOrders($orders, $fulfillmentModel);
    $fulfillmentModel->filePath = $filePath;
    if ($fulfillmentModel->uploadToFulfillment()) {
        $sql = "UPDATE `orders` as o\n                JOIN `campaigns` AS c ON o.`campaign_id` = c.`campaign_id`\n                JOIN `orders_pn` AS opn ON o.`order_id` = opn.`order_id`\n                JOIN `products` AS p ON o.`product_id` = p.`product_id`\n                LEFT JOIN `shipping` AS s ON o.`shipping_id` = s.`shipping_id`\n                LEFT JOIN `shipcat` AS sc ON s.`shipcat_id` = sc.`shipcat_id`\n                LEFT JOIN `gateways` AS g ON c.`gateway_id` = g.`gateway_id`\n                SET o.`status` = 'sent'\n                WHERE o.`status` = 'ok' AND o.`order_id` IN(?a)";
        $msql->query($sql, OrderFTP::$updateOrders);
        foreach (OrderFTP::$updateOrders as $orderID) {
            OrderLog::createLog(0, $orderID, 19);
        }
    }
}