public function processCallback(\XLite\Model\Payment\Transaction $transaction)
 {
     parent::processCallback($transaction);
     $request = \XLite\Core\Request::getInstance();
     $json = file_get_contents('php://input');
     //\XLite\Logger::logCustom('pmt', var_export($json,1), '');
     $temp = json_decode($json, true);
     if ($this->getSetting('test')) {
         $this->public_key = $this->getSetting('testPublicKey');
         $this->secret_key = $this->getSetting('testSecretKey');
     } else {
         $this->public_key = $this->getSetting('realPublicKey');
         $this->secret_key = $this->getSetting('realSecretKey');
     }
     $signature_check = sha1($this->secret_key . $temp['account_id'] . $temp['api_version'] . $temp['event'] . $temp['data']['id']);
     $signature_check_sha512 = hash('sha512', $this->secret_key . $temp['account_id'] . $temp['api_version'] . $temp['event'] . $temp['data']['id']);
     if ($signature_check != $temp['signature'] && $signature_check_sha512 != $temp['signature']) {
         //hack detected
         $status = $transaction::STATUS_FAILED;
         $this->setDetail('verification', 'Verification failed', 'Verification');
         $this->transaction->setNote('Verification failed');
     } else {
         $status = $transaction::STATUS_SUCCESS;
         $this->setDetail('result', 'Accept', 'Result');
     }
     $this->transaction->setStatus($status);
 }
Esempio n. 2
0
 public function processCallback(\XLite\Model\Payment\Transaction $transaction)
 {
     parent::processCallback($transaction);
     $this->callEbanxLib();
     $request = \XLite\Core\Request::getInstance();
     $hashes = explode(',', $request->hash_codes);
     foreach ($hashes as $hash) {
         $query = \Ebanx\Ebanx::doQuery(array('hash' => $hash));
         $status = null;
         if ($query->status == 'SUCCESS') {
             $transaction = \XLite\Core\Database::getRepo('XLite\\Model\\Payment\\Transaction')->find($query->payment->merchant_payment_code);
             if ($query->payment->status == 'PE') {
                 $status = $transaction::STATUS_PENDING;
                 echo "STATUS PENDING\n";
             }
             if ($query->payment->status == 'CO') {
                 if ($request->notification_type == 'refund') {
                     $transaction->getPaymentTransaction()->getOrder()->setPaymentStatus(\XLite\Model\Order\Status\Payment::STATUS_REFUNDED);
                     echo "STATUS REFUNDED\n";
                 } else {
                     if ($request->notification_type == 'chargeback') {
                         return "SKIP: payment was not updated due to chargeback.";
                     } else {
                         $status = $transaction::STATUS_SUCCESS;
                         echo "STATUS SUCCESS\n";
                     }
                 }
             }
             if ($query->payment->status == 'CA') {
                 $status = $transaction::STATUS_CANCELED;
                 echo "STATUS CANCELED\n";
             }
             if ($query->payment->status == 'OP') {
                 $status = $transaction::STATUS_INPROGRESS;
                 echo "STATUS OPENED\n";
             }
             $transaction->setStatus($status);
             $transaction->getOrder()->setPaymentStatusByTransaction($transaction);
         } else {
             echo "Failure in contacting EBANX\n";
         }
     }
 }
Esempio n. 3
0
 public function processCallback(\XLite\Model\Payment\Transaction $transaction)
 {
     parent::processCallback($transaction);
     $request = \XLite\Core\Request::getInstance();
     $headers = getallheaders();
     $schema = isset($_SERVER['HTTPS']) ? "https://" : "http://";
     $currentUrl = $schema . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     // Get the raw HTTP POST body (JSON object encoded as a string)
     // Note: Substitute getBody() with a function call to retrieve the raw HTTP body.
     // In "plain" PHP this can be done with file_get_contents('php://input')
     $body = file_get_contents('php://input');
     // Get the signature from the HTTP or email headers
     $signature = $_SERVER['HTTP_X_COINIFY_CALLBACK_SIGNATURE'];
     // Calculate the signature using the callback data and your IPN secret
     $expected_signature = strtolower(hash_hmac('sha256', $body, $this->getSetting('ipnSecret'), false));
     // Check that the signatures match
     if (strtolower($signature) != $expected_signature) {
         exit("Invalid callback");
     }
     // Valid signature
     $this->transaction->setStatus($transaction::STATUS_SUCCESS);
 }
Esempio n. 4
0
 /**
  * Process callback
  *
  * @param \XLite\Model\Payment\Transaction $transaction Callback-owner transaction
  *
  * @return void
  */
 public function processCallback(\XLite\Model\Payment\Transaction $transaction)
 {
     parent::processCallback($transaction);
     if (Paypal\Model\Payment\Processor\PaypalIPN::getInstance()->isCallbackIPN()) {
         // If callback is IPN request from Paypal
         Paypal\Model\Payment\Processor\PaypalIPN::getInstance()->processCallbackIPN($transaction, $this);
         $transaction->registerTransactionInOrderHistory('callback, IPN');
     }
     $this->saveDataFromRequest();
 }
Esempio n. 5
0
 /**
  * Process callback
  *
  * @param \XLite\Model\Payment\Transaction $transaction Callback-owner transaction
  *
  * @return void
  */
 public function processCallback(\XLite\Model\Payment\Transaction $transaction)
 {
     parent::processCallback($transaction);
     $request = \XLite\Core\Request::getInstance();
     $status = $transaction::STATUS_FAILED;
     switch ($this->getIPNVerification()) {
         case self::IPN_DECLINED:
             $status = $transaction::STATUS_FAILED;
             $this->markCallbackRequestAsInvalid(static::t('IPN verification failed'));
             break;
         case self::IPN_REQUEST_ERROR:
             $status = $transaction::STATUS_PENDING;
             $this->markCallbackRequestAsInvalid(static::t('IPN HTTP error'));
             break;
         case self::IPN_VERIFIED:
             switch ($request->payment_status) {
                 case 'Completed':
                     if ($transaction->getValue() == $request->mc_gross) {
                         $status = $transaction::STATUS_SUCCESS;
                     } else {
                         $status = $transaction::STATUS_FAILED;
                         $this->setDetail('amount_error', 'Payment transaction\'s amount is corrupted' . PHP_EOL . 'Amount from request: ' . $request->mc_gross . PHP_EOL . 'Amount from transaction: ' . $transaction->getValue(), 'Hacking attempt');
                         $this->markCallbackRequestAsInvalid(static::t('Transaction amount mismatch'));
                     }
                     break;
                 case 'Pending':
                     $status = $transaction::STATUS_PENDING;
                     break;
                 default:
             }
         default:
     }
     $this->saveDataFromRequest();
     $this->transaction->setStatus($status);
 }
Esempio n. 6
0
 /**
  * Process callback
  *
  * @param \XLite\Model\Payment\Transaction $transaction Callback-owner transaction
  *
  * @return void
  */
 public function processCallback(\XLite\Model\Payment\Transaction $transaction)
 {
     parent::processCallback($transaction);
     if (\XLite\Module\CDev\Paypal\Model\Payment\Processor\PaypalIPN::getInstance()->isCallbackIPN()) {
         // If callback is IPN request from Paypal
         \XLite\Module\CDev\Paypal\Model\Payment\Processor\PaypalIPN::getInstance()->processCallbackIPN($transaction, $this);
     }
     $this->saveDataFromRequest();
 }