Example #1
0
 protected function _exportAddressses($data)
 {
     $version = Mage::getVersionInfo();
     if ($version['major'] >= 1 && $version['minor'] >= 7) {
         parent::_exportAddressses($data);
     } else {
         $address = new Varien_Object();
         Varien_Object_Mapper::accumulateByMap($data, $address, $this->_billingAddressMap);
         $address->setExportedKeys(array_values($this->_billingAddressMap));
         $this->_applyStreetAndRegionWorkarounds($address);
         $this->setExportedBillingAddress($address);
         // assume there is shipping address if there is at least one field specific to shipping
         if (isset($data['SHIPTONAME'])) {
             $shippingAddress = clone $address;
             Varien_Object_Mapper::accumulateByMap($data, $shippingAddress, $this->_shippingAddressMap);
             $this->_applyStreetAndRegionWorkarounds($shippingAddress);
             // PayPal doesn't provide detailed shipping name fields, so the name will be overwritten
             $firstName = $data['SHIPTONAME'];
             $lastName = null;
             if (isset($data['FIRSTNAME']) && $data['LASTNAME']) {
                 $firstName = $data['FIRSTNAME'];
                 $lastName = $data['LASTNAME'];
             }
             $shippingAddress->addData(array('prefix' => null, 'firstname' => $firstName, 'middlename' => null, 'lastname' => $lastName, 'suffix' => null));
             $this->setExportedShippingAddress($shippingAddress);
         }
     }
 }
 /**
  * Update quote when returned from PayPal
  * @param string $token
  */
 public function returnFromPaypal($token)
 {
     $this->_getApi();
     $this->_api->setToken($token)->callGetExpressCheckoutDetails();
     // import addresses
     $billingAddress = $this->_quote->getBillingAddress();
     $exportedBillingAddress = $this->_api->getExportedBillingAddress();
     foreach ($exportedBillingAddress->getExportedKeys() as $key) {
         $billingAddress->setDataUsingMethod($key, $exportedBillingAddress->getData($key));
     }
     $exportedShippingAddress = $this->_api->getExportedShippingAddress();
     if (!$this->_quote->getIsVirtual() && $exportedShippingAddress && ($shippingAddress = $this->_quote->getShippingAddress())) {
         foreach ($exportedShippingAddress->getExportedKeys() as $key) {
             $shippingAddress->setDataUsingMethod($key, $exportedShippingAddress->getData($key));
         }
         $shippingAddress->setCollectShippingRates(true);
     }
     $this->_ignoreAddressValidation();
     // import payment info
     $payment = $this->_quote->getPayment();
     $payment->setMethod($this->_methodType);
     Mage::getSingleton('paypal/info')->importToPayment($this->_api, $payment);
     $payment->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID, $this->_api->getPayerId())->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_TOKEN, $token);
     $this->_quote->collectTotals()->save();
 }
Example #3
0
 public function call($methodName, array $request)
 {
     if (in_array($methodName, array(self::DO_EXPRESS_CHECKOUT_PAYMENT, self::SET_EXPRESS_CHECKOUT))) {
         $request = $this->prepareGiftWrap($request, $methodName == self::SET_EXPRESS_CHECKOUT);
     }
     return parent::call($methodName, $request);
 }
Example #4
0
 public function callDoExpressCheckoutPayment()
 {
     if (!Mage::getStoreConfig('aitconfcheckout/shipping/active') || !Mage::getStoreConfig('aitconfcheckout/shipping/address') || !Mage::getStoreConfig('aitconfcheckout/shipping/city') || !Mage::getStoreConfig('aitconfcheckout/shipping/region') || !Mage::getStoreConfig('aitconfcheckout/shipping/country') || !Mage::getStoreConfig('aitconfcheckout/shipping/postcode') || !Mage::getStoreConfig('aitconfcheckout/shipping/telephone')) {
         $this->setSuppressShipping(true);
     }
     parent::callDoExpressCheckoutPayment();
 }
Example #5
0
 /**
  * API instance getter
  * Sets current store id to current config instance and passes it to API
  *
  * @return Mage_Paypal_Model_Api_Nvp
  */
 public function getApi()
 {
     if (null === $this->_api) {
         $this->_api = Mage::getModel($this->_apiType);
     }
     $this->_api->setConfigObject($this->_config);
     return $this->_api;
 }
 /**
  * Is capture request needed on this transaction
  *
  * @return true
  */
 protected function _isCaptureNeeded()
 {
     $this->_api->callGetTransactionDetails();
     if ($this->_api->isPaymentComplete()) {
         Mage::getModel('paypal/info')->importToPayment($api, $payment);
         return false;
     }
     return true;
 }
Example #7
0
 /**
  * Set create billing agreement flag to api call
  *
  * @return Mage_Paypal_Model_Express_Checkout
  */
 protected function _setBillingAgreementRequest()
 {
     if (!$this->_customerId || $this->_quote->hasNominalItems()) {
         return $this;
     }
     $isRequested = $this->_isBARequested || $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
     if (!($this->_config->allow_ba_signup == Mage_Paypal_Model_Config::EC_BA_SIGNUP_AUTO || $isRequested && $this->_config->shouldAskToCreateBillingAgreement())) {
         return $this;
     }
     if (!Mage::getModel('sales/billing_agreement')->needToCreateForCustomer($this->_customerId)) {
         return $this;
     }
     $this->_api->setBillingType($this->_api->getBillingAgreementType());
     return $this;
 }
 /**
  * Checking negative line items
  *
  * @param array $request
  * @param int $i
  * @return null|true
  */
 protected function _exportLineItems(array &$request, $i = 0)
 {
     $requestBefore = $request;
     $result = parent::_exportLineItems($request, $i);
     if ($this->getIsLineItemsEnabled() && $this->_cart->hasNegativeItemAmount()) {
         $this->_lineItemTotalExportMap = array(Mage_Paypal_Model_Cart::TOTAL_TAX => 'TAXAMT', Mage_Paypal_Model_Cart::TOTAL_SHIPPING => 'FREIGHTAMT', 'amount' => 'PAYMENTREQUEST_0_ITEMAMT');
         $this->_lineItemExportItemsFormat = array('name' => 'L_PAYMENTREQUEST_0_NAME%d', 'qty' => 'L_PAYMENTREQUEST_0_QTY%d', 'amount' => 'L_PAYMENTREQUEST_0_AMT%d');
         $request = $requestBefore;
         $result = parent::_exportLineItems($request, $i);
         $paypalNvp = new Mage_Paypal_Model_Api_Nvp();
         $this->_doCaptureResponse = $paypalNvp->_doCaptureResponse;
         $this->_refundTransactionResponse = $paypalNvp->_refundTransactionResponse;
         $this->_getTransactionDetailsResponse = $paypalNvp->_getTransactionDetailsResponse;
         $this->_paymentInformationResponse = $paypalNvp->_paymentInformationResponse;
         $this->_headers[] = 'PAYPAL-NVP: Y';
         $this->_setSpecificForNegativeLineItems();
     }
     return $result;
 }
Example #9
0
 protected function _construct()
 {
     parent::_construct();
     $this->_globalMap['BUTTONSOURCE'] = 'paypal_info_code';
     $this->_debugReplacePrivateDataKeys[] = 'BUTTONSOURCE';
 }
Example #10
0
 /**
  * Import refund results to payment
  *
  * @param Mage_Paypal_Model_Api_Nvp $api
  * @param Mage_Sales_Model_Order_Payment $payment
  * @param bool $canRefundMore
  */
 protected function _importRefundResultToPayment($api, $payment, $canRefundMore)
 {
     $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(1)->setShouldCloseParentTransaction(!$canRefundMore)->setTransactionAdditionalInfo(self::TRANSPORT_PAYFLOW_TXN_ID, $api->getPayflowTrxid());
     $payment->setPreparedMessage(Mage::helper('enterprise_pbridge')->__('Payflow PNREF: #%s.', $api->getData(self::TRANSPORT_PAYFLOW_TXN_ID)));
     Mage::getModel('paypal/info')->importToPayment($api, $payment);
 }