Example #1
0
 /**
  * Save some payment settings from payment method to the transaction
  *
  * @param \XLite\Model\Payment\Transaction $transaction Transaction
  *
  * @return string
  */
 public function savePaymentSettingsToTransaction(\XLite\Model\Payment\Transaction $transaction, $parentTransaction = null)
 {
     if ($parentTransaction) {
         $paymentMethod = $parentTransaction->getPaymentMethod();
     } else {
         $paymentMethod = $transaction->getPaymentMethod();
     }
     foreach ($this->paymentSettingsToSave as $field) {
         $key = 'xpc_can_do_' . $field;
         if ($paymentMethod->getSetting($field)) {
             $transaction->setDataCell($key, $paymentMethod->getSetting($field), null, 'C');
         }
     }
     $transaction->setDataCell('xpc_session_id', \XLite\Core\Session::getInstance()->getID(), null, 'C');
 }
 /**
  * {@inheritDoc}
  */
 public function setDataCell($name, $value, $label = NULL, $accessLevel = NULL)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setDataCell', array($name, $value, $label, $accessLevel));
     return parent::setDataCell($name, $value, $label, $accessLevel);
 }
Example #3
0
 /**
  * Process card validation data
  *
  * @param \XLite\Model\Payment\Transaction $transaction Callback-owner transaction
  * @param array $data Data
  *
  * @return void
  */
 protected function processCardValidationData(\XLite\Model\Payment\Transaction $transaction, $data)
 {
     $cardValidation = array('avs_z' => 'AVS ZIP/Postal code', 'avs_a' => 'AVS Address (street)', 'avs_c' => 'AVS Cardholder name (optional)', 'cvv' => 'CVV2/CVD/Card secure code');
     if (isset($data['cardValidation']) && !empty($data['cardValidation']) && is_array($data['cardValidation'])) {
         foreach ($cardValidation as $key => $label) {
             if (isset($data['cardValidation'][$key])) {
                 $transaction->setDataCell('xpc_' . $key, $data['cardValidation'][$key], null, 'C');
                 $transaction->setDataCell('xpc_' . $key . '_text', self::getCardValidationText($data['cardValidation'][$key]), $label, 'C');
             }
         }
     }
 }
Example #4
0
 /**
  * Set X-Payments API error to:
  *  - Logs
  *  - Transaction data
  *  - Controller
  *
  * @param \XLite\Model\Payment\Transaction $transaction Transaction
  * @param string $message Error message
  *
  * @return void
  */
 protected function setXpcInitError(\XLite\Model\Payment\Transaction $transaction, $message = '')
 {
     self::writeLogError('X-Paymets payment initialization failed: ' . $message);
     $transaction->setDataCell('status', $message, 'X-Payments error', 'C');
     $transaction->setNote($message);
     $iframe = \XLite::getController()->getIframe();
     $iframe->setError($message);
     if (\XLite::getController()->isCheckoutReady()) {
         $type = $this->isChangeMethodMessage($message) ? \XLite\Module\CDev\XPaymentsConnector\Core\Iframe::IFRAME_CHANGE_METHOD : \XLite\Module\CDev\XPaymentsConnector\Core\Iframe::IFRAME_ALERT;
         $iframe->setType($type);
     } else {
         $iframe->setType(\XLite\Module\CDev\XPaymentsConnector\Core\Iframe::IFRAME_DO_NOTHING);
     }
     $this->clearInitDataFromSession();
     $iframe->finalize();
 }