Esempio n. 1
0
 /**
  * Get specific transaction URL on PayPal side
  * 
  * @param \XLite\Model\Payment\Transaction $transaction Payment transaction object
  * @param string                           $id          Transaction ID (PPREF)
  *  
  * @return string
  */
 protected function getTransactionIdURL($transaction, $id)
 {
     $isTestMode = $transaction->getDataCell('test_mode');
     return isset($isTestMode) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=' . $id : 'https://www.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=' . $id;
 }
 /**
  * {@inheritDoc}
  */
 public function getDataCell($name)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getDataCell', array($name));
     return parent::getDataCell($name);
 }
Esempio n. 3
0
 /**
  * Do Recharge the difference request.
  * Returns false on failure or redirects admin back to the order page
  * the necessary actions with the backend transaction are taken in the
  * Callback request processing
  *
  * @param \XLite\Model\Order $order Order which is recharged
  * @param \XLite\Model\Payment\Transaction $parentCardTransaction Trandaction with saved card
  * @param float $amount Amount to recharge
  *
  * @return boolean
  */
 public function doRecharge(\XLite\Model\Order $order, \XLite\Model\Payment\Transaction $parentCardTransaction, $amount)
 {
     $newTransaction = new \XLite\Model\Payment\Transaction();
     $newTransaction->setPaymentMethod($this->getSavedCardsPaymentMethod());
     $newTransaction->setStatus(\XLite\Model\Payment\Transaction::STATUS_INPROGRESS);
     $newTransaction->setDataCell('is_recharge', 'Y', null, 'C');
     $newTransaction->setValue($amount);
     $order->addPaymentTransactions($newTransaction);
     $newTransaction->setOrder($order);
     foreach ($this->paymentSettingsToSave as $field) {
         $key = 'xpc_can_do_' . $field;
         if ($parentCardTransaction->getDataCell($key) && $parentCardTransaction->getDataCell($key)->getValue()) {
             $newTransaction->setDataCell($key, $parentCardTransaction->getDataCell($key)->getValue(), null, 'C');
         }
     }
     $this->copyMaskedCard($parentCardTransaction, $newTransaction);
     $recharge = $this->client->requestPaymentRecharge($parentCardTransaction->getDataCell('xpc_txnid')->getValue(), $newTransaction);
     if ($recharge->isSuccess()) {
         $response = $recharge->getResponse();
         if (self::STATUS_AUTH == $response['status'] || self::STATUS_CHARGED == $response['status']) {
             \XLite\Core\TopMessage::getInstance()->addInfo($response['message'] ? $response['message'] : 'Operation successfull');
             if ($response['transaction_id']) {
                 $newTransaction->setDataCell('xpc_txnid', $response['transaction_id'], 'X-Payments transaction ID', 'C');
             }
         } else {
             \XLite\Core\TopMessage::getInstance()->addError($response['error'] ? $response['error'] : 'Operation failed');
             $newTransaction->setStatus(\XLite\Model\Payment\Transaction::STATUS_FAILED);
         }
     } else {
         $message = 'Operation failed';
         if ($recharge->getError()) {
             $message .= '. ' . $recharge->getError();
         }
         \XLite\Core\TopMessage::getInstance()->addError($message);
         $newTransaction->setStatus(\XLite\Model\Payment\Transaction::STATUS_FAILED);
     }
     \XLite\Core\Database::getEM()->flush();
 }
Esempio n. 4
0
 /**
  * Check payment status at X-Payments to make sure token is valid
  *
  * @param \XLite\Model\Payment\Transaction $transaction Transaction
  *
  * @return bool
  */
 protected function checkInitPaymentStatus(\XLite\Model\Payment\Transaction $transaction)
 {
     $result = false;
     $txnId = $transaction->getDataCell('xpc_txnid') ? $transaction->getDataCell('xpc_txnid')->getValue() : false;
     if ($txnId) {
         $info = $this->requestPaymentInfo($txnId);
         if ($info->isSuccess()) {
             $response = $info->getResponse();
             $result = \XLite\Module\CDev\XPaymentsConnector\Model\Payment\Processor\XPayments::STATUS_NEW == $response['status'];
         }
     }
     return $result;
 }