<?php include_once '../settings/autoload.php'; @(include_once '../../ws/class/ravenrequest.class.php'); $msql = SafeMySQL::getInstance(); while ($orderArray = Order::getOneNewPanding()) { $orderModel = new Order(); $orderModel->fillFromArray($orderArray); $saveOrderModel = new Order(); $saveOrderModel->setIsNewRecord(false); $saveOrderModel->order_id = $orderArray['order_id']; $pymtReq = new RavenRequest('response', $orderArray); $pymtReq->set('RequestID', $orderArray['request_id']); try { $pymtResp = $pymtReq->send(); $paymentModel = new OrderPn(); $paymentModel->setIsNewRecord(false); $paymentModel->order_id = $orderArray['order_id']; /* echo '<pre>'; print_r($pymtResp->get('Status')); echo '</pre>'; */ if ($pymtResp->get('RequestResult') != 'ok') { $saveOrderModel->status = 'error'; $saveOrderModel->recurring = 'NULL:sql'; $saveOrderModel->recurring_next = 'NULL:sql'; $saveOrderModel->save(false); $paymentModel->pn_status = 'incorrect request id'; $paymentModel->save(false); continue;
$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(); */ } ?> <!DOCTYPE html> <html><head> <meta charset="utf-8"> <title>Get Order Status</title>
$pymtReq->set('BillingPostal', $orderModel->billing_country_id ? $orderModel->billing_zip : $orderModel->zip); $pymtReq->set('BillingCountry', $orderModel->billing_country_id ? $orderModel->billing_country_id : $orderModel->country_id); $pymtReq->set('ShipToCity', $orderModel->city); $pymtReq->set('ShipToRegion', $resultState); $pymtReq->set('ShipToPostal', $orderModel->zip); $pymtReq->set('ShipToCountry', $orderModel->country_id); $pymtReq->set('ShippingAddressLine1', $orderModel->address1); $pymtReq->set('ShippingAddressLine2', $orderModel->address2); $pymtReq->set('ContactEmail', $orderModel->email); $pymtReq->set('CustomerPhone', $orderModel->phone); // Submit the request $pymtResp = $pymtReq->send(); if ($pymtResp->get('httpStatus') == 'timeout') { $respReq = new RavenRequest('response', $gateway); $respReq->set('RequestID', $pymtReq->get('RequestID')); $pymtResp = $respReq->send(); } if ($pymtResp->get('httpStatus') != 200) { $orderModel->status = 'error'; $newPaymentModel->pn_status = $pymtResp->get('httpStatus'); $newPaymentModel->note = $pymtResp->get('Message'); $newPaymentModel->attempt = $paymentModel->attemt + 1; $orderModel->save(false); $newPaymentModel->save(false); //setErrors($pymtResp->get('httpStatus')); continue; } if ($pymtResp->get('Status') != 'Approved') { $orderModel->status = 'error'; $newPaymentModel->pn_status = $pymtResp->get('Status'); $newPaymentModel->note = $pymtResp->get('Message');
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; }