コード例 #1
0
ファイル: XPayments.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Process return
  *
  * @param \XLite\Model\Payment\Transaction $transaction Return-owner transaction
  *
  * @return void
  */
 public function processReturn(\XLite\Model\Payment\Transaction $transaction)
 {
     $txnId = \XLite\Core\Request::getInstance()->txnId;
     $info = $this->client->requestPaymentInfo($txnId);
     $transactionStatus = $transaction::STATUS_FAILED;
     $this->client->clearInitDataFromSession();
     if ($info->isSuccess()) {
         $response = $info->getResponse();
         $transaction->setDataCell('xpc_message', $response['message'], 'X-Payments response');
         if ($response['isFraudStatus']) {
             $transaction->setDataCell('xpc_fmf', 'blocked', 'Fraud status');
         }
         $errorDescription = false;
         if (abs($response['amount'] - $transaction->getValue()) > 0.01) {
             // Total wrong
             $errorDescription = 'Total amount doesn\'t match. ' . 'Transaction total: ' . $transaction->getValue() . ', ' . 'X-Payments amount: ' . $response['amount'];
         }
         if (!$transaction->getCurrency()) {
             // Adjust currency if it's not set
             $currency = $this->client->getCurrencyForPaymentMethod($transaction->getPaymentMethod());
             $transaction->setCurrency($currency);
         }
         if ($response['currency'] != $transaction->getCurrency()->getCode()) {
             // Currency wrong
             $errorDescription = 'Currence doesn\'t match. ' . 'Transaction currency: ' . $transaction->getCurrency()->getCode() . ', ' . 'X-Payments currency: ' . $response['currency'];
         }
         if ($errorDescription) {
             // Set error details, status remails Failed
             $transaction->setDataCell('error', 'Hacking attempt!', 'Error');
             $transaction->setDataCell('errorDescription', $errorDescription, 'Hacking attempt details');
         } else {
             // Set the transaction status
             $transactionStatus = $this->getTransactionStatus($response, $transaction);
         }
     }
     if ($transactionStatus) {
         $transaction->setStatus($transactionStatus);
     }
     // AntiFraud check block by AVS
     if (method_exists($transaction, 'checkAvsDataValid') && $transaction->checkAvsDataValid()) {
         $result = $transaction->getAntiFraudResult();
         if ($transaction->checkBlockAvs()) {
             $result->setDataCell('blocked_by_avs', '1');
             $result->setScore($result::MAX_SCORE);
         } else {
             $result->setDataCell('blocked_by_avs', '0');
         }
     }
     $this->transaction = $transaction;
 }
コード例 #2
0
 /**
  * {@inheritDoc}
  */
 public function getValue()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getValue', array());
     return parent::getValue();
 }
コード例 #3
0
ファイル: PaypalAPI.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Convert order to array for DoExpressCheckoutPayment
  *
  * @param \XLite\Model\Payment\Transaction $transaction Transaction
  * @param string                           $token       Token
  * @param string                           $payerId     Payer id
  *
  * @return array
  * @see    https://developer.paypal.com/docs/classic/api/merchant/DoExpressCheckoutPayment_API_Operation_NVP/
  */
 public function convertDoExpressCheckoutPaymentParams($transaction, $token, $payerId)
 {
     /** @var \XLite\Model\Order $order */
     $order = $transaction->getOrder();
     /** @var \XLite\Model\Currency $currency */
     $currency = $order->getCurrency();
     $orderTotal = $currency->roundValue($transaction->getValue());
     $shippingCost = $this->getShippingCost($order);
     /** @var \XLite\Module\CDev\Paypal\Model\Payment\Processor\ExpressCheckoutMerchantAPI $processor */
     $processor = $this->getProcessor();
     $params = array('TOKEN' => $token, 'PAYERID' => $payerId, 'PAYMENTREQUEST_0_AMT' => $orderTotal, 'PAYMENTREQUEST_0_PAYMENTACTION' => $this->getPaymentAction(), 'PAYMENTREQUEST_0_CURRENCYCODE' => $currency->getCode(), 'PAYMENTREQUEST_0_HANDLINGAMT' => 0, 'PAYMENTREQUEST_0_INSURANCEAMT' => 0, 'PAYMENTREQUEST_0_SHIPPINGAMT' => (double) $shippingCost, 'PAYMENTREQUEST_0_NOTIFYURL' => $processor->getPaymentCallbackUrl());
     $items = $this->getItems($order);
     // To avoid total mismatch clear tax and shipping cost
     $taxAmt = isset($items['PAYMENTREQUEST_0_TAXAMT']) ? $items['PAYMENTREQUEST_0_TAXAMT'] : 0;
     if (abs($orderTotal - $items['PAYMENTREQUEST_0_ITEMAMT'] - $taxAmt - $shippingCost) > 1.0E-10) {
         $correction = $orderTotal - $items['PAYMENTREQUEST_0_ITEMAMT'] - $taxAmt - $shippingCost;
         $correction = round($correction, 2);
         $index = $order->countItems() + 1;
         $items['L_PAYMENTREQUEST_0_AMT' . $index] = $correction;
         $items['L_PAYMENTREQUEST_0_NAME' . $index] = 'Correction';
         $items['L_PAYMENTREQUEST_0_QTI' . $index] = 1;
         $items['PAYMENTREQUEST_0_ITEMAMT'] += $correction;
     }
     $params += $items;
     return $params;
 }
コード例 #4
0
ファイル: XPaymentsClient.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Get recharge request via saved credit card 
  *
  * @param string                           $txnId       Transaction ID
  * @param \XLite\Model\Payment\Transaction $transaction Payment transaction
  * @param string                           $description Description OPTIONAL
  *
  * @return array
  */
 public function requestPaymentRecharge($txnId, \XLite\Model\Payment\Transaction $transaction, $description = null)
 {
     $xpcBackReference = $transaction->getPublicId();
     // Save back refernece to transaction from  X-Payments
     $transaction->setDataCell('xpcBackReference', $xpcBackReference, 'X-Payments back reference', 'C');
     \XLite\Core\Database::getEM()->flush();
     return $this->apiRequest->send('payment', 'recharge', array('callbackUrl' => self::getCallbackUrl($xpcBackReference), 'txnId' => $txnId, 'amount' => $transaction->getValue(), 'description' => !isset($description) ? 'New payment for transaction #' . $txnId : $description, 'refId' => $xpcBackReference));
 }
コード例 #5
0
ファイル: PayflowAPI.php プロジェクト: kirkbauer2/kirkxc
 /**
  * Convert order to array for DoExpressCheckoutPayment
  *
  * @param \XLite\Model\Payment\Transaction $transaction Transaction
  * @param string                           $token       Token
  * @param string                           $payerId     Payer id
  *
  * @return array
  * @see    https://www.paypalobjects.com/webstatic/en_US/developer/docs/pdf/pfp_expresscheckout_pp.pdf
  */
 public function convertDoExpressCheckoutPaymentParams($transaction, $token, $payerId)
 {
     /** @var \XLite\Model\Order $order */
     $order = $transaction->getOrder();
     /** @var \XLite\Model\Currency $currency */
     $currency = $order->getCurrency();
     $orderTotal = $currency->roundValue($transaction->getValue());
     $shippingCost = $this->getShippingCost($order);
     /** @var \XLite\Module\CDev\Paypal\Model\Payment\Processor\ExpressCheckoutMerchantAPI $processor */
     $processor = $this->getProcessor();
     $params = array('TRXTYPE' => $this->getPaymentAction(), 'TENDER' => 'P', 'ACTION' => 'D', 'TOKEN' => $token, 'PAYERID' => $payerId, 'AMT' => $orderTotal, 'CURRENCY' => $currency->getCode(), 'FREIGHTAMT' => (double) $shippingCost, 'HANDLINGAMT' => 0, 'INSURANCEAMT' => 0, 'NOTIFYURL' => $processor->getPaymentCallbackUrl(), 'ALLOWNOTE' => 1);
     $items = $this->getItems($order);
     // To avoid total mismatch clear tax and shipping cost
     $taxAmt = isset($items['TAXAMT']) ? $items['TAXAMT'] : 0;
     if (abs($orderTotal - $items['ITEMAMT'] - $taxAmt - $shippingCost) > 1.0E-10) {
         $items['ITEMAMT'] = $orderTotal;
         $items['TAXAMT'] = 0;
         $params['FREIGHTAMT'] = 0;
     }
     $params += $items;
     return $params;
 }