/**
  * {@inheritDoc}
  */
 public function getPublicId()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getPublicId', array());
     return parent::getPublicId();
 }
Esempio n. 2
0
 /**
  * Send request to X-Payments to initialize new payment
  *
  * @param \XLite\Model\Payment\Transaction $transaction Payment transaction
  * @param \XLite\Model\Cart           $cart          Shopping cart info
  * @param boolean                     $forceAuth     Force enable AUTH mode OPTIONAL
  *
  * @return array
  */
 protected function requestPaymentInit(\XLite\Model\Payment\Transaction $transaction, \XLite\Model\Cart $cart, $forceAuth = false)
 {
     $paymentMethod = $transaction->getPaymentMethod();
     // Prepare cart
     $preparedCart = $this->prepareCart($cart, $paymentMethod, null, $forceAuth);
     if ($cart && $preparedCart) {
         $xpcBackReference = $transaction->getPublicId();
         // Send request to X-Payments
         $result = $this->apiRequest->send('payment', 'init', $this->getInitRequestData($paymentMethod->getSetting('id'), $xpcBackReference, $preparedCart));
         if ($result->isSuccess()) {
             $response = $result->getResponse();
             // Set fields for the "Redirect to X-Payments" form
             $result->setResponse(array('xpcBackReference' => $xpcBackReference, 'txnId' => $response['txnId'], 'module_name' => $paymentMethod->getSetting('moduleName'), 'url' => \XLite\Core\Config::getInstance()->CDev->XPaymentsConnector->xpc_xpayments_url . '/payment.php', 'fields' => array('target' => 'main', 'action' => 'start', 'token' => $response['token'])));
         }
     } else {
         // Something is wrong with the cart. Should not ever happen
         $result = new \XLite\Module\CDev\XPaymentsConnector\Transport\Response();
         $result->setError('Unable to prepare cart data');
     }
     return $result;
 }