<?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;
$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(); */ } ?> <!DOCTYPE html>
$pymtReq->set('BillingCity', $orderModel->billing_country_id ? $orderModel->billing_city : $orderModel->city); $pymtReq->set('BillingRegion', $orderModel->billing_country_id ? $resultBillingState : $resultState); $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';
protected function getAttemptInfo($isSave = false) { $pacnetOptions = $this->gatewayModel->getAttributes(); //$pacnetOptions['request_id'] = $this->attemptModel->request_id; $pymtReq = new RavenRequest('response', $pacnetOptions); $pymtReq->set('RequestID', $this->attemptModel->getrequest_id('pn')); //$pymtReq->set('RequestID', '2z7rewh311h'); // Submit the request try { fb($pymtReq); $pymtResp = $pymtReq->send(); } catch (Exception $e) { //Change Attempt Status to unknown $this->_paymetnResponse->addError('error_processing_request'); $this->_paymetnResponse->addAlert('error_processing_your_request'); $this->_paymetnResponse->status = PaymentAPIResponse::ERROR_STATUS; return false; } $this->_paymetnResponse->status = PaymentAPIResponse::SUCCESS_STATUS; $this->attemptModel->status_note = $pymtResp->get('Status') ? $pymtResp->get('Status') : ''; $this->attemptModel->tracking_number = $pymtResp->get('TrackingNumber'); switch ($pymtResp->get('Status')) { case 'Approved': $this->attemptModel->status = Attempt::SUCCESS_STATUS; break; case 'Declined': $this->attemptModel->status = Attempt::DECLINED_STATUS; break; } $this->_paymetnResponse->attemptModel = $this->attemptModel; $this->_paymetnResponse->paymentModel = $this->paymentModel; return true; }