コード例 #1
0
ファイル: Card.php プロジェクト: LybeAB/magento-module
 /**
  * Capture (confirm) an open transaction ('AUTHORIZED') at svea. We use the
  * ConfirmTransaction class directly because the operation is simple.
  *
  * @param Varien_Object $payment
  * @param float $amount
  * @return $this|void
  * @throws Mage_Payment_Exception
  */
 public function capture(Varien_Object $payment, $amount)
 {
     $sveaOrderId = $payment->getParentTransactionId();
     if (null === $sveaOrderId) {
         // If there is no previous authorization
         $sveaOrderId = $payment->getTransactionId();
     }
     $order = $payment->getOrder();
     $paymentMethodConfig = $this->getSveaStoreConfClass($order->getStoreId());
     $config = new SveaMageConfigProvider($paymentMethodConfig);
     $countryId = $order->getBillingAddress()->getCountryId();
     $confirmTransactionRequest = new Svea\HostedService\ConfirmTransaction($config);
     $confirmTransactionRequest->countryCode = $countryId;
     $confirmTransactionRequest->transactionId = $sveaOrderId;
     $defaultCaptureDate = explode('T', date('c'));
     // [0] contains date part
     $confirmTransactionRequest->captureDate = $defaultCaptureDate[0];
     $response = $confirmTransactionRequest->doRequest();
     if ($response->accepted !== 1) {
         $message = 'Capture failed for transaction ' . $sveaOrderId . ': ' . $response->errormessage . ' (' . $response->resultcode . ')';
         throw new Mage_Payment_Exception($message);
     }
     $result = $this->_flatten($response);
     $payment->setIsTransactionClosed(true)->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
     return $this;
 }
コード例 #2
0
ファイル: Neft.php プロジェクト: mSupply/runnable_test_repo
 public function assignData($data)
 {
     if (!$data instanceof Varien_Object) {
         $data = new Varien_Object($data);
     }
     $info = $this->getInfoInstance();
     $info->setTransactionId($data->getTransactionId());
     return $this;
 }
コード例 #3
0
ファイル: Authorizenet.php プロジェクト: CE-Webmaster/CE-Hub
 /**
  * It sets card`s data into additional information of payment model
  * AuthorizeNet has added additional_information field in sale_flat_order_payment table
  * where they savve credit card info, and disallow to save the card in other fields,
  * This method is temprory and we need to fetch the card info from additional_information
  * field.
  * @param Mage_Paygate_Model_Authorizenet_Result $response
  * @param Mage_Sales_Model_Order_Payment $payment
  * @return Varien_Object
  */
 protected function _registerCard(Varien_Object $response, Mage_Sales_Model_Order_Payment $payment)
 {
     //$isAuth = Mage::getStoreConfig('editorder/general/reauth');
     //if(isset($isAuth) && $isAuth == 1) {
     $cardsStorage = $this->getCardsStorage($payment);
     $card = $cardsStorage->registerCard();
     $card->setRequestedAmount($response->getRequestedAmount())->setBalanceOnCard($response->getBalanceOnCard())->setLastTransId($response->getTransactionId())->setProcessedAmount($response->getAmount())->setCcType($payment->getCcType())->setCcOwner($payment->getCcOwner())->setCcLast4($payment->getCcLast4())->setCcExpMonth($payment->getCcExpMonth())->setCcExpYear($payment->getCcExpYear())->setCcSsIssue($payment->getCcSsIssue())->setCcSsStartMonth($payment->getCcSsStartMonth())->setCcSsStartYear($payment->getCcSsStartYear());
     $cardsStorage->updateCard($card);
     //below is the only reason to override this method,
     //$this->_clearAssignedData($payment);
     return $card;
     //}
 }
コード例 #4
0
 /**
  * Make prepaid credit card payloads for any payments
  * remaining in the list
  * @param Mage_Sales_Model_Order $order
  * @param IPaymentContainer      $paymentContainer
  * @param SplObjectStorage       $processedPayments
  */
 public function addPaymentsToPayload(Mage_Sales_Model_Order $order, IPaymentContainer $paymentContainer, SplObjectStorage $processedPayments)
 {
     foreach ($order->getAllPayments() as $payment) {
         if ($this->_shouldIgnorePayment($payment, $processedPayments)) {
             continue;
         }
         $iterable = $paymentContainer->getPayments();
         $payload = $iterable->getEmptyCreditCardPayment();
         $additionalInfo = new Varien_Object($payment->getAdditionalInformation());
         $payload->setOrderId($order->getIncrementId())->setTenderType($additionalInfo->getTenderType())->setAccountUniqueId($this->_getAccountUniqueId($payment))->setPanIsToken($additionalInfo->getPanIsToken())->setPaymentRequestId($additionalInfo->getRequestId())->setCreateTimestamp($this->_getAsDateTime($payment->getCreatedAt()))->setAmount($payment->getAmountAuthorized())->setBankAuthorizationCode($additionalInfo->getBankAuthorizationCode())->setResponseCode($additionalInfo->getResponseCode())->setCVV2ResponseCode($additionalInfo->getCvv2ResponseCode())->setAVSResponseCode($additionalInfo->getAvsResponseCode())->setPhoneResponseCode($additionalInfo->getPhoneResponseCode())->setNameResponseCode($additionalInfo->getNameResponseCode())->setEmailResponseCode($additionalInfo->getEmailResponseCode())->setAmountAuthorized($additionalInfo->getAmountAuthorized())->setExpirationDate($this->_getExpirationDateTime($payment))->setExtendedAuthDescription($additionalInfo->getExtendedAuthDescription())->setExtendedAuthReasonCode($additionalInfo->getExtendedAuthReasonCode())->setIssueNumber($additionalInfo->getIssueNumber())->setAuthenticationAvailable($additionalInfo->getAuthenticationAvailable())->setAuthenticationStatus($additionalInfo->getAuthenticationStatus())->setCavvUcaf($additionalInfo->getCavvUcaf())->setTransactionId($additionalInfo->getTransactionId())->setECI($additionalInfo->getECI())->setPayerAuthenticationResponse($additionalInfo->getPayerAuthenticationResponse())->setPurchasePlanCode($additionalInfo->getPurchasePlanCode())->setPurchasePlanDescription($additionalInfo->getPurchasePlanDescription());
         if ($additionalInfo->getStartDate()) {
             // prevent death by type error if getStartDate returns null
             $payload->setStartDate($this->_getAsDateTime($additionalInfo->getStartDate()));
         }
         // add the new payload
         $iterable->OffsetSet($payload, $payload);
         // put the payment in the processed payments set
         $processedPayments->attach($payment);
     }
 }
コード例 #5
0
ファイル: Invoice.php プロジェクト: LybeAB/magento-module
 /**
  * For Svea, Deliver order
  *
  * @param Varien_Object $payment
  * @param type $amount
  * @return type
  */
 public function capture(Varien_Object $payment, $amount)
 {
     // Check if we are trying to deliver an existing order, or this is an autodeliver
     // If no flag e.g. -capture, or if no transactionid, assume this is not sent from admin
     //TODO: Make sure compatible with onestep checkout
     $sveaOrderId = $payment->getTransactionId();
     if (empty($sveaOrderId) || preg_match('/[A-Za-z]/', $sveaOrderId) == FALSE) {
         if (!$this->getConfigData('autodeliver')) {
             $errorTranslated = Mage::helper('svea_webpay')->responseCodes("", 'no_orderid');
             Mage::throwException($errorTranslated);
         }
         $sveaOrderId = $this->getInfoInstance()->getAdditionalInformation('svea_order_id');
     }
     $order = $payment->getOrder();
     $paymentMethodConfig = $this->getSveaStoreConfClass($order->getStoreId());
     $invoice = $this->getCurrentInvoice();
     Mage::helper('svea_webpay')->getDeliverInvoiceRequest($invoice, $paymentMethodConfig, $sveaOrderId);
     $sveaObject = $invoice->getData('svea_deliver_request');
     $response = $sveaObject->deliverInvoiceOrder()->doRequest();
     if ($response->accepted == 1) {
         $successMessage = Mage::helper('svea_webpay')->__('delivered');
         $orderStatus = $this->getConfigData('paid_order_status') ?: $order->getStatus();
         if (!empty($orderStatus)) {
             $order->addStatusToHistory($orderStatus, $successMessage, false);
         }
         $rawDetails = $this->_sveaResponseToArray($response);
         $payment->setTransactionId($response->invoiceId)->setIsTransactionClosed(false)->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $rawDetails);
     } else {
         $errorMessage = $response->errormessage;
         $statusCode = $response->resultcode;
         $errorTranslated = Mage::helper('svea_webpay')->responseCodes($statusCode, $errorMessage);
         if ($order->canCancel()) {
             $order->addStatusToHistory($order->getStatus(), $errorTranslated, false);
             $order->cancel();
             $order->save();
         }
         return Mage::throwException($errorTranslated);
     }
     return $this;
 }
コード例 #6
0
 /**
  * Capture payment
  *
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param float $amount
  * @return Mage_Paypal_Model_Express
  */
 public function capture(Varien_Object $payment, $amount)
 {
     $authorizationTransaction = $payment->getAuthorizationTransaction();
     $authorizationPeriod = abs(intval($this->getConfigData('authorization_honor_period')));
     $maxAuthorizationNumber = abs(intval($this->getConfigData('child_authorization_number')));
     $order = $payment->getOrder();
     $isAuthorizationCreated = false;
     if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)) {
         $voided = false;
         if (!$authorizationTransaction->getIsClosed() && $this->_isTransactionExpired($authorizationTransaction, $authorizationPeriod)) {
             //Save payment state and configure payment object for voiding
             $isCaptureFinal = $payment->getShouldCloseParentTransaction();
             $captureTrxId = $payment->getTransactionId();
             $payment->setShouldCloseParentTransaction(false);
             $payment->setParentTransactionId($authorizationTransaction->getTxnId());
             $payment->unsTransactionId();
             $payment->setVoidOnlyAuthorization(true);
             $payment->void(new Varien_Object());
             //Revert payment state after voiding
             $payment->unsAuthorizationTransaction();
             $payment->unsTransactionId();
             $payment->setShouldCloseParentTransaction($isCaptureFinal);
             $voided = true;
         }
         if ($authorizationTransaction->getIsClosed() || $voided) {
             if ($payment->getAdditionalInformation($this->_authorizationCountKey) > $maxAuthorizationNumber - 1) {
                 Mage::throwException(Mage::helper('paypal')->__('The maximum number of child authorizations is reached.'));
             }
             $api = $this->_callDoAuthorize($amount, $payment, $authorizationTransaction->getParentTxnId());
             //Adding authorization transaction
             $this->_pro->importPaymentInfo($api, $payment);
             $payment->setTransactionId($api->getTransactionId());
             $payment->setParentTransactionId($authorizationTransaction->getParentTxnId());
             $payment->setIsTransactionClosed(false);
             $formatedPrice = $order->getBaseCurrency()->formatTxt($amount);
             if ($payment->getIsTransactionPending()) {
                 $message = Mage::helper('paypal')->__('Authorizing amount of %s is pending approval on gateway.', $formatedPrice);
             } else {
                 $message = Mage::helper('paypal')->__('Authorized amount of %s.', $formatedPrice);
             }
             $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null, true, $message);
             $payment->setParentTransactionId($api->getTransactionId());
             $isAuthorizationCreated = true;
         }
         //close order transaction if needed
         if ($payment->getShouldCloseParentTransaction()) {
             $orderTransaction = $payment->lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER);
             if ($orderTransaction) {
                 $orderTransaction->setIsClosed(true);
                 $order->addRelatedObject($orderTransaction);
             }
         }
     }
     if (false === $this->_pro->capture($payment, $amount)) {
         $this->_placeOrder($payment, $amount);
     }
     if ($isAuthorizationCreated && isset($transaction)) {
         $transaction->setIsClosed(true);
     }
     return $this;
 }
コード例 #7
0
 /**
  * It sets card`s data into additional information of payment model
  *
  * @param Mage_Paygate_Model_Authorizenet_Result $response
  * @param Mage_Sales_Model_Order_Payment $payment
  * @return Varien_Object
  */
 protected function _registerCard(Varien_Object $response, Mage_Sales_Model_Order_Payment $payment)
 {
     $cardsStorage = $this->getCardsStorage($payment);
     $card = $cardsStorage->registerCard();
     $card->setRequestedAmount($response->getRequestedAmount())->setBalanceOnCard($response->getBalanceOnCard())->setLastTransId($response->getTransactionId())->setProcessedAmount($response->getAmount())->setCcType($payment->getCcType())->setCcOwner($payment->getCcOwner())->setCcLast4($payment->getCcLast4())->setCcExpMonth($payment->getCcExpMonth())->setCcExpYear($payment->getCcExpYear())->setCcSsIssue($payment->getCcSsIssue())->setCcSsStartMonth($payment->getCcSsStartMonth())->setCcSsStartYear($payment->getCcSsStartYear());
     $cardsStorage->updateCard($card);
     $this->_clearAssignedData($payment);
     return $card;
 }
コード例 #8
0
ファイル: Pro.php プロジェクト: hyhoocchan/mage-local
 /**
  * Refund a capture transaction
  *
  * @param Varien_Object $payment
  * @param float $amount
  */
 public function refund(Varien_Object $payment, $amount)
 {
     $result = $this->getPbridgeMethodInstance()->refund($payment, $amount);
     if ($result) {
         $result = new Varien_Object($result);
         $result->setRefundTransactionId($result->getTransactionId());
         $canRefundMore = $payment->getOrder()->canCreditmemo();
         $this->_importRefundResultToPayment($result, $payment, $canRefundMore);
     }
     return $result;
 }
コード例 #9
0
 /**
  * Authorize, with option to Capture
  */
 protected function _authorize(Varien_Object $payment, $amount, $captureNow = false)
 {
     $order = $payment->getOrder();
     $sellerAuthorizationNote = null;
     // Sandbox simulation testing for Stand Alone Checkout
     if ($payment->getAdditionalInformation('sandbox') && $this->_getApi()->getConfig()->isSandbox()) {
         $sellerAuthorizationNote = $payment->getAdditionalInformation('sandbox');
     }
     // For core and third-party checkouts, may test credit card decline by uncommenting:
     //$sellerAuthorizationNote = '{"SandboxSimulation": {"State":"Declined", "ReasonCode":"InvalidPaymentMethod", "PaymentMethodUpdateTimeInMins":5}}';
     $result = $this->_getApi()->authorize($payment->getTransactionId(), $this->_getMagentoReferenceId($payment) . '-auth', $amount, $order->getBaseCurrencyCode(), $captureNow, $captureNow ? $this->_getSoftDescriptor() : null, $sellerAuthorizationNote);
     $status = $result->getAuthorizationStatus();
     switch ($status->getState()) {
         case Amazon_Payments_Model_Api::AUTH_STATUS_PENDING:
         case Amazon_Payments_Model_Api::AUTH_STATUS_OPEN:
         case Amazon_Payments_Model_Api::AUTH_STATUS_CLOSED:
             $payment->setTransactionId($result->getAmazonAuthorizationId());
             $payment->setParentTransactionId($payment->getAdditionalInformation('order_reference'));
             $payment->setIsTransactionClosed(false);
             // Add transaction
             if ($captureNow) {
                 if (!$this->getConfigData('is_async')) {
                     $transactionSave = Mage::getModel('core/resource_transaction');
                     $captureReferenceIds = $result->getIdList()->getmember();
                     if ($order->canInvoice()) {
                         // Create invoice
                         $invoice = $order->prepareInvoice()->register();
                         $invoice->setTransactionId(current($captureReferenceIds));
                         $transactionSave->addObject($invoice)->addObject($invoice->getOrder());
                     }
                     $transactionSave->save();
                 }
                 $transactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE;
                 $message = Mage::helper('payment')->__('Authorize and capture request for %s sent to Amazon Payments.', $order->getStore()->convertPrice($amount, true, false));
             } else {
                 $transactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH;
                 $message = Mage::helper('payment')->__('Authorize request for %s sent to Amazon Payments.', $order->getStore()->convertPrice($amount, true, false));
             }
             $payment->addTransaction($transactionType, null, false, $message);
             break;
         case Amazon_Payments_Model_Api::AUTH_STATUS_DECLINED:
             // Cancel order reference
             if ($status->getReasonCode() == 'TransactionTimedOut') {
                 $this->_getApi()->cancelOrderReference($payment->getTransactionId());
             }
             $this->_setErrorCheck();
             Mage::throwException("Amazon could not process your order.\n\n" . $status->getReasonCode() . " (" . $status->getState() . ")\n" . $status->getReasonDescription());
             break;
         default:
             $this->_setErrorCheck();
             Mage::throwException('Amazon could not process your order.');
             break;
     }
 }
コード例 #10
0
ファイル: Pro.php プロジェクト: HelioFreitas/magento-pt_br
 /**
  * Prepare base request
  *
  * @access public
  * @return object which was set with all basic required information
  */
 protected function _buildBasicRequest(Varien_Object $payment)
 {
     if (!$payment->getTender()) {
         $payment->setTender(self::TENDER_CC);
     }
     $request = Mage::getModel('paygate/payflow_pro_request')->setUser($this->getConfigData('user'))->setVendor($this->getConfigData('vendor'))->setPartner($this->getConfigData('partner'))->setPwd($this->getConfigData('pwd'))->setTender($payment->getTender())->setTrxtype($payment->getTrxtype())->setVerbosity($this->getConfigData('verbosity'))->setRequestId($this->_generateRequestId())->setOrigid($payment->getTransactionId());
     return $request;
 }
コード例 #11
0
 /**
  * Authorize, with option to Capture
  */
 protected function _authorize(Varien_Object $payment, $amount, $captureNow = false)
 {
     $order = $payment->getOrder();
     $sellerAuthorizationNote = null;
     // Sandbox simulation testing for Stand Alone Checkout
     if ($payment->getAdditionalInformation('sandbox') && $this->_getApi($order->getStoreId())->getConfig()->isSandbox()) {
         $sellerAuthorizationNote = $payment->getAdditionalInformation('sandbox');
         // Allow async decline testing
         if ($this->getConfigData('is_async') && strpos($sellerAuthorizationNote, 'InvalidPaymentMethod') !== false) {
             $this->isForceSync = false;
         }
     }
     // For core and third-party checkouts, may test credit card decline by uncommenting:
     //$sellerAuthorizationNote = '{"SandboxSimulation": {"State":"Declined", "ReasonCode":"InvalidPaymentMethod", "PaymentMethodUpdateTimeInMins":5}}';
     $result = $this->_getApi($order->getStoreId())->authorize($payment->getTransactionId(), $this->_getMagentoReferenceId($payment) . '-auth', $amount, $order->getBaseCurrencyCode(), $captureNow, $captureNow ? $this->_getSoftDescriptor() : null, $sellerAuthorizationNote, $this->isForceSync);
     $status = $result->getAuthorizationStatus();
     switch ($status->getState()) {
         case Amazon_Payments_Model_Api::AUTH_STATUS_PENDING:
         case Amazon_Payments_Model_Api::AUTH_STATUS_OPEN:
         case Amazon_Payments_Model_Api::AUTH_STATUS_CLOSED:
             $payment->setTransactionId($result->getAmazonAuthorizationId());
             $payment->setParentTransactionId($payment->getAdditionalInformation('order_reference'));
             $payment->setIsTransactionClosed(false);
             // Add transaction
             if ($captureNow) {
                 if ($this->isForceSync) {
                     // Not async
                     $transactionSave = Mage::getModel('core/resource_transaction');
                     $captureReferenceIds = $result->getIdList()->getmember();
                     if ($order->canInvoice()) {
                         // Create invoice
                         $invoice = $order->prepareInvoice()->register();
                         $invoice->setTransactionId(current($captureReferenceIds));
                         $transactionSave->addObject($invoice)->addObject($invoice->getOrder());
                     }
                     $transactionSave->save();
                 }
                 $transactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE;
                 $message = Mage::helper('payment')->__('Authorize and capture request for %s sent to Amazon Payments.', $order->getStore()->convertPrice($amount, true, false));
             } else {
                 $transactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH;
                 $message = Mage::helper('payment')->__('Authorize request for %s sent to Amazon Payments.', $order->getStore()->convertPrice($amount, true, false));
             }
             $payment->addTransaction($transactionType, null, false, $message);
             break;
         case Amazon_Payments_Model_Api::AUTH_STATUS_DECLINED:
             if ($status->getReasonCode() == 'TransactionTimedOut') {
                 // Preform async if TTO
                 if ($this->isForceSync && $this->getConfigData('is_async')) {
                     // Remove sandbox simulation test
                     if (strpos($sellerAuthorizationNote, 'TransactionTimedOut') !== false) {
                         $payment->setAdditionalInformation('sandbox', null);
                     }
                     $this->isForceSync = false;
                     $order->addStatusHistoryComment('Error: TransactionTimedOut, performing asynchronous authorization.');
                     $order->save();
                     $this->_authorize($payment, $amount, $captureNow);
                     return;
                 } else {
                     $this->_getApi($order->getStoreId())->cancelOrderReference($payment->getTransactionId());
                 }
             }
             $this->_setErrorCheck();
             // specific error handling for InvalidPaymentMethod decline scenario
             if ($status->getReasonCode() == 'InvalidPaymentMethod') {
                 Mage::throwException("There was a problem with your payment. Please select another payment method from the Amazon Wallet and try again.");
                 break;
             }
             // all other declines - AmazonRejected && ProcessingFailure && TransactionTimedOut (when async is off)
             Mage::throwException("Amazon could not process your order. Please try again. If this continues, please select a different payment option.\n\n" . $status->getReasonCode() . " (" . $status->getState() . ")\n" . $status->getReasonDescription());
             break;
         default:
             $this->_setErrorCheck();
             Mage::throwException('Amazon could not process your order.');
             break;
     }
 }
コード例 #12
0
 /**
  * Import direct payment results to payment
  *
  * @param Varien_Object $api
  * @param Mage_Sales_Model_Order_Payment $payment
  */
 protected function _importResultToPayment($api, $payment)
 {
     $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0)->setIsTransactionPending($api->getIsPaymentPending());
     $payflowTrxid = $api->getData(Enterprise_Pbridge_Model_Payment_Method_Paypaluk_Pro::TRANSPORT_PAYFLOW_TXN_ID);
     $payment->setPreparedMessage(Mage::helper('enterprise_pbridge')->__('Payflow PNREF: #%s.', $payflowTrxid));
     $this->_pro->importPaymentInfo($api, $payment);
 }
コード例 #13
0
 /**
  * Add transaction with correct transaction Id
  *
  * @param Varien_Object $payment
  * @param string $txnId
  * @return void
  */
 protected function _addTransaction($payment, $txnId)
 {
     $previousTxnId = $payment->getTransactionId();
     $payment->setTransactionId($txnId);
     $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
     $payment->setTransactionId($previousTxnId);
 }
コード例 #14
0
ファイル: Method.php プロジェクト: billadams/forever-frame
 /**
  * Catch execution after capturing to reauthorize (if incomplete partial capture).
  */
 protected function _afterCapture(Varien_Object $payment, $amount, Varien_Object $response)
 {
     $outstanding = round($payment->getOrder()->getBaseTotalDue() - $amount, 4);
     /**
      * If this is a pre-auth capture for less than the total value of the order,
      * try to reauthorize any remaining balance. So we have it.
      */
     if ($this->gateway()->getHaveAuthorized() && $this->getConfigData('advanced/require_ccv') !== true && $outstanding > 0) {
         try {
             $this->_log(sprintf('_afterCapture(): Reauthorizing for %s', $outstanding));
             $shippingId = $this->gateway()->getParameter('customerShippingAddressId');
             $this->gateway()->clearParameters();
             $this->gateway()->setCard($this->gateway()->getCard());
             $this->gateway()->setParameter('customerShippingAddressId', $shippingId);
             $this->gateway()->setIsReauthorize(true);
             $authResponse = $this->gateway()->authorize($payment, $outstanding);
             $payment->getOrder()->setExtOrderId(sprintf('%s:%s', $authResponse->getTransactionId(), $authResponse->getAuthCode()));
         } catch (Exception $e) {
             $payment->getOrder()->setExtOrderId(sprintf('%s:', $response->getTransactionId()));
         }
     } else {
         $payment->getOrder()->setExtOrderId(sprintf('%s:', $response->getTransactionId()));
     }
     return parent::_afterCapture($payment, $amount, $response);
 }
コード例 #15
0
 /**
  * Process authenticate validation
  *
  * @param Varien_Object $data
  */
 public function authenticate($data)
 {
     $validationState = $this->_getValidationState();
     if (!$validationState || $data->getTransactionId() != $validationState->getLookupTransactionId()) {
         throw new Exception('Authentication impossible: transaction id or validation state is wrong.');
     }
     $api = $this->_getApi();
     $result = $api->callAuthentication($data);
     $validationState->setAuthenticateResult($result);
     if (!$validationState->isAuthenticateSuccessful()) {
         $this->reset();
     }
 }
コード例 #16
0
ファイル: WithGUI.php プロジェクト: nilshopsahl/hasla.local
 public function capture(Varien_Object $payment, $amount)
 {
     $error = false;
     if (in_array($payment->getAdditionalInformation(self::PAYMENTMETHOD), $this->_directPaymentMethods)) {
         // Do not run financial transactions on directpayment.
         return $this;
     }
     $bbs_amount = sprintf("%0.0f", $amount * 100);
     $order = $payment->getOrder();
     if ($payment->getAdditionalInformation(self::IS_GIFTCARD)) {
         // Special checks for giftcards.
         $invoiced = sprintf("%0.0f", $order->getBaseTotalInvoiced() * 100);
         $giftcardAmount = $payment->getAdditionalInformation(self::GIFTCARD_AMOUNT);
         if ($invoiced <= $giftcardAmount) {
             // The whole giftcard amount is not invoiced
             if ($bbs_amount <= $giftcardAmount - $invoiced) {
                 // The amount that is invoiced is exactly the same
                 // or less than the remaining giftcard amount
                 // Don't do any capture to Nets. Just approve the amount.
                 $payment->setTransactionId($payment->getTransactionId() . '-giftcard');
                 return $this;
             } else {
                 // Substract the giftcard amount from
                 // the amount that is going to be captured.
                 $bbs_amount = $bbs_amount - ($giftcardAmount - $invoiced);
             }
         }
     }
     if (!$payment->getAdditionalInformation(self::TRANSACTION_ID)) {
         if (!$payment->getBbsTransactionId()) {
             Mage::throwException(Mage::helper('bbsnetaxept')->__('Could not find transaction id.'));
         } else {
             $bbsTransId = $payment->getBbsTransactionId();
             // Make it compatible with old fashion BBSNetterminal.
         }
     } else {
         $bbsTransId = $payment->getAdditionalInformation(self::TRANSACTION_ID);
     }
     $this->_useMobile = $payment->getAdditionalInformation(self::MOBILE_CLIENT) === true;
     $InvoiceId = $order->getIncrementId() ? $order->getIncrementId() : 'Unknown';
     $this->getApi()->doLog('Sending request to capture ' . $bbs_amount . ' on ' . $invoiceId);
     if ($this->getApi()->capture($bbsTransId, $bbs_amount, $InvoiceId) === true) {
         $payment->setStatus(Mage_Payment_Model_Method_Abstract::STATUS_APPROVED);
         $inc = (int) $order->hasInvoices();
         $transId = $this->getApi()->Result()->getTransactionId();
         $payment->setTransactionId($transId . '-' . $inc);
     } else {
         $error = Mage::helper('bbsnetaxept')->__('Error capturing the payment: %s', $this->getApi()->getErrorMessage());
     }
     if ($error !== false) {
         Mage::throwException($error);
     }
     return $this;
 }
コード例 #17
0
ファイル: Abstract.php プロジェクト: LybeAB/magento-module
 /**
  * Svea Close Order
  *
  * @param Varien_Object $payment
  * @return type
  */
 public function void(Varien_Object $payment)
 {
     $order = $payment->getOrder();
     $auth = $this->getSveaStoreConfClass($order->getStoreId());
     $conf = new SveaMageConfigProvider($auth);
     $sveaObject = WebPay::closeOrder($conf);
     $sveaObject->setOrderId($payment->getTransactionId())->setCountryCode("");
     $response = $this->_closeOrder($sveaObject);
     if ($response->accepted == 1) {
         return parent::void($payment);
     } else {
         $errorMessage = $response->errormessage;
         $statusCode = $response->resultcode;
         $errorTranslated = Mage::helper('svea_webpay')->responseCodes($statusCode, $errorMessage);
         Mage::throwException($errorTranslated);
     }
 }
コード例 #18
0
ファイル: Gateway.php プロジェクト: billadams/forever-frame
 /**
  * Turn transaction results and directResponse into a usable object.
  */
 protected function _interpretTransaction($transactionResult)
 {
     /**
      * Turn the direct response string into an array, as best we can.
      */
     $directResponse = isset($transactionResult['directResponse']) ? $transactionResult['directResponse'] : '';
     if (strlen($directResponse) > 1) {
         // Strip out quotes, we don't want any.
         $directResponse = str_replace('"', '', $directResponse);
         // Use the second character as the delimiter. The first will always be the one-digit response code.
         $directResponse = explode(substr($directResponse, 1, 1), $directResponse);
     }
     if (empty($directResponse) || count($directResponse) == 0) {
         Mage::throwException(Mage::helper('tokenbase')->__('Authorize.Net CIM Gateway: Transaction failed; no direct response.'));
     }
     /**
      * Turn the array into a keyed object and infer some things.
      */
     $data = array('response_code' => (int) $directResponse[0], 'response_subcode' => (int) $directResponse[1], 'response_reason_code' => (int) $directResponse[2], 'response_reason_text' => $directResponse[3], 'approval_code' => $directResponse[4], 'auth_code' => $directResponse[4], 'avs_result_code' => $directResponse[5], 'transaction_id' => $directResponse[6], 'invoice_number' => $directResponse[7], 'description' => $directResponse[8], 'amount' => $directResponse[9], 'method' => $directResponse[10], 'transaction_type' => $directResponse[11], 'customer_id' => $directResponse[12], 'md5_hash' => $directResponse[37], 'card_code_response_code' => $directResponse[38], 'cavv_response_code' => $directResponse[39], 'acc_number' => $directResponse[50], 'card_type' => $directResponse[51], 'split_tender_id' => $directResponse[52], 'requested_amount' => $directResponse[53], 'balance_on_card' => $directResponse[54], 'profile_id' => $this->getParameter('customerProfileId'), 'payment_id' => $this->getParameter('customerPaymentProfileId'), 'is_fraud' => false, 'is_error' => false);
     $response = new Varien_Object();
     $response->setData($data);
     if ($response->getResponseCode() == 4) {
         $response->setIsFraud(true);
     }
     if (!in_array($response->getResponseReasonCode(), array(16, 54))) {
         // Response 54 is 'can't refund; txn has not settled.' 16 is 'cannot find txn' (expired). We deal with them.
         if ($transactionResult['messages']['resultCode'] != 'Ok' || in_array($response->getResponseCode(), array(2, 3)) || !in_array($response->getTransactionType(), array('credit', 'void')) && ($response->getTransactionId() == '' || $response->getAuthCode() == '')) {
             $response->setIsError(true);
             Mage::helper('tokenbase')->log($this->_code, sprintf("Transaction error: %s\n%s\n%s", $response->getResponseReasonText(), json_encode($response->getData()), $this->_log));
             Mage::throwException(Mage::helper('tokenbase')->__('Authorize.Net CIM Gateway: Transaction failed. ' . $response->getResponseReasonText()));
         }
     }
     return $response;
 }