Ejemplo n.º 1
0
 public function testGetInstructionsSetInformation()
 {
     $this->assertNull($this->_instructions->getInstructions());
     $testInstruction = 'second test';
     $this->_info->setAdditionalInformation('instructions', $testInstruction);
     $this->assertEquals($testInstruction, $this->_instructions->getInstructions());
 }
 public function testGetTokenInfo()
 {
     $payment = new Varien_Object();
     $payment->setCcCid('789');
     $vaultCard = new Varien_Object();
     $vaultCard->setCcType('VI');
     $vaultCard->setLast4('1234');
     $vaultCard->setType('VI');
     $vaultCard->setExpirationMonth('12');
     $vaultCard->setExpirationYear('2050');
     $vaultCard->setToken('1111222233331234');
     $litle = new Litle_CreditCard_Model_PaymentLogic();
     $modelPalorusVault = $this->getMock('Litle_Palorus_Model_Vault');
     $modelPalorusVault->expects($this->any())->method('load')->with($this->equalTo(50))->will($this->returnValue($vaultCard));
     $litle->setModelPalorusVault($modelPalorusVault);
     $info = new Mage_Payment_Model_Info();
     $info->setAdditionalInformation('cc_vaulted', 50);
     $arr = array('info_instance' => $info);
     $litle->addData($arr);
     $tokenInfo = $litle->getTokenInfo($payment);
     $this->assertEquals('1234', $payment->getCcLast4());
     $this->assertEquals('VI', $payment->getCcType());
     $this->assertEquals('789', $tokenInfo['cardValidationNum']);
     $this->assertEquals('VI', $tokenInfo['type']);
     $this->assertEquals('1111222233331234', $tokenInfo['litleToken']);
     $this->assertEquals('1250', $tokenInfo['expDate']);
 }
 /**
  * Get the encrypted card number or the ROM PAN
  * @param  Mage_Payment_Model_Info $payment
  * @return string
  */
 protected function _getAccountUniqueId(Mage_Payment_Model_Info $payment)
 {
     $encCardNumber = $payment->getCcNumberEnc();
     if ($encCardNumber) {
         return $payment->decrypt($encCardNumber);
     }
     return $payment->getAdditionalInformation('pan');
 }
Ejemplo n.º 4
0
 public function testGetInfoBlock()
 {
     $block = new Mage_Payment_Helper_Data();
     $paymentInfo = new Mage_Payment_Model_Info();
     $paymentInfo->setMethod('checkmo');
     $result = $block->getInfoBlock($paymentInfo);
     $this->assertInstanceOf('Mage_Payment_Block_Info_Checkmo', $result);
 }
 /**
  * verify
  * - non ebayenterprise_creditcard payment will not be made into a payload
  */
 public function testAddPaymentsToPayloadNonCreditCardPayment()
 {
     $processedPayments = new SplObjectStorage();
     $this->_paymentStub->setMethod('non-ebayenterprise_creditcard');
     $this->_payloadStub->expects($this->never())->method('setOrderId');
     $handler = Mage::getModel('ebayenterprise_creditcard/order_create_payment');
     $handler->addPaymentsToPayload($this->_orderStub, $this->_paymentContainer, $processedPayments);
 }
Ejemplo n.º 6
0
 /**
  *
  * @param Mage_Payment_Model_Info $payment
  * @return bool
  */
 public function isPaymentCancelRegistered(Mage_Payment_Model_Info $payment)
 {
     $value = $this->registry(self::KEY_PAYMENT_CANCEL . $payment->getId());
     if (empty($value) or !$value) {
         return false;
     } else {
         return true;
     }
 }
 /**
  * Send request with new payment to gateway
  *
  * @param Mage_Payment_Model_Info $payment
  * @param decimal $amount
  * @param string $requestType
  * @return Mage_Paygate_Model_Authorizenet
  * @throws Mage_Core_Exception
  */
 protected function _place($payment, $amount, $requestType)
 {
     $payment->setAnetTransType($requestType);
     $payment->setAmount($amount);
     $request = $this->_buildRequest($payment);
     $result = $this->_postRequest($request);
     switch ($requestType) {
         case self::REQUEST_TYPE_AUTH_ONLY:
             $newTransactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH;
             $defaultExceptionMessage = Mage::helper('paygate')->__('Payment authorization error.');
             break;
         case self::REQUEST_TYPE_AUTH_CAPTURE:
             $newTransactionType = Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE;
             $defaultExceptionMessage = Mage::helper('paygate')->__('Payment capturing error.');
             break;
     }
     switch ($result->getResponseCode()) {
         case self::RESPONSE_CODE_APPROVED:
             $this->getCardsStorage($payment)->flushCards();
             $card = $this->_registerCard($result, $payment);
             $this->_addTransaction($payment, $card->getLastTransId(), $newTransactionType, array('is_transaction_closed' => 0), array($this->_realTransactionIdKey => $card->getLastTransId()), Mage::helper('paygate')->getTransactionMessage($payment, $requestType, $card->getLastTransId(), $card, $amount));
             if ($requestType == self::REQUEST_TYPE_AUTH_CAPTURE) {
                 $card->setCapturedAmount($card->getProcessedAmount());
                 $this->getCardsStorage($payment)->updateCard($card);
             }
             return $this;
         case self::RESPONSE_CODE_HELD:
             if ($result->getResponseReasonCode() == self::RESPONSE_REASON_CODE_PENDING_REVIEW_AUTHORIZED || $result->getResponseReasonCode() == self::RESPONSE_REASON_CODE_PENDING_REVIEW) {
                 $card = $this->_registerCard($result, $payment);
                 $this->_addTransaction($payment, $card->getLastTransId(), $newTransactionType, array('is_transaction_closed' => 0), array($this->_realTransactionIdKey => $card->getLastTransId(), $this->_isTransactionFraud => true), Mage::helper('paygate')->getTransactionMessage($payment, $requestType, $card->getLastTransId(), $card, $amount));
                 if ($requestType == self::REQUEST_TYPE_AUTH_CAPTURE) {
                     $card->setCapturedAmount($card->getProcessedAmount());
                     $this->getCardsStorage()->updateCard($card);
                 }
                 $payment->setIsTransactionPending(true)->setIsFraudDetected(true);
                 return $this;
             }
             if ($result->getResponseReasonCode() == self::RESPONSE_REASON_CODE_PARTIAL_APPROVE) {
                 $checksum = $this->_generateChecksum($request, $this->_partialAuthorizationChecksumDataKeys);
                 $this->_getSession()->setData($this->_partialAuthorizationChecksumSessionKey, $checksum);
                 if ($this->_processPartialAuthorizationResponse($result, $payment)) {
                     return $this;
                 }
             }
             Mage::throwException($defaultExceptionMessage);
         case self::RESPONSE_CODE_DECLINED:
         case self::RESPONSE_CODE_ERROR:
             Mage::throwException($this->_wrapGatewayError($result->getResponseReasonText()));
         default:
             Mage::throwException($defaultExceptionMessage);
     }
     return $this;
 }
Ejemplo n.º 8
0
 public function testSetInfoTemplate()
 {
     $block = $this->getMock('Mage_Payment_Block_Info_ContainerAbstract', array('getChildBlock', 'getPaymentInfo'));
     $paymentInfo = new Mage_Payment_Model_Info();
     $methodInstance = new Mage_Payment_Model_Method_Checkmo();
     $paymentInfo->setMethodInstance($methodInstance);
     $block->expects($this->atLeastOnce())->method('getPaymentInfo')->will($this->returnValue($paymentInfo));
     $childBlock = new Mage_Core_Block_Template();
     $block->expects($this->atLeastOnce())->method('getChildBlock')->with('payment.info.checkmo')->will($this->returnValue($childBlock));
     $template = 'any_template.phtml';
     $this->assertNotEquals($template, $childBlock->getTemplate());
     $block->setInfoTemplate('checkmo', $template);
     $this->assertEquals($template, $childBlock->getTemplate());
 }
Ejemplo n.º 9
0
 /**
  * Assign data to info model instance
  *
  * @param Varien_Object|Array $data
  * @return TemplateTag_Stripe_Model_Payment
  */
 public function assignData($data)
 {
     if (is_array($data)) {
         $data = new Varien_Object($data);
     }
     try {
         $token = $this->getToken($data->getStripeToken());
         $data->addData(array('cc_last4' => $token->card->last4, 'cc_type' => $token->card->type, 'cc_owner' => $token->card->name));
     } catch (Exception $e) {
     }
     $data->setData('stripe_test', $this->_getHelper()->getTest());
     return parent::assignData($data);
 }
Ejemplo n.º 10
0
 /**
  * @magentoConfigFixture current_store payment/banktransfer/title Bank Method Title
  * @magentoConfigFixture current_store payment/checkmo/title Checkmo Title Of The Method
  */
 public function testGetChildPdfAsArray()
 {
     $block = new Mage_Payment_Block_Info();
     $layout = new Mage_Core_Model_Layout();
     $layout->addBlock($block, 'block');
     $paymentInfoBank = new Mage_Payment_Model_Info();
     $paymentInfoBank->setMethodInstance(new Mage_Payment_Model_Method_Banktransfer());
     $childBank = $layout->addBlock('Mage_Payment_Block_Info_Instructions', 'child.one', 'block');
     $childBank->setInfo($paymentInfoBank)->setArea('adminhtml');
     $nonExpectedHtml = 'non-expected html';
     $childHtml = $layout->addBlock('Mage_Core_Block_Text', 'child.html', 'block');
     $childHtml->setText($nonExpectedHtml);
     $paymentInfoCheckmo = new Mage_Payment_Model_Info();
     $paymentInfoCheckmo->setMethodInstance(new Mage_Payment_Model_Method_Checkmo());
     $childCheckmo = $layout->addBlock('Mage_Payment_Block_Info_Checkmo', 'child.just.another', 'block');
     $childCheckmo->setInfo($paymentInfoCheckmo)->setArea('adminhtml');
     $pdfArray = $block->getChildPdfAsArray();
     $this->assertInternalType('array', $pdfArray);
     $this->assertCount(2, $pdfArray);
     $text = implode('', $pdfArray);
     $this->assertContains('Bank Method Title', $text);
     $this->assertContains('Checkmo Title Of The Method', $text);
     $this->assertNotContains($nonExpectedHtml, $text);
 }
Ejemplo n.º 11
0
 /**
  * Format price with currency sign
  * @param  Mage_Payment_Model_Info $payment
  * @param float $amount
  * @return string
  */
 protected function _formatPrice($payment, $amount)
 {
     return $payment->getOrder()->getBaseCurrency()->formatTxt($amount);
 }
Ejemplo n.º 12
0
 public function collectPayment(\Mage_Payment_Model_Info $payment, $amount, $capture = true)
 {
     $Currency = Mage::app()->getStore()->getBaseCurrencyCode();
     require_once MAGENTO_ROOT . '/lib/Start/autoload.php';
     # At the top of your PHP file
     $token = isset($_POST['payfortToken']) ? $_POST['payfortToken'] : false;
     $email = isset($_POST['payfortEmail']) ? $_POST['payfortEmail'] : false;
     if (!$token || !$email) {
         //this block will be executed if the order was authorized earlier and now trying to capture amount
         $token_array = $payment->getAdditionalInformation('token');
         $token = $token_array['token'];
         $email = $token_array['email'];
     }
     if (!$token || !$email) {
         Mage::throwException('Invalid Token');
     }
     $currency = !isset($Currency) ? 'AED' : $Currency;
     if (file_exists(MAGENTO_ROOT . '/data/currencies.json')) {
         $currency_json_data = json_decode(file_get_contents(MAGENTO_ROOT . '/data/currencies.json'), 1);
         $currency_multiplier = $currency_json_data[$currency];
     } else {
         $currency_multiplier = 100;
     }
     $amount_in_cents = $amount * $currency_multiplier;
     $order = $payment->getOrder();
     $order_items_array_full = array();
     foreach ($order->getAllVisibleItems() as $value) {
         $order_items_array['title'] = $value->getName();
         $order_items_array['amount'] = round($value->getPrice(), 2) * $currency_multiplier;
         $order_items_array['quantity'] = $value->getQtyOrdered();
         array_push($order_items_array_full, $order_items_array);
     }
     $shipping_amount = $order->getShippingAmount();
     $shipping_amount = $shipping_amount * $currency_multiplier;
     if (Mage::getSingleton('customer/session')->isLoggedIn()) {
         $customer = Mage::getSingleton('customer/session')->getCustomer();
         $username = $customer->getName();
         $registered_at = date(DATE_ISO8601, strtotime($customer->getCreatedAt()));
     } else {
         $username = "******";
         $registered_at = date(DATE_ISO8601, strtotime(date("Y-m-d H:i:s")));
     }
     $billing_data = $order->getBillingAddress()->getData();
     if (is_object($order->getShippingAddress())) {
         $shipping_data = $order->getShippingAddress()->getData();
         $shipping_address = array("first_name" => $shipping_data['firstname'], "last_name" => $shipping_data['lastname'], "country" => $shipping_data['country_id'], "city" => $shipping_data['city'], "address" => $shipping_data['customer_address'], "phone" => $shipping_data['telephone'], "postcode" => $shipping_data['postcode']);
     } else {
         $shipping_address = array();
     }
     $billing_address = array("first_name" => $billing_data['firstname'], "last_name" => $billing_data['lastname'], "country" => $billing_data['country_id'], "city" => $billing_data['city'], "address" => $billing_data['customer_address'], "phone" => $billing_data['telephone'], "postcode" => $billing_data['postcode']);
     $shopping_cart_array = array('user_name' => $username, 'registered_at' => $registered_at, 'items' => $order_items_array_full, 'billing_address' => $billing_address, 'shipping_address' => $shipping_address);
     $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
     $charge_args = array('description' => "Magento charge for " . $email, 'card' => $token, 'currency' => $currency, 'email' => $email, 'ip' => $_SERVER['REMOTE_ADDR'], 'amount' => $amount_in_cents, 'capture' => $capture, 'shipping_amount' => $shipping_amount, 'shopping_cart' => $shopping_cart_array, 'metadata' => array('reference_id' => $orderId));
     $ver = new Mage();
     $version = $ver->getVersion();
     $userAgent = 'Magento ' . $version . ' / Start Plugin ' . self::PLUGIN_VERSION;
     Start::setUserAgent($userAgent);
     $method = $payment->getMethodInstance();
     if ($method->getConfigData('test_mode') == 1) {
         Start::setApiKey($method->getConfigData('test_secret_key'));
     } else {
         Start::setApiKey($method->getConfigData('live_secret_key'));
     }
     try {
         // Charge the token
         $charge = Start_Charge::create($charge_args);
         //need to process charge as success or failed
         $payment->setTransactionId($charge["id"]);
         if ($capture) {
             $payment->setIsTransactionClosed(1);
         } else {
             $payment->setIsTransactionClosed(0);
         }
     } catch (Start_Error $e) {
         $error_code = $e->getErrorCode();
         if ($error_code === "card_declined") {
             $errorMsg = 'Charge was declined. Please, contact you bank for more information or use a different card.';
         } else {
             $errorMsg = $e->getMessage();
         }
         throw new Mage_Payment_Model_Info_Exception($errorMsg);
     }
     //need to process charge as success or failed
 }
Ejemplo n.º 13
0
 /**
  * Remove all cards from payment instance
  *
  * @return Mage_Paygate_Model_Authorizenet_Cart
  */
 public function flushCards()
 {
     $this->_cards = array();
     $this->_payment->setAdditionalInformation(self::CARDS_NAMESPACE, null);
     return $this;
 }
Ejemplo n.º 14
0
 /**
  * Enable payment deny when __VENDOR status == 0
  *
  * @param Mage_Payment_Model_Info $payment
  * @return bool
  */
 public function denyPayment(Mage_Payment_Model_Info $payment)
 {
     if ($payment->getAdditionalInformation('status') == Netresearch_OPS_Model_Payment_Abstract::OPS_INVALID) {
         // returning true will automatically invoke the payment cancellation process
         return true;
     }
     return false;
 }
Ejemplo n.º 15
0
 /**
  * Returns request object with needed data for API request to PayPal to get form URL.
  *
  * @param Mage_Payment_Model_Info $payment
  * @return Mage_Paypal_Model_Hostedpro_Request
  */
 protected function _buildFormUrlRequest(Mage_Payment_Model_Info $payment)
 {
     $request = $this->_buildBasicRequest()->setOrder($payment->getOrder())->setPaymentMethod($this);
     return $request;
 }
 /**
  * Validate the card expiration date.
  * @param Mage_Payment_Model_Info $info
  * @return self
  */
 protected function _validateExpirationDate(Mage_Payment_Model_Info $info)
 {
     if (!$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
         throw Mage::exception('EbayEnterprise_CreditCard', $this->_helper->__(self::INVALID_EXPIRATION_DATE));
     }
     return $this;
 }
 /**
  * Get transaction status from gateway response array and change payment status to appropriate
  *
  * @param Varien_Object $from
  * @param Mage_Payment_Model_Info $to
  * @return Enterprise_Pbridge_Model_Payment_Method_Authorizenet
  */
 public function importPaymentInfo(Varien_Object $from, Mage_Payment_Model_Info $to)
 {
     $approvedTransactionStatuses = array(self::TRANSACTION_STATUS_AUTHORIZED_PENDING_PAYMENT, self::TRANSACTION_STATUS_CAPTURED_PENDING_SETTLEMENT);
     $transactionStatus = $from->getTransactionStatus();
     if (in_array($transactionStatus, $approvedTransactionStatuses)) {
         $to->setIsTransactionApproved(true);
     } elseif (in_array($transactionStatus, array(self::TRANSACTION_STATUS_VOIDED, self::TRANSACTION_STATUS_DECLINED))) {
         $to->setIsTransactionDenied(true);
     }
     return $this;
 }
Ejemplo n.º 18
0
 /**
  * Deny payment
  * @param Mage_Payment_Model_Info $payment
  * @return mixed
  */
 public function denyPayment(Mage_Payment_Model_Info $payment)
 {
     $transactionId = $payment->getLastTransId();
     if (!$transactionId) {
         return false;
     }
     $request = $this->_getApiRequest();
     $this->_setAdditionalRequestParameters($request, $payment);
     $request->setData('transaction_id', $transactionId)->setData('order_id', $payment->getOrder()->getIncrementId());
     $api = $this->_getApi()->doDeny($request);
     $this->_importResultToPayment($payment, $api->getResponse());
     $apiResponse = $api->getResponse();
     return $apiResponse;
 }
Ejemplo n.º 19
0
 /**
  * Before object save manipulations
  *
  * @return Mage_Sales_Model_Order_Payment
  */
 protected function _beforeSave()
 {
     parent::_beforeSave();
     if (!$this->getParentId() && $this->getOrder()) {
         $this->setParentId($this->getOrder()->getId());
     }
     return $this;
 }
Ejemplo n.º 20
0
 /**
  * Submit RP to the gateway
  *
  * @param Mage_Payment_Model_Recurring_Profile $profile
  * @param Mage_Payment_Model_Info $paymentInfo
  */
 public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile, Mage_Payment_Model_Info $paymentInfo)
 {
     $token = $paymentInfo->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN);
     $profile->setToken($token);
     $this->_pro->submitRecurringProfile($profile, $paymentInfo);
 }
Ejemplo n.º 21
0
 /**
  * Process exceptions for gateway action with a lot of transactions
  *
  * @param  Mage_Payment_Model_Info $payment
  * @param  string $messages
  * @param  bool $isSuccessfulTransactions
  */
 protected function _processFailureMultitransactionAction($payment, $messages, $isSuccessfulTransactions)
 {
     if ($isSuccessfulTransactions) {
         $messages[] = Mage::helper('paygate')->__('Gateway actions are locked because the gateway cannot complete one or more of the transactions. Please log in to your Authorize.Net account to manually resolve the issue(s).');
         /**
          * If there is successful transactions we can not to cancel order but
          * have to save information about processed transactions in order`s comments and disable
          * opportunity to voiding\capturing\refunding in future. Current order and payment will not be saved because we have to
          * load new order object and set information into this object.
          */
         $currentOrderId = $payment->getOrder()->getId();
         $copyOrder = Mage::getModel('sales/order')->load($currentOrderId);
         $copyOrder->getPayment()->setAdditionalInformation($this->_isGatewayActionsLockedKey, 1);
         foreach ($messages as $message) {
             $copyOrder->addStatusHistoryComment($message);
         }
         $copyOrder->save();
     }
     Mage::throwException(Mage::helper('paygate')->convertMessagesToMessage($messages));
 }
Ejemplo n.º 22
0
 /**
  * saves the alias and if given the cvc to the payment information
  *
  * @param Mage_Payment_Model_Info $payment - the payment which should be updated
  * @param array                   $aliasData - the data we will update
  * @param boolean                 $userIsRegistering - is registering method in checkout
  * @param boolean                 $paymentSave - is it necessary to save the payment afterwards
  */
 public function setAliasToPayment(Mage_Payment_Model_Info $payment, array $aliasData, $userIsRegistering = false, $paymentSave = false)
 {
     if (array_key_exists('alias', $aliasData) && 0 < strlen(trim($aliasData['alias']))) {
         $payment->setAdditionalInformation('alias', trim($aliasData['alias']));
         $payment->setAdditionalInformation('userIsRegistering', $userIsRegistering);
         if (array_key_exists('CVC', $aliasData)) {
             $payment->setAdditionalInformation('cvc', $aliasData['CVC']);
             $this->setCardHolderToAlias($payment->getQuote(), $aliasData);
         }
         $payment->setDataChanges(true);
         if ($paymentSave === true) {
             $payment->save();
         }
     } else {
         Mage::helper('ops/data')->log('did not save alias due to empty alias');
         Mage::helper('ops/data')->log($aliasData);
     }
 }
Ejemplo n.º 23
0
 /**
  * Retrieve payment information block
  *
  * @param   Mage_Payment_Model_Info $info
  * @return  Mage_Core_Block_Template
  */
 public function getInfoBlock(Mage_Payment_Model_Info $info)
 {
     $blockType = $info->getMethodInstance()->getInfoBlockType();
     $layout = $this->getLayout() ?: Mage::app()->getLayout();
     $block = $layout->createBlock($blockType);
     $block->setInfo($info);
     return $block;
 }
Ejemplo n.º 24
0
 /**
  * Prepare object for save
  *
  * @return Mage_Sales_Model_Quote_Payment
  */
 protected function _beforeSave()
 {
     try {
         $method = $this->getMethodInstance();
     } catch (Mage_Core_Exception $e) {
         return parent::_beforeSave();
     }
     $method->prepareSave();
     if ($this->getOrder()) {
         $this->setQuoteId($this->getOrder()->getId());
     }
     return parent::_beforeSave();
 }
Ejemplo n.º 25
0
 /**
  * Retrieve payment information block
  *
  * @param   Mage_Payment_Model_Info $info
  * @return  Mage_Core_Block_Template
  */
 public function getInfoBlock(Mage_Payment_Model_Info $info)
 {
     $blockType = $info->getMethodInstance()->getInfoBlockType();
     if ($this->getLayout()) {
         $block = $this->getLayout()->createBlock($blockType);
     } else {
         $className = Mage::getConfig()->getBlockClassName($blockType);
         $block = new $className();
     }
     $block->setInfo($info);
     return $block;
 }
Ejemplo n.º 26
0
 /**
  * Render info item
  *
  * @param array $keys
  * @param Mage_Payment_Model_Info $payment
  * @param bool $labelValuesOnly
  */
 protected function _getFullInfo(array $keys, Mage_Payment_Model_Info $payment, $labelValuesOnly)
 {
     $result = array();
     foreach ($keys as $key) {
         if (!isset($this->_paymentMapFull[$key])) {
             $this->_paymentMapFull[$key] = array();
         }
         if (!isset($this->_paymentMapFull[$key]['label'])) {
             if (!$payment->hasAdditionalInformation($key)) {
                 $this->_paymentMapFull[$key]['label'] = false;
                 $this->_paymentMapFull[$key]['value'] = false;
             } else {
                 $value = $payment->getAdditionalInformation($key);
                 $this->_paymentMapFull[$key]['label'] = $this->_getLabel($key);
                 $this->_paymentMapFull[$key]['value'] = $this->_getValue($value, $key);
             }
         }
         if (!empty($this->_paymentMapFull[$key]['value'])) {
             if ($labelValuesOnly) {
                 $result[$this->_paymentMapFull[$key]['label']] = $this->_paymentMapFull[$key]['value'];
             } else {
                 $result[$key] = $this->_paymentMapFull[$key];
             }
         }
     }
     return $result;
 }
Ejemplo n.º 27
0
 /**
  * Perform the payment review
  *
  * @param Mage_Payment_Model_Info $payment
  * @param string $action
  * @return bool
  */
 public function reviewPayment(Mage_Payment_Model_Info $payment, $action)
 {
     $api = $this->getApi()->setTransactionId($payment->getLastTransId());
     // check whether the review is still needed
     $api->callGetTransactionDetails();
     $this->importPaymentInfo($api, $payment);
     if (!$this->getInfo()->isPaymentReviewRequired($payment)) {
         return false;
     }
     // perform the review action
     $api->setAction($action)->callManagePendingTransactionStatus();
     $api->callGetTransactionDetails();
     $this->importPaymentInfo($api, $payment);
     return true;
 }
 /**
  * Process exceptions for gateway action with a lot of transactions
  *
  * @param  Mage_Payment_Model_Info $payment
  * @param  string $messages
  * @param  bool $isSuccessfulTransactions
  */
 protected function _processFailureMultitransactionAction($payment, $messages, $isSuccessfulTransactions)
 {
     if ($isSuccessfulTransactions) {
         $currentOrderId = $payment->getOrder()->getId();
         $copyOrder = Mage::getModel('sales/order')->load($currentOrderId);
         foreach ($messages as $message) {
             $copyOrder->addStatusHistoryComment($message);
         }
         $copyOrder->save();
     }
     Mage::throwException(Mage::helper('paygate')->convertMessagesToMessage($messages));
 }
Ejemplo n.º 29
0
 /**
  * Retrieve payment method model object
  *
  * @return Mage_Payment_Model_Method_Abstract
  */
 public function getMethodInstance()
 {
     $method = parent::getMethodInstance();
     return $method->setStore($this->getQuote()->getStore());
 }
Ejemplo n.º 30
0
 /**
  * Map payment information from IPN to payment object
  * Returns true if there were changes in information
  *
  * @param Mage_Payment_Model_Info $payment
  * @return bool
  */
 protected function _importPaymentInformation(Mage_Payment_Model_Info $payment)
 {
     $was = $payment->getAdditionalInformation();
     $from = array();
     foreach (array(Mage_Paypal_Model_Info::PAYER_ID, 'payer_email' => Mage_Paypal_Model_Info::PAYER_EMAIL, Mage_Paypal_Model_Info::PAYER_STATUS, Mage_Paypal_Model_Info::ADDRESS_STATUS, Mage_Paypal_Model_Info::PROTECTION_EL) as $privateKey => $publicKey) {
         if (is_int($privateKey)) {
             $privateKey = $publicKey;
         }
         $value = $this->getIpnFormData($privateKey);
         if ($value) {
             $from[$publicKey] = $value;
         }
     }
     // collect fraud filters
     $fraudFilters = array();
     for ($i = 1; $value = $this->getIpnFormData("fraud_management_pending_filters_{$i}"); $i++) {
         $fraudFilters[] = $value;
     }
     if ($fraudFilters) {
         $from[Mage_Paypal_Model_Info::FRAUD_FILTERS] = $fraudFilters;
     }
     Mage::getSingleton('paypal/info')->importToPayment($from, $payment);
     return $was != $payment->getAdditionalInformation();
 }