$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'; $newPaymentModel->pn_status = $pymtResp->get('Status');
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; }