From 83908ee6cc9699c383a3ef63aff269fe0e49f2e1 Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Wed, 11 Jun 2025 12:57:36 +0200 Subject: [PATCH 01/40] refactor: remove PaypalUk --- .../core/Mage/PaypalUk/Block/Bml/Form.php | 22 - .../core/Mage/PaypalUk/Block/Express/Form.php | 20 - .../Mage/PaypalUk/Block/Express/Shortcut.php | 57 -- app/code/core/Mage/PaypalUk/Helper/Data.php | 18 - .../Mage/PaypalUk/Model/Api/Express/Nvp.php | 31 - app/code/core/Mage/PaypalUk/Model/Api/Nvp.php | 610 ------------------ app/code/core/Mage/PaypalUk/Model/Bml.php | 38 -- app/code/core/Mage/PaypalUk/Model/Direct.php | 86 --- app/code/core/Mage/PaypalUk/Model/Express.php | 86 --- .../Mage/PaypalUk/Model/Express/Checkout.php | 40 -- .../core/Mage/PaypalUk/Model/Express/Pro.php | 23 - app/code/core/Mage/PaypalUk/Model/Pro.php | 133 ---- app/code/core/Mage/PaypalUk/Model/Session.php | 22 - .../PaypalUk/controllers/BmlController.php | 24 - .../controllers/ExpressController.php | 35 - app/code/core/Mage/PaypalUk/etc/config.xml | 106 --- .../sql/paypaluk_setup/install-1.6.0.0.php | 11 - .../paypaluk_setup/mysql4-install-0.7.0.php | 29 - .../frontend/base/default/layout/paypaluk.xml | 137 ---- app/etc/modules/Mage_PaypalUk.xml | 23 - app/locale/en_US/Mage_PaypalUk.csv | 2 - 21 files changed, 1553 deletions(-) delete mode 100644 app/code/core/Mage/PaypalUk/Block/Bml/Form.php delete mode 100644 app/code/core/Mage/PaypalUk/Block/Express/Form.php delete mode 100644 app/code/core/Mage/PaypalUk/Block/Express/Shortcut.php delete mode 100644 app/code/core/Mage/PaypalUk/Helper/Data.php delete mode 100644 app/code/core/Mage/PaypalUk/Model/Api/Express/Nvp.php delete mode 100644 app/code/core/Mage/PaypalUk/Model/Api/Nvp.php delete mode 100644 app/code/core/Mage/PaypalUk/Model/Bml.php delete mode 100644 app/code/core/Mage/PaypalUk/Model/Direct.php delete mode 100644 app/code/core/Mage/PaypalUk/Model/Express.php delete mode 100644 app/code/core/Mage/PaypalUk/Model/Express/Checkout.php delete mode 100644 app/code/core/Mage/PaypalUk/Model/Express/Pro.php delete mode 100644 app/code/core/Mage/PaypalUk/Model/Pro.php delete mode 100644 app/code/core/Mage/PaypalUk/Model/Session.php delete mode 100644 app/code/core/Mage/PaypalUk/controllers/BmlController.php delete mode 100644 app/code/core/Mage/PaypalUk/controllers/ExpressController.php delete mode 100644 app/code/core/Mage/PaypalUk/etc/config.xml delete mode 100644 app/code/core/Mage/PaypalUk/sql/paypaluk_setup/install-1.6.0.0.php delete mode 100644 app/code/core/Mage/PaypalUk/sql/paypaluk_setup/mysql4-install-0.7.0.php delete mode 100644 app/design/frontend/base/default/layout/paypaluk.xml delete mode 100644 app/etc/modules/Mage_PaypalUk.xml delete mode 100644 app/locale/en_US/Mage_PaypalUk.csv diff --git a/app/code/core/Mage/PaypalUk/Block/Bml/Form.php b/app/code/core/Mage/PaypalUk/Block/Bml/Form.php deleted file mode 100644 index 38819454c83..00000000000 --- a/app/code/core/Mage/PaypalUk/Block/Bml/Form.php +++ /dev/null @@ -1,22 +0,0 @@ -getMethodInstance(Mage_Paypal_Model_Config::METHOD_WPP_PE_BML); - $isBmlEnabled = $bml && $bml->isAvailable($quote); - /** @var Mage_Core_Helper_Data $helper */ - $helper = $this->helper('core'); - $this->setBmlShortcutHtmlId($helper->uniqHash('ec_shortcut_bml_')) - ->setBmlCheckoutUrl($this->getUrl('paypaluk/bml/start/button/1')) - ->setBmlImageUrl('https://www.paypalobjects.com/webstatic/en_US/i/buttons/ppcredit-logo-medium.png') - ->setMarketMessage('https://www.paypalobjects.com/webstatic/en_US/btn/btn_bml_text.png') - ->setMarketMessageUrl('https://www.securecheckout.billmelater.com/paycapture-content/' - . 'fetch?hash=AU826TU8&content=/bmlweb/ppwpsiw.html') - ->setIsBmlEnabled($isBmlEnabled); - return $this; - } -} diff --git a/app/code/core/Mage/PaypalUk/Helper/Data.php b/app/code/core/Mage/PaypalUk/Helper/Data.php deleted file mode 100644 index 48a78bcd38f..00000000000 --- a/app/code/core/Mage/PaypalUk/Helper/Data.php +++ /dev/null @@ -1,18 +0,0 @@ -_setExpressCheckoutResponse = $paypalNvp->_setExpressCheckoutResponse; - $index = array_search('PPREF', $this->_doExpressCheckoutPaymentResponse); - if ($index !== false) { - unset($this->_doExpressCheckoutPaymentResponse[$index]); - } - $this->_doExpressCheckoutPaymentResponse[] = 'PAYMENTINFO_0_TRANSACTIONID'; - $this->_requiredResponseParams[self::DO_EXPRESS_CHECKOUT_PAYMENT][] = 'PAYMENTINFO_0_TRANSACTIONID'; - } -} diff --git a/app/code/core/Mage/PaypalUk/Model/Api/Nvp.php b/app/code/core/Mage/PaypalUk/Model/Api/Nvp.php deleted file mode 100644 index 60952e1474f..00000000000 --- a/app/code/core/Mage/PaypalUk/Model/Api/Nvp.php +++ /dev/null @@ -1,610 +0,0 @@ - 'partner', - 'VENDOR' => 'vendor', - 'USER' => 'user', - 'PWD' => 'password', - 'BUTTONSOURCE' => 'build_notation_code', - 'TENDER' => 'tender', - // commands - 'RETURNURL' => 'return_url', - 'CANCELURL' => 'cancel_url', - 'INVNUM' => 'inv_num', - 'TOKEN' => 'token', - 'CORRELATIONID' => 'correlation_id', - 'CUSTIP' => 'ip_address', - 'NOTIFYURL' => 'notify_url', - 'NOTE' => 'note', - // style settings - 'PAGESTYLE' => 'page_style', - 'HDRIMG' => 'hdrimg', - 'HDRBORDERCOLOR' => 'hdrbordercolor', - 'HDRBACKCOLOR' => 'hdrbackcolor', - 'PAYFLOWCOLOR' => 'payflowcolor', - 'LOCALECODE' => 'locale_code', - - // transaction info - 'PPREF' => 'paypal_transaction_id', //We need to store paypal trx id for correct IPN working - 'PAYMENTINFO_0_TRANSACTIONID' => 'paypal_transaction_id', - 'TRANSACTIONID' => 'paypal_transaction_id', - 'REFUNDTRANSACTIONID' => 'paypal_transaction_id', - - 'PNREF' => 'transaction_id', - 'ORIGID' => 'authorization_id', - 'CAPTURECOMPLETE' => 'complete_type', - 'AMT' => 'amount', - 'AVSADDR' => 'address_verification', - 'AVSZIP' => 'postcode_verification', - - // payment/billing info - 'CURRENCY' => 'currency_code', - 'PAYMENTSTATUS' => 'payment_status', - 'PENDINGREASON' => 'pending_reason', - 'PAYERID' => 'payer_id', - 'PAYERSTATUS' => 'payer_status', - 'EMAIL' => 'email', - // backwards compatibility - 'FIRSTNAME' => 'firstname', - 'LASTNAME' => 'lastname', - // paypal direct credit card information - 'ACCT' => 'credit_card_number', - 'EXPDATE' => 'credit_card_expiration_date', - 'CVV2' => 'credit_card_cvv2', - 'CARDSTART' => 'maestro_solo_issue_date', // MMYY, including leading zero - 'CARDISSUE' => 'maestro_solo_issue_number', - 'CVV2MATCH' => 'cvv2_check_result', - // cardinal centinel - 'AUTHSTATUS3DS' => 'centinel_authstatus', - 'MPIVENDOR3DS' => 'centinel_mpivendor', - 'CAVV' => 'centinel_cavv', - 'ECI' => 'centinel_eci', - 'XID' => 'centinel_xid', - 'VPAS' => 'centinel_vpas_result', - 'ECISUBMITTED3DS' => 'centinel_eci_result', - 'USERSELECTEDFUNDINGSOURCE' => 'funding_source', - ]; - - /** - * Fields that should be replaced in debug with '***' - * - * @var array - */ - protected $_debugReplacePrivateDataKeys = [ - 'ACCT', 'EXPDATE', 'CVV2', - 'PARTNER', 'USER', 'VENDOR', 'PWD', - ]; - - /** - * DoDirectPayment request/response map - * - * @var array - */ - protected $_doDirectPaymentRequest = [ - 'ACCT', 'EXPDATE', 'CVV2', 'CURRENCY', 'EMAIL', 'TENDER', 'NOTIFYURL', - 'AMT', 'CUSTIP', 'INVNUM', - 'CARDISSUE', 'CARDSTART', - 'AUTHSTATUS3DS', 'MPIVENDOR3DS', 'CAVV', 'ECI', 'XID',//cardinal centinel params - 'TAXAMT', 'FREIGHTAMT', - ]; - protected $_doDirectPaymentResponse = [ - 'PNREF', 'PPREF', 'CORRELATIONID', 'CVV2MATCH', 'AVSADDR', 'AVSZIP', 'PENDINGREASON', - ]; - - /** - * DoCapture request/response map - * - * @var array - */ - protected $_doCaptureRequest = ['ORIGID', 'CAPTURECOMPLETE', 'AMT', 'TENDER', 'NOTE', 'INVNUM']; - protected $_doCaptureResponse = ['PNREF', 'PPREF']; - - /** - * DoVoid request map - * - * @var array - */ - protected $_doVoidRequest = ['ORIGID', 'NOTE', 'TENDER']; - - /** - * Request map for each API call - * - * @var array - */ - protected $_eachCallRequest = ['PARTNER', 'USER', 'VENDOR', 'PWD', 'BUTTONSOURCE']; - - /** - * RefundTransaction request/response map - * - * @var array - */ - protected $_refundTransactionRequest = ['ORIGID', 'TENDER']; - protected $_refundTransactionResponse = ['PNREF', 'PPREF']; - - /** - * SetExpressCheckout request/response map - * - * @var array - */ - protected $_setExpressCheckoutRequest = [ - 'TENDER', 'AMT', 'CURRENCY', 'RETURNURL', 'CANCELURL', 'INVNUM', - 'PAGESTYLE', 'HDRIMG', 'HDRBORDERCOLOR', 'HDRBACKCOLOR', 'PAYFLOWCOLOR', 'LOCALECODE', - 'USERSELECTEDFUNDINGSOURCE', - ]; - protected $_setExpressCheckoutResponse = ['REPMSG', 'TOKEN']; - - /** - * GetExpressCheckoutDetails request/response map - * - * @var array - */ - protected $_getExpressCheckoutDetailsRequest = ['TENDER', 'TOKEN']; - - /** - * DoExpressCheckoutPayment request/response map - * - * @var array - */ - protected $_doExpressCheckoutPaymentRequest = [ - 'TENDER', 'TOKEN', 'PAYERID', 'AMT', 'CURRENCY', 'CUSTIP', 'BUTTONSOURCE', 'NOTIFYURL', - ]; - protected $_doExpressCheckoutPaymentResponse = [ - 'PNREF', 'PPREF', 'REPMSG', 'AMT', 'PENDINGREASON', - 'CVV2MATCH', 'AVSADDR', 'AVSZIP', 'CORRELATIONID', - ]; - - /** - * GetTransactionDetailsRequest - * - * @var array - */ - protected $_getTransactionDetailsRequest = ['ORIGID', 'TENDER']; - protected $_getTransactionDetailsResponse = [ - 'PAYERID', 'FIRSTNAME', 'LASTNAME', 'TRANSACTIONID', - 'PARENTTRANSACTIONID', 'CURRENCYCODE', 'AMT', 'PAYMENTSTATUS', - ]; - - /** - * Map for shipping address import/export (extends billing address mapper) - * - * @var array - */ - protected $_shippingAddressMap = [ - 'SHIPTOCOUNTRY' => 'country_id', - 'SHIPTOSTATE' => 'region', - 'SHIPTOCITY' => 'city', - 'SHIPTOSTREET' => 'street', - 'SHIPTOSTREET2' => 'street2', - 'SHIPTOZIP' => 'postcode', - 'SHIPTOPHONENUM' => 'telephone', // does not supported by PaypalUk - ]; - - /** - * Map for billing address import/export - * - * @var array - */ - protected $_billingAddressMap = [ - 'BUSINESS' => 'company', - 'NOTETEXT' => 'customer_notes', - 'EMAIL' => 'email', - 'FIRSTNAME' => 'firstname', - 'LASTNAME' => 'lastname', - 'MIDDLENAME' => 'middlename', - 'SALUTATION' => 'prefix', - 'SUFFIX' => 'suffix', - - 'COUNTRYCODE' => 'country_id', // iso-3166 two-character code - 'STATE' => 'region', - 'CITY' => 'city', - 'STREET' => 'street', - 'STREET2' => 'street2', - 'ZIP' => 'postcode', - 'PHONENUM' => 'telephone', - ]; - - /** - * Map for billing address to do request to PayPalUk - * - * @var array - */ - protected $_billingAddressMapRequest = [ - 'country_id' => 'COUNTRY', - ]; - - /** - * Line items export mapping settings - * - * @var array - */ - protected $_lineItemTotalExportMap = [ - Mage_Paypal_Model_Cart::TOTAL_TAX => 'TAXAMT', - Mage_Paypal_Model_Cart::TOTAL_SHIPPING => 'FREIGHTAMT', - ]; - - protected $_lineItemExportItemsFormat = [ - 'name' => 'L_NAME%d', - 'qty' => 'L_QTY%d', - 'amount' => 'L_COST%d', - ]; - - /** - * Payment information response specifically to be collected after some requests - * - * @var array - */ - protected $_paymentInformationResponse = [ - 'PAYERID', 'CORRELATIONID', 'ADDRESSID', 'ADDRESSSTATUS', - 'PAYMENTSTATUS', 'PENDINGREASON', 'PROTECTIONELIGIBILITY', 'EMAIL', - ]; - - /** - * Required fields in the response - * - * @var array - */ - protected $_requiredResponseParams = [ - self::DO_DIRECT_PAYMENT => ['RESULT', 'PNREF'], - ]; - - /** - * API endpoint getter - * - * @return string - */ - public function getApiEndpoint() - { - return sprintf('https://%spayflowpro.paypal.com/transaction', $this->_config->sandboxFlag ? 'pilot-' : ''); - } - - /** - * Return PaypalUk partner based on config data - * - * @return string - */ - public function getPartner() - { - return $this->_getDataOrConfig('partner'); - } - - /** - * Return PaypalUk user based on config data - * - * @return string - */ - public function getUser() - { - return $this->_getDataOrConfig('user'); - } - - /** - * Return PaypalUk password based on config data - * - * @return string - */ - public function getPassword() - { - return $this->_getDataOrConfig('pwd'); - } - - /** - * Return PaypalUk vendor based on config data - * - * @return string - */ - public function getVendor() - { - return $this->_getDataOrConfig('vendor'); - } - - /** - * Return PaypalUk tender based on config data - * - * @return string - */ - public function getTender() - { - if ($this->_config->getMethodCode() == Mage_Paypal_Model_Config::METHOD_WPP_PE_EXPRESS) { - return self::TENDER_PAYPAL; - } - return self::TENDER_CC; - } - - /** - * Override transaction id getting to process payflow accounts not assigned to paypal side - * - * @return string - */ - public function getPaypalTransactionId() - { - if ($this->getData('paypal_transaction_id')) { - return $this->getData('paypal_transaction_id'); - } - return $this->getTransactionId(); - } - - /** - * Add method to request array - * - * @param string $methodName - * @param array $request - * @return array - */ - protected function _addMethodToRequest($methodName, $request) - { - $request['TRXTYPE'] = $this->_mapPaypalMethodName($methodName); - if (!is_null($this->_getPaypalUkActionName($methodName))) { - $request['ACTION'] = $this->_getPaypalUkActionName($methodName); - } - return $request; - } - - /** - * Return Payflow Edition - * - * @param string $methodName - * @return string|null - */ - protected function _getPaypalUkActionName($methodName) - { - switch ($methodName) { - case Mage_Paypal_Model_Api_Nvp::SET_EXPRESS_CHECKOUT: - return self::EXPRESS_SET; - case Mage_Paypal_Model_Api_Nvp::GET_EXPRESS_CHECKOUT_DETAILS: - return self::EXPRESS_GET; - case Mage_Paypal_Model_Api_Nvp::DO_EXPRESS_CHECKOUT_PAYMENT: - return self::EXPRESS_DO_PAYMENT; - } - return null; - } - - /** - * Map paypal method names - * - * @param string $methodName - * @return string|void - */ - protected function _mapPaypalMethodName($methodName) - { - switch ($methodName) { - case Mage_Paypal_Model_Api_Nvp::DO_EXPRESS_CHECKOUT_PAYMENT: - case Mage_Paypal_Model_Api_Nvp::GET_EXPRESS_CHECKOUT_DETAILS: - case Mage_Paypal_Model_Api_Nvp::SET_EXPRESS_CHECKOUT: - case Mage_Paypal_Model_Api_Nvp::DO_DIRECT_PAYMENT: - return ($this->_config->payment_action == Mage_Paypal_Model_Config::PAYMENT_ACTION_AUTH) - ? self::TRXTYPE_AUTH_ONLY - : self::TRXTYPE_SALE; - case Mage_Paypal_Model_Api_Nvp::DO_CAPTURE: - return self::TRXTYPE_DELAYED_CAPTURE; - case Mage_Paypal_Model_Api_Nvp::DO_VOID: - return self::TRXTYPE_DELAYED_VOID; - case Mage_Paypal_Model_Api_Nvp::REFUND_TRANSACTION: - return self::TRXTYPE_CREDIT; - } - } - - /** - * Catch success calls and collect warnings - * - * @param array $response - * @return bool success flag - */ - protected function _isCallSuccessful($response) - { - $this->_callWarnings = []; - if ($response['RESULT'] == self::RESPONSE_CODE_APPROVED) { - // collect warnings - if (!empty($response['RESPMSG']) && strtoupper($response['RESPMSG']) != 'APPROVED') { - $this->_callWarnings[] = $response['RESPMSG']; - } - return true; - } - return false; - } - - /** - * Handle logical errors - * - * @param array $response - */ - protected function _handleCallErrors($response) - { - if ($response['RESULT'] != self::RESPONSE_CODE_APPROVED) { - $message = $response['RESPMSG']; - $e = new Exception(sprintf('PayPal gateway errors: %s.', $message)); - Mage::logException($e); - Mage::throwException( - Mage::helper('paypal')->__('PayPal gateway rejected the request. %s', $message), - ); - } - } - - /** - * Build query string without urlencoding from request - * - * @param array $request - * @return string - */ - protected function _buildQuery($request) - { - $result = ''; - foreach ($request as $k => $v) { - $result .= '&' . $k . '=' . $v; - } - return trim($result, '&'); - } - - /** - * Generate Request ID - * - * @return string - */ - protected function getRequestId() - { - return Mage::helper('core')->uniqHash(); - } - - /** - * "GetTransactionDetails" method does not exists in PaypalUK - */ - public function callGetTransactionDetails() {} - - /** - * Get FMF results from response, if any - */ - protected function _importFraudFiltersResult(array $from, array $collectedWarnings) - { - if ($from['RESULT'] != self::RESPONSE_CODE_FRAUD) { - return; - } - $this->setIsPaymentPending(true); - } - - /** - * Return each call request fields - * (PayFlow edition doesn't support Unilateral payments) - * - * @param string $methodName Current method name - * @return array - */ - protected function _prepareEachCallRequest($methodName) - { - return $this->_eachCallRequest; - } - - /** - * Overwrite parent logic, simply return input data - * (PayFlow edition doesn't support Unilateral payments) - * - * @param array $requestFields Standard set of values - * @return array - */ - protected function _prepareExpressCheckoutCallRequest(&$requestFields) - { - return $requestFields; - } - - /** - * Adopt specified request array to be compatible with Paypal - * Puerto Rico should be as state of USA and not as a country - * - * @param array $request - */ - protected function _applyCountryWorkarounds(&$request) - { - if (isset($request['SHIPTOCOUNTRY']) && $request['SHIPTOCOUNTRY'] == 'PR') { - $request['SHIPTOCOUNTRY'] = 'US'; - $request['SHIPTOSTATE'] = 'PR'; - } - } - - /** - * Checking negative line items - * - * @param int $i - * @return bool|void - */ - protected function _exportLineItems(array &$request, $i = 0) - { - $requestBefore = $request; - $result = parent::_exportLineItems($request, $i); - if ($this->getIsLineItemsEnabled() && $this->_cart->hasNegativeItemAmount()) { - $this->_lineItemTotalExportMap = [ - Mage_Paypal_Model_Cart::TOTAL_TAX => 'TAXAMT', - Mage_Paypal_Model_Cart::TOTAL_SHIPPING => 'FREIGHTAMT', - 'amount' => 'PAYMENTREQUEST_0_ITEMAMT', - ]; - $this->_lineItemExportItemsFormat = [ - '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; - } - - /** - * Set specific data when negative line item case - */ - protected function _setSpecificForNegativeLineItems() - { - $index = array_search('PPREF', $this->_doDirectPaymentResponse); - if ($index !== false) { - unset($this->_doDirectPaymentResponse[$index]); - } - $this->_doDirectPaymentResponse[] = 'TRANSACTIONID'; - } -} diff --git a/app/code/core/Mage/PaypalUk/Model/Bml.php b/app/code/core/Mage/PaypalUk/Model/Bml.php deleted file mode 100644 index 242af8512c3..00000000000 --- a/app/code/core/Mage/PaypalUk/Model/Bml.php +++ /dev/null @@ -1,38 +0,0 @@ -_pro->getConfig()->cctypes; - } - - /** - * Merchant country limitation for 3d secure feature, rewrite for parent implementation - * - * @return bool - */ - public function getIsCentinelValidationEnabled() - { - if (!parent::getIsCentinelValidationEnabled()) { - return false; - } - // available only for US and UK merchants - if (in_array($this->_pro->getConfig()->getMerchantCountry(), ['US', 'GB'])) { - return true; - } - return false; - } - - /** - * Import direct payment results to payment - * - * @param Mage_Paypal_Model_Api_Nvp $api - * @param Mage_Sales_Model_Order_Payment $payment - */ - protected function _importResultToPayment($api, $payment) - { - $payment->setTransactionId($api->getPaypalTransactionId())->setIsTransactionClosed(0) - ->setIsTransactionPending($api->getIsPaymentPending()) - ->setTransactionAdditionalInfo(Mage_PaypalUk_Model_Pro::TRANSPORT_PAYFLOW_TXN_ID, $api->getTransactionId()) - ; - $payment->setPreparedMessage(Mage::helper('paypaluk')->__('Payflow PNREF: #%s.', $api->getTransactionId())); - $this->_pro->importPaymentInfo($api, $payment); - } - - /** - * Format credit card expiration date based on month and year values - * Format: mmyy - * - * @param string|int $month - * @param string|int $year - * @return string - */ - protected function _getFormattedCcExpirationDate($month, $year) - { - return sprintf('%02d', $month) . sprintf('%02d', substr($year, -2, 2)); - } -} diff --git a/app/code/core/Mage/PaypalUk/Model/Express.php b/app/code/core/Mage/PaypalUk/Model/Express.php deleted file mode 100644 index f749b649007..00000000000 --- a/app/code/core/Mage/PaypalUk/Model/Express.php +++ /dev/null @@ -1,86 +0,0 @@ -_ecInstance) { - $this->_ecInstance = Mage::helper('payment') - ->getMethodInstance(Mage_Paypal_Model_Config::METHOD_WPP_EXPRESS); - } - if ($quote && $this->_ecInstance) { - $this->_ecInstance->setStore($quote->getStoreId()); - } - return $this->_ecInstance ? !$this->_ecInstance->isAvailable() : false; - } - - /** - * Import payment info to payment - * - * @param Mage_Paypal_Model_Api_Nvp $api - * @param Mage_Sales_Model_Order_Payment $payment - */ - protected function _importToPayment($api, $payment) - { - $payment->setTransactionId($api->getPaypalTransactionId())->setIsTransactionClosed(0) - ->setAdditionalInformation( - Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_REDIRECT, - $api->getRedirectRequired() || $api->getRedirectRequested(), - ) - ->setIsTransactionPending($api->getIsPaymentPending()) - ->setTransactionAdditionalInfo(Mage_PaypalUk_Model_Pro::TRANSPORT_PAYFLOW_TXN_ID, $api->getTransactionId()) - ; - $payment->setPreparedMessage(Mage::helper('paypaluk')->__('Payflow PNREF: #%s.', $api->getTransactionId())); - Mage::getModel('paypal/info')->importToPayment($api, $payment); - } - - /** - * Checkout redirect URL getter for onepage checkout (hardcode) - * - * @see Mage_Checkout_OnepageController::savePaymentAction() - * @see Mage_Sales_Model_Quote_Payment::getCheckoutRedirectUrl() - * @return string - */ - public function getCheckoutRedirectUrl() - { - return Mage::getUrl('paypaluk/express/start'); - } -} diff --git a/app/code/core/Mage/PaypalUk/Model/Express/Checkout.php b/app/code/core/Mage/PaypalUk/Model/Express/Checkout.php deleted file mode 100644 index bccd20c592b..00000000000 --- a/app/code/core/Mage/PaypalUk/Model/Express/Checkout.php +++ /dev/null @@ -1,40 +0,0 @@ -_quote->save(); - } -} diff --git a/app/code/core/Mage/PaypalUk/Model/Express/Pro.php b/app/code/core/Mage/PaypalUk/Model/Express/Pro.php deleted file mode 100644 index f68fd914baf..00000000000 --- a/app/code/core/Mage/PaypalUk/Model/Express/Pro.php +++ /dev/null @@ -1,23 +0,0 @@ -_getParentTransactionId($payment)) { - $api = $this->getApi(); - $api->setAuthorizationId($captureTxnId); - } - parent::refund($payment, $amount); - } - - /** - * Is capture request needed on this transaction - * - * @return true - */ - protected function _isCaptureNeeded() - { - return true; - } - - /** - * Get payflow transaction id from parent transaction - * - * @return string - */ - protected function _getParentTransactionId(Varien_Object $payment) - { - if ($payment->getParentTransactionId()) { - return $payment->getTransaction($payment->getParentTransactionId()) - ->getAdditionalInformation(self::TRANSPORT_PAYFLOW_TXN_ID); - } - return $payment->getParentTransactionId(); - } - - /** - * Import capture results to payment - * - * @param Mage_Paypal_Model_Api_Nvp $api - * @param Mage_Sales_Model_Order_Payment $payment - */ - protected function _importCaptureResultToPayment($api, $payment) - { - $payment->setTransactionId($api->getPaypalTransactionId()) - ->setIsTransactionClosed(false) - ->setTransactionAdditionalInfo( - self::TRANSPORT_PAYFLOW_TXN_ID, - $api->getTransactionId(), - ); - $payment->setPreparedMessage( - Mage::helper('paypaluk')->__('Payflow PNREF: #%s.', $api->getTransactionId()), - ); - Mage::getModel('paypal/info')->importToPayment($api, $payment); - } - - /** - * Fetch transaction details info method does not exists in PaypalUK - * - * @param string $transactionId - * @throws Mage_Core_Exception - * @return void - */ - public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId) - { - Mage::throwException( - Mage::helper('paypaluk')->__('Fetch transaction details method does not exists in PaypalUK'), - ); - } - - /** - * 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->getPaypalTransactionId()) - ->setIsTransactionClosed(1) // refund initiated by merchant - ->setShouldCloseParentTransaction(!$canRefundMore) - ->setTransactionAdditionalInfo( - self::TRANSPORT_PAYFLOW_TXN_ID, - $api->getTransactionId(), - ); - $payment->setPreparedMessage( - Mage::helper('paypaluk')->__('Payflow PNREF: #%s.', $api->getTransactionId()), - ); - Mage::getModel('paypal/info')->importToPayment($api, $payment); - } -} diff --git a/app/code/core/Mage/PaypalUk/Model/Session.php b/app/code/core/Mage/PaypalUk/Model/Session.php deleted file mode 100644 index 78f50a2ddd4..00000000000 --- a/app/code/core/Mage/PaypalUk/Model/Session.php +++ /dev/null @@ -1,22 +0,0 @@ -init('paypaluk'); - } -} diff --git a/app/code/core/Mage/PaypalUk/controllers/BmlController.php b/app/code/core/Mage/PaypalUk/controllers/BmlController.php deleted file mode 100644 index 96ac09228fe..00000000000 --- a/app/code/core/Mage/PaypalUk/controllers/BmlController.php +++ /dev/null @@ -1,24 +0,0 @@ -_forward('start', 'express', 'payflow', ['bml' => 1]); - } -} diff --git a/app/code/core/Mage/PaypalUk/controllers/ExpressController.php b/app/code/core/Mage/PaypalUk/controllers/ExpressController.php deleted file mode 100644 index cd1b840e85b..00000000000 --- a/app/code/core/Mage/PaypalUk/controllers/ExpressController.php +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - 1.6.0.0 - - - - - - Mage_PaypalUk_Model - paypaluk_resource - - - Mage_PaypalUk_Model_Resource - paypaluk_mysql4 - - - paypaluk_api_debug
-
-
-
-
- - - Mage_PaypalUk_Helper - - - - - - Mage_PaypalUk - - - - - - Mage_PaypalUk_Block - - -
- - - /paypaluk/express - - - - standard - - Mage_PaypalUk - payflow - - - - - - - - Mage_PaypalUk.csv - - - - - - - - paypaluk.xml - - - - - - - - - - Mage_PaypalUk.csv - - - - - - - - - paypaluk/express - - - paypaluk/bml - Paypal Credit - paypal - - - paypaluk/direct - - - -
diff --git a/app/code/core/Mage/PaypalUk/sql/paypaluk_setup/install-1.6.0.0.php b/app/code/core/Mage/PaypalUk/sql/paypaluk_setup/install-1.6.0.0.php deleted file mode 100644 index 3fc5f596851..00000000000 --- a/app/code/core/Mage/PaypalUk/sql/paypaluk_setup/install-1.6.0.0.php +++ /dev/null @@ -1,11 +0,0 @@ -startSetup(); - -$installer->run(" - --- DROP TABLE IF EXISTS {$this->getTable('paypaluk_api_debug')}; - -CREATE TABLE {$this->getTable('paypaluk_api_debug')} ( - `debug_id` int(10) unsigned NOT NULL auto_increment, - `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `request_body` text, - `response_body` text, - PRIMARY KEY (`debug_id`), - KEY `debug_at` (`debug_at`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - "); - -$installer->endSetup(); diff --git a/app/design/frontend/base/default/layout/paypaluk.xml b/app/design/frontend/base/default/layout/paypaluk.xml deleted file mode 100644 index e56c9f90c2f..00000000000 --- a/app/design/frontend/base/default/layout/paypaluk.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - 1 - - - - - 1 - - - - - - - - - - - - - - - - - paypaluk - - - defaultcheckout/cart_item_renderer - groupedcheckout/cart_item_renderer_grouped - configurablecheckout/cart_item_renderer_configurable - - - - - - - skin_jsjs/checkout/review.js - - - - - - defaultcheckout/cart_item_renderer - groupedcheckout/cart_item_renderer_grouped - configurablecheckout/cart_item_renderer_configurable - - - - - - - - - p - paypal-logo - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - after - - - - - diff --git a/app/etc/modules/Mage_PaypalUk.xml b/app/etc/modules/Mage_PaypalUk.xml deleted file mode 100644 index 3e1294b8be2..00000000000 --- a/app/etc/modules/Mage_PaypalUk.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - true - core - - - - - - - - - diff --git a/app/locale/en_US/Mage_PaypalUk.csv b/app/locale/en_US/Mage_PaypalUk.csv deleted file mode 100644 index 94085b297f0..00000000000 --- a/app/locale/en_US/Mage_PaypalUk.csv +++ /dev/null @@ -1,2 +0,0 @@ -"PayPal Express Checkout (Payflow Edition) Shortcut Wrapper","PayPal Express Checkout (Payflow Edition) Shortcut Wrapper" -"PayPal Express Order Review Form","PayPal Express Order Review Form" From 1f30097786ace204242c681e3880b6eeb173d419 Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Wed, 11 Jun 2025 12:59:25 +0200 Subject: [PATCH 02/40] refactor: add paypal/paypal-server-sdk --- composer.json | 1 + composer.lock | 420 +++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 369 insertions(+), 52 deletions(-) diff --git a/composer.json b/composer.json index 8a75b4be6af..bbd76fde70d 100644 --- a/composer.json +++ b/composer.json @@ -37,6 +37,7 @@ "mklkj/tinymce-i18n": "^25.2", "nnnick/chartjs": "^4.4", "openmage/composer-plugin": "^3.0", + "paypal/paypal-server-sdk": "^1.1", "pelago/emogrifier": "^7.0", "phpseclib/mcrypt_compat": "^2.0.3", "phpseclib/phpseclib": "^3.0.14", diff --git a/composer.lock b/composer.lock index c4adef85bb0..eeaf4433128 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,224 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "9b28e4ca972506fbf0f405c2b014d7b5", + "content-hash": "037033d886a52bad856ff19653b42c53", "packages": [ + { + "name": "apimatic/core", + "version": "0.3.14", + "source": { + "type": "git", + "url": "https://github.com/apimatic/core-lib-php.git", + "reference": "c3eaad6cf0c00b793ce6d9bee8b87176247da582" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/apimatic/core-lib-php/zipball/c3eaad6cf0c00b793ce6d9bee8b87176247da582", + "reference": "c3eaad6cf0c00b793ce6d9bee8b87176247da582", + "shasum": "" + }, + "require": { + "apimatic/core-interfaces": "~0.1.5", + "apimatic/jsonmapper": "^3.1.1", + "ext-curl": "*", + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "php": "^7.2 || ^8.0", + "php-jsonpointer/php-jsonpointer": "^3.0.2", + "psr/log": "^1.1.4 || ^2.0.0 || ^3.0.0" + }, + "require-dev": { + "phan/phan": "5.4.5", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Core\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Core logic and the utilities for the Apimatic's PHP SDK", + "homepage": "https://github.com/apimatic/core-lib-php", + "keywords": [ + "apimatic", + "core", + "corelib", + "php" + ], + "support": { + "issues": "https://github.com/apimatic/core-lib-php/issues", + "source": "https://github.com/apimatic/core-lib-php/tree/0.3.14" + }, + "time": "2025-02-27T06:03:30+00:00" + }, + { + "name": "apimatic/core-interfaces", + "version": "0.1.5", + "source": { + "type": "git", + "url": "https://github.com/apimatic/core-interfaces-php.git", + "reference": "b4f1bffc8be79584836f70af33c65e097eec155c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/apimatic/core-interfaces-php/zipball/b4f1bffc8be79584836f70af33c65e097eec155c", + "reference": "b4f1bffc8be79584836f70af33c65e097eec155c", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "CoreInterfaces\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Definition of the behavior of apimatic/core, apimatic/unirest-php and Apimatic's PHP SDK", + "homepage": "https://github.com/apimatic/core-interfaces-php", + "keywords": [ + "apimatic", + "core", + "corelib", + "interface", + "php", + "unirest" + ], + "support": { + "issues": "https://github.com/apimatic/core-interfaces-php/issues", + "source": "https://github.com/apimatic/core-interfaces-php/tree/0.1.5" + }, + "time": "2024-05-09T06:32:07+00:00" + }, + { + "name": "apimatic/jsonmapper", + "version": "3.1.6", + "source": { + "type": "git", + "url": "https://github.com/apimatic/jsonmapper.git", + "reference": "c6cc21bd56bfe5d5822bbd08f514be465c0b24e7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/apimatic/jsonmapper/zipball/c6cc21bd56bfe5d5822bbd08f514be465c0b24e7", + "reference": "c6cc21bd56bfe5d5822bbd08f514be465c0b24e7", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^5.6 || ^7.0 || ^8.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0", + "squizlabs/php_codesniffer": "^3.0.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "apimatic\\jsonmapper\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "OSL-3.0" + ], + "authors": [ + { + "name": "Christian Weiske", + "email": "christian.weiske@netresearch.de", + "homepage": "http://www.netresearch.de/", + "role": "Developer" + }, + { + "name": "Mehdi Jaffery", + "email": "mehdi.jaffery@apimatic.io", + "homepage": "http://apimatic.io/", + "role": "Developer" + } + ], + "description": "Map nested JSON structures onto PHP classes", + "support": { + "email": "mehdi.jaffery@apimatic.io", + "issues": "https://github.com/apimatic/jsonmapper/issues", + "source": "https://github.com/apimatic/jsonmapper/tree/3.1.6" + }, + "time": "2024-11-28T09:15:32+00:00" + }, + { + "name": "apimatic/unirest-php", + "version": "4.0.6", + "source": { + "type": "git", + "url": "https://github.com/apimatic/unirest-php.git", + "reference": "df38c93ffa71e8a1b7a075c2322c28cdfe8fe1f5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/apimatic/unirest-php/zipball/df38c93ffa71e8a1b7a075c2322c28cdfe8fe1f5", + "reference": "df38c93ffa71e8a1b7a075c2322c28cdfe8fe1f5", + "shasum": "" + }, + "require": { + "apimatic/core-interfaces": "^0.1.0", + "ext-curl": "*", + "ext-json": "*", + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "phan/phan": "5.4.2", + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Unirest\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mashape", + "email": "opensource@mashape.com", + "homepage": "https://www.mashape.com", + "role": "Developer" + }, + { + "name": "APIMATIC", + "email": "opensource@apimatic.io", + "homepage": "https://www.apimatic.io", + "role": "Developer" + } + ], + "description": "Unirest PHP", + "homepage": "https://github.com/apimatic/unirest-php", + "keywords": [ + "client", + "curl", + "http", + "https", + "rest" + ], + "support": { + "email": "opensource@apimatic.io", + "issues": "https://github.com/apimatic/unirest-php/issues", + "source": "https://github.com/apimatic/unirest-php/tree/4.0.6" + }, + "time": "2025-04-22T09:12:12+00:00" + }, { "name": "carbonphp/carbon-doctrine-types", "version": "3.2.0", @@ -1536,6 +1752,50 @@ }, "time": "2020-10-15T08:29:30+00:00" }, + { + "name": "paypal/paypal-server-sdk", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/paypal/PayPal-PHP-Server-SDK.git", + "reference": "3964c1732b1815fa8cf8aee37069ccc4e95d9572" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paypal/PayPal-PHP-Server-SDK/zipball/3964c1732b1815fa8cf8aee37069ccc4e95d9572", + "reference": "3964c1732b1815fa8cf8aee37069ccc4e95d9572", + "shasum": "" + }, + "require": { + "apimatic/core": "~0.3.13", + "apimatic/core-interfaces": "~0.1.5", + "apimatic/unirest-php": "^4.0.6", + "ext-curl": "*", + "ext-json": "*", + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "phan/phan": "5.4.5", + "squizlabs/php_codesniffer": "^3.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "PaypalServerSdkLib\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "PayPal's SDK for interacting with the REST APIs", + "homepage": "https://github.com/paypal/PayPal-PHP-Server-SDK", + "support": { + "issues": "https://github.com/paypal/PayPal-PHP-Server-SDK/issues", + "source": "https://github.com/paypal/PayPal-PHP-Server-SDK/tree/1.1.0" + }, + "time": "2025-05-27T17:46:31+00:00" + }, { "name": "pelago/emogrifier", "version": "v7.3.0", @@ -1618,6 +1878,62 @@ }, "time": "2024-10-28T16:12:26+00:00" }, + { + "name": "php-jsonpointer/php-jsonpointer", + "version": "v3.0.2", + "source": { + "type": "git", + "url": "https://github.com/raphaelstolt/php-jsonpointer.git", + "reference": "4428f86c6f23846e9faa5a420c4ef14e485b3afb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/raphaelstolt/php-jsonpointer/zipball/4428f86c6f23846e9faa5a420c4ef14e485b3afb", + "reference": "4428f86c6f23846e9faa5a420c4ef14e485b3afb", + "shasum": "" + }, + "require": { + "php": ">=5.4" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^1.11", + "phpunit/phpunit": "4.6.*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Rs\\Json": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Raphael Stolt", + "email": "raphael.stolt@gmail.com", + "homepage": "http://raphaelstolt.blogspot.com/" + } + ], + "description": "Implementation of JSON Pointer (http://tools.ietf.org/html/rfc6901)", + "homepage": "https://github.com/raphaelstolt/php-jsonpointer", + "keywords": [ + "json", + "json pointer", + "json traversal" + ], + "support": { + "issues": "https://github.com/raphaelstolt/php-jsonpointer/issues", + "source": "https://github.com/raphaelstolt/php-jsonpointer/tree/master" + }, + "time": "2016-08-29T08:51:01+00:00" + }, { "name": "phpseclib/mcrypt_compat", "version": "2.0.6", @@ -1897,6 +2213,56 @@ }, "time": "2021-11-05T16:47:00+00:00" }, + { + "name": "psr/log", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/ef29f6d262798707a9edd554e2b82517ef3a9376", + "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/2.0.0" + }, + "time": "2021-07-14T16:41:46+00:00" + }, { "name": "psr/simple-cache", "version": "3.0.0", @@ -6757,56 +7123,6 @@ }, "time": "2019-01-08T18:20:26+00:00" }, - { - "name": "psr/log", - "version": "2.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/ef29f6d262798707a9edd554e2b82517ef3a9376", - "reference": "ef29f6d262798707a9edd554e2b82517ef3a9376", - "shasum": "" - }, - "require": { - "php": ">=8.0.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "https://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "support": { - "source": "https://github.com/php-fig/log/tree/2.0.0" - }, - "time": "2021-07-14T16:41:46+00:00" - }, { "name": "react/cache", "version": "v1.2.0", @@ -9257,5 +9573,5 @@ "platform-overrides": { "php": "8.1" }, - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } From 48f1b1c37a929eef69db2b151503ce8cf3c9aa91 Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Wed, 11 Jun 2025 18:23:55 +0200 Subject: [PATCH 03/40] refactor: refactor paypal module --- .../Mage/Adminhtml/Helper/Help/Mapping.php | 4 - app/code/core/Mage/Core/Model/Config.php | 1 - .../core_setup/mysql4-upgrade-0.7.3-0.7.4.php | 3 +- .../Mage/Paypal/Block/Adminhtml/Debug.php | 20 + .../Paypal/Block/Adminhtml/Debug/Grid.php | 93 + .../Debug/Grid/Renderer/Exception.php | 24 + .../Adminhtml/Debug/Grid/Renderer/Request.php | 25 + .../Debug/Grid/Renderer/Response.php | 25 + .../Block/Adminhtml/Grid/Renderer/Json.php | 42 + .../Block/Adminhtml/Grid/Renderer/Order.php | 28 + .../core/Mage/Paypal/Block/Adminhtml/Info.php | 119 + .../Block/Adminhtml/Settlement/Details.php | 41 - .../Adminhtml/Settlement/Details/Form.php | 104 - .../Block/Adminhtml/Settlement/Report.php | 42 - .../Adminhtml/Settlement/Report/Grid.php | 123 - .../Adminhtml/System/Config/ApiWizard.php | 92 - .../Adminhtml/System/Config/BmlApiWizard.php | 33 - .../Adminhtml/System/Config/Field/Country.php | 109 +- .../Adminhtml/System/Config/Field/Hidden.php | 28 - .../System/Config/Field/SolutionType.php | 31 - .../System/Config/Fieldset/Deprecated.php | 120 - .../System/Config/Fieldset/Expanded.php | 28 - .../System/Config/Fieldset/Global.php | 211 - .../System/Config/Fieldset/Group.php | 55 - .../Adminhtml/System/Config/Fieldset/Hint.php | 80 - .../System/Config/Fieldset/Location.php | 368 -- .../System/Config/Fieldset/PathDependent.php | 42 - .../System/Config/Fieldset/Payment.php | 125 - .../System/Config/Fieldset/Store.php | 65 - .../System/Config/Payflowlink/Advanced.php | 23 - .../System/Config/Payflowlink/Info.php | 63 - .../core/Mage/Paypal/Block/Bml/Banners.php | 75 - app/code/core/Mage/Paypal/Block/Bml/Form.php | 44 - app/code/core/Mage/Paypal/Block/Button.php | 190 + .../core/Mage/Paypal/Block/Express/Form.php | 47 - .../core/Mage/Paypal/Block/Express/Review.php | 227 - .../Paypal/Block/Express/Review/Billing.php | 43 - .../Paypal/Block/Express/Review/Details.php | 41 - .../Paypal/Block/Express/Review/Shipping.php | 34 - .../Mage/Paypal/Block/Express/Shortcut.php | 196 - app/code/core/Mage/Paypal/Block/Form.php | 92 + .../Mage/Paypal/Block/Hosted/Pro/Form.php | 26 - .../Mage/Paypal/Block/Hosted/Pro/Iframe.php | 36 - .../Mage/Paypal/Block/Hosted/Pro/Info.php | 26 - app/code/core/Mage/Paypal/Block/Iframe.php | 228 - app/code/core/Mage/Paypal/Block/Info.php | 45 + app/code/core/Mage/Paypal/Block/Logo.php | 58 - .../Paypal/Block/Payflow/Advanced/Form.php | 36 - .../Paypal/Block/Payflow/Advanced/Iframe.php | 48 - .../Paypal/Block/Payflow/Advanced/Info.php | 15 - .../Paypal/Block/Payflow/Advanced/Review.php | 16 - .../Mage/Paypal/Block/Payflow/Link/Form.php | 36 - .../Mage/Paypal/Block/Payflow/Link/Iframe.php | 83 - .../Mage/Paypal/Block/Payflow/Link/Info.php | 26 - .../Mage/Paypal/Block/Payflow/Link/Review.php | 27 - .../core/Mage/Paypal/Block/Payment/Info.php | 50 - .../core/Mage/Paypal/Block/Standard/Form.php | 63 - .../Mage/Paypal/Block/Standard/Redirect.php | 42 - .../Paypal/Controller/Express/Abstract.php | 536 -- app/code/core/Mage/Paypal/Exception.php | 13 - app/code/core/Mage/Paypal/Helper/Checkout.php | 78 - app/code/core/Mage/Paypal/Helper/Data.php | 114 +- app/code/core/Mage/Paypal/Helper/Hss.php | 63 - app/code/core/Mage/Paypal/Model/Api.php | 387 ++ .../core/Mage/Paypal/Model/Api/Abstract.php | 574 --- .../core/Mage/Paypal/Model/Api/Exception.php | 23 + .../core/Mage/Paypal/Model/Api/Helper.php | 95 + app/code/core/Mage/Paypal/Model/Api/Nvp.php | 1565 ------ .../Paypal/Model/Api/ProcessableException.php | 53 - .../core/Mage/Paypal/Model/Api/Standard.php | 234 - app/code/core/Mage/Paypal/Model/Bml.php | 38 - app/code/core/Mage/Paypal/Model/Cart.php | 548 +- app/code/core/Mage/Paypal/Model/Cert.php | 115 - app/code/core/Mage/Paypal/Model/Config.php | 1934 +------ app/code/core/Mage/Paypal/Model/Debug.php | 8 + app/code/core/Mage/Paypal/Model/Direct.php | 379 -- app/code/core/Mage/Paypal/Model/Exception.php | 16 + app/code/core/Mage/Paypal/Model/Express.php | 709 --- .../Mage/Paypal/Model/Express/Checkout.php | 1072 ---- app/code/core/Mage/Paypal/Model/Hostedpro.php | 244 - .../Mage/Paypal/Model/Hostedpro/Request.php | 224 - app/code/core/Mage/Paypal/Model/Info.php | 682 --- app/code/core/Mage/Paypal/Model/Ipn.php | 819 --- .../Mage/Paypal/Model/Method/Agreement.php | 325 -- .../core/Mage/Paypal/Model/Mysql4/Cert.php | 16 - .../Paypal/Model/Mysql4/Report/Settlement.php | 14 - .../Model/Mysql4/Report/Settlement/Row.php | 14 - .../Report/Settlement/Row/Collection.php | 16 - .../core/Mage/Paypal/Model/Mysql4/Setup.php | 16 - app/code/core/Mage/Paypal/Model/Observer.php | 139 - .../Mage/Paypal/Model/Payflow/Request.php | 47 - .../Mage/Paypal/Model/Payflowadvanced.php | 44 - .../core/Mage/Paypal/Model/Payflowlink.php | 654 --- .../core/Mage/Paypal/Model/Payflowpro.php | 552 -- .../Mage/Paypal/Model/Payment/Transaction.php | 219 - app/code/core/Mage/Paypal/Model/Paypal.php | 920 ++++ app/code/core/Mage/Paypal/Model/Pro.php | 449 -- .../Mage/Paypal/Model/Report/Settlement.php | 432 -- .../Paypal/Model/Report/Settlement/Row.php | 266 - .../core/Mage/Paypal/Model/Resource/Cert.php | 59 - .../core/Mage/Paypal/Model/Resource/Debug.php | 9 + .../Model/Resource/Debug/Collection.php | 69 + .../Model/Resource/Payment/Transaction.php | 122 - .../Payment/Transaction/Collection.php | 77 - .../Model/Resource/Report/Settlement.php | 105 - .../Model/Resource/Report/Settlement/Row.php | 21 - .../Report/Settlement/Row/Collection.php | 54 - .../core/Mage/Paypal/Model/Resource/Setup.php | 2 +- app/code/core/Mage/Paypal/Model/Session.php | 22 - app/code/core/Mage/Paypal/Model/Standard.php | 199 - .../Model/System/Config/Backend/Cert.php | 58 - .../Model/System/Config/Backend/Cron.php | 40 - .../System/Config/Backend/MerchantCountry.php | 42 +- .../Config/Source/AuthorizationAmounts.php | 27 - .../System/Config/Source/BmlPosition.php | 68 - .../Model/System/Config/Source/BmlSize.php | 151 - .../System/Config/Source/ButtonColors.php | 29 + .../System/Config/Source/ButtonLabels.php | 29 + .../System/Config/Source/ButtonLayouts.php | 17 + .../System/Config/Source/ButtonShapes.php | 21 + .../System/Config/Source/BuyerCountry.php | 25 - .../System/Config/Source/FetchingSchedule.php | 29 - .../Model/System/Config/Source/Logo.php | 22 - .../System/Config/Source/MerchantCountry.php | 81 +- .../System/Config/Source/PaymentActions.php | 28 +- .../Config/Source/PaymentActions/Express.php | 26 - .../Config/Source/RequireBillingAddress.php | 28 - .../Model/System/Config/Source/UrlMethod.php | 27 - .../System/Config/Source/YesnoShortcut.php | 27 - .../core/Mage/Paypal/Model/Validator/Api.php | 28 + .../Mage/Paypal/Model/Validator/Payment.php | 69 + .../core/Mage/Paypal/Model/Webhook/Log.php | 20 + .../core/Mage/Paypal/UnavailableException.php | 13 - .../Adminhtml/Paypal/DebugController.php | 68 + .../Adminhtml/Paypal/ReportsController.php | 120 - .../Paypal/TransactionController.php | 89 + .../Mage/Paypal/controllers/BmlController.php | 27 - .../Paypal/controllers/ExpressController.php | 35 - .../controllers/HostedproController.php | 82 - .../Mage/Paypal/controllers/IpnController.php | 40 - .../Paypal/controllers/PayflowController.php | 132 - .../controllers/PayflowadvancedController.php | 152 - .../Paypal/controllers/PaymentController.php | 487 ++ .../Paypal/controllers/StandardController.php | 98 - .../paypal_setup/data-install-1.6.0.5.php | 36 - .../data-upgrade-1.6.0.2-1.6.0.3.php | 23 - .../data-upgrade-1.6.0.4-1.6.0.5.php | 14 - .../data-upgrade-1.6.0.5-1.6.0.6.php | 30 - app/code/core/Mage/Paypal/etc/adminhtml.xml | 57 +- app/code/core/Mage/Paypal/etc/config.xml | 303 +- app/code/core/Mage/Paypal/etc/system.xml | 4468 +---------------- .../sql/paypal_setup/install-1.6.0.0.php | 156 - .../sql/paypal_setup/install-2.0.0.0.php | 182 + .../sql/paypal_setup/mysql4-install-0.7.0.php | 32 - .../paypal_setup/mysql4-install-1.4.0.0.php | 29 - .../mysql4-upgrade-0.7.1-0.7.2.php | 14 - .../mysql4-upgrade-0.7.2-0.7.3.php | 27 - .../mysql4-upgrade-1.4.0.0-1.4.0.1.php | 53 - .../mysql4-upgrade-1.4.0.1-1.4.0.2.php | 30 - .../mysql4-upgrade-1.5.9.9-1.6.0.0.php | 286 -- .../paypal_setup/upgrade-1.6.0.0-1.6.0.1.php | 40 - .../paypal_setup/upgrade-1.6.0.1-1.6.0.2.php | 18 - .../paypal_setup/upgrade-1.6.0.3-1.6.0.4.php | 17 - app/code/core/Mage/Persistent/etc/config.xml | 8 - app/code/core/Mage/Sales/Model/Order.php | 2 - app/code/core/Mage/Sales/etc/wsdl.xml | 1 - app/code/core/Mage/Sales/etc/wsi.xml | 1 - .../sales_setup/mysql4-install-1.4.0.0.php | 1 - .../mysql4-upgrade-0.9.50-0.9.51.php | 6 +- .../mysql4-upgrade-1.3.99-1.4.0.0.php | 1 - .../default/default/layout/paypal.xml | 20 + .../default/template/paypal/info.phtml | 73 + .../paypal/system/config/api_wizard.phtml | 22 - .../paypal/system/config/bml_api_wizard.phtml | 19 - .../system/config/fieldset/global.phtml | 583 --- .../paypal/system/config/fieldset/hint.phtml | 19 - .../paypal/system/config/fieldset/store.phtml | 84 - .../system/config/payflowlink/advanced.phtml | 22 - .../system/config/payflowlink/info.phtml | 24 - .../frontend/base/default/layout/bml.xml | 111 - .../frontend/base/default/layout/bundle.xml | 22 - .../base/default/layout/downloadable.xml | 22 - .../frontend/base/default/layout/paypal.xml | 168 +- .../frontend/base/default/layout/review.xml | 10 +- .../base/default/template/paypal/bml.phtml | 23 - .../template/paypal/express/review.phtml | 155 - .../paypal/express/review/details.phtml | 47 - .../express/review/shipping/method.phtml | 35 - .../template/paypal/express/shortcut.phtml | 62 - .../default/template/paypal/hss/form.phtml | 28 - .../default/template/paypal/hss/iframe.phtml | 34 - .../default/template/paypal/hss/info.phtml | 18 - .../base/default/template/paypal/hss/js.phtml | 44 - .../template/paypal/hss/redirect.phtml | 45 - .../template/paypal/hss/review/button.phtml | 9 - .../base/default/template/paypal/info.phtml | 11 + .../template/paypal/partner/logo.phtml | 18 - .../template/paypal/partner/us_logo.phtml | 18 - .../paypal/payflowadvanced/iframe.phtml | 31 - .../paypal/payflowadvanced/info.phtml | 17 - .../paypal/payflowadvanced/redirect.phtml | 53 - .../template/paypal/payflowlink/iframe.phtml | 31 - .../template/paypal/payflowlink/info.phtml | 17 - .../paypal/payflowlink/redirect.phtml | 53 - .../default/template/paypal/payment.phtml | 29 + .../template/paypal/payment/mark.phtml | 21 - .../template/paypal/payment/redirect.phtml | 24 - .../frontend/rwd/default/layout/bundle.xml | 21 - .../rwd/default/layout/downloadable.xml | 21 - .../frontend/rwd/default/layout/paypal.xml | 170 - .../frontend/rwd/default/layout/review.xml | 10 +- .../rwd/default/template/paypal/bml.phtml | 32 - .../paypal/express/minicart/shortcut.phtml | 55 - .../paypal/express/product/shortcut.phtml | 51 - .../template/paypal/express/review.phtml | 159 - .../paypal/express/review/address.phtml | 173 - .../paypal/express/review/details.phtml | 47 - .../express/review/shipping/method.phtml | 35 - .../template/paypal/partner/us_logo.phtml | 25 - js/paypal/payment.js | 408 ++ js/varien/payment.js | 2 +- skin/adminhtml/default/default/boxes.css | 17 - skin/frontend/base/default/css/paypal.css | 25 + skin/frontend/base/default/js/msrp.js | 3 - skin/frontend/rwd/default/css/styles.css | 313 -- skin/frontend/rwd/default/scss/_core.scss | 1 - .../rwd/default/scss/core/_common.scss | 46 - .../default/scss/module/_catalog-msrp.scss | 39 - .../default/scss/module/_catalog-product.scss | 56 - .../scss/module/_checkout-cart-minicart.scss | 42 - .../default/scss/module/_checkout-cart.scss | 44 - .../scss/module/_checkout-onepage.scss | 17 - .../rwd/default/scss/module/_paypal.scss | 171 - .../Traits/DataProvider/Base/ModulesTrait.php | 1 - .../Traits/PhpStormMetaData/BlocksTrait.php | 55 - 235 files changed, 4349 insertions(+), 27184 deletions(-) create mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/Debug.php create mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php create mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php create mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php create mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php create mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php create mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php create mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/Info.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Details.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Details/Form.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report/Grid.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/ApiWizard.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/BmlApiWizard.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Hidden.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/SolutionType.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Deprecated.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Expanded.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Global.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Group.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Hint.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Location.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/PathDependent.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Store.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Advanced.php delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Info.php delete mode 100644 app/code/core/Mage/Paypal/Block/Bml/Banners.php delete mode 100644 app/code/core/Mage/Paypal/Block/Bml/Form.php create mode 100644 app/code/core/Mage/Paypal/Block/Button.php delete mode 100644 app/code/core/Mage/Paypal/Block/Express/Form.php delete mode 100644 app/code/core/Mage/Paypal/Block/Express/Review.php delete mode 100644 app/code/core/Mage/Paypal/Block/Express/Review/Billing.php delete mode 100644 app/code/core/Mage/Paypal/Block/Express/Review/Details.php delete mode 100644 app/code/core/Mage/Paypal/Block/Express/Review/Shipping.php delete mode 100644 app/code/core/Mage/Paypal/Block/Express/Shortcut.php create mode 100644 app/code/core/Mage/Paypal/Block/Form.php delete mode 100644 app/code/core/Mage/Paypal/Block/Hosted/Pro/Form.php delete mode 100644 app/code/core/Mage/Paypal/Block/Hosted/Pro/Iframe.php delete mode 100644 app/code/core/Mage/Paypal/Block/Hosted/Pro/Info.php delete mode 100644 app/code/core/Mage/Paypal/Block/Iframe.php create mode 100644 app/code/core/Mage/Paypal/Block/Info.php delete mode 100644 app/code/core/Mage/Paypal/Block/Logo.php delete mode 100644 app/code/core/Mage/Paypal/Block/Payflow/Advanced/Form.php delete mode 100644 app/code/core/Mage/Paypal/Block/Payflow/Advanced/Iframe.php delete mode 100644 app/code/core/Mage/Paypal/Block/Payflow/Advanced/Info.php delete mode 100644 app/code/core/Mage/Paypal/Block/Payflow/Advanced/Review.php delete mode 100644 app/code/core/Mage/Paypal/Block/Payflow/Link/Form.php delete mode 100644 app/code/core/Mage/Paypal/Block/Payflow/Link/Iframe.php delete mode 100644 app/code/core/Mage/Paypal/Block/Payflow/Link/Info.php delete mode 100644 app/code/core/Mage/Paypal/Block/Payflow/Link/Review.php delete mode 100644 app/code/core/Mage/Paypal/Block/Payment/Info.php delete mode 100644 app/code/core/Mage/Paypal/Block/Standard/Form.php delete mode 100644 app/code/core/Mage/Paypal/Block/Standard/Redirect.php delete mode 100644 app/code/core/Mage/Paypal/Controller/Express/Abstract.php delete mode 100644 app/code/core/Mage/Paypal/Exception.php delete mode 100644 app/code/core/Mage/Paypal/Helper/Checkout.php delete mode 100644 app/code/core/Mage/Paypal/Helper/Hss.php create mode 100644 app/code/core/Mage/Paypal/Model/Api.php delete mode 100644 app/code/core/Mage/Paypal/Model/Api/Abstract.php create mode 100644 app/code/core/Mage/Paypal/Model/Api/Exception.php create mode 100644 app/code/core/Mage/Paypal/Model/Api/Helper.php delete mode 100644 app/code/core/Mage/Paypal/Model/Api/Nvp.php delete mode 100644 app/code/core/Mage/Paypal/Model/Api/ProcessableException.php delete mode 100644 app/code/core/Mage/Paypal/Model/Api/Standard.php delete mode 100644 app/code/core/Mage/Paypal/Model/Bml.php delete mode 100644 app/code/core/Mage/Paypal/Model/Cert.php create mode 100644 app/code/core/Mage/Paypal/Model/Debug.php delete mode 100644 app/code/core/Mage/Paypal/Model/Direct.php create mode 100644 app/code/core/Mage/Paypal/Model/Exception.php delete mode 100644 app/code/core/Mage/Paypal/Model/Express.php delete mode 100644 app/code/core/Mage/Paypal/Model/Express/Checkout.php delete mode 100644 app/code/core/Mage/Paypal/Model/Hostedpro.php delete mode 100644 app/code/core/Mage/Paypal/Model/Hostedpro/Request.php delete mode 100644 app/code/core/Mage/Paypal/Model/Info.php delete mode 100644 app/code/core/Mage/Paypal/Model/Ipn.php delete mode 100644 app/code/core/Mage/Paypal/Model/Method/Agreement.php delete mode 100644 app/code/core/Mage/Paypal/Model/Mysql4/Cert.php delete mode 100644 app/code/core/Mage/Paypal/Model/Mysql4/Report/Settlement.php delete mode 100644 app/code/core/Mage/Paypal/Model/Mysql4/Report/Settlement/Row.php delete mode 100644 app/code/core/Mage/Paypal/Model/Mysql4/Report/Settlement/Row/Collection.php delete mode 100644 app/code/core/Mage/Paypal/Model/Mysql4/Setup.php delete mode 100644 app/code/core/Mage/Paypal/Model/Observer.php delete mode 100644 app/code/core/Mage/Paypal/Model/Payflow/Request.php delete mode 100644 app/code/core/Mage/Paypal/Model/Payflowadvanced.php delete mode 100644 app/code/core/Mage/Paypal/Model/Payflowlink.php delete mode 100644 app/code/core/Mage/Paypal/Model/Payflowpro.php delete mode 100644 app/code/core/Mage/Paypal/Model/Payment/Transaction.php create mode 100644 app/code/core/Mage/Paypal/Model/Paypal.php delete mode 100644 app/code/core/Mage/Paypal/Model/Pro.php delete mode 100644 app/code/core/Mage/Paypal/Model/Report/Settlement.php delete mode 100644 app/code/core/Mage/Paypal/Model/Report/Settlement/Row.php delete mode 100644 app/code/core/Mage/Paypal/Model/Resource/Cert.php create mode 100644 app/code/core/Mage/Paypal/Model/Resource/Debug.php create mode 100644 app/code/core/Mage/Paypal/Model/Resource/Debug/Collection.php delete mode 100644 app/code/core/Mage/Paypal/Model/Resource/Payment/Transaction.php delete mode 100644 app/code/core/Mage/Paypal/Model/Resource/Payment/Transaction/Collection.php delete mode 100644 app/code/core/Mage/Paypal/Model/Resource/Report/Settlement.php delete mode 100644 app/code/core/Mage/Paypal/Model/Resource/Report/Settlement/Row.php delete mode 100644 app/code/core/Mage/Paypal/Model/Resource/Report/Settlement/Row/Collection.php delete mode 100644 app/code/core/Mage/Paypal/Model/Session.php delete mode 100644 app/code/core/Mage/Paypal/Model/Standard.php delete mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Backend/Cert.php delete mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Backend/Cron.php delete mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Source/AuthorizationAmounts.php delete mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Source/BmlPosition.php delete mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Source/BmlSize.php create mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonColors.php create mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLabels.php create mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLayouts.php create mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonShapes.php delete mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Source/BuyerCountry.php delete mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Source/FetchingSchedule.php delete mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Source/Logo.php delete mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions/Express.php delete mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Source/RequireBillingAddress.php delete mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Source/UrlMethod.php delete mode 100644 app/code/core/Mage/Paypal/Model/System/Config/Source/YesnoShortcut.php create mode 100644 app/code/core/Mage/Paypal/Model/Validator/Api.php create mode 100644 app/code/core/Mage/Paypal/Model/Validator/Payment.php create mode 100644 app/code/core/Mage/Paypal/Model/Webhook/Log.php delete mode 100644 app/code/core/Mage/Paypal/UnavailableException.php create mode 100644 app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/DebugController.php delete mode 100644 app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php create mode 100644 app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php delete mode 100644 app/code/core/Mage/Paypal/controllers/BmlController.php delete mode 100644 app/code/core/Mage/Paypal/controllers/ExpressController.php delete mode 100644 app/code/core/Mage/Paypal/controllers/HostedproController.php delete mode 100644 app/code/core/Mage/Paypal/controllers/IpnController.php delete mode 100644 app/code/core/Mage/Paypal/controllers/PayflowController.php delete mode 100644 app/code/core/Mage/Paypal/controllers/PayflowadvancedController.php create mode 100644 app/code/core/Mage/Paypal/controllers/PaymentController.php delete mode 100644 app/code/core/Mage/Paypal/controllers/StandardController.php delete mode 100644 app/code/core/Mage/Paypal/data/paypal_setup/data-install-1.6.0.5.php delete mode 100644 app/code/core/Mage/Paypal/data/paypal_setup/data-upgrade-1.6.0.2-1.6.0.3.php delete mode 100644 app/code/core/Mage/Paypal/data/paypal_setup/data-upgrade-1.6.0.4-1.6.0.5.php delete mode 100644 app/code/core/Mage/Paypal/data/paypal_setup/data-upgrade-1.6.0.5-1.6.0.6.php delete mode 100644 app/code/core/Mage/Paypal/sql/paypal_setup/install-1.6.0.0.php create mode 100644 app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php delete mode 100644 app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-install-0.7.0.php delete mode 100644 app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-install-1.4.0.0.php delete mode 100644 app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-0.7.1-0.7.2.php delete mode 100644 app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-0.7.2-0.7.3.php delete mode 100644 app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-1.4.0.0-1.4.0.1.php delete mode 100644 app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-1.4.0.1-1.4.0.2.php delete mode 100644 app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php delete mode 100644 app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.0-1.6.0.1.php delete mode 100644 app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.1-1.6.0.2.php delete mode 100644 app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.3-1.6.0.4.php create mode 100644 app/design/adminhtml/default/default/layout/paypal.xml create mode 100644 app/design/adminhtml/default/default/template/paypal/info.phtml delete mode 100644 app/design/adminhtml/default/default/template/paypal/system/config/api_wizard.phtml delete mode 100644 app/design/adminhtml/default/default/template/paypal/system/config/bml_api_wizard.phtml delete mode 100644 app/design/adminhtml/default/default/template/paypal/system/config/fieldset/global.phtml delete mode 100644 app/design/adminhtml/default/default/template/paypal/system/config/fieldset/hint.phtml delete mode 100644 app/design/adminhtml/default/default/template/paypal/system/config/fieldset/store.phtml delete mode 100644 app/design/adminhtml/default/default/template/paypal/system/config/payflowlink/advanced.phtml delete mode 100644 app/design/adminhtml/default/default/template/paypal/system/config/payflowlink/info.phtml delete mode 100644 app/design/frontend/base/default/layout/bml.xml delete mode 100644 app/design/frontend/base/default/template/paypal/bml.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/express/review.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/express/review/details.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/express/review/shipping/method.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/express/shortcut.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/hss/form.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/hss/iframe.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/hss/info.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/hss/js.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/hss/redirect.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/hss/review/button.phtml create mode 100644 app/design/frontend/base/default/template/paypal/info.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/partner/logo.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/partner/us_logo.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/payflowadvanced/iframe.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/payflowadvanced/info.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/payflowadvanced/redirect.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/payflowlink/iframe.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/payflowlink/info.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/payflowlink/redirect.phtml create mode 100644 app/design/frontend/base/default/template/paypal/payment.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/payment/mark.phtml delete mode 100644 app/design/frontend/base/default/template/paypal/payment/redirect.phtml delete mode 100644 app/design/frontend/rwd/default/layout/paypal.xml delete mode 100644 app/design/frontend/rwd/default/template/paypal/bml.phtml delete mode 100644 app/design/frontend/rwd/default/template/paypal/express/minicart/shortcut.phtml delete mode 100644 app/design/frontend/rwd/default/template/paypal/express/product/shortcut.phtml delete mode 100644 app/design/frontend/rwd/default/template/paypal/express/review.phtml delete mode 100644 app/design/frontend/rwd/default/template/paypal/express/review/address.phtml delete mode 100644 app/design/frontend/rwd/default/template/paypal/express/review/details.phtml delete mode 100644 app/design/frontend/rwd/default/template/paypal/express/review/shipping/method.phtml delete mode 100644 app/design/frontend/rwd/default/template/paypal/partner/us_logo.phtml create mode 100644 js/paypal/payment.js create mode 100644 skin/frontend/base/default/css/paypal.css delete mode 100644 skin/frontend/rwd/default/scss/module/_paypal.scss diff --git a/app/code/core/Mage/Adminhtml/Helper/Help/Mapping.php b/app/code/core/Mage/Adminhtml/Helper/Help/Mapping.php index 5ae2342ae02..84a0f1e6e69 100644 --- a/app/code/core/Mage/Adminhtml/Helper/Help/Mapping.php +++ b/app/code/core/Mage/Adminhtml/Helper/Help/Mapping.php @@ -32,7 +32,6 @@ abstract class Mage_Adminhtml_Helper_Help_Mapping extends Mage_Core_Helper_Abstr 'sales_creditmemo' => 'order-processing/credit-refunds.html', 'sales_transactions' => 'order-processing/sales-transactions.html', 'sales_recurring_profile' => 'catalog/product-recurring-profile.html', - 'sales_billing_agreement' => 'payment/paypal-billing-agreements.html', 'checkout_agreement' => 'order-processing/terms-conditions.html', /* Sales → Tax */ 'tax_rule' => 'tax/tax-rules.html', @@ -174,9 +173,6 @@ abstract class Mage_Adminhtml_Helper_Help_Mapping extends Mage_Core_Helper_Abstr 'Mage_Widget_Adminhtml' => [ 'widget_instance' => 'cms/widgets.html', ], - 'Mage_Paypal_Adminhtml' => [ - 'paypal_reports' => 'store-operations/reports-available.html', - ], 'Mage_Api2_Adminhtml' => [ 'api2_attribute' => 'system-operations/web-services.html', ], diff --git a/app/code/core/Mage/Core/Model/Config.php b/app/code/core/Mage/Core/Model/Config.php index 3b157cfbdc7..67af3ebf8cb 100644 --- a/app/code/core/Mage/Core/Model/Config.php +++ b/app/code/core/Mage/Core/Model/Config.php @@ -56,7 +56,6 @@ class Mage_Core_Model_Config extends Mage_Core_Model_Config_Base 'Mage_Tax' => 38, 'Mage_Wishlist' => 39, 'Mage_Media' => 40, - 'Mage_PaypalUk' => 41, 'Mage_Contacts' => 42, 'Mage_GiftMessage' => 43, 'Mage_Sendfriend' => 44, diff --git a/app/code/core/Mage/Core/sql/core_setup/mysql4-upgrade-0.7.3-0.7.4.php b/app/code/core/Mage/Core/sql/core_setup/mysql4-upgrade-0.7.3-0.7.4.php index be2ee4b292f..2d5d8fb0361 100644 --- a/app/code/core/Mage/Core/sql/core_setup/mysql4-upgrade-0.7.3-0.7.4.php +++ b/app/code/core/Mage/Core/sql/core_setup/mysql4-upgrade-0.7.3-0.7.4.php @@ -14,8 +14,7 @@ $rows = $installer->getConnection()->fetchAll( "select * from {$this->getTable('core_config_data')} where path in ( - 'paypal/wpp/api_password', 'paypal/wpp/api_signature', 'paypal/wpp/api_username', - 'paypal/wps/business_account', 'paypal/wpuk/user', 'paypal/wpuk/pwd', 'carriers/dhl/id', + 'payment/paypal/client_secret', 'carriers/dhl/id', 'carriers/dhl/password', 'carriers/dhl/shipping_key', 'carriers/dhl/shipping_intlkey', 'carriers/fedex/account', 'carriers/ups/account_license_number', 'carriers/ups/username', 'carriers/usps/userid', 'payment/authorizenet/login', 'payment/authorizenet/trans_key', diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug.php new file mode 100644 index 00000000000..826d51de47c --- /dev/null +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug.php @@ -0,0 +1,20 @@ +_blockGroup = 'paypal'; + $this->_controller = 'adminhtml_debug'; + $this->_headerText = Mage::helper('paypal')->__('PayPal Debug Log'); + parent::__construct(); + $this->_removeButton('add'); + + $this->_addButton('delete_all', [ + 'label' => Mage::helper('paypal')->__('Delete All Logs'), + 'onclick' => 'deleteConfirm(\'' . + Mage::helper('paypal')->__('Are you sure you want to delete all debug logs?') . + '\', \'' . $this->getUrl('*/*/deleteAll') . '\')', + 'class' => 'delete' + ]); + } +} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php new file mode 100644 index 00000000000..a4a00802bf6 --- /dev/null +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php @@ -0,0 +1,93 @@ +setId('paypalDebugGrid'); + $this->setDefaultSort('created_at'); + $this->setDefaultDir('DESC'); + $this->setSaveParametersInSession(true); + } + + protected function _prepareCollection() + { + $collection = Mage::getModel('paypal/debug')->getCollection(); + $this->setCollection($collection); + return parent::_prepareCollection(); + } + + protected function _prepareColumns() + { + $this->addColumn('entity_id', [ + 'header' => Mage::helper('paypal')->__('ID'), + 'index' => 'entity_id', + 'type' => 'number', + ]); + + $this->addColumn('quote_id', [ + 'header' => Mage::helper('paypal')->__('Quote #'), + 'index' => 'quote_id', + 'type' => 'number', + ]); + + $this->addColumn('increment_id', [ + 'header' => Mage::helper('paypal')->__('Order #'), + 'index' => 'increment_id', + 'renderer' => 'paypal/adminhtml_grid_renderer_order', + ]); + + + $this->addColumn('action', [ + 'header' => Mage::helper('paypal')->__('Action'), + 'index' => 'action', + ]); + + $this->addColumn('transaction_id', [ + 'header' => Mage::helper('paypal')->__('Transaction ID'), + 'index' => 'transaction_id', + ]); + + $this->addColumn('request_body', [ + 'header' => Mage::helper('paypal')->__('Request'), + 'index' => 'request_body', + 'renderer' => 'paypal/adminhtml_debug_grid_renderer_request', + 'width' => '700px', + ]); + + $this->addColumn('response_body', [ + 'header' => Mage::helper('paypal')->__('Response'), + 'index' => 'response_body', + 'renderer' => 'paypal/adminhtml_debug_grid_renderer_response', + 'width' => '700px', + ]); + + $this->addColumn('exception_message', [ + 'header' => Mage::helper('paypal')->__('Exception'), + 'index' => 'exception_message', + 'renderer' => 'paypal/adminhtml_debug_grid_renderer_exception', + ]); + + $this->addColumn('created_at', [ + 'header' => Mage::helper('paypal')->__('Created At'), + 'index' => 'created_at', + 'type' => 'datetime', + ]); + + return parent::_prepareColumns(); + } + + protected function _prepareMassaction() + { + $this->setMassactionIdField('entity_id'); + $this->getMassactionBlock()->setFormFieldName('debug'); + + $this->getMassactionBlock()->addItem('delete', [ + 'label' => Mage::helper('paypal')->__('Delete'), + 'url' => $this->getUrl('*/*/massDelete'), + 'confirm' => Mage::helper('paypal')->__('Are you sure?') + ]); + + return $this; + } +} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php new file mode 100644 index 00000000000..0360706d69a --- /dev/null +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php @@ -0,0 +1,24 @@ +getData($this->getColumn()->getIndex()); + if (empty($value)) { + return ''; + } + + $escapedValue = $this->escapeHtml($value); + + return '' . $escapedValue . ''; + } +} \ No newline at end of file diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php new file mode 100644 index 00000000000..5c494f901df --- /dev/null +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php @@ -0,0 +1,25 @@ +getData($this->getColumn()->getIndex()); + if (empty($value)) { + return ''; + } + + $formattedValue = $this->_formatJson($value); + $rawValue = $this->escapeHtml($value); + + return '
' . $formattedValue . '
'; + } +} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php new file mode 100644 index 00000000000..b380584bfee --- /dev/null +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php @@ -0,0 +1,25 @@ +getData($this->getColumn()->getIndex()); + if (empty($value)) { + return ''; + } + + $formattedValue = $this->_formatJson($value); + $rawValue = $this->escapeHtml($value); + + return '
' . $formattedValue . '
'; + } +} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php new file mode 100644 index 00000000000..4927d7aee8a --- /dev/null +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php @@ -0,0 +1,42 @@ +jsonDecode($json); + + // Format with proper indentation and spacing + $formattedJson = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); + + // Escape HTML entities + $formattedJson = $this->escapeHtml($formattedJson); + + return sprintf('
%s
', $formattedJson); + } catch (Exception $e) { + return $this->escapeHtml($json); + } + } + + /** + * Render cell content + * + * @param Varien_Object $row + * @return string + */ + public function render(Varien_Object $row) + { + return $this->_formatJson($row->getData($this->getColumn()->getIndex())); + } +} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php new file mode 100644 index 00000000000..e9f24f2718f --- /dev/null +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php @@ -0,0 +1,28 @@ +getData($this->getColumn()->getIndex()); + if (!$incrementId) { + return ''; + } + + $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId); + if (!$order->getId()) { + return $this->escapeHtml($incrementId); + } + + return sprintf( + '%s', + $this->getUrl('*/sales_order/view', ['order_id' => $order->getId()]), + $this->escapeHtml($incrementId) + ); + } +} \ No newline at end of file diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php new file mode 100644 index 00000000000..51b189accf6 --- /dev/null +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php @@ -0,0 +1,119 @@ +setTemplate('paypal/info.phtml'); + } + + /** + * Get transaction ID + * + * @return string|null + */ + public function getTransactionId() + { + return $this->getInfo()->getLastTransId(); + } + + /** + * Get PayPal transaction URL + * + * @return string|null + */ + public function getTransactionUrl() + { + $transactionId = $this->getTransactionId(); + if (!$transactionId) { + return null; + } + + $isSandbox = Mage::getSingleton('paypal/config')->isSandbox(); + return Mage::helper('paypal')->getTransactionUrl($transactionId, $isSandbox); + } + + /** + * Get additional information from payment + * + * @return array + */ + public function getPaymentInfo() + { + $payment = $this->getInfo(); + $info = []; + if ($payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_STATUS)) { + $info[Mage::helper('paypal')->__('Status')] = $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_STATUS); + } + if ($payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID)) { + $info[Mage::helper('paypal')->__('Authorization ID')] = $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID); + if ($payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME)) { + $expirationTime = $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME); + $info[Mage::helper('paypal')->__('Authorization Expires')] = $this->formatExpirationDate($expirationTime); + } + } + + return $info; + } + + /** + * Format expiration date to local timezone + * + * @param string $expirationTime + * @return string + */ + protected function formatExpirationDate($expirationTime) + { + $storeTimezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE); + $date = new DateTime($expirationTime, new DateTimeZone('UTC')); + $date->setTimezone(new DateTimeZone($storeTimezone)); + return $date->format('Y-m-d H:i:s'); + } + + /** + * Check if payment can be reauthorized + * + * @return bool + */ + public function canReauthorize() + { + $payment = $this->getInfo(); + + if ($payment->getMethod() !== 'paypal' || + !$payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID)) { + return false; + } + + $expirationTime = $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME); + if ($expirationTime) { + $now = new DateTime(); + $expDate = new DateTime($expirationTime); + $daysDiff = $now->diff($expDate)->days; + return $daysDiff <= 26; + } + + $authTime = $payment->getCreatedAt(); + $now = new DateTime(); + $authDate = new DateTime($authTime); + $daysDiff = $now->diff($authDate)->days; + + return $daysDiff >= 3; + } + + /** + * Get reauthorize URL + * + * @return string + */ + public function getReauthorizeUrl() + { + return Mage::getUrl('*/paypal_transaction/reauthorize', [ + 'order_id' => $this->getInfo()->getOrder()->getId(), + '_secure' => true + ]); + } +} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Details.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Details.php deleted file mode 100644 index b0e766ce322..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Details.php +++ /dev/null @@ -1,41 +0,0 @@ -_controller = ''; - $this->_headerText = Mage::helper('paypal')->__('View Transaction Details'); - $this->_removeButton('reset') - ->_removeButton('delete') - ->_removeButton('save'); - } - - /** - * Initialize form - * @return $this - */ - protected function _prepareLayout() - { - parent::_prepareLayout(); - $this->setChild('form', $this->getLayout()->createBlock('paypal/adminhtml_settlement_details_form')); - return $this; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Details/Form.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Details/Form.php deleted file mode 100644 index a9f011b1e3c..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Details/Form.php +++ /dev/null @@ -1,104 +0,0 @@ - [ - 'fields' => [ - 'transaction_id' => ['label' => $settlement->getFieldLabel('transaction_id')], - 'invoice_id' => ['label' => $settlement->getFieldLabel('invoice_id')], - 'paypal_reference_id' => ['label' => $settlement->getFieldLabel('paypal_reference_id')], - 'paypal_reference_id_type' => [ - 'label' => $settlement->getFieldLabel('paypal_reference_id_type'), - 'value' => $model->getReferenceType($model->getData('paypal_reference_id_type')), - ], - 'custom_field' => ['label' => $settlement->getFieldLabel('custom_field')], - ], - 'legend' => Mage::helper('paypal')->__('Reference Information'), - ], - - 'transaction_fieldset' => [ - 'fields' => [ - 'transaction_event_code' => [ - 'label' => $settlement->getFieldLabel('transaction_event_code'), - 'value' => sprintf('%s (%s)', $model->getData('transaction_event_code'), $model->getTransactionEvent($model->getData('transaction_event_code'))), - ], - 'transaction_initiation_date' => [ - 'label' => $settlement->getFieldLabel('transaction_initiation_date'), - 'value' => $this->formatDate($model->getData('transaction_initiation_date'), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true), - ], - 'transaction_completion_date' => [ - 'label' => $settlement->getFieldLabel('transaction_completion_date'), - 'value' => $this->formatDate($model->getData('transaction_completion_date'), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true), - ], - 'transaction_debit_or_credit' => [ - 'label' => $settlement->getFieldLabel('transaction_debit_or_credit'), - 'value' => $model->getDebitCreditText($model->getData('transaction_debit_or_credit')), - ], - 'gross_transaction_amount' => [ - 'label' => $settlement->getFieldLabel('gross_transaction_amount'), - 'value' => Mage::app()->getLocale() - ->currency($model->getData('gross_transaction_currency')) - ->toCurrency($model->getData('gross_transaction_amount')), - ], - ], - 'legend' => Mage::helper('paypal')->__('Transaction Information'), - ], - - 'fee_fieldset' => [ - 'fields' => [ - 'fee_debit_or_credit' => [ - 'label' => $settlement->getFieldLabel('fee_debit_or_credit'), - 'value' => $model->getDebitCreditText($model->getData('fee_debit_or_credit')), - ], - 'fee_amount' => [ - 'label' => $settlement->getFieldLabel('fee_amount'), - 'value' => Mage::app()->getLocale() - ->currency($model->getData('fee_currency')) - ->toCurrency($model->getData('fee_amount')), - ], - ], - 'legend' => Mage::helper('paypal')->__('PayPal Fee Information'), - ], - ]; - - $form = new Varien_Data_Form(); - foreach ($fieldsets as $key => $data) { - $fieldset = $form->addFieldset($key, ['legend' => $data['legend']]); - foreach ($data['fields'] as $id => $info) { - $fieldset->addField($id, 'label', [ - 'name' => $id, - 'label' => $info['label'], - 'title' => $info['label'], - 'value' => $info['value'] ?? $model->getData($id), - ]); - } - } - $this->setForm($form); - return parent::_prepareForm(); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report.php deleted file mode 100644 index 1d7e8abf4f4..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report.php +++ /dev/null @@ -1,42 +0,0 @@ -_blockGroup = 'paypal'; - $this->_controller = 'adminhtml_settlement_report'; - $this->_headerText = Mage::helper('paypal')->__('PayPal Settlement Reports'); - parent::__construct(); - $this->_removeButton('add'); - $this->_addButton('fetch', [ - 'label' => Mage::helper('paypal')->__('Fetch Updates'), - 'onclick' => Mage::helper('core/js')->getConfirmSetLocationJs( - $this->getUrl('*/*/fetch'), - Mage::helper('paypal')->__('Connecting to PayPal SFTP server to fetch new reports. Are you sure you want to proceed?'), - ), - 'class' => 'task', - ]); - } - - /** - * @return string - */ - public function getHeaderCssClass() - { - return 'icon-head head-report'; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report/Grid.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report/Grid.php deleted file mode 100644 index 5fe8de933df..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Settlement/Report/Grid.php +++ /dev/null @@ -1,123 +0,0 @@ -setId('settlementGrid'); - $this->setUseAjax(true); - } - - /** - * @inheritDoc - */ - protected function _prepareCollection() - { - $collection = Mage::getResourceModel('paypal/report_settlement_row_collection'); - $this->setCollection($collection); - if (!$this->getParam($this->getVarNameSort())) { - $collection->setOrder('row_id', 'desc'); - } - return parent::_prepareCollection(); - } - - /** - * @inheritDoc - */ - protected function _prepareColumns() - { - $settlement = Mage::getSingleton('paypal/report_settlement'); - $this->addColumn('report_date', [ - 'header' => $settlement->getFieldLabel('report_date'), - 'index' => 'report_date', - 'type' => 'date', - ]); - $this->addColumn('account_id', [ - 'header' => $settlement->getFieldLabel('account_id'), - 'index' => 'account_id', - ]); - $this->addColumn('transaction_id', [ - 'header' => $settlement->getFieldLabel('transaction_id'), - 'index' => 'transaction_id', - ]); - $this->addColumn('invoice_id', [ - 'header' => $settlement->getFieldLabel('invoice_id'), - 'index' => 'invoice_id', - ]); - $this->addColumn('paypal_reference_id', [ - 'header' => $settlement->getFieldLabel('paypal_reference_id'), - 'index' => 'paypal_reference_id', - ]); - $this->addColumn('transaction_event_code', [ - 'header' => $settlement->getFieldLabel('transaction_event'), - 'index' => 'transaction_event_code', - 'type' => 'options', - 'options' => Mage::getModel('paypal/report_settlement_row')->getTransactionEvents(), - ]); - $this->addColumn('transaction_initiation_date', [ - 'header' => $settlement->getFieldLabel('transaction_initiation_date'), - 'index' => 'transaction_initiation_date', - 'type' => 'datetime', - ]); - $this->addColumn('transaction_completion_date', [ - 'header' => $settlement->getFieldLabel('transaction_completion_date'), - 'index' => 'transaction_completion_date', - 'type' => 'datetime', - ]); - $this->addColumn('gross_transaction_amount', [ - 'header' => $settlement->getFieldLabel('gross_transaction_amount'), - 'index' => 'gross_transaction_amount', - 'type' => 'currency', - 'currency' => 'gross_transaction_currency', - ]); - $this->addColumn('fee_amount', [ - 'header' => $settlement->getFieldLabel('fee_amount'), - 'index' => 'fee_amount', - 'type' => 'currency', - 'currency' => 'gross_transaction_currency', - ]); - return parent::_prepareColumns(); - } - - /** - * Return grid URL - * @return string - */ - public function getGridUrl() - { - return $this->getUrl('*/*/grid'); - } - - /** - * Return item view URL - * @return string - */ - public function getRowUrl($item) - { - return $this->getUrl('*/*/details', ['id' => $item->getId()]); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/ApiWizard.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/ApiWizard.php deleted file mode 100644 index 9f9a2447539..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/ApiWizard.php +++ /dev/null @@ -1,92 +0,0 @@ -getTemplate()) { - $this->setTemplate($this->_wizardTemplate); - } - return $this; - } - - /** - * Unset some non-related element parameters - * - * @return string - */ - public function render(Varien_Data_Form_Element_Abstract $element) - { - $element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue(); - return parent::render($element); - } - - /** - * Get the button and scripts contents - * - * @return string - */ - protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) - { - $originalData = $element->getOriginalData(); - $elementHtmlId = $element->getHtmlId(); - $this->addData(array_merge( - $this->_getButtonData($elementHtmlId, $originalData), - $this->_getSandboxButtonData($elementHtmlId, $originalData), - )); - return $this->_toHtml(); - } - - /** - * Prepare button data - * - * @param string $elementHtmlId - * @param array $originalData - * @return array - */ - protected function _getButtonData($elementHtmlId, $originalData) - { - return [ - 'button_label' => Mage::helper('paypal')->__($originalData['button_label']), - 'button_url' => $originalData['button_url'], - 'html_id' => $elementHtmlId, - ]; - } - - /** - * Prepare sandbox button data - * - * @param string $elementHtmlId - * @param array $originalData - * @return array - */ - protected function _getSandboxButtonData($elementHtmlId, $originalData) - { - return [ - 'sandbox_button_label' => Mage::helper('paypal')->__($originalData['sandbox_button_label']), - 'sandbox_button_url' => $originalData['sandbox_button_url'], - 'sandbox_html_id' => 'sandbox_' . $elementHtmlId, - ]; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/BmlApiWizard.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/BmlApiWizard.php deleted file mode 100644 index 0fa4a4bb6f6..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/BmlApiWizard.php +++ /dev/null @@ -1,33 +0,0 @@ -getRequest()->getParam(self::REQUEST_PARAM_COUNTRY); - if ($country) { - $element->setValue($country); - } - - if ($element->getCanUseDefaultValue()) { - $defaultConfigNode = Mage::getConfig()->getNode(null, 'default'); - if ($defaultConfigNode) { - $this->_defaultCountry = (string) $defaultConfigNode->descend('paypal/general/merchant_country'); - } - if (!$this->_defaultCountry) { - $this->_defaultCountry = Mage::helper('core')->getDefaultCountry(); - } - if ($country) { - $shouldInherit = $country == $this->_defaultCountry - && $this->getRequest()->getParam(self::REQUEST_PARAM_DEFAULT); - $element->setInherit($shouldInherit); - } - if ($element->getInherit()) { - $this->_defaultCountry = null; - } - } - - return parent::render($element); - } - - /** - * Get country selector html - * - * @return string - */ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { - $configDataModel = Mage::getSingleton('adminhtml/config_data'); - $urlParams = [ - 'section' => $configDataModel->getSection(), - 'website' => $configDataModel->getWebsite(), - 'store' => $configDataModel->getStore(), - self::REQUEST_PARAM_COUNTRY => '__country__', - ]; - $urlString = $this->helper('core') - ->jsQuoteEscape(Mage::getModel('adminhtml/url')->getUrl('*/*/*', $urlParams)); - $jsString = ' - $("' . $element->getHtmlId() . '").observe("change", function () { - location.href = \'' . $urlString . '\'.replace("__country__", this.value); - }); - '; - - if ($this->_defaultCountry) { - $urlParams[self::REQUEST_PARAM_DEFAULT] = '__default__'; - $urlString = $this->helper('core') - ->jsQuoteEscape(Mage::getModel('adminhtml/url')->getUrl('*/*/*', $urlParams)); - $jsParentCountry = $this->helper('core')->jsQuoteEscape($this->_defaultCountry); - $jsString .= ' - $("' . $element->getHtmlId() . '_inherit").observe("click", function () { - if (this.checked) { - location.href = \'' . $urlString . '\'.replace("__country__", \'' . $jsParentCountry . '\') - .replace("__default__", "1"); - } - }); - '; - } - - /** @var Mage_Adminhtml_Helper_Js $helper */ - $helper = $this->helper('adminhtml/js'); - return parent::_getElementHtml($element) . - $helper->getScript('document.observe("dom:loaded", function() {' . $jsString . '});'); + $countries = Mage::getSingleton('adminhtml/system_config_source_country') + ->toOptionArray(false); + + $element->setValues($countries) + ->setClass('paypal-merchant-country'); + + return parent::_getElementHtml($element); } -} +} \ No newline at end of file diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Hidden.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Hidden.php deleted file mode 100644 index 203c29bfb72..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Hidden.php +++ /dev/null @@ -1,28 +0,0 @@ -getHtmlId() . '" style="display: none;">' . $html . ''; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/SolutionType.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/SolutionType.php deleted file mode 100644 index 8a0c1629e9e..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/SolutionType.php +++ /dev/null @@ -1,31 +0,0 @@ -getConfigurationCountryCode(); - if ($countryCode === 'DE') { - /** @var Mage_Paypal_Block_Adminhtml_System_Config_Field_Hidden $block */ - $block = Mage::getBlockSingleton('paypal/adminhtml_System_config_field_hidden'); - return $block->render($element); - } - - return parent::render($element); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Deprecated.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Deprecated.php deleted file mode 100644 index c759a813807..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Deprecated.php +++ /dev/null @@ -1,120 +0,0 @@ -getGroup($element)->asArray(); - return $groupConfig['was_enabled_path'] ?? ''; - } - - /** - * Check whether solution was enabled - * - * @return bool - */ - protected function _wasActive(Varien_Data_Form_Element_Abstract $element) - { - $wasActiveConfigPath = $this->_getWasActiveConfigPath($element); - return empty($wasActiveConfigPath) - ? false - : (bool) (string) $this->_getConfigDataModel()->getConfigDataValue($wasActiveConfigPath); - } - - /** - * Set solution as was enabled - * - * @return $this - */ - protected function _setWasActive(Varien_Data_Form_Element_Abstract $element) - { - $wasActiveConfigPath = $this->_getWasActiveConfigPath($element); - Mage::getConfig()->saveConfig($wasActiveConfigPath, 1); - return $this; - } - - /** - * Get config data model - * - * @return Mage_Core_Model_Config - */ - protected function _getConfigModel() - { - if (!$this->hasConfigModel()) { - $this->setConfigModel(Mage::getConfig()); - } - - return $this->getConfigModel(); - } - - /** - * Get all websites - * - * @return array - */ - protected function _getWebsites() - { - if (!$this->hasWebsites()) { - $this->setWebsites(Mage::app()->getWebsites()); - } - - return $this->getWebsites(); - } - - /** - * Check whether current payment method is enabled on any scope - * - * @param string $activityPath - * @return bool - */ - public function isPaymentEnabledAnyScope($activityPath) - { - if ((bool) (string) $this->_getConfigModel()->getNode($activityPath, 'default')) { - return true; - } - foreach ($this->_getWebsites() as $website) { - if ((bool) (string) $this->_getConfigModel()->getNode($activityPath, 'website', (int) $website->getId())) { - return true; - } - } - - return false; - } - - /** - * Do not render solution if disabled - * - * @return string - */ - public function render(Varien_Data_Form_Element_Abstract $element) - { - $isPaymentEnabled = $this->_isPaymentEnabled($element, [$this, 'isPaymentEnabledAnyScope']); - if ($this->_wasActive($element) && $isPaymentEnabled) { - return parent::render($element); - } - - if ($isPaymentEnabled) { - $this->_setWasActive($element); - return parent::render($element); - } - - return ''; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Expanded.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Expanded.php deleted file mode 100644 index ad9680f7ca2..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Expanded.php +++ /dev/null @@ -1,28 +0,0 @@ -getUser()->getExtra(); - return $extra['configState'][$element->getId()] ?? true; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Global.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Global.php deleted file mode 100644 index c2d0c00492d..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Global.php +++ /dev/null @@ -1,211 +0,0 @@ -getSortedElements() as $element) { - $htmlId = $element->getHtmlId(); - $this->_elements[$htmlId] = $element; - } - $originalData = $fieldset->getOriginalData(); - $this->addData([ - 'fieldset_label' => $fieldset->getLegend(), - 'fieldset_help_url' => $originalData['help_url'] ?? '', - ]); - return $this->toHtml(); - } - - /** - * Get array of element objects - * - * @return array - */ - public function getElements() - { - return $this->_elements; - } - - /** - * Get element by id - * - * @param string $elementId - * @return Varien_Data_Form_Element_Abstract|false - */ - public function getElement($elementId) - { - return $this->_elements[$elementId] ?? false; - } - - /** - * Return checkbox html with hidden field for correct config values - * - * @return string - */ - public function getElementHtml(Varien_Data_Form_Element_Abstract $element) - { - $configValue = (string) $element->getValue(); - if ($configValue) { - $element->setChecked(true); - } else { - $element->setValue('1'); - } - if ($element->getCanUseDefaultValue() && $element->getInherit()) { - $element->setDisabled(true); - } - - $hidden = new Varien_Data_Form_Element_Hidden([ - 'html_id' => $element->getHtmlId() . '_value', - 'name' => $element->getName(), - 'value' => '0', - ]); - $hidden->setForm($element->getForm()); - return $hidden->getElementHtml() . $element->getElementHtml(); - } - - /** - * Whether element should be rendered in "simplified" mode - * - * @return bool - */ - public function getIsElementSimplified(Varien_Data_Form_Element_Abstract $element) - { - $originalData = $element->getOriginalData(); - return isset($originalData['is_simplified']) && $originalData['is_simplified'] == 1; - } - - /** - * Getter for element label - * - * @return string - */ - public function getElementLabel(Varien_Data_Form_Element_Abstract $element) - { - return $element->getLabel(); - } - - /** - * Getter for element comment - * - * @return string - */ - public function getElementComment(Varien_Data_Form_Element_Abstract $element) - { - return $element->getComment(); - } - - /** - * Getter for element comment - * - * @return string - */ - public function getElementOriginalData(Varien_Data_Form_Element_Abstract $element, $key) - { - $data = $element->getOriginalData(); - return $data[$key] ?? ''; - } - - /** - * Check whether checkbox has "Use default" option or not - * - * @return bool - */ - public function hasInheritElement(Varien_Data_Form_Element_Abstract $element) - { - return (bool) $element->getCanUseDefaultValue(); - } - - /** - * Return "Use default" checkbox html - * - * @return string - */ - public function getInheritElementHtml(Varien_Data_Form_Element_Abstract $element) - { - $elementId = $element->getHtmlId(); - $inheritCheckbox = new Varien_Data_Form_Element_Checkbox([ - 'html_id' => $elementId . '_inherit', - 'name' => preg_replace('/\[value\](\[\])?$/', '[inherit]', $element->getName()), - 'value' => '1', - 'class' => 'checkbox config-inherit', - 'onclick' => 'toggleValueElements(this, $(\'' . $elementId . '\').up())', - ]); - if ($element->getInherit()) { - $inheritCheckbox->setChecked(true); - } - - $inheritCheckbox->setForm($element->getForm()); - return $inheritCheckbox->getElementHtml(); - } - - /** - * Return label for "Use default" checkbox - * - * @return string - */ - public function getInheritElementLabelHtml(Varien_Data_Form_Element_Abstract $element) - { - return sprintf( - '', - $element->getHtmlId() . '_inherit', - $element->getDefaultValue(), - Mage::helper('adminhtml')->__('Use Default'), - ); - } - - /** - * Return element label with tag SPAN - * - * @return string - */ - public function getElementLabelTextHtml(Varien_Data_Form_Element_Abstract $element) - { - return sprintf( - '%s', - $element->getHtmlId() . '_label_text', - $this->escapeHtml($this->getElementLabel($element)), - ); - } - - /** - * Return backend config for element like JSON - * - * @return string - */ - public function getElementBackendConfig(Varien_Data_Form_Element_Abstract $element) - { - return Mage::helper('paypal')->getElementBackendConfig($element); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Group.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Group.php deleted file mode 100644 index d6f455fb730..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Group.php +++ /dev/null @@ -1,55 +0,0 @@ -getGroup($element)->asArray(); - - if (empty($groupConfig['help_url']) || !$element->getComment()) { - return parent::_getHeaderCommentHtml($element); - } - - return '
' . $element->getComment() - . ' ' - . Mage::helper('paypal')->__('Help') . '
'; - } - - /** - * Return collapse state - * - * @param Varien_Data_Form_Element_Abstract $element - * @return int|false - */ - protected function _getCollapseState($element) - { - $extra = Mage::getSingleton('admin/session')->getUser()->getExtra(); - if (isset($extra['configState'][$element->getId()])) { - return $extra['configState'][$element->getId()]; - } - - if ($element->getExpanded() !== null) { - return 1; - } - - return false; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Hint.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Hint.php deleted file mode 100644 index 13029bdc035..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Hint.php +++ /dev/null @@ -1,80 +0,0 @@ -getOriginalData(); - if (isset($elementOriginalData['help_link'])) { - $this->setHelpLink($elementOriginalData['help_link']); - } - $js = ' - paypalToggleSolution = function(id, url) { - var doScroll = false; - Fieldset.toggleCollapse(id, url); - if ($(this).hasClassName("open")) { - $$(".with-button button.button").each(function(anotherButton) { - if (anotherButton != this && $(anotherButton).hasClassName("open")) { - $(anotherButton).click(); - doScroll = true; - } - }.bind(this)); - } - if (doScroll) { - var pos = Element.cumulativeOffset($(this)); - window.scrollTo(pos[0], pos[1] - 45); - } - } - - togglePaypalSolutionConfigureButton = function(button, enable) { - var $button = $(button); - $button.disabled = !enable; - if ($button.hasClassName("disabled") && enable) { - $button.removeClassName("disabled"); - } else if (!$button.hasClassName("disabled") && !enable) { - $button.addClassName("disabled"); - } - } - - // check store-view disabling Express Checkout - document.observe("dom:loaded", function() { - var ecButton = $$(".pp-method-express button.button")[0]; - var ecEnabler = $$(".paypal-ec-enabler")[0]; - if (typeof ecButton == "undefined" || typeof ecEnabler != "undefined") { - return; - } - var $ecButton = $(ecButton); - $$(".with-button button.button").each(function(configureButton) { - if (configureButton != ecButton && !configureButton.disabled - && !$(configureButton).hasClassName("paypal-ec-separate") - ) { - togglePaypalSolutionConfigureButton(ecButton, false); - } - }); - }); - '; - - /** @var Mage_Adminhtml_Helper_Js $helper */ - $helper = $this->helper('adminhtml/js'); - return $this->toHtml() . $helper->getScript($js); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Location.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Location.php deleted file mode 100644 index 923d198f149..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Location.php +++ /dev/null @@ -1,368 +0,0 @@ -helper('core')->jsQuoteEscape($this->__('There is already another PayPal solution enabled. Enable this solution instead?')) . '\'); - } else { - paypalConflictsObject.isConflict = true; - } - confirmationShowed = true; - } - if (conflict && confirmationApproved) { - anotherEnabler.value = 0; - if (anotherEnablerScopeElement && anotherEnablerScopeElement.checked && isEvent) { - paypalConflictsObject.checklessEventAction(anotherEnablerScopeElement, false); - } - paypalConflictsObject.checklessEventAction(anotherEnabler, true); - } - }); - - if (!enabler.enablerObject.ecIndependent) { - if (!isEvent && (typeof ecEnabler == "undefined" || ecEnabler.value == 0)) { - if (!enabler.enablerObject.ecPayflow) { - paypalConflictsObject.ecMissed = true; - } - } else if (isEvent && typeof ecEnabler != "undefined" && confirmationApproved) { - var ecEnablerScopeElement = adminSystemConfig.getScopeElement(ecEnabler); - if (ecEnablerScopeElement && ecEnablerScopeElement.checked) { - paypalConflictsObject.checklessEventAction(ecEnablerScopeElement, false); - } - if (ecEnabler.value == 0) { - ecEnabler.value = 1; - paypalConflictsObject.checklessEventAction(ecEnabler, true); - } - } - } - - if (!confirmationApproved && isEvent) { - enabler.value = 0; - paypalConflictsObject.checklessEventAction(enabler, true); - } - paypalConflictsObject.ecCheckAvailability(); - paypalConflictsObject.sharePayflowEnabling(enabler, isEvent); - }, - - handleBmlEnabler: function(event) { - required = Event.element(event); - var bml = $(required).bmlEnabler; - if (required.value == "1") { - bml.value = "1"; - } - paypalConflictsObject.toggleBmlEnabler(required); - }, - - toggleBmlEnabler: function(required) { - var bml = $(required).bmlEnabler; - if (!bml) { - return; - } - if (required.value != "1") { - bml.value = "0"; - $(bml).disable(); - } - $(bml).requiresObj.indicateEnabled(); - } - }; - - // fill enablers with conflict data - $$(".paypal-enabler").each(function(enablerElement) { - var enablerObj = { - ecIndependent: false, - ecConflicts: false, - ecEnabler: false, - ecSeparate: false, - ecPayflow: false - }; - $(enablerElement).classNames().each(function(className) { - switch (className) { - case "paypal-ec-conflicts": - enablerObj.ecConflicts = true; - case "paypal-ec-independent": - enablerObj.ecIndependent = true; - break; - case "paypal-ec-enabler": - enablerObj.ecEnabler = true; - enablerObj.ecIndependent = true; - break; - case "paypal-ec-separate": - enablerObj.ecSeparate = true; - enablerObj.ecIndependent = true; - break; - case "paypal-ec-pe": - enablerObj.ecPayflow = true; - break; - } - }); - enablerElement.enablerObject = enablerObj; - - Event.observe(enablerElement, "change", paypalConflictsObject.onChangeEnabler); - var enablerScopeElement = adminSystemConfig.getScopeElement(enablerElement); - if (enablerScopeElement) { - Event.observe(enablerScopeElement, "click", paypalConflictsObject.onClickEnablerScope); - } - }); - - // initially uncheck payflow - var ecPayflowEnabler = $$(".paypal-ec-payflow-enabler")[0]; - if (typeof ecPayflowEnabler != "undefined") { - if (ecPayflowEnabler.value == 1) { - ecPayflowEnabler.value = 0; - fireEvent(ecPayflowEnabler, "change"); - } - - var ecPayflowScopeElement = adminSystemConfig.getScopeElement(ecPayflowEnabler); - if (ecPayflowScopeElement && !ecPayflowScopeElement.checked) { - $(ecPayflowScopeElement).click(); - } - } - - $$(".paypal-bml").each(function(bmlEnabler) { - $(bmlEnabler).classNames().each(function(className) { - if (className.indexOf("requires-") !== -1) { - var required = $(className.replace("requires-", "")); - required.bmlEnabler = bmlEnabler; - Event.observe(required, "change", paypalConflictsObject.handleBmlEnabler); - } - }); - }); - - $$(".paypal-enabler").each(function(enablerElement) { - paypalConflictsObject.checkPaymentConflicts(enablerElement, "initial"); - paypalConflictsObject.toggleBmlEnabler(enablerElement); - }); - if (paypalConflictsObject.isConflict || paypalConflictsObject.ecMissed) { - var notification = \'' . $this->helper('core')->jsQuoteEscape($this->__('The following error(s) occured:')) . '\'; - if (paypalConflictsObject.isConflict) { - notification += "\\n " + \'' . $this->helper('core')->jsQuoteEscape($this->__('Some PayPal solutions conflict.')) . '\'; - } - if (paypalConflictsObject.ecMissed) { - notification += "\\n " + \'' . $this->helper('core')->jsQuoteEscape($this->__('PayPal Express Checkout is not enabled.')) . '\'; - } - notification += "\\n" + \'' . $this->helper('core')->jsQuoteEscape($this->__('Please re-enable the previously enabled payment solutions.')) . '\'; - setTimeout(function() { - alert(notification); - }, 1); - } - - $$(".requires").each(function(dependent) { - var $dependent = $(dependent); - if ($dependent.hasClassName("paypal-ec-enabler")) { - $dependent.requiresObj.callback = function(required) { - if ($(required).hasClassName("paypal-enabler") && required.value == 0) { - $dependent.disable(); - } - } - $dependent.requiresObj.requires.each(function(required) { - $dependent.requiresObj.callback(required); - }); - } - }); - - var originalFormValidation = configForm.validator.options.onFormValidate; - configForm.validator.options.onFormValidate = function(result, form) { - originalFormValidation(result, form); - if (result) { - var ecPayflowEnabler = $$(".paypal-ec-payflow-enabler")[0]; - if (typeof ecPayflowEnabler == "undefined") { - return; - } - var ecPayflowScopeElement = adminSystemConfig.getScopeElement(ecPayflowEnabler); - if ((typeof ecPayflowScopeElement == "undefined" || !ecPayflowScopeElement.checked) - && ecPayflowEnabler.value == 1 - ) { - $$(".paypal-ec-enabler").each(function(ecEnabler) { - ecEnabler.value = 0; - }); - } - } - } - }); - '; - - /** @var Mage_Adminhtml_Helper_Js $helper */ - $helper = $this->helper('adminhtml/js'); - return parent::_getExtraJs($element, $tooltipsExist) . $helper->getScript($js); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/PathDependent.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/PathDependent.php deleted file mode 100644 index cb42fec4793..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/PathDependent.php +++ /dev/null @@ -1,42 +0,0 @@ -_getConfigDataModel()->getConfigDataValue($activityPath); - } - - /** - * Do not render solution if disabled - * - * @return string - */ - public function render(Varien_Data_Form_Element_Abstract $element) - { - if (!$this->hasActivePathDependencies($this->getGroup($element)->asArray())) { - return parent::render($element); - } - - return ''; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php deleted file mode 100644 index 31e754ffe21..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Payment.php +++ /dev/null @@ -1,125 +0,0 @@ -_isPaymentEnabled($element) ? ' enabled' : ''); - } - - /** - * Check whether current payment method is enabled - * - * @param Varien_Data_Form_Element_Abstract $element - * @param callback|null $configCallback - * @return bool - */ - protected function _isPaymentEnabled($element, $configCallback = null) - { - $groupConfig = $this->getGroup($element)->asArray(); - $activityPath = $groupConfig['activity_path'] ?? ''; - - if (empty($activityPath)) { - return false; - } - - if ($configCallback && is_callable($configCallback)) { - $isPaymentEnabled = call_user_func($configCallback, $activityPath); - } else { - $isPaymentEnabled = (bool) (string) $this->_getConfigDataModel()->getConfigDataValue($activityPath); - } - - return (bool) $isPaymentEnabled; - } - - /** - * Get config data model - * - * @return Mage_Adminhtml_Model_Config_Data - */ - protected function _getConfigDataModel() - { - if (!$this->hasConfigDataModel()) { - $this->setConfigDataModel(Mage::getSingleton('adminhtml/config_data')); - } - - return $this->getConfigDataModel(); - } - - /** - * Return header title part of html for payment solution - * - * @param Varien_Data_Form_Element_Abstract $element - * @return string - */ - protected function _getHeaderTitleHtml($element) - { - $html = '
' . $element->getLegend(); - - $groupConfig = $this->getGroup($element)->asArray(); - if (!empty($groupConfig['learn_more_link'])) { - $html .= '' - . $this->__('Learn More') . ''; - } - if (!empty($groupConfig['demo_link'])) { - $html .= '' - . $this->__('View Demo') . ''; - } - $html .= ''; - - if ($element->getComment()) { - $html .= '' . $element->getComment() . ''; - } - $html .= '
'; - - return $html . ('
'); - } - - /** - * Return header comment part of html for payment solution - * - * @param Varien_Data_Form_Element_Abstract $element - * @return string - */ - protected function _getHeaderCommentHtml($element) - { - return ''; - } - - /** - * Get collapsed state on-load - * - * @param Varien_Data_Form_Element_Abstract $element - * @return bool - */ - protected function _getCollapseState($element) - { - return false; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Store.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Store.php deleted file mode 100644 index 11c97860177..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Store.php +++ /dev/null @@ -1,65 +0,0 @@ -toHtml(); - } - - /** - * Returns list of disabled (in the Default or the Website Scope) paypal methods - * - * @return array - */ - protected function getPaypalDisabledMethods() - { - // Assoc array that contains info about paypal methods (their IDs and corresponding Config Paths) - $methods = [ - 'express' => 'payment/paypal_express/active', - 'wps' => 'payment/paypal_standard/active', - 'wpp' => 'payment/paypal_direct/active', - 'wpppe' => 'payment/paypaluk_direct/active', - 'verisign' => 'payment/verisign/active', - 'expresspe' => 'payment/paypaluk_express/active', - ]; - // Retrieve a code of the current website - $website = $this->getRequest()->getParam('website'); - - $configRoot = Mage::getConfig()->getNode(null, 'website', $website); - - $disabledMethods = []; - foreach ($methods as $methodId => $methodPath) { - $isEnabled = (int) $configRoot->descend($methodPath); - if ($isEnabled === 0) { - $disabledMethods[$methodId] = $isEnabled; - } - } - - return $disabledMethods; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Advanced.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Advanced.php deleted file mode 100644 index 25938de5d10..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Payflowlink/Advanced.php +++ /dev/null @@ -1,23 +0,0 @@ -getRequest()->getParam('website') || $this->getRequest()->getParam('store')) ? 5 : 4; - return $this->_decorateRowHtml($element, "" . $this->toHtml() . ''); - } - - /** - * Get frontend url - * - * @deprecated since 1.7.0.1 - * @param string $routePath - * @return string - */ - public function getFrontendUrl($routePath) - { - if ($this->getRequest()->getParam('website')) { - $website = Mage::getModel('core/website')->load($this->getRequest()->getParam('website')); - $secure = Mage::getStoreConfigFlag( - Mage_Core_Model_Url::XML_PATH_SECURE_IN_FRONT, - $website->getDefaultStore(), - ); - $path = $secure ? - Mage_Core_Model_Store::XML_PATH_SECURE_BASE_LINK_URL : - Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_LINK_URL; - $websiteUrl = Mage::getStoreConfig($path, $website->getDefaultStore()); - } else { - $secure = Mage::getStoreConfigFlag( - Mage_Core_Model_Url::XML_PATH_SECURE_IN_FRONT, - ); - $websiteUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, $secure); - } - - return $websiteUrl . $routePath; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Bml/Banners.php b/app/code/core/Mage/Paypal/Block/Bml/Banners.php deleted file mode 100644 index 1835a5a7d9c..00000000000 --- a/app/code/core/Mage/Paypal/Block/Bml/Banners.php +++ /dev/null @@ -1,75 +0,0 @@ -_section = $section; - } - - /** - * @param int $position - */ - public function setPosition($position = 0) - { - $this->_position = $position; - } - - /** - * Getter for paypal config - * - * @return Mage_Paypal_Model_Config - */ - protected function _getConfig() - { - return Mage::getSingleton('paypal/config'); - } - - /** - * Disable block output if banner turned off or PublisherId is miss - * - * @return string - */ - protected function _toHtml() - { - if (!$this->_getConfig()->isMethodAvailable(Mage_Paypal_Model_Config::METHOD_BML) - && !$this->_getConfig()->isMethodAvailable(Mage_Paypal_Model_Config::METHOD_WPP_PE_BML) - ) { - return ''; - } - $publisherId = $this->_getConfig()->getBmlPublisherId(); - $display = $this->_getConfig()->getBmlDisplay($this->_section); - $position = $this->_getConfig()->getBmlPosition($this->_section); - if (!$publisherId || $display == 0 || $this->_position != $position) { - return ''; - } - $this->setPublisherId($publisherId); - $this->setSize($this->_getConfig()->getBmlSize($this->_section)); - return parent::_toHtml(); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Bml/Form.php b/app/code/core/Mage/Paypal/Block/Bml/Form.php deleted file mode 100644 index bfde70f094b..00000000000 --- a/app/code/core/Mage/Paypal/Block/Bml/Form.php +++ /dev/null @@ -1,44 +0,0 @@ -_config = Mage::getModel('paypal/config')->setMethod($this->getMethodCode()); - $mark = Mage::getConfig()->getBlockClassName('core/template'); - $mark = new $mark(); - $mark->setTemplate('paypal/payment/mark.phtml') - ->setPaymentAcceptanceMarkHref('https://www.securecheckout.billmelater.com/paycapture-content/' - . 'fetch?hash=AU826TU8&content=/bmlweb/ppwpsiw.html') - ->setPaymentAcceptanceMarkSrc('https://www.paypalobjects.com/webstatic/en_US/i/buttons/' - . 'ppc-acceptance-medium.png') - ->setPaymentWhatIs('See terms'); - $this->setTemplate('paypal/payment/redirect.phtml') - ->setRedirectMessage( - Mage::helper('paypal')->__('You will be redirected to the PayPal website.'), - ) - ->setMethodTitle('') // Output PayPal mark, omit title - ->setMethodLabelAfterHtml($mark->toHtml()); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Button.php b/app/code/core/Mage/Paypal/Block/Button.php new file mode 100644 index 00000000000..25af3f3b983 --- /dev/null +++ b/app/code/core/Mage/Paypal/Block/Button.php @@ -0,0 +1,190 @@ +getButtonConfig(); + } + + /** + * Get PayPal client ID + * + * @return string + */ + public function getClientId() + { + return Mage::helper('paypal')->getConfig()->getApiCredentials()['client_id']; + } + + /** + * Get PayPal SDK URL + * + * @return string + */ + public function getSdkUrl() + { + $config = $this->getButtonConfig(); + $intent = Mage::getSingleton('paypal/config')->getPaymentAction(); + + $params = [ + 'client-id' => $this->getClientId(), + 'components' => 'buttons,messages', + 'intent' => $intent, + 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode() + ]; + + if ($config['message']) { + $params['enable-funding'] = 'paylater'; + } + + return 'https://www.paypal.com/sdk/js?' . http_build_query($params); + } + + /** + * Get form key for CSRF protection + * + * @return string + */ + public function getFormKey() + { + return Mage::getSingleton('core/session')->getFormKey(); + } + + /** + * Check if button should be rendered + * + * @return bool + */ + public function shouldRender() + { + return Mage::helper('paypal')->isAvailable() + && $this->getClientId(); + } + + /** + * Get button container ID + * + * @return string + */ + public function getContainerId() + { + return 'paypal-button-container-' . $this->getNameInLayout(); + } + + /** + * Get button container attributes + * + * @return string + */ + public function getContainerAttributes() + { + return sprintf( + 'id="%s" class="paypal-button-container" data-loading="false" style="min-height: 35px;"', + $this->getContainerId() + ); + } + + /** + * Get button initialization script + * + * @return string + */ + public function getButtonScript() + { + $config = $this->getButtonConfig(); + $containerId = $this->getContainerId(); + + return sprintf( + 'window.paypalLoadPromise = window.paypalLoadPromise || new Promise(function(resolve) { + var script = document.createElement("script"); + script.src = "%s"; + script.onload = resolve; + document.body.appendChild(script); + }); + + window.paypalLoadPromise.then(function() { + var container = document.getElementById("%s"); + container.setAttribute("data-loading", "true"); + + try { + paypal.Buttons({ + style: { + layout: "%s", + color: "%s", + shape: "%s", + label: "%s" + }, + createOrder: function() { + container.setAttribute("data-loading", "true"); + return fetch("%s", { + method: "POST", + headers: { + "Content-Type": "application/json" + } + }) + .then(function(res) { return res.json(); }) + .then(function(data) { + if (!data.success) { + throw new Error(data.error || "Error creating PayPal order"); + } + return data.order_id; + }); + }, + onApprove: function(data) { + container.setAttribute("data-loading", "true"); + return fetch("%s", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify({ + order_id: data.orderID + }) + }) + .then(function(res) { return res.json(); }) + .then(function(data) { + if (!data.success) { + throw new Error(data.error || "Error processing payment"); + } + window.location.href = "%s"; + }); + }, + onError: function(err) { + console.error("PayPal Error:", err); + alert("There was an error with PayPal. Please try again."); + container.setAttribute("data-loading", "false"); + } + }).render("#%s") + .catch(function(err) { + console.error("PayPal Render Error:", err); + container.innerHTML = "
Could not load PayPal button
"; + container.setAttribute("data-loading", "false"); + }); + } catch (err) { + console.error("PayPal Init Error:", err); + container.innerHTML = "
Could not initialize PayPal
"; + container.setAttribute("data-loading", "false"); + } + });', + $this->getSdkUrl(), + $containerId, + $config['layout'], + $config['color'], + $config['shape'], + $config['label'], + $this->getUrl('paypal/payment/createOrder'), + $this->getUrl('paypal/payment/capture'), + $this->getUrl('checkout/onepage/success'), + $containerId + ); + } +} diff --git a/app/code/core/Mage/Paypal/Block/Express/Form.php b/app/code/core/Mage/Paypal/Block/Express/Form.php deleted file mode 100644 index f25a1a73803..00000000000 --- a/app/code/core/Mage/Paypal/Block/Express/Form.php +++ /dev/null @@ -1,47 +0,0 @@ -setRedirectMessage(Mage::helper('paypal')->__('You will be redirected to the PayPal website.')); - } - - /** - * Set data to block - * - * @return Mage_Core_Block_Abstract - */ - protected function _beforeToHtml() - { - $customerId = Mage::getSingleton('customer/session')->getCustomerId(); - if (Mage::helper('paypal')->shouldAskToCreateBillingAgreement($this->_config, $customerId) - && $this->canCreateBillingAgreement() - ) { - $this->setCreateBACode(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT); - } - return parent::_beforeToHtml(); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Express/Review.php b/app/code/core/Mage/Paypal/Block/Express/Review.php deleted file mode 100644 index 747c1c3c08e..00000000000 --- a/app/code/core/Mage/Paypal/Block/Express/Review.php +++ /dev/null @@ -1,227 +0,0 @@ -_quote = $quote; - return $this; - } - - /** - * Return quote billing address - * - * @return Mage_Sales_Model_Quote_Address - */ - public function getBillingAddress() - { - return $this->_quote->getBillingAddress(); - } - - /** - * Return quote shipping address - * - * @return Mage_Sales_Model_Quote_Address|false - */ - public function getShippingAddress() - { - if ($this->_quote->getIsVirtual()) { - return false; - } - return $this->_quote->getShippingAddress(); - } - - /** - * Get HTML output for specified address - * - * @param Mage_Sales_Model_Quote_Address $address - * @return string - */ - public function renderAddress($address) - { - return $address->getFormated(true); - } - - /** - * Return carrier name from config, base on carrier code - * - * @param string $carrierCode - * @return string - */ - public function getCarrierName($carrierCode) - { - if ($name = Mage::getStoreConfig("carriers/{$carrierCode}/title")) { - return $name; - } - return $carrierCode; - } - - /** - * Get either shipping rate code or empty value on error - * - * @return string - */ - public function renderShippingRateValue(Varien_Object $rate) - { - if ($rate->getErrorMessage()) { - return ''; - } - return $rate->getCode(); - } - - /** - * Get shipping rate code title and its price or error message - * - * @param Varien_Object $rate - * @param string $format - * @param string $inclTaxFormat - * @return string - */ - public function renderShippingRateOption($rate, $format = '%s - %s%s', $inclTaxFormat = ' (%s %s)') - { - $renderedInclTax = ''; - if ($rate->getErrorMessage()) { - $price = $rate->getErrorMessage(); - } else { - /** @var Mage_Tax_Helper_Data $helper */ - $helper = $this->helper('tax'); - - $price = $this->_getShippingPrice($rate->getPrice(), $helper->displayShippingPriceIncludingTax()); - $incl = $this->_getShippingPrice($rate->getPrice(), true); - if (($incl != $price) && $helper->displayShippingBothPrices()) { - $renderedInclTax = sprintf($inclTaxFormat, Mage::helper('tax')->__('Incl. Tax'), $incl); - } - } - return sprintf($format, $this->escapeHtml($rate->getMethodTitle()), $price, $renderedInclTax); - } - - /** - * Getter for current shipping rate - * - * @return Mage_Sales_Model_Quote_Address_Rate - */ - public function getCurrentShippingRate() - { - return $this->_currentShippingRate; - } - - /** - * Set paypal actions prefix - * @param string $prefix - */ - public function setPaypalActionPrefix($prefix) - { - $this->_paypalActionPrefix = $prefix; - } - - /** - * Return formatted shipping price - * - * @param float $price - * @param bool $isInclTax - * @return float - */ - protected function _getShippingPrice($price, $isInclTax) - { - /** @var Mage_Tax_Helper_Data $helper */ - $helper = $this->helper('tax'); - return $helper->getShippingPrice($price, $isInclTax, $this->_address); - } - - /** - * Format price base on store convert price method - * - * @param float $price - * @return float - */ - protected function _formatPrice($price) - { - return $this->_quote->getStore()->convertPrice($price, true); - } - - /** - * Retrieve payment method and assign additional template values - * - * @return $this - */ - protected function _beforeToHtml() - { - $methodInstance = $this->_quote->getPayment()->getMethodInstance(); - $this->setPaymentMethodTitle($methodInstance->getTitle()); - - $this->setShippingRateRequired(true); - if ($this->_quote->getIsVirtual()) { - $this->setShippingRateRequired(false); - } else { - // prepare shipping rates - $this->_address = $this->_quote->getShippingAddress(); - $groups = $this->_address->getGroupedAllShippingRates(); - if ($groups && $this->_address) { - $this->setShippingRateGroups($groups); - // determine current selected code & name - foreach ($groups as $code => $rates) { - foreach ($rates as $rate) { - if ($this->_address->getShippingMethod() == $rate->getCode()) { - $this->_currentShippingRate = $rate; - break(2); - } - } - } - } - - $canEditShippingAddress = $this->_quote->getMayEditShippingAddress() && $this->_quote->getPayment() - ->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_BUTTON) == 1; - // misc shipping parameters - $this->setShippingMethodSubmitUrl($this->getUrl("{$this->_paypalActionPrefix}/express/saveShippingMethod")) - ->setCanEditShippingAddress($canEditShippingAddress) - ->setCanEditShippingMethod($this->_quote->getMayEditShippingMethod()) - ; - } - - $this->setEditUrl($this->getUrl("{$this->_paypalActionPrefix}/express/edit")) - ->setPlaceOrderUrl($this->getUrl("{$this->_paypalActionPrefix}/express/placeOrder")); - - return parent::_beforeToHtml(); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Express/Review/Billing.php b/app/code/core/Mage/Paypal/Block/Express/Review/Billing.php deleted file mode 100644 index ea7e7086e97..00000000000 --- a/app/code/core/Mage/Paypal/Block/Express/Review/Billing.php +++ /dev/null @@ -1,43 +0,0 @@ -_address)) { - if ($this->isCustomerLoggedIn() || $this->getQuote()->getBillingAddress()) { - $this->_address = $this->getQuote()->getBillingAddress(); - if (!$this->_address->getFirstname()) { - $this->_address->setFirstname($this->getQuote()->getCustomer()->getFirstname()); - } - if (!$this->_address->getMiddlename()) { - $this->_address->setMiddlename($this->getQuote()->getCustomer()->getMiddlename()); - } - if (!$this->_address->getLastname()) { - $this->_address->setLastname($this->getQuote()->getCustomer()->getLastname()); - } - } else { - $this->_address = Mage::getModel('sales/quote_address'); - } - } - - return $this->_address; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Express/Review/Details.php b/app/code/core/Mage/Paypal/Block/Express/Review/Details.php deleted file mode 100644 index 97ac738e254..00000000000 --- a/app/code/core/Mage/Paypal/Block/Express/Review/Details.php +++ /dev/null @@ -1,41 +0,0 @@ -_address)) { - $this->_address = $this->getQuote()->getShippingAddress(); - } - return $this->_address; - } - - /** - * Return review quote totals - * - * @return array - */ - public function getTotals() - { - return $this->getQuote()->getTotals(); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Express/Review/Shipping.php b/app/code/core/Mage/Paypal/Block/Express/Review/Shipping.php deleted file mode 100644 index 47082eb2567..00000000000 --- a/app/code/core/Mage/Paypal/Block/Express/Review/Shipping.php +++ /dev/null @@ -1,34 +0,0 @@ -_address)) { - if ($this->isCustomerLoggedIn() || $this->getQuote()->getShippingAddress()) { - $this->_address = $this->getQuote()->getShippingAddress(); - } else { - $this->_address = Mage::getModel('sales/quote_address'); - } - } - - return $this->_address; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Express/Shortcut.php b/app/code/core/Mage/Paypal/Block/Express/Shortcut.php deleted file mode 100644 index 5e8ab37cc9e..00000000000 --- a/app/code/core/Mage/Paypal/Block/Express/Shortcut.php +++ /dev/null @@ -1,196 +0,0 @@ -_paymentMethodCode]); - $isInCatalog = $this->getIsInCatalogProduct(); - $quote = ($isInCatalog || $this->getIsQuoteAllowed() == '') - ? null : Mage::getSingleton('checkout/session')->getQuote(); - - // check visibility on cart or product page - $context = $isInCatalog ? 'visible_on_product' : 'visible_on_cart'; - if (!$config->$context) { - $this->_shouldRender = false; - return $result; - } - - if ($isInCatalog) { - /** @var Mage_Catalog_Model_Product $currentProduct */ - $currentProduct = Mage::registry('current_product'); - if (!is_null($currentProduct)) { - $price = (float) $currentProduct->getFinalPrice(); - $typeInstance = $currentProduct->getTypeInstance(); - if (empty($price) && !$currentProduct->isSuper() && !$typeInstance->canConfigure($currentProduct)) { - $this->_shouldRender = false; - return $result; - } - } - } - - // validate minimum quote amount and validate quote for zero grandtotal - if ($quote !== null && (!$quote->validateMinimumAmount() - || (!$quote->getGrandTotal() && !$quote->hasNominalItems())) - ) { - $this->_shouldRender = false; - return $result; - } - - // check payment method availability - $methodInstance = Mage::helper('payment')->getMethodInstance($this->_paymentMethodCode); - if (!$methodInstance || !$methodInstance->isAvailable($quote)) { - $this->_shouldRender = false; - return $result; - } - - // set misc data - /** @var Mage_Core_Helper_Data $helper */ - $helper = $this->helper('core'); - $this->setShortcutHtmlId($helper->uniqHash('ec_shortcut_')) - ->setCheckoutUrl($this->getUrl($this->_startAction)); - - $this->_getBmlShortcut($quote); - - // use static image if in catalog - if ($isInCatalog || $quote === null) { - $this->setImageUrl($config->getExpressCheckoutShortcutImageUrl(Mage::app()->getLocale()->getLocaleCode())); - } else { - $this->setImageUrl(Mage::getModel($this->_checkoutType, [ - 'quote' => $quote, - 'config' => $config, - ])->getCheckoutShortcutImageUrl()); - } - - // ask whether to create a billing agreement - $customerId = Mage::getSingleton('customer/session')->getCustomerId(); // potential issue for caching - if (Mage::helper('paypal')->shouldAskToCreateBillingAgreement($config, $customerId)) { - $this->setConfirmationUrl( - $this->getUrl( - $this->_startAction, - [Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT => 1], - ), - ); - $this->setConfirmationMessage(Mage::helper('paypal')->__('Would you like to sign a billing agreement to streamline further purchases with PayPal?')); - } - - return $result; - } - - /** - * @param Mage_Sales_Model_Quote $quote - * - * @return $this - */ - protected function _getBmlShortcut($quote) - { - /** @var Mage_Core_Helper_Data $helper */ - $helper = $this->helper('core'); - $bml = Mage::helper('payment')->getMethodInstance(Mage_Paypal_Model_Config::METHOD_BML); - $isBmlEnabled = $bml && $bml->isAvailable($quote); - $this->setBmlShortcutHtmlId($helper->uniqHash('ec_shortcut_bml_')) - ->setBmlCheckoutUrl($this->getUrl('paypal/bml/start/button/1')) - ->setBmlImageUrl('https://www.paypalobjects.com/webstatic/en_US/i/buttons/ppcredit-logo-medium.png') - ->setMarketMessage('https://www.paypalobjects.com/webstatic/en_US/btn/btn_bml_text.png') - ->setMarketMessageUrl('https://www.securecheckout.billmelater.com/paycapture-content/' - . 'fetch?hash=AU826TU8&content=/bmlweb/ppwpsiw.html') - ->setIsBmlEnabled($isBmlEnabled); - return $this; - } - - /** - * Render the block if needed - * - * @return string - */ - protected function _toHtml() - { - if (!$this->_shouldRender) { - return ''; - } - return parent::_toHtml(); - } - - /** - * Check is "OR" label position before shortcut - * - * @return bool - */ - public function isOrPositionBefore() - { - return ($this->getIsInCatalogProduct() && !$this->getShowOrPosition()) - || ($this->getShowOrPosition() && $this->getShowOrPosition() === self::POSITION_BEFORE); - } - - /** - * Check is "OR" label position after shortcut - * - * @return bool - */ - public function isOrPositionAfter() - { - return (!$this->getIsInCatalogProduct() && !$this->getShowOrPosition()) - || ($this->getShowOrPosition() && $this->getShowOrPosition() === self::POSITION_AFTER); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Form.php b/app/code/core/Mage/Paypal/Block/Form.php new file mode 100644 index 00000000000..3937315218d --- /dev/null +++ b/app/code/core/Mage/Paypal/Block/Form.php @@ -0,0 +1,92 @@ +setTemplate('paypal/payment.phtml'); + } + + /** + * Get PayPal button configuration + * + * @return array + */ + public function getButtonConfig() + { + return Mage::helper('paypal')->getButtonConfig(); + } + + /** + * Get PayPal endpoint URL + * + * @return string + */ + public function getEndpointUrl() + { + return Mage::helper('paypal')->getConfig()->getEndpoint(); + } + + /** + * Get PayPal client ID + * + * @return string + */ + public function getClientId() + { + return Mage::helper('paypal')->getConfig()->getApiCredentials()['client_id']; + } + + /** + * Get PayPal SDK URL + * + * @return string + */ + public function getSdkUrl() + { + $intent = Mage::getSingleton('paypal/config')->getPaymentAction(); + + $params = array( + 'client-id' => $this->getClientId(), + 'components' => 'buttons', + 'intent' => $intent, + 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode() + ); + + $baseUrl = $this->getEndpointUrl(); + if (substr($baseUrl, -1) !== '/') { + $baseUrl .= '/'; + } + $url = $baseUrl . 'sdk/js?' . http_build_query($params); + return $url; + } + + /** + * Get order amount + * + * @return float + */ + public function getAmount() + { + return $this->getMethod()->getQuote()->getGrandTotal(); + } + + /** + * Get currency code + * + * @return string + */ + public function getCurrencyCode() + { + return Mage::app()->getStore()->getCurrentCurrencyCode(); + } +} diff --git a/app/code/core/Mage/Paypal/Block/Hosted/Pro/Form.php b/app/code/core/Mage/Paypal/Block/Hosted/Pro/Form.php deleted file mode 100644 index 362d092fe42..00000000000 --- a/app/code/core/Mage/Paypal/Block/Hosted/Pro/Form.php +++ /dev/null @@ -1,26 +0,0 @@ -setTemplate('paypal/hss/info.phtml'); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Hosted/Pro/Iframe.php b/app/code/core/Mage/Paypal/Block/Hosted/Pro/Iframe.php deleted file mode 100644 index f7e4d212940..00000000000 --- a/app/code/core/Mage/Paypal/Block/Hosted/Pro/Iframe.php +++ /dev/null @@ -1,36 +0,0 @@ -_paymentMethodCode = Mage_Paypal_Model_Config::METHOD_HOSTEDPRO; - } - - /** - * Get iframe action URL - * @return string - */ - public function getFrameActionUrl() - { - return $this->_getOrder() - ->getPayment() - ->getAdditionalInformation('secure_form_url'); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Hosted/Pro/Info.php b/app/code/core/Mage/Paypal/Block/Hosted/Pro/Info.php deleted file mode 100644 index 9bae4489b0d..00000000000 --- a/app/code/core/Mage/Paypal/Block/Hosted/Pro/Info.php +++ /dev/null @@ -1,26 +0,0 @@ -_getCheckout() - ->getQuote() - ->getPayment() - ->getMethod(); - /** @var Mage_Paypal_Helper_Hss $helper */ - $helper = $this->helper('paypal/hss'); - if (in_array($paymentCode, $helper->getHssMethods())) { - $this->_paymentMethodCode = $paymentCode; - $templatePath = str_replace('_', '', $paymentCode); - $templateFile = "paypal/{$templatePath}/iframe.phtml"; - if (file_exists(Mage::getDesign()->getTemplateFilename($templateFile))) { - $this->setTemplate($templateFile); - } else { - $this->setTemplate('paypal/hss/iframe.phtml'); - } - } - } - - /** - * Get current block instance - * - * @return Mage_Paypal_Block_Iframe - * @throws Mage_Core_Exception - */ - protected function _getBlock() - { - if (!$this->_block) { - $block = $this->getAction() - ->getLayout() - ->createBlock('paypal/' . $this->_paymentMethodCode . '_iframe'); - if (!$block instanceof Mage_Paypal_Block_Iframe) { - Mage::throwException('Invalid block type'); - } - $this->_block = $block; - } - - return $this->_block; - } - - /** - * Get order object - * - * @return Mage_Sales_Model_Order - */ - protected function _getOrder() - { - if (!$this->_order) { - $incrementId = $this->_getCheckout()->getLastRealOrderId(); - $this->_order = Mage::getModel('sales/order') - ->loadByIncrementId($incrementId); - } - return $this->_order; - } - - /** - * Get frontend checkout session object - * - * @return Mage_Checkout_Model_Session - */ - protected function _getCheckout() - { - return Mage::getSingleton('checkout/session'); - } - - /** - * Before rendering html, check if is block rendering needed - * - * @return Mage_Core_Block_Abstract - */ - protected function _beforeToHtml() - { - if ($this->_getOrder()->getId() && - $this->_getOrder()->getQuoteId() == $this->_getCheckout()->getLastQuoteId() && - $this->_paymentMethodCode - ) { - $this->_shouldRender = true; - } - - if ($this->getGotoSection() || $this->getGotoSuccessPage()) { - $this->_shouldRender = true; - } - - return parent::_beforeToHtml(); - } - - /** - * Render the block if needed - * - * @return string - * @throws Exception - */ - protected function _toHtml() - { - if ($this->_isAfterPaymentSave()) { - $this->setTemplate('paypal/hss/js.phtml'); - return parent::_toHtml(); - } - if (!$this->_shouldRender) { - return ''; - } - return parent::_toHtml(); - } - - /** - * Check whether block is rendering after save payment - * - * @return bool - * @throws Exception - */ - protected function _isAfterPaymentSave() - { - $quote = $this->_getCheckout()->getQuote(); - if ($quote->getPayment()->getMethod() == $this->_paymentMethodCode && - $quote->getIsActive() && - $this->getTemplate() && - $this->getRequest()->getActionName() == 'savePayment' - ) { - return true; - } - - return false; - } - - /** - * Get iframe action URL - * - * @return string - * @throws Mage_Core_Exception - */ - public function getFrameActionUrl() - { - return $this->_getBlock()->getFrameActionUrl(); - } - - /** - * Get secure token - * - * @return string - * @throws Mage_Core_Exception - */ - public function getSecureToken() - { - return $this->_getBlock()->getSecureToken(); - } - - /** - * Get secure token ID - * - * @return string - * @throws Mage_Core_Exception - */ - public function getSecureTokenId() - { - return $this->_getBlock()->getSecureTokenId(); - } - - /** - * Get payflow transaction URL - * - * @return string - * @throws Mage_Core_Exception - */ - public function getTransactionUrl() - { - return $this->_getBlock()->getTransactionUrl(); - } - - /** - * Check sandbox mode - * - * @return bool - * @throws Mage_Core_Exception - */ - public function isTestMode() - { - return $this->_getBlock()->isTestMode(); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Info.php b/app/code/core/Mage/Paypal/Block/Info.php new file mode 100644 index 00000000000..0de3d521281 --- /dev/null +++ b/app/code/core/Mage/Paypal/Block/Info.php @@ -0,0 +1,45 @@ +setTemplate('paypal/info.phtml'); + } + + /** + * Get transaction ID + * + * @return string|null + */ + public function getTransactionId() + { + return $this->getInfo()->getLastTransId(); + } + + /** + * Get PayPal transaction URL + * + * @return string|null + */ + public function getTransactionUrl() + { + // Frontend doesn't show transaction URL + return null; + } + + /** + * Get additional information from payment + * + * @return array + */ + public function getPaymentInfo() + { + // Frontend shows minimal information + return []; + } +} diff --git a/app/code/core/Mage/Paypal/Block/Logo.php b/app/code/core/Mage/Paypal/Block/Logo.php deleted file mode 100644 index d397594ae6a..00000000000 --- a/app/code/core/Mage/Paypal/Block/Logo.php +++ /dev/null @@ -1,58 +0,0 @@ -_getConfig()->getPaymentMarkWhatIsPaypalUrl(Mage::app()->getLocale()); - } - - /** - * Getter for paypal config - * - * @return Mage_Paypal_Model_Config - */ - protected function _getConfig() - { - return Mage::getSingleton('paypal/config'); - } - - /** - * Disable block output if logo turned off - * - * @return string - */ - protected function _toHtml() - { - $type = $this->getLogoType(); // assigned in layout etc. - $logoUrl = $this->_getConfig()->getAdditionalOptionsLogoUrl(Mage::app()->getLocale()->getLocaleCode(), $type); - if (!$logoUrl) { - return ''; - } - $country = Mage::getStoreConfig(Mage_Paypal_Helper_Data::MERCHANT_COUNTRY_CONFIG_PATH); - if ($country == Mage_Paypal_Helper_Data::US_COUNTRY) { - $this->setTemplate('paypal/partner/us_logo.phtml'); - return parent::_toHtml(); - } - $this->setLogoImageUrl($logoUrl); - return parent::_toHtml(); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Payflow/Advanced/Form.php b/app/code/core/Mage/Paypal/Block/Payflow/Advanced/Form.php deleted file mode 100644 index ca2b82f6a49..00000000000 --- a/app/code/core/Mage/Paypal/Block/Payflow/Advanced/Form.php +++ /dev/null @@ -1,36 +0,0 @@ -setTemplate('paypal/payflowadvanced/info.phtml'); - } - - /** - * Get frame action URL - * - * @return string - */ - public function getFrameActionUrl() - { - return $this->getUrl('paypal/payflowadvanced/form', ['_secure' => true]); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Payflow/Advanced/Iframe.php b/app/code/core/Mage/Paypal/Block/Payflow/Advanced/Iframe.php deleted file mode 100644 index 454100269ce..00000000000 --- a/app/code/core/Mage/Paypal/Block/Payflow/Advanced/Iframe.php +++ /dev/null @@ -1,48 +0,0 @@ -_paymentMethodCode = Mage_Paypal_Model_Config::METHOD_PAYFLOWADVANCED; - } - - /** - * Get frame action URL - * @return string - */ - public function getFrameActionUrl() - { - return $this->getTransactionUrl() . '?SECURETOKEN=' . $this->getSecureToken() . '&SECURETOKENID=' - . $this->getSecureTokenId() . '&MODE=' . ($this->isTestMode() ? 'TEST' : 'LIVE'); - } - - /** - * Check sandbox mode - * - * @return bool - */ - public function isTestMode() - { - $mode = Mage::helper('payment') - ->getMethodInstance(Mage_Paypal_Model_Config::METHOD_PAYFLOWADVANCED) - ->getConfigData('sandbox_flag'); - return (bool) $mode; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Payflow/Advanced/Info.php b/app/code/core/Mage/Paypal/Block/Payflow/Advanced/Info.php deleted file mode 100644 index bda357ad9da..00000000000 --- a/app/code/core/Mage/Paypal/Block/Payflow/Advanced/Info.php +++ /dev/null @@ -1,15 +0,0 @@ -setTemplate('paypal/payflowlink/info.phtml'); - } - - /** - * Get frame action URL - * - * @return string - */ - public function getFrameActionUrl() - { - return $this->getUrl('paypal/payflow/form', ['_secure' => true]); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Payflow/Link/Iframe.php b/app/code/core/Mage/Paypal/Block/Payflow/Link/Iframe.php deleted file mode 100644 index 750ee5d0d3b..00000000000 --- a/app/code/core/Mage/Paypal/Block/Payflow/Link/Iframe.php +++ /dev/null @@ -1,83 +0,0 @@ -_paymentMethodCode = Mage_Paypal_Model_Config::METHOD_PAYFLOWLINK; - } - - /** - * Get frame action URL - * - * @return string - */ - public function getFrameActionUrl() - { - return $this->getTransactionUrl() . '?SECURETOKEN=' . $this->getSecureToken() . '&SECURETOKENID=' - . $this->getSecureTokenId() . '&MODE=' . ($this->isTestMode() ? 'TEST' : 'LIVE'); - } - - /** - * Get secure token - * - * @return string - */ - public function getSecureToken() - { - return $this->_getOrder() - ->getPayment() - ->getAdditionalInformation('secure_token'); - } - - /** - * Get secure token ID - * - * @return string - */ - public function getSecureTokenId() - { - return $this->_getOrder() - ->getPayment() - ->getAdditionalInformation('secure_token_id'); - } - - /** - * Get payflow transaction URL - * - * @return string - */ - public function getTransactionUrl() - { - return Mage_Paypal_Model_Payflowlink::TRANSACTION_PAYFLOW_URL; - } - - /** - * Check sandbox mode - * - * @return bool - */ - public function isTestMode() - { - $mode = Mage::helper('payment') - ->getMethodInstance($this->_paymentMethodCode) - ->getConfigData('sandbox_flag'); - return (bool) $mode; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Payflow/Link/Info.php b/app/code/core/Mage/Paypal/Block/Payflow/Link/Info.php deleted file mode 100644 index 9f349f5f646..00000000000 --- a/app/code/core/Mage/Paypal/Block/Payflow/Link/Info.php +++ /dev/null @@ -1,26 +0,0 @@ -getInfo()->getMethod())) { - return parent::getCcTypeName(); - } - return null; - } - - /** - * Prepare PayPal-specific payment information - * - * @param Varien_Object|array $transport - * return Varien_Object - * @return Varien_Object - */ - protected function _prepareSpecificInformation($transport = null) - { - $transport = parent::_prepareSpecificInformation($transport); - $payment = $this->getInfo(); - $paypalInfo = Mage::getModel('paypal/info'); - if (!$this->getIsSecureMode()) { - $info = $paypalInfo->getPaymentInfo($payment, true); - } else { - $info = $paypalInfo->getPublicPaymentInfo($payment, true); - } - return $transport->addData($info); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Standard/Form.php b/app/code/core/Mage/Paypal/Block/Standard/Form.php deleted file mode 100644 index 2d8c85b11fa..00000000000 --- a/app/code/core/Mage/Paypal/Block/Standard/Form.php +++ /dev/null @@ -1,63 +0,0 @@ -_config = Mage::getModel('paypal/config')->setMethod($this->getMethodCode()); - $locale = Mage::app()->getLocale(); - $mark = Mage::getConfig()->getBlockClassName('core/template'); - $mark = new $mark(); - $mark->setTemplate('paypal/payment/mark.phtml') - ->setPaymentAcceptanceMarkHref($this->_config->getPaymentMarkWhatIsPaypalUrl($locale)) - ->setPaymentAcceptanceMarkSrc($this->_config->getPaymentMarkImageUrl($locale->getLocaleCode())) - ; // known issue: code above will render only static mark image - $this->setTemplate('paypal/payment/redirect.phtml') - ->setRedirectMessage( - Mage::helper('paypal')->__('You will be redirected to the PayPal website when you place an order.'), - ) - ->setMethodTitle('') // Output PayPal mark, omit title - ->setMethodLabelAfterHtml($mark->toHtml()) - ; - parent::_construct(); - } - - /** - * Payment method code getter - * @return string - */ - public function getMethodCode() - { - return $this->_methodCode; - } -} diff --git a/app/code/core/Mage/Paypal/Block/Standard/Redirect.php b/app/code/core/Mage/Paypal/Block/Standard/Redirect.php deleted file mode 100644 index 5ef8bdd308e..00000000000 --- a/app/code/core/Mage/Paypal/Block/Standard/Redirect.php +++ /dev/null @@ -1,42 +0,0 @@ -setAction($standard->getConfig()->getPaypalUrl()) - ->setId('paypal_standard_checkout') - ->setName('paypal_standard_checkout') - ->setMethod('POST') - ->setUseContainer(true); - foreach ($standard->getStandardCheckoutFormFields() as $field => $value) { - $form->addField($field, 'hidden', ['name' => $field, 'value' => $value]); - } - $idSuffix = Mage::helper('core')->uniqHash(); - $submitButton = new Varien_Data_Form_Element_Submit([ - 'value' => $this->__('Click here if you are not redirected within 10 seconds...'), - ]); - $id = "submit_to_paypal_button_{$idSuffix}"; - $submitButton->setId($id); - $form->addElement($submitButton); - $html = ''; - $html .= $this->__('You will be redirected to the PayPal website in a few seconds.'); - $html .= $form->toHtml(); - $html .= ''; - - return $html . ''; - } -} diff --git a/app/code/core/Mage/Paypal/Controller/Express/Abstract.php b/app/code/core/Mage/Paypal/Controller/Express/Abstract.php deleted file mode 100644 index ebd07f5c8c8..00000000000 --- a/app/code/core/Mage/Paypal/Controller/Express/Abstract.php +++ /dev/null @@ -1,536 +0,0 @@ -_configType, [$this->_configMethod]); - $this->_config = $classInstance; - } - - /** - * Start Express Checkout by requesting initial token and dispatching customer to PayPal - */ - public function startAction() - { - try { - $this->_initCheckout(); - - if ($this->_getQuote()->getIsMultiShipping()) { - $this->_getQuote()->setIsMultiShipping(false); - $this->_getQuote()->removeAllAddresses(); - } - - $customer = Mage::getSingleton('customer/session')->getCustomer(); - $quoteCheckoutMethod = $this->_getQuote()->getCheckoutMethod(); - if ($customer && $customer->getId()) { - $this->_checkout->setCustomerWithAddressChange( - $customer, - $this->_getQuote()->getBillingAddress(), - $this->_getQuote()->getShippingAddress(), - ); - } elseif ((!$quoteCheckoutMethod - || $quoteCheckoutMethod != Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER) - && !Mage::helper('checkout')->isAllowedGuestCheckout( - $this->_getQuote(), - $this->_getQuote()->getStoreId(), - ) - ) { - Mage::getSingleton('core/session')->addNotice( - Mage::helper('paypal')->__('To proceed to Checkout, please log in using your email address.'), - ); - $this->redirectLogin(); - Mage::getSingleton('customer/session') - ->setBeforeAuthUrl(Mage::getUrl('*/*/*', ['_current' => true])); - return; - } - - // billing agreement - $isBARequested = (bool) $this->getRequest() - ->getParam(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT); - if ($customer && $customer->getId()) { - $this->_checkout->setIsBillingAgreementRequested($isBARequested); - } - - // Bill Me Later - $this->_checkout->setIsBml((bool) $this->getRequest()->getParam('bml')); - - // giropay - $this->_checkout->prepareGiropayUrls( - Mage::getUrl('checkout/onepage/success'), - Mage::getUrl('paypal/express/cancel'), - Mage::getUrl('checkout/onepage/success'), - ); - - $button = (bool) $this->getRequest()->getParam(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_BUTTON); - $token = $this->_checkout->start(Mage::getUrl('*/*/return'), Mage::getUrl('*/*/cancel'), $button); - if ($token && $url = $this->_checkout->getRedirectUrl()) { - $this->_initToken($token); - $this->getResponse()->setRedirect($url); - return; - } - } catch (Mage_Core_Exception $e) { - $this->_getCheckoutSession()->addError($e->getMessage()); - } catch (Exception $e) { - $this->_getCheckoutSession()->addError($this->__('Unable to start Express Checkout.')); - Mage::logException($e); - } - - $this->_redirect('checkout/cart'); - } - - /** - * Return shipping options items for shipping address from request - */ - public function shippingOptionsCallbackAction() - { - try { - $quoteId = $this->getRequest()->getParam('quote_id'); - $this->_quote = Mage::getModel('sales/quote')->load($quoteId); - $this->_initCheckout(); - $response = $this->_checkout->getShippingOptionsCallbackResponse($this->getRequest()->getParams()); - $this->getResponse()->setBody($response); - } catch (Exception $e) { - Mage::logException($e); - } - } - - /** - * Cancel Express Checkout - */ - public function cancelAction() - { - try { - $this->_initToken(false); - // TODO verify if this logic of order cancellation is deprecated - // if there is an order - cancel it - $orderId = $this->_getCheckoutSession()->getLastOrderId(); - $order = ($orderId) ? Mage::getModel('sales/order')->load($orderId) : false; - if ($order && $order->getId() && $order->getQuoteId() == $this->_getCheckoutSession()->getQuoteId()) { - $order->cancel()->save(); - $this->_getCheckoutSession() - ->unsLastQuoteId() - ->unsLastSuccessQuoteId() - ->unsLastOrderId() - ->unsLastRealOrderId() - ->addSuccess($this->__('Express Checkout and Order have been canceled.')) - ; - } else { - $this->_getCheckoutSession()->addSuccess($this->__('Express Checkout has been canceled.')); - } - } catch (Mage_Core_Exception $e) { - $this->_getCheckoutSession()->addError($e->getMessage()); - } catch (Exception $e) { - $this->_getCheckoutSession()->addError($this->__('Unable to cancel Express Checkout.')); - Mage::logException($e); - } - - $this->_redirect('checkout/cart'); - } - - /** - * Return from PayPal and dispatch customer to order review page - */ - public function returnAction() - { - if ($this->getRequest()->getParam('retry_authorization') == 'true' - && is_array($this->_getCheckoutSession()->getPaypalTransactionData()) - ) { - $this->_forward('placeOrder'); - return; - } - try { - $this->_getCheckoutSession()->unsPaypalTransactionData(); - $this->_checkout = $this->_initCheckout(); - $this->_checkout->returnFromPaypal($this->_initToken()); - - if ($this->_checkout->canSkipOrderReviewStep()) { - $this->_forward('placeOrder'); - } else { - $this->_redirect('*/*/review'); - } - - return; - } catch (Mage_Core_Exception $e) { - Mage::getSingleton('checkout/session')->addError($e->getMessage()); - } catch (Exception $e) { - Mage::getSingleton('checkout/session')->addError($this->__('Unable to process Express Checkout approval.')); - Mage::logException($e); - } - $this->_redirect('checkout/cart'); - } - - /** - * Review order after returning from PayPal - */ - public function reviewAction() - { - try { - $this->_initCheckout(); - $this->_checkout->prepareOrderReview($this->_initToken()); - $this->loadLayout(); - $this->_initLayoutMessages('paypal/session'); - $reviewBlock = $this->getLayout()->getBlock('paypal.express.review'); - $reviewBlock->setQuote($this->_getQuote()); - $reviewBlock->getChild('details')->setQuote($this->_getQuote()); - if ($reviewBlock->getChild('shipping_method')) { - $reviewBlock->getChild('shipping_method')->setQuote($this->_getQuote()); - } - $this->renderLayout(); - return; - } catch (Mage_Core_Exception $e) { - Mage::getSingleton('checkout/session')->addError($e->getMessage()); - } catch (Exception $e) { - Mage::getSingleton('checkout/session')->addError( - $this->__('Unable to initialize Express Checkout review.'), - ); - Mage::logException($e); - } - $this->_redirect('checkout/cart'); - } - - /** - * Dispatch customer back to PayPal for editing payment information - */ - public function editAction() - { - try { - $this->getResponse()->setRedirect($this->_config->getExpressCheckoutEditUrl($this->_initToken())); - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - $this->_redirect('*/*/review'); - } - } - - /** - * Update shipping method (combined action for ajax and regular request) - */ - public function saveShippingMethodAction() - { - try { - $isAjax = $this->getRequest()->getParam('isAjax'); - $this->_initCheckout(); - $this->_checkout->updateShippingMethod($this->getRequest()->getParam('shipping_method')); - if ($isAjax) { - $this->loadLayout('paypal_express_review_details'); - $this->getResponse()->setBody($this->getLayout()->getBlock('root') - ->setQuote($this->_getQuote()) - ->toHtml()); - return; - } - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - } catch (Exception $e) { - $this->_getSession()->addError($this->__('Unable to update shipping method.')); - Mage::logException($e); - } - if (isset($isAjax) && $isAjax) { - $this->getResponse()->setBody(''); - } else { - $this->_redirect('*/*/review'); - } - } - - /** - * Update Order (combined action for ajax and regular request) - */ - public function updateShippingMethodsAction() - { - try { - $this->_initCheckout(); - $this->_checkout->prepareOrderReview($this->_initToken()); - $this->loadLayout('paypal_express_review'); - - $this->getResponse()->setBody($this->getLayout()->getBlock('express.review.shipping.method') - ->setQuote($this->_getQuote()) - ->toHtml()); - return; - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - } catch (Exception $e) { - $this->_getSession()->addError($this->__('Unable to update shipping method.')); - Mage::logException($e); - } - $this->getResponse()->setBody(''); - } - - /** - * Submit the order - */ - public function placeOrderAction() - { - try { - $requiredAgreements = Mage::helper('checkout')->getRequiredAgreementIds(); - if ($requiredAgreements) { - $postedAgreements = array_keys($this->getRequest()->getPost('agreement', [])); - if (array_diff($requiredAgreements, $postedAgreements)) { - Mage::throwException(Mage::helper('paypal')->__('Please agree to all the terms and conditions before placing the order.')); - } - } - - $this->_initCheckout(); - $this->_checkout->place($this->_initToken()); - - // prepare session to success or cancellation page - $session = $this->_getCheckoutSession(); - $session->clearHelperData(); - - // "last successful quote" - $quoteId = $this->_getQuote()->getId(); - $session->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId); - - // an order may be created - $order = $this->_checkout->getOrder(); - if ($order) { - $session->setLastOrderId($order->getId()) - ->setLastRealOrderId($order->getIncrementId()); - // as well a billing agreement can be created - $agreement = $this->_checkout->getBillingAgreement(); - if ($agreement) { - $session->setLastBillingAgreementId($agreement->getId()); - } - } - - // recurring profiles may be created along with the order or without it - $profiles = $this->_checkout->getRecurringPaymentProfiles(); - if ($profiles) { - $ids = []; - foreach ($profiles as $profile) { - $ids[] = $profile->getId(); - } - $session->setLastRecurringProfileIds($ids); - } - - // redirect if PayPal specified some URL (for example, to Giropay bank) - $url = $this->_checkout->getRedirectUrl(); - if ($url) { - $this->getResponse()->setRedirect($url); - return; - } - $this->_initToken(false); // no need in token anymore - $this->_redirect('checkout/onepage/success'); - return; - } catch (Mage_Paypal_Model_Api_ProcessableException $e) { - $this->_processPaypalApiError($e); - } catch (Mage_Core_Exception $e) { - Mage::helper('checkout')->sendPaymentFailedEmail($this->_getQuote(), $e->getMessage()); - $this->_getSession()->addError($e->getMessage()); - $this->_redirect('*/*/review'); - } catch (Exception $e) { - Mage::helper('checkout')->sendPaymentFailedEmail( - $this->_getQuote(), - $this->__('Unable to place the order.'), - ); - $this->_getSession()->addError($this->__('Unable to place the order.')); - Mage::logException($e); - $this->_redirect('*/*/review'); - } - } - - /** - * Process PayPal API's processable errors - * - * @param Mage_Paypal_Model_Api_ProcessableException $exception - */ - protected function _processPaypalApiError($exception) - { - switch ($exception->getCode()) { - case Mage_Paypal_Model_Api_ProcessableException::API_MAX_PAYMENT_ATTEMPTS_EXCEEDED: - case Mage_Paypal_Model_Api_ProcessableException::API_TRANSACTION_EXPIRED: - $this->getResponse()->setRedirect( - $this->_getQuote()->getPayment()->getCheckoutRedirectUrl(), - ); - break; - case Mage_Paypal_Model_Api_ProcessableException::API_DO_EXPRESS_CHECKOUT_FAIL: - $this->_redirectSameToken(); - break; - case Mage_Paypal_Model_Api_ProcessableException::API_UNABLE_TRANSACTION_COMPLETE: - if ($this->_config->getPaymentAction() == Mage_Payment_Model_Method_Abstract::ACTION_ORDER) { - $paypalTransactionData = $this->_getCheckoutSession()->getPaypalTransactionData(); - $this->getResponse()->setRedirect( - $this->_config->getExpressCheckoutOrderUrl($paypalTransactionData['transaction_id']), - ); - } else { - $this->_redirectSameToken(); - } - break; - default: - $this->_redirectToCartAndShowError($exception->getUserMessage()); - break; - } - } - - /** - * Redirect customer back to PayPal with the same token - */ - protected function _redirectSameToken() - { - $token = $this->_initToken(); - $this->getResponse()->setRedirect( - $this->_config->getExpressCheckoutStartUrl($token), - ); - } - - /** - * Redirect customer to shopping cart and show error message - * - * @param string $errorMessage - */ - protected function _redirectToCartAndShowError($errorMessage) - { - $cart = Mage::getSingleton('checkout/cart'); - $cart->getCheckoutSession()->addError($errorMessage); - $this->_redirect('checkout/cart'); - } - - /** - * Instantiate quote and checkout - * - * @return Mage_Paypal_Model_Express_Checkout - * @throws Mage_Core_Exception - */ - protected function _initCheckout() - { - $quote = $this->_getQuote(); - if (!$quote->hasItems() || $quote->getHasError()) { - $this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden'); - Mage::throwException(Mage::helper('paypal')->__('Unable to initialize Express Checkout.')); - } - - /** @var Mage_Paypal_Model_Express_Checkout $classInstance */ - $classInstance = Mage::getSingleton($this->_checkoutType, [ - 'config' => $this->_config, - 'quote' => $quote, - ]); - $this->_checkout = $classInstance; - return $this->_checkout; - } - - /** - * Search for proper checkout token in request or session or (un)set specified one - * Combined getter/setter - * - * @param string $setToken - * @return $this|string - */ - protected function _initToken($setToken = null) - { - if ($setToken !== null) { - if ($setToken === false) { - // security measure for avoid unsetting token twice - if (!$this->_getSession()->getExpressCheckoutToken()) { - Mage::throwException($this->__('PayPal Express Checkout Token does not exist.')); - } - $this->_getSession()->unsExpressCheckoutToken(); - } else { - $this->_getSession()->setExpressCheckoutToken($setToken); - } - return $this; - } - if ($setToken = $this->getRequest()->getParam('token')) { - if ($setToken !== $this->_getSession()->getExpressCheckoutToken()) { - Mage::throwException($this->__('Wrong PayPal Express Checkout Token specified.')); - } - } else { - $setToken = $this->_getSession()->getExpressCheckoutToken(); - } - return $setToken; - } - - /** - * PayPal session instance getter - * - * @return Mage_Paypal_Model_Session - */ - private function _getSession() - { - return Mage::getSingleton('paypal/session'); - } - - /** - * Return checkout session object - * - * @return Mage_Checkout_Model_Session - */ - protected function _getCheckoutSession() - { - return Mage::getSingleton('checkout/session'); - } - - /** - * Return checkout quote object - * - * @return Mage_Sales_Model_Quote - */ - private function _getQuote() - { - if (!$this->_quote) { - $this->_quote = $this->_getCheckoutSession()->getQuote(); - } - return $this->_quote; - } - - /** - * Redirect to login page - * - */ - public function redirectLogin() - { - $this->setFlag('', 'no-dispatch', true); - $this->getResponse()->setRedirect( - Mage::helper('core/url')->addRequestParam( - Mage::helper('customer')->getLoginUrl(), - ['context' => 'checkout'], - ), - ); - } -} diff --git a/app/code/core/Mage/Paypal/Exception.php b/app/code/core/Mage/Paypal/Exception.php deleted file mode 100644 index 5528c9507df..00000000000 --- a/app/code/core/Mage/Paypal/Exception.php +++ /dev/null @@ -1,13 +0,0 @@ -_getCheckoutSession()->getLastRealOrder(); - if ($order->getId()) { - $quote = $this->_getQuote($order->getQuoteId()); - if ($quote->getId()) { - $quote->setIsActive(1) - ->setReservedOrderId(null) - ->save(); - $this->_getCheckoutSession() - ->replaceQuote($quote) - ->unsLastRealOrderId(); - return true; - } - } - return false; - } - - /** - * Cancel last placed order with specified comment message - * - * @param string $comment Comment appended to order history - * @return bool True if order cancelled, false otherwise - */ - public function cancelCurrentOrder($comment) - { - $order = $this->_getCheckoutSession()->getLastRealOrder(); - if ($order->getId() && $order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) { - $order->registerCancellation($comment)->save(); - return true; - } - return false; - } - - /** - * Return checkout session instance - * - * @return Mage_Checkout_Model_Session - */ - protected function _getCheckoutSession() - { - return Mage::getSingleton('checkout/session'); - } - - /** - * Return sales quote instance for specified ID - * - * @param int $quoteId Quote identifier - * @return Mage_Sales_Model_Quote - */ - protected function _getQuote($quoteId) - { - return Mage::getModel('sales/quote')->load($quoteId); - } -} diff --git a/app/code/core/Mage/Paypal/Helper/Data.php b/app/code/core/Mage/Paypal/Helper/Data.php index 6522de53d95..f9494dd2abd 100644 --- a/app/code/core/Mage/Paypal/Helper/Data.php +++ b/app/code/core/Mage/Paypal/Helper/Data.php @@ -1,119 +1,71 @@ setStoreId($store); + } /** - * Check whether customer should be asked confirmation whether to sign a billing agreement + * Check if PayPal is available * - * @param int $customerId + * @param mixed $store * @return bool */ - public function shouldAskToCreateBillingAgreement(Mage_Paypal_Model_Config $config, $customerId) + public function isAvailable($store = null) { - if (self::$_shouldAskToCreateBillingAgreement === null) { - self::$_shouldAskToCreateBillingAgreement = false; - if ($customerId && $config->shouldAskToCreateBillingAgreement()) { - if (Mage::getModel('sales/billing_agreement')->needToCreateForCustomer($customerId)) { - self::$_shouldAskToCreateBillingAgreement = true; - } - } - } - return self::$_shouldAskToCreateBillingAgreement; + return $this->getConfig($store)->isActive(); } /** - * Return backend config for element like JSON + * Get PayPal button configuration * - * @return false|string + * @param mixed $store + * @return array */ - public function getElementBackendConfig(Varien_Data_Form_Element_Abstract $element) + public function getButtonConfig($store = null) { - $config = $element->getFieldConfig()->backend_congif; - if (!$config) { - return false; - } - $config = $config->asCanonicalArray(); - if (isset($config['enable_for_countries'])) { - $config['enable_for_countries'] = explode(',', str_replace(' ', '', $config['enable_for_countries'])); - } - if (isset($config['disable_for_countries'])) { - $config['disable_for_countries'] = explode(',', str_replace(' ', '', $config['disable_for_countries'])); - } - return Mage::helper('core')->jsonEncode($config); + return $this->getConfig($store)->getButtonConfiguration(); } /** - * Get selected merchant country code in system configuration + * Format price for PayPal API * + * @param float $amount * @return string */ - public function getConfigurationCountryCode() + public function formatPrice($amount) { - $requestParam = Mage_Paypal_Block_Adminhtml_System_Config_Field_Country::REQUEST_PARAM_COUNTRY; - $countryCode = Mage::app()->getRequest()->getParam($requestParam); - if (is_null($countryCode) || preg_match('/^[a-zA-Z]{2}$/', $countryCode) == 0) { - $countryCode = (string) Mage::getSingleton('adminhtml/config_data') - ->getConfigDataValue(self::MERCHANT_COUNTRY_CONFIG_PATH); - } - if (empty($countryCode)) { - $countryCode = Mage::helper('core')->getDefaultCountry(); - } - return $countryCode; + return number_format($amount, 2, '.', ''); } /** - * Get HTML representation of transaction id + * Get transaction URL in PayPal merchant dashboard * - * @param string $methodCode - * @param string $txnId + * @param string $transactionId + * @param bool $sandbox * @return string */ - public function getHtmlTransactionId($methodCode, $txnId) + public function getTransactionUrl($transactionId, $sandbox = false) { - if (in_array($methodCode, [ - Mage_Paypal_Model_Config::METHOD_WPP_DIRECT, - Mage_Paypal_Model_Config::METHOD_WPP_EXPRESS, - Mage_Paypal_Model_Config::METHOD_HOSTEDPRO, - Mage_Paypal_Model_Config::METHOD_WPS, - ]) - ) { - /** @var Mage_Paypal_Model_Config $config */ - $config = Mage::getModel('paypal/config')->setMethod($methodCode); - $url = 'https://www.' . ($config->sandboxFlag ? 'sandbox.' : '') - . 'paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=' . $txnId; - return '' . $txnId . ''; + if (strpos($transactionId, '-') !== false) { + $parts = explode('-', $transactionId); + $transactionId = $parts[0]; } - return $txnId; + + $baseUrl = $sandbox + ? 'https://www.sandbox.paypal.com/activity/payment/' + : 'https://www.paypal.com/activity/payment/'; + return $baseUrl . $transactionId; } } diff --git a/app/code/core/Mage/Paypal/Helper/Hss.php b/app/code/core/Mage/Paypal/Helper/Hss.php deleted file mode 100644 index ad18a701628..00000000000 --- a/app/code/core/Mage/Paypal/Helper/Hss.php +++ /dev/null @@ -1,63 +0,0 @@ -getQuote(); - if ($quote) { - $payment = $quote->getPayment(); - if ($payment && in_array($payment->getMethod(), $this->_hssMethods)) { - return $name; - } - } - - if ($blockObject = Mage::getSingleton('core/layout')->getBlock($block)) { - return $blockObject->getTemplate(); - } - - return ''; - } - - /** - * Get methods - * - * @return array - */ - public function getHssMethods() - { - return $this->_hssMethods; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Api.php b/app/code/core/Mage/Paypal/Model/Api.php new file mode 100644 index 00000000000..22647aaa110 --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Api.php @@ -0,0 +1,387 @@ +helper = Mage::getSingleton('paypal/api_helper'); + $this->config = Mage::getSingleton('paypal/config'); + } + + /** + * Create a new PayPal order with a pre-built request + * + * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote + * @param object $orderRequest Pre-built order request object + * @return ApiResponse|null + * @throws Mage_Core_Exception + */ + public function createOrder( + Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote, + object $orderRequest + ): ?ApiResponse { + $this->_validateQuote($quote); + + try { + $request = [ + 'prefer' => self::PREFER_RETURN_REPRESENTATION, + 'body' => $orderRequest + ]; + $response = $this->getClient()->getOrdersController()->createOrder($request); + + $this->helper->logDebug('Create Order', $quote, $request, $response); + return $response; + } catch (Exception $e) { + $this->_logAndThrowError('Create Order Error', $e); + } + } + + /** + * Authorize payment for a PayPal order + * + * @param string $id PayPal order ID + * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote + * @return ApiResponse|null + * @throws Mage_Core_Exception + */ + public function authorizeOrder( + string $id, + Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote + ): ?ApiResponse { + $this->_validateOrderId($id); + + try { + $request = [ + 'id' => $id, + 'prefer' => self::PREFER_RETURN_REPRESENTATION + ]; + + $response = $this->getClient()->getOrdersController()->authorizeOrder($request); + + $this->helper->logDebug('Authorize Order', $quote, $request, $response); + return $response; + } catch (Exception $e) { + $this->_logAndThrowError('Authorize Order Error', $e); + } + } + /** + * Authorize payment for a PayPal order + * + * @param string $id PayPal order ID + * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote + * @return ApiResponse|null + * @throws Mage_Core_Exception + */ + public function reAuthorizeOrder( + string $id, + Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote + ): ?ApiResponse { + $this->_validateAuthorizationId($id); + + try { + $request = [ + 'authorizationId' => $id, + 'prefer' => self::PREFER_RETURN_REPRESENTATION + ]; + + $response = $this->getClient()->getPaymentsController()->reauthorizePayment($request); + + $this->helper->logDebug('Reauthorize Order', $quote, $request, $response); + return $response; + } catch (Exception $e) { + $this->_logAndThrowError('Reauthorize Order Error', $e); + } + } + + /** + * Capture authorized payment for a PayPal order + * + * @param string $id PayPal order ID + * @param Mage_Sales_Model_Order $order + * @return ApiResponse|null + * @throws Mage_Core_Exception + */ + public function captureAuthorizedPayment(string $id, Mage_Sales_Model_Order $order): ?ApiResponse + { + $this->_validateOrderId($id); + + try { + $request = [ + 'authorizationId' => $id, + 'prefer' => self::PREFER_RETURN_REPRESENTATION + ]; + $response = $this->getClient()->getPaymentsController()->captureAuthorizedPayment($request); + $this->helper->logDebug('Capture Authorized Payment', $order, $request, $response); + return $response; + } catch (Exception $e) { + $this->_logAndThrowError('Capture Authorized Order Error', $e); + } + } + + /** + * Capture payment for a PayPal order + * + * @param string $id PayPal order ID + * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote + * @return ApiResponse|null + * @throws Mage_Core_Exception + */ + public function captureOrder( + string $id, + Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote + ): ?ApiResponse { + $this->_validateOrderId($id); + + try { + $request = [ + 'id' => $id, + 'prefer' => self::PREFER_RETURN_REPRESENTATION + ]; + + $response = $this->getClient()->getOrdersController()->captureOrder($request); + + $this->helper->logDebug('Capture Order', $quote, $request, $response); + + return $response; + } catch (Exception $e) { + $this->_logAndThrowError('Capture Order Error', $e); + } + } + + /** + * Refund a captured payment + * + * @param string $captureId PayPal capture ID + * @param float $amount Amount to refund + * @param string $currencyCode Currency code + * @param Mage_Sales_Model_Order $order + * @return ApiResponse|null + * @throws Mage_Core_Exception + */ + public function refundCapturedPayment( + string $captureId, + float $amount, + string $currencyCode, + Mage_Sales_Model_Order $order + ): ?ApiResponse { + $this->_validateCaptureId($captureId); + $this->_validateAmount($amount); + + try { + $request = [ + 'captureId' => $captureId, + 'prefer' => self::PREFER_RETURN_REPRESENTATION, + 'body' => $this->_buildRefundBody($amount, $currencyCode) + ]; + $response = $this->getClient()->getPaymentsController()->refundCapturedPayment($request); + + $this->helper->logDebug('Refund Payment', $order, $request, $response); + return $response; + } catch (Exception $e) { + $this->_logAndThrowError('Refund Payment Error', $e); + } + } + + /** + * Void an authorization + * + * @param string $authorizationId PayPal authorization ID + * @param Mage_Sales_Model_Order $order + * @return ApiResponse|null + * @throws Mage_Core_Exception + */ + public function voidPayment(string $authorizationId, Mage_Sales_Model_Order $order): ?ApiResponse + { + $this->_validateAuthorizationId($authorizationId); + + try { + $request = [ + 'authorizationId' => $authorizationId, + 'prefer' => self::PREFER_RETURN_REPRESENTATION + ]; + $response = $this->getClient()->getPaymentsController()->voidPayment($request); + + $this->helper->logDebug('Void Authorization', $order, $request, $response); + return $response; + } catch (Exception $e) { + $this->_logAndThrowError('Void Authorization Error', $e); + } + } + + /** + * Get PayPal API client instance with lazy loading + * + * @return PaypalServerSdkClient + * @throws Mage_Core_Exception + */ + public function getClient(): PaypalServerSdkClient + { + if ($this->client === null) { + $this->_initializeClient(); + } + return $this->client; + } + + /** + * Reset client instance (useful for testing or config changes) + * + * @return $this + */ + public function resetClient(): self + { + $this->client = null; + return $this; + } + + /** + * Initialize PayPal client + * + * @throws Mage_Core_Exception + */ + private function _initializeClient(): void + { + try { + $credentials = $this->config->getApiCredentials(); + $environment = $this->config->isSandbox() ? Environment::SANDBOX : Environment::PRODUCTION; + + $this->client = PaypalServerSdkClientBuilder::init() + ->clientCredentialsAuthCredentials( + ClientCredentialsAuthCredentialsBuilder::init( + $credentials['client_id'], + $credentials['client_secret'] + ) + ) + ->environment($environment) + ->build(); + } catch (Exception $e) { + throw new Mage_Core_Exception('Failed to initialize PayPal client: ' . $e->getMessage()); + } + } + + /** + * Validate quote object + * + * @param mixed $quote + * @throws Mage_Core_Exception + */ + private function _validateQuote(mixed $quote): void + { + if (!$quote || !$quote->hasItems()) { + throw new Mage_Core_Exception(self::ERROR_INVALID_QUOTE); + } + } + + /** + * Validate order ID + * + * @param string $id + * @throws Mage_Core_Exception + */ + private function _validateOrderId(string $id): void + { + if (empty($id)) { + throw new Mage_Core_Exception(self::ERROR_EMPTY_ORDER_ID); + } + } + + /** + * Validate capture ID + * + * @param string $captureId + * @throws Mage_Core_Exception + */ + private function _validateCaptureId(string $captureId): void + { + if (empty($captureId)) { + throw new Mage_Core_Exception(self::ERROR_EMPTY_CAPTURE_ID); + } + } + + /** + * Validate authorization ID + * + * @param string $authorizationId + * @throws Mage_Core_Exception + */ + private function _validateAuthorizationId(string $authorizationId): void + { + if (empty($authorizationId)) { + throw new Mage_Core_Exception(self::ERROR_EMPTY_AUTH_ID); + } + } + + /** + * Validate amount + * + * @param float $amount + * @throws Mage_Core_Exception + */ + private function _validateAmount(float $amount): void + { + if (!is_numeric($amount) || $amount <= 0) { + throw new Mage_Core_Exception(self::ERROR_INVALID_AMOUNT); + } + } + + /** + * Build refund request body + * + * @param float $amount + * @param string $currencyCode + * @return array + */ + private function _buildRefundBody(float $amount, string $currencyCode): array + { + return [ + 'amount' => [ + 'value' => number_format($amount, 2, '.', ''), + 'currency_code' => $currencyCode + ] + ]; + } + + /** + * Log error and throw exception + * + * @param string $message + * @param Exception $e + * @throws Exception + */ + private function _logAndThrowError(string $message, Exception $e): never + { + $this->helper->logError($message, $e); + throw $e; + } +} diff --git a/app/code/core/Mage/Paypal/Model/Api/Abstract.php b/app/code/core/Mage/Paypal/Model/Api/Abstract.php deleted file mode 100644 index 78b746eb6a5..00000000000 --- a/app/code/core/Mage/Paypal/Model/Api/Abstract.php +++ /dev/null @@ -1,574 +0,0 @@ -_config->apiUsername; - } - - /** - * Return Paypal Api password based on config data - * - * @return string - */ - public function getApiPassword() - { - return $this->_config->apiPassword; - } - - /** - * Return Paypal Api signature based on config data - * - * @return string - */ - public function getApiSignature() - { - return $this->_config->apiSignature; - } - - /** - * Return Paypal Api certificate based on config data - * - * @return string - */ - public function getApiCertificate() - { - return $this->_config->getApiCertificate(); - } - - /** - * BN code getter - * - * @return string - */ - public function getBuildNotationCode() - { - return $this->_config->getBuildNotationCode(); - } - - /** - * Return Paypal Api proxy status based on config data - * - * @return bool - */ - public function getUseProxy() - { - return $this->_getDataOrConfig('use_proxy', false); - } - - /** - * Return Paypal Api proxy host based on config data - * - * @return string - */ - public function getProxyHost() - { - return $this->_getDataOrConfig('proxy_host', '127.0.0.1'); - } - - /** - * Return Paypal Api proxy port based on config data - * - * @return string - */ - public function getProxyPort() - { - return $this->_getDataOrConfig('proxy_port', '808'); - } - - /** - * @deprecated after 1.4.1.0 - * - * @return bool - */ - public function getDebug() - { - return $this->getDebugFlag(); - } - - /** - * PayPal page CSS getter - * - * @return string - */ - public function getPageStyle() - { - return $this->_getDataOrConfig('page_style'); - } - - /** - * PayPal page header image URL getter - * - * @return string - */ - public function getHdrimg() - { - return $this->_getDataOrConfig('paypal_hdrimg'); - } - - /** - * PayPal page header border color getter - * - * @return string - */ - public function getHdrbordercolor() - { - return $this->_getDataOrConfig('paypal_hdrbordercolor'); - } - - /** - * PayPal page header background color getter - * - * @return string - */ - public function getHdrbackcolor() - { - return $this->_getDataOrConfig('paypal_hdrbackcolor'); - } - - /** - * PayPal page "payflow color" (?) getter - * - * @return string - */ - public function getPayflowcolor() - { - return $this->_getDataOrConfig('paypal_payflowcolor'); - } - - /** - * Payment action getter - * - * @return string - */ - public function getPaymentAction() - { - return $this->_getDataOrConfig('payment_action'); - } - - /** - * PayPal merchant email getter - */ - public function getBusinessAccount() - { - return $this->_getDataOrConfig('business_account'); - } - - /** - * Import $this public data to specified object or array - * - * @param array|Varien_Object $to - * @return array|Varien_Object - */ - public function &import($to, array $publicMap = []) - { - return Varien_Object_Mapper::accumulateByMap([$this, 'getDataUsingMethod'], $to, $publicMap); - } - - /** - * Export $this public data from specified object or array - * - * @param array|Varien_Object $from - * @return Mage_Paypal_Model_Api_Abstract - */ - public function export($from, array $publicMap = []) - { - Varien_Object_Mapper::accumulateByMap($from, [$this, 'setDataUsingMethod'], $publicMap); - return $this; - } - - /** - * Set PayPal cart instance - * - * @return Mage_Paypal_Model_Api_Abstract - */ - public function setPaypalCart(Mage_Paypal_Model_Cart $cart) - { - $this->_cart = $cart; - return $this; - } - - /** - * Config instance setter - * @return Mage_Paypal_Model_Api_Abstract - */ - public function setConfigObject(Mage_Paypal_Model_Config $config) - { - $this->_config = $config; - return $this; - } - - /** - * Current locale code getter - * - * @return string - */ - public function getLocaleCode() - { - return Mage::app()->getLocale()->getLocaleCode(); - } - - /** - * Always take into account - */ - public function getFraudManagementFiltersEnabled() - { - return 1; - } - - /** - * Set recurring profiles - * - * @return Mage_Paypal_Model_Api_Abstract - */ - public function addRecurringPaymentProfiles(array $items) - { - if ($items) { - $this->_recurringPaymentProfiles = $items; - } - return $this; - } - - /** - * Export $this public data to private request array - * - * @return array - */ - protected function &_exportToRequest(array $privateRequestMap, array $request = []) - { - $map = []; - foreach ($privateRequestMap as $key) { - if (isset($this->_globalMap[$key])) { - $map[$this->_globalMap[$key]] = $key; - } - } - $result = Varien_Object_Mapper::accumulateByMap([$this, 'getDataUsingMethod'], $request, $map); - foreach ($privateRequestMap as $key) { - if (isset($this->_exportToRequestFilters[$key]) && isset($result[$key])) { - $callback = $this->_exportToRequestFilters[$key]; - $privateKey = $result[$key]; - $publicKey = $map[$this->_globalMap[$key]]; - $result[$key] = call_user_func([$this, $callback], $privateKey, $publicKey); - } - } - return $result; - } - - /** - * Import $this public data from a private response array - */ - protected function _importFromResponse(array $privateResponseMap, array $response) - { - $map = []; - foreach ($privateResponseMap as $key) { - if (isset($this->_globalMap[$key])) { - $map[$key] = $this->_globalMap[$key]; - } - if (isset($response[$key]) && isset($this->_importFromRequestFilters[$key])) { - $callback = $this->_importFromRequestFilters[$key]; - $response[$key] = call_user_func([$this, $callback], $response[$key], $key, $map[$key]); - } - } - Varien_Object_Mapper::accumulateByMap($response, [$this, 'setDataUsingMethod'], $map); - } - - /** - * Prepare line items request - * - * Returns true if there were line items added - * - * @param int $i - * @return bool - */ - protected function _exportLineItems(array &$request, $i = 0) - { - if (!$this->_cart) { - return false; - } - - // always add cart totals, even if line items are not requested - if ($this->_lineItemTotalExportMap) { - foreach ($this->_cart->getTotals() as $key => $total) { - if (isset($this->_lineItemTotalExportMap[$key])) { // !empty($total) - $privateKey = $this->_lineItemTotalExportMap[$key]; - $request[$privateKey] = $this->_filterAmount($total); - } - } - } - - // add cart line items - $items = $this->_cart->getItems(); - if (empty($items) || !$this->getIsLineItemsEnabled()) { - return false; - } - $result = false; - foreach ($items as $item) { - foreach ($this->_lineItemExportItemsFormat as $publicKey => $privateFormat) { - $result = true; - $value = $item->getDataUsingMethod($publicKey); - if (isset($this->_lineItemExportItemsFilters[$publicKey])) { - $callback = $this->_lineItemExportItemsFilters[$publicKey]; - $value = call_user_func([$this, $callback], $value); - } - if (is_float($value)) { - $value = $this->_filterAmount($value); - } - $request[sprintf($privateFormat, $i)] = $value; - } - $i++; - } - return $result; - } - - /** - * Prepare shipping options request - * Returns false if there are no shipping options - * - * @param int $i - * @return bool - */ - protected function _exportShippingOptions(array &$request, $i = 0) - { - $options = $this->getShippingOptions(); - if (empty($options)) { - return false; - } - foreach ($options as $option) { - foreach ($this->_shippingOptionsExportItemsFormat as $publicKey => $privateFormat) { - $value = $option->getDataUsingMethod($publicKey); - if (is_float($value)) { - $value = $this->_filterAmount($value); - } - if (is_bool($value)) { - $value = $this->_filterBool($value); - } - $request[sprintf($privateFormat, $i)] = $value; - } - $i++; - } - return true; - } - - /** - * Filter amounts in API calls - * @param float|string $value - * @return string - */ - protected function _filterAmount($value) - { - return sprintf('%.2F', $value); - } - - /** - * Filter boolean values in API calls - * - * @param mixed $value - * @return string - */ - protected function _filterBool($value) - { - return ($value) ? 'true' : 'false'; - } - - /** - * Filter int values in API calls - * - * @param mixed $value - * @return int - */ - protected function _filterInt($value) - { - return (int) $value; - } - - /** - * Unified getter that looks in data or falls back to config - * - * @param string $key - * @param mixed $default - * @return mixed - */ - protected function _getDataOrConfig($key, $default = null) - { - if ($this->hasData($key)) { - return $this->getData($key); - } - return $this->_config->$key ? $this->_config->$key : $default; - } - - /** - * region_id workaround: PayPal requires state code, try to find one in the address - * - * @return string - */ - protected function _lookupRegionCodeFromAddress(Varien_Object $address) - { - if ($regionId = $address->getData('region_id')) { - $region = Mage::getModel('directory/region')->load($regionId); - if ($region->getId()) { - return $region->getCode(); - } - } - return ''; - } - - /** - * Street address workaround: divides address lines into parts by specified keys - * (keys should go as 3rd, 4th[...] parameters) - */ - protected function _importStreetFromAddress(Varien_Object $address, array &$to) - { - $keys = func_get_args(); - array_shift($keys); - array_shift($keys); - $street = $address->getStreet(); - if (!$keys || !$street || !is_array($street)) { - return; - } - - $street = Mage::helper('customer/address') - ->convertStreetLines($address->getStreet(), count($keys)); - - $i = 0; - foreach ($keys as $key) { - $to[$key] = $street[$i] ?? ''; - $i++; - } - } - - /** - * Build query string from request - * - * @param array $request - * @return string - */ - protected function _buildQuery($request) - { - return http_build_query($request); - } - - /** - * Filter qty in API calls - * Paypal note: The value for quantity must be a positive integer. Null, zero, or negative numbers are not allowed. - * - * @param float|string|int $value - * @return int - */ - protected function _filterQty($value) - { - return (int) $value; - } - - /** - * Log debug data to file - * - * @param mixed $debugData - */ - protected function _debug($debugData) - { - if ($this->getDebugFlag()) { - Mage::getModel('core/log_adapter', 'payment_' . $this->_config->getMethodCode() . '.log') - ->setFilterDataKeys($this->_debugReplacePrivateDataKeys) - ->log($debugData); - } - } - - /** - * Define if debugging is enabled - * - * @return bool - */ - public function getDebugFlag() - { - return $this->_config->debug; - } - - /** - * Check whether API certificate authentication should be used - * - * @return bool - */ - public function getUseCertAuthentication() - { - return (bool) $this->_config->apiAuthentication; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Api/Exception.php b/app/code/core/Mage/Paypal/Model/Api/Exception.php new file mode 100644 index 00000000000..d7b13f473d1 --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Api/Exception.php @@ -0,0 +1,23 @@ +_errorCode = $errorCode; + $this->_debugData = $debugData; + parent::__construct($message); + } + + public function getErrorCode() + { + return $this->_errorCode; + } + + public function getDebugData() + { + return $this->_debugData; + } +} \ No newline at end of file diff --git a/app/code/core/Mage/Paypal/Model/Api/Helper.php b/app/code/core/Mage/Paypal/Model/Api/Helper.php new file mode 100644 index 00000000000..0753fb049c8 --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Api/Helper.php @@ -0,0 +1,95 @@ +_validator = Mage::getSingleton('paypal/validator_payment'); + $this->_helper = Mage::helper('paypal'); + } + + public function validatePurchaseUnit($purchaseUnit) + { + if (empty($purchaseUnit['amount']) || empty($purchaseUnit['amount']['value'])) { + throw new Mage_Paypal_Model_Exception('Invalid purchase unit: missing amount'); + } + + if (empty($purchaseUnit['reference_id'])) { + throw new Mage_Paypal_Model_Exception('Invalid purchase unit: missing reference ID'); + } + + return true; + } + + /** + * Log debug information + * + * @param string $action Action being performed + * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote Quote or order object + * @param mixed $request Request object or data + * @param PaypalServerSdkLib\Http\ApiResponse|null $response API response (optional) + * @return void + */ + public function logDebug($action, $quote, $request, $response = null) + { + if (Mage::getStoreConfigFlag('payment/paypal/debug')) { + $requestData = ''; + + if (is_object($request) && method_exists($request, 'jsonSerialize')) { + $requestData = json_encode($request->jsonSerialize()); + } elseif (is_object($request)) { + $requestData = json_encode($request); + } elseif (is_string($request)) { + $requestData = $request; + } elseif (is_array($request)) { + $requestData = json_encode($request); + } + $debug = Mage::getModel('paypal/debug'); + if ($quote instanceof Mage_Sales_Model_Quote) { + $debug->setQuoteId($quote->getId()); + } elseif ($quote instanceof Mage_Sales_Model_Order) { + $debug->setIncrementId($quote->getIncrementId()); + } + + $debug->setAction($action) + ->setRequestBody($requestData); + Mage::log($response, null, 'paypal.log'); + if ($response instanceof PaypalServerSdkLib\Http\ApiResponse) { + $result = $response->getResult(); + if ($response->isError()) { + $debug->setTransactionId($result['debug_id']) + ->setResponseBody(json_encode($result)); + } else { + $debug->setTransactionId($response->getResult()->getId() ?? null) + ->setResponseBody(json_encode($response->getResult())); + } + } + $debug->save(); + } + } + + /** + * Log error information + * + * @param string $message Error message + * @param Exception $exception Exception object + * @return void + */ + public function logError($message, $exception) + { + if (Mage::getStoreConfigFlag('payment/paypal/debug')) { + $errorData = [ + 'message' => $message, + 'error' => $exception->getMessage() + ]; + + if ($exception instanceof Mage_Paypal_Model_Exception) { + $errorData['debug_data'] = $exception->getDebugData(); + } + + Mage::log($message, Zend_Log::ERR, 'paypal.log', true); + } + } +} diff --git a/app/code/core/Mage/Paypal/Model/Api/Nvp.php b/app/code/core/Mage/Paypal/Model/Api/Nvp.php deleted file mode 100644 index 97e001377b3..00000000000 --- a/app/code/core/Mage/Paypal/Model/Api/Nvp.php +++ /dev/null @@ -1,1565 +0,0 @@ - 'version', - 'USER' => 'api_username', - 'PWD' => 'api_password', - 'SIGNATURE' => 'api_signature', - 'BUTTONSOURCE' => 'build_notation_code', - - // for Unilateral payments - 'SUBJECT' => 'business_account', - - // commands - 'PAYMENTACTION' => 'payment_action', - 'RETURNURL' => 'return_url', - 'CANCELURL' => 'cancel_url', - 'INVNUM' => 'inv_num', - 'TOKEN' => 'token', - 'CORRELATIONID' => 'correlation_id', - 'SOLUTIONTYPE' => 'solution_type', - 'GIROPAYCANCELURL' => 'giropay_cancel_url', - 'GIROPAYSUCCESSURL' => 'giropay_success_url', - 'BANKTXNPENDINGURL' => 'giropay_bank_txn_pending_url', - 'IPADDRESS' => 'ip_address', - 'NOTIFYURL' => 'notify_url', - 'RETURNFMFDETAILS' => 'fraud_management_filters_enabled', - 'NOTE' => 'note', - 'REFUNDTYPE' => 'refund_type', - 'ACTION' => 'action', - 'REDIRECTREQUIRED' => 'redirect_required', - 'SUCCESSPAGEREDIRECTREQUESTED' => 'redirect_requested', - 'REQBILLINGADDRESS' => 'require_billing_address', - // style settings - 'PAGESTYLE' => 'page_style', - 'HDRIMG' => 'hdrimg', - 'HDRBORDERCOLOR' => 'hdrbordercolor', - 'HDRBACKCOLOR' => 'hdrbackcolor', - 'PAYFLOWCOLOR' => 'payflowcolor', - 'LOCALECODE' => 'locale_code', - 'PAL' => 'pal', - 'USERSELECTEDFUNDINGSOURCE' => 'funding_source', - - // transaction info - 'TRANSACTIONID' => 'transaction_id', - 'AUTHORIZATIONID' => 'authorization_id', - 'REFUNDTRANSACTIONID' => 'refund_transaction_id', - 'COMPLETETYPE' => 'complete_type', - 'AMT' => 'amount', - 'ITEMAMT' => 'subtotal_amount', - 'GROSSREFUNDAMT' => 'refunded_amount', // possible mistake, check with API reference - - // payment/billing info - 'CURRENCYCODE' => 'currency_code', - 'PAYMENTSTATUS' => 'payment_status', - 'PENDINGREASON' => 'pending_reason', - 'PROTECTIONELIGIBILITY' => 'protection_eligibility', - 'PAYERID' => 'payer_id', - 'PAYERSTATUS' => 'payer_status', - 'ADDRESSID' => 'address_id', - 'ADDRESSSTATUS' => 'address_status', - 'EMAIL' => 'email', - // backwards compatibility - 'FIRSTNAME' => 'firstname', - 'LASTNAME' => 'lastname', - - // shipping rate - 'SHIPPINGOPTIONNAME' => 'shipping_rate_code', - 'NOSHIPPING' => 'suppress_shipping', - - // paypal direct credit card information - 'CREDITCARDTYPE' => 'credit_card_type', - 'ACCT' => 'credit_card_number', - 'EXPDATE' => 'credit_card_expiration_date', - 'CVV2' => 'credit_card_cvv2', - 'STARTDATE' => 'maestro_solo_issue_date', // MMYYYY, always six chars, including leading zero - 'ISSUENUMBER' => 'maestro_solo_issue_number', - 'CVV2MATCH' => 'cvv2_check_result', - 'AVSCODE' => 'avs_result', - // cardinal centinel - 'AUTHSTATUS3DS' => 'centinel_authstatus', - 'MPIVENDOR3DS' => 'centinel_mpivendor', - 'CAVV' => 'centinel_cavv', - 'ECI3DS' => 'centinel_eci', - 'XID' => 'centinel_xid', - 'VPAS' => 'centinel_vpas_result', - 'ECISUBMITTED3DS' => 'centinel_eci_result', - - // recurring payment profiles - //'TOKEN' => 'token', - 'SUBSCRIBERNAME' => 'subscriber_name', - 'PROFILESTARTDATE' => 'start_datetime', - 'PROFILEREFERENCE' => 'internal_reference_id', - 'DESC' => 'schedule_description', - 'MAXFAILEDPAYMENTS' => 'suspension_threshold', - 'AUTOBILLAMT' => 'bill_failed_later', - 'BILLINGPERIOD' => 'period_unit', - 'BILLINGFREQUENCY' => 'period_frequency', - 'TOTALBILLINGCYCLES' => 'period_max_cycles', - //'AMT' => 'billing_amount', // have to use 'amount', see above - 'TRIALBILLINGPERIOD' => 'trial_period_unit', - 'TRIALBILLINGFREQUENCY' => 'trial_period_frequency', - 'TRIALTOTALBILLINGCYCLES' => 'trial_period_max_cycles', - 'TRIALAMT' => 'trial_billing_amount', - // 'CURRENCYCODE' => 'currency_code', - 'SHIPPINGAMT' => 'shipping_amount', - 'TAXAMT' => 'tax_amount', - 'INITAMT' => 'init_amount', - 'FAILEDINITAMTACTION' => 'init_may_fail', - 'PROFILEID' => 'recurring_profile_id', - 'PROFILESTATUS' => 'recurring_profile_status', - 'STATUS' => 'status', - - //Next two fields are used for Brazil only - 'TAXID' => 'buyer_tax_id', - 'TAXIDTYPE' => 'buyer_tax_id_type', - - 'BILLINGAGREEMENTID' => 'billing_agreement_id', - 'REFERENCEID' => 'reference_id', - 'BILLINGAGREEMENTSTATUS' => 'billing_agreement_status', - 'BILLINGTYPE' => 'billing_type', - 'SREET' => 'street', - 'CITY' => 'city', - 'STATE' => 'state', - 'COUNTRYCODE' => 'countrycode', - 'ZIP' => 'zip', - 'PAYERBUSINESS' => 'payer_business', - ]; - - /** - * Filter callbacks for preparing internal amounts to NVP request - * - * @var array - */ - protected $_exportToRequestFilters = [ - 'AMT' => '_filterAmount', - 'ITEMAMT' => '_filterAmount', - 'TRIALAMT' => '_filterAmount', - 'SHIPPINGAMT' => '_filterAmount', - 'TAXAMT' => '_filterAmount', - 'INITAMT' => '_filterAmount', - 'CREDITCARDTYPE' => '_filterCcType', - 'AUTOBILLAMT' => '_filterBillFailedLater', - 'BILLINGPERIOD' => '_filterPeriodUnit', - 'TRIALBILLINGPERIOD' => '_filterPeriodUnit', - 'FAILEDINITAMTACTION' => '_filterInitialAmountMayFail', - 'BILLINGAGREEMENTSTATUS' => '_filterBillingAgreementStatus', - 'NOSHIPPING' => '_filterInt', - ]; - - protected $_importFromRequestFilters = [ - 'REDIRECTREQUIRED' => '_filterToBool', - 'SUCCESSPAGEREDIRECTREQUESTED' => '_filterToBool', - 'PAYMENTSTATUS' => '_filterPaymentStatusFromNvpToInfo', - ]; - - /** - * Request map for each API call - * @var array - */ - protected $_eachCallRequest = ['VERSION', 'USER', 'PWD', 'SIGNATURE', 'BUTTONSOURCE',]; - - /** - * SetExpressCheckout request/response map - * @var array - */ - protected $_setExpressCheckoutRequest = [ - 'PAYMENTACTION', 'AMT', 'CURRENCYCODE', 'RETURNURL', 'CANCELURL', 'INVNUM', 'SOLUTIONTYPE', 'NOSHIPPING', - 'GIROPAYCANCELURL', 'GIROPAYSUCCESSURL', 'BANKTXNPENDINGURL', - 'PAGESTYLE', 'HDRIMG', 'HDRBORDERCOLOR', 'HDRBACKCOLOR', 'PAYFLOWCOLOR', 'LOCALECODE', - 'BILLINGTYPE', 'SUBJECT', 'ITEMAMT', 'SHIPPINGAMT', 'TAXAMT', 'REQBILLINGADDRESS', - 'USERSELECTEDFUNDINGSOURCE', - ]; - protected $_setExpressCheckoutResponse = ['TOKEN']; - - /** - * GetExpressCheckoutDetails request/response map - * @var array - */ - protected $_getExpressCheckoutDetailsRequest = ['TOKEN', 'SUBJECT',]; - - /** - * DoExpressCheckoutPayment request/response map - * @var array - */ - protected $_doExpressCheckoutPaymentRequest = [ - 'TOKEN', 'PAYERID', 'PAYMENTACTION', 'AMT', 'CURRENCYCODE', 'IPADDRESS', 'BUTTONSOURCE', 'NOTIFYURL', - 'RETURNFMFDETAILS', 'SUBJECT', 'ITEMAMT', 'SHIPPINGAMT', 'TAXAMT', - ]; - protected $_doExpressCheckoutPaymentResponse = [ - 'TRANSACTIONID', 'AMT', 'PAYMENTSTATUS', 'PENDINGREASON', 'REDIRECTREQUIRED', - ]; - - /** - * DoDirectPayment request/response map - * @var array - */ - protected $_doDirectPaymentRequest = [ - 'PAYMENTACTION', 'IPADDRESS', 'RETURNFMFDETAILS', - 'AMT', 'CURRENCYCODE', 'INVNUM', 'NOTIFYURL', 'EMAIL', 'ITEMAMT', 'SHIPPINGAMT', 'TAXAMT', - 'CREDITCARDTYPE', 'ACCT', 'EXPDATE', 'CVV2', 'STARTDATE', 'ISSUENUMBER', - 'AUTHSTATUS3DS', 'MPIVENDOR3DS', 'CAVV', 'ECI3DS', 'XID', - ]; - protected $_doDirectPaymentResponse = [ - 'TRANSACTIONID', 'AMT', 'AVSCODE', 'CVV2MATCH', 'VPAS', 'ECISUBMITTED3DS', - ]; - - /** - * DoReauthorization request/response map - * @var array - */ - protected $_doReauthorizationRequest = ['AUTHORIZATIONID', 'AMT', 'CURRENCYCODE']; - protected $_doReauthorizationResponse = [ - 'AUTHORIZATIONID', 'PAYMENTSTATUS', 'PENDINGREASON', 'PROTECTIONELIGIBILITY', - ]; - - /** - * DoCapture request/response map - * @var array - */ - protected $_doCaptureRequest = ['AUTHORIZATIONID', 'COMPLETETYPE', 'AMT', 'CURRENCYCODE', 'NOTE', 'INVNUM',]; - protected $_doCaptureResponse = ['TRANSACTIONID', 'CURRENCYCODE', 'AMT', 'PAYMENTSTATUS', 'PENDINGREASON',]; - - /** - * DoAuthorization request/response map - * @var array - */ - protected $_doAuthorizationRequest = ['TRANSACTIONID', 'AMT', 'CURRENCYCODE']; - protected $_doAuthorizationResponse = ['TRANSACTIONID', 'AMT']; - - /** - * DoVoid request map - * @var array - */ - protected $_doVoidRequest = ['AUTHORIZATIONID', 'NOTE',]; - - /** - * GetTransactionDetailsRequest - * @var array - */ - protected $_getTransactionDetailsRequest = ['TRANSACTIONID']; - protected $_getTransactionDetailsResponse = [ - 'PAYERID', 'FIRSTNAME', 'LASTNAME', 'TRANSACTIONID', 'PARENTTRANSACTIONID', 'CURRENCYCODE', 'AMT', - 'PAYMENTSTATUS', 'PENDINGREASON', - ]; - - /** - * RefundTransaction request/response map - * @var array - */ - protected $_refundTransactionRequest = ['TRANSACTIONID', 'REFUNDTYPE', 'CURRENCYCODE', 'NOTE',]; - protected $_refundTransactionResponse = ['REFUNDTRANSACTIONID', 'GROSSREFUNDAMT',]; - - /** - * ManagePendingTransactionStatus request/response map - */ - protected $_managePendingTransactionStatusRequest = ['TRANSACTIONID', 'ACTION']; - protected $_managePendingTransactionStatusResponse = ['TRANSACTIONID', 'STATUS']; - - /** - * GetPalDetails response map - * @var array - */ - protected $_getPalDetailsResponse = ['PAL']; - - /** - * CreateRecurringPaymentsProfile request/response map - * - * @var array - */ - protected $_createRecurringPaymentsProfileRequest = [ - 'TOKEN', 'SUBSCRIBERNAME', 'PROFILESTARTDATE', 'PROFILEREFERENCE', 'DESC', 'MAXFAILEDPAYMENTS', 'AUTOBILLAMT', - 'BILLINGPERIOD', 'BILLINGFREQUENCY', 'TOTALBILLINGCYCLES', 'AMT', 'TRIALBILLINGPERIOD', 'TRIALBILLINGFREQUENCY', - 'TRIALTOTALBILLINGCYCLES', 'TRIALAMT', 'CURRENCYCODE', 'SHIPPINGAMT', 'TAXAMT', 'INITAMT', 'FAILEDINITAMTACTION', - ]; - protected $_createRecurringPaymentsProfileResponse = [ - 'PROFILEID', 'PROFILESTATUS', - ]; - - /** - * Request/response for ManageRecurringPaymentsProfileStatus map - * - * @var array - */ - protected $_manageRecurringPaymentsProfileStatusRequest = ['PROFILEID', 'ACTION']; - // protected $_manageRecurringPaymentsProfileStatusResponse = array('PROFILEID'); - - /** - * Request/response for GetRecurringPaymentsProfileDetails - * - * @var array - */ - protected $_getRecurringPaymentsProfileDetailsRequest = ['PROFILEID']; - protected $_getRecurringPaymentsProfileDetailsResponse = ['STATUS', /* TODO: lot of other stuff */]; - - /** - * Map for billing address import/export - * @var array - */ - protected $_billingAddressMap = [ - 'BUSINESS' => 'company', - 'NOTETEXT' => 'customer_notes', - 'EMAIL' => 'email', - 'FIRSTNAME' => 'firstname', - 'LASTNAME' => 'lastname', - 'MIDDLENAME' => 'middlename', - 'SALUTATION' => 'prefix', - 'SUFFIX' => 'suffix', - - 'COUNTRYCODE' => 'country_id', // iso-3166 two-character code - 'STATE' => 'region', - 'CITY' => 'city', - 'STREET' => 'street', - 'STREET2' => 'street2', - 'ZIP' => 'postcode', - 'PHONENUM' => 'telephone', - ]; - - /** - * Map for billing address to do request (not response) - * Merging with $_billingAddressMap - * - * @var array - */ - protected $_billingAddressMapRequest = []; - - /** - * Map for shipping address import/export (extends billing address mapper) - * @var array - */ - protected $_shippingAddressMap = [ - 'SHIPTOCOUNTRYCODE' => 'country_id', - 'SHIPTOSTATE' => 'region', - 'SHIPTOCITY' => 'city', - 'SHIPTOSTREET' => 'street', - 'SHIPTOSTREET2' => 'street2', - 'SHIPTOZIP' => 'postcode', - 'SHIPTOPHONENUM' => 'telephone', - // 'SHIPTONAME' will be treated manually in address import/export methods - ]; - - /** - * Map for callback request - * @var array - */ - protected $_callbackRequestMap = [ - 'SHIPTOCOUNTRY' => 'country_id', - 'SHIPTOSTATE' => 'region', - 'SHIPTOCITY' => 'city', - 'SHIPTOSTREET' => 'street', - 'SHIPTOSTREET2' => 'street2', - 'SHIPTOZIP' => 'postcode', - ]; - - /** - * Payment information response specifically to be collected after some requests - * @var array - */ - protected $_paymentInformationResponse = [ - 'PAYERID', 'PAYERSTATUS', 'CORRELATIONID', 'ADDRESSID', 'ADDRESSSTATUS', - 'PAYMENTSTATUS', 'PENDINGREASON', 'PROTECTIONELIGIBILITY', 'EMAIL', 'SHIPPINGOPTIONNAME', 'TAXID', 'TAXIDTYPE', - ]; - - /** - * Line items export mapping settings - * @var array - */ - protected $_lineItemTotalExportMap = [ - Mage_Paypal_Model_Cart::TOTAL_SUBTOTAL => 'ITEMAMT', - Mage_Paypal_Model_Cart::TOTAL_TAX => 'TAXAMT', - Mage_Paypal_Model_Cart::TOTAL_SHIPPING => 'SHIPPINGAMT', - ]; - protected $_lineItemExportItemsFormat = [ - 'id' => 'L_NUMBER%d', - 'name' => 'L_NAME%d', - 'qty' => 'L_QTY%d', - 'amount' => 'L_AMT%d', - ]; - - /** - * Shipping options export to request mapping settings - * @var array - */ - protected $_shippingOptionsExportItemsFormat = [ - 'is_default' => 'L_SHIPPINGOPTIONISDEFAULT%d', - 'amount' => 'L_SHIPPINGOPTIONAMOUNT%d', - 'code' => 'L_SHIPPINGOPTIONNAME%d', - 'name' => 'L_SHIPPINGOPTIONLABEL%d', - 'tax_amount' => 'L_TAXAMT%d', - ]; - - /** - * init Billing Agreement request/response map - * @var array - */ - protected $_customerBillingAgreementRequest = ['RETURNURL', 'CANCELURL', 'BILLINGTYPE']; - protected $_customerBillingAgreementResponse = ['TOKEN']; - - /** - * Billing Agreement details request/response map - * @var array - */ - protected $_billingAgreementCustomerDetailsRequest = ['TOKEN']; - protected $_billingAgreementCustomerDetailsResponse = ['EMAIL', 'PAYERID', 'PAYERSTATUS', 'SHIPTOCOUNTRYCODE', - 'PAYERBUSINESS', - ]; - - /** - * Create Billing Agreement request/response map - * @var array - */ - protected $_createBillingAgreementRequest = ['TOKEN']; - protected $_createBillingAgreementResponse = ['BILLINGAGREEMENTID']; - - /** - * Update Billing Agreement request/response map - * @var array - */ - protected $_updateBillingAgreementRequest = [ - 'REFERENCEID', 'BILLINGAGREEMENTDESCRIPTION', 'BILLINGAGREEMENTSTATUS', 'BILLINGAGREEMENTCUSTOM', - ]; - protected $_updateBillingAgreementResponse = [ - 'REFERENCEID', 'BILLINGAGREEMENTDESCRIPTION', 'BILLINGAGREEMENTSTATUS', 'BILLINGAGREEMENTCUSTOM', - ]; - - /** - * Do Reference Transaction request/response map - * - * @var array - */ - protected $_doReferenceTransactionRequest = ['REFERENCEID', 'PAYMENTACTION', 'AMT', 'ITEMAMT', 'SHIPPINGAMT', - 'TAXAMT', 'INVNUM', 'NOTIFYURL', 'CURRENCYCODE', - ]; - - protected $_doReferenceTransactionResponse = ['BILLINGAGREEMENTID', 'TRANSACTIONID']; - - /** - * Fields that should be replaced in debug with '***' - * - * @var array - */ - protected $_debugReplacePrivateDataKeys = [ - - 'ACCT', 'EXPDATE', 'CVV2', 'CARDISSUE', 'CARDSTART', 'CREDITCARDTYPE', 'USER', 'PWD', 'SIGNATURE', - - ]; - - /** - * Map of credit card types supported by this API - * @var array - */ - protected $_supportedCcTypes = [ - 'VI' => 'Visa', 'MC' => 'MasterCard', 'DI' => 'Discover', 'AE' => 'Amex', 'SM' => 'Maestro', 'SO' => 'Solo']; - - /** - * Required fields in the response - * - * @var array - */ - protected $_requiredResponseParams = [ - self::DO_DIRECT_PAYMENT => ['ACK', 'CORRELATIONID', 'AMT'], - self::DO_EXPRESS_CHECKOUT_PAYMENT => ['ACK', 'CORRELATIONID'], - ]; - - /** - * Warning codes recollected after each API call - * - * @var array - */ - protected $_callWarnings = []; - - /** - * Error codes recollected after each API call - * - * @var array - */ - protected $_callErrors = []; - - /** - * Whether to return raw response information after each call - * - * @var bool - */ - protected $_rawResponseNeeded = false; - - /** - * API call HTTP headers - * - * @var array - */ - protected $_headers = []; - - /** - * API endpoint getter - * - * @return string - */ - public function getApiEndpoint() - { - $url = $this->getUseCertAuthentication() ? 'https://api%s.paypal.com/nvp' : 'https://api-3t%s.paypal.com/nvp'; - return sprintf($url, $this->_config->sandboxFlag ? '.sandbox' : ''); - } - - /** - * Return Paypal Api version - * - * @return string - */ - public function getVersion() - { - return '72.0'; - } - - /** - * Retrieve billing agreement type - * - * @return string - */ - public function getBillingAgreementType() - { - return 'MerchantInitiatedBilling'; - } - - /** - * SetExpressCheckout call - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetExpressCheckout - * TODO: put together style and giropay settings - */ - public function callSetExpressCheckout() - { - $this->_prepareExpressCheckoutCallRequest($this->_setExpressCheckoutRequest); - $request = $this->_exportToRequest($this->_setExpressCheckoutRequest); - $this->_exportLineItems($request); - - // import/suppress shipping address, if any - $options = $this->getShippingOptions(); - if ($this->getAddress()) { - $request = $this->_importAddresses($request); - $request['ADDROVERRIDE'] = 1; - } elseif ($options && (count($options) <= 10)) { // doesn't support more than 10 shipping options - $request['CALLBACK'] = $this->getShippingOptionsCallbackUrl(); - $request['CALLBACKTIMEOUT'] = 6; // max value - $request['MAXAMT'] = $request['AMT'] + 999.00; // it is impossible to calculate max amount - $this->_exportShippingOptions($request); - } - - // add recurring profiles information - $i = 0; - foreach ($this->_recurringPaymentProfiles as $profile) { - $request["L_BILLINGTYPE{$i}"] = 'RecurringPayments'; - $request["L_BILLINGAGREEMENTDESCRIPTION{$i}"] = $profile->getScheduleDescription(); - $i++; - } - - $response = $this->call(self::SET_EXPRESS_CHECKOUT, $request); - $this->_importFromResponse($this->_setExpressCheckoutResponse, $response); - } - - /** - * GetExpressCheckoutDetails call - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetExpressCheckoutDetails - */ - public function callGetExpressCheckoutDetails() - { - $this->_prepareExpressCheckoutCallRequest($this->_getExpressCheckoutDetailsRequest); - $request = $this->_exportToRequest($this->_getExpressCheckoutDetailsRequest); - $response = $this->call(self::GET_EXPRESS_CHECKOUT_DETAILS, $request); - $this->_importFromResponse($this->_paymentInformationResponse, $response); - $this->_exportAddressses($response); - } - - /** - * DoExpressCheckout call - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoExpressCheckoutPayment - */ - public function callDoExpressCheckoutPayment() - { - $this->_prepareExpressCheckoutCallRequest($this->_doExpressCheckoutPaymentRequest); - $request = $this->_exportToRequest($this->_doExpressCheckoutPaymentRequest); - $this->_exportLineItems($request); - - $response = $this->call(self::DO_EXPRESS_CHECKOUT_PAYMENT, $request); - $this->_importFromResponse($this->_paymentInformationResponse, $response); - $this->_importFromResponse($this->_doExpressCheckoutPaymentResponse, $response); - $this->_importFromResponse($this->_createBillingAgreementResponse, $response); - } - - /** - * Process a credit card payment - */ - public function callDoDirectPayment() - { - $request = $this->_exportToRequest($this->_doDirectPaymentRequest); - $this->_exportLineItems($request); - if ($this->getAddress()) { - $request = $this->_importAddresses($request); - } - $response = $this->call(self::DO_DIRECT_PAYMENT, $request); - $this->_importFromResponse($this->_doDirectPaymentResponse, $response); - } - - /** - * Do Reference Transaction call - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoReferenceTransaction - */ - public function callDoReferenceTransaction() - { - $request = $this->_exportToRequest($this->_doReferenceTransactionRequest); - $this->_exportLineItems($request); - $response = $this->call('DoReferenceTransaction', $request); - $this->_importFromResponse($this->_doReferenceTransactionResponse, $response); - } - - /** - * Check whether the last call was returned with fraud warning - * - * @return bool - */ - public function getIsFraudDetected() - { - return in_array(11610, $this->_callWarnings); - } - - /** - * Made additional request to paypal to get autharization id - */ - public function callDoReauthorization() - { - $request = $this->_export($this->_doReauthorizationRequest); - $response = $this->call('DoReauthorization', $request); - $this->_import($response, $this->_doReauthorizationResponse); - } - - /** - * DoCapture call - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoCapture - */ - public function callDoCapture() - { - $this->setCompleteType($this->_getCaptureCompleteType()); - $request = $this->_exportToRequest($this->_doCaptureRequest); - $response = $this->call(self::DO_CAPTURE, $request); - $this->_importFromResponse($this->_paymentInformationResponse, $response); - $this->_importFromResponse($this->_doCaptureResponse, $response); - } - - /** - * DoAuthorization call - * - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoAuthorization - * @return $this - */ - public function callDoAuthorization() - { - $request = $this->_exportToRequest($this->_doAuthorizationRequest); - $response = $this->call(self::DO_AUTHORIZATION, $request); - $this->_importFromResponse($this->_paymentInformationResponse, $response); - $this->_importFromResponse($this->_doAuthorizationResponse, $response); - - return $this; - } - - /** - * DoVoid call - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoVoid - */ - public function callDoVoid() - { - $request = $this->_exportToRequest($this->_doVoidRequest); - $this->call(self::DO_VOID, $request); - } - - /** - * GetTransactionDetails - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetTransactionDetails - */ - public function callGetTransactionDetails() - { - $request = $this->_exportToRequest($this->_getTransactionDetailsRequest); - $response = $this->call('GetTransactionDetails', $request); - $this->_importFromResponse($this->_getTransactionDetailsResponse, $response); - } - - /** - * RefundTransaction call - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_RefundTransaction - */ - public function callRefundTransaction() - { - $request = $this->_exportToRequest($this->_refundTransactionRequest); - if ($this->getRefundType() === Mage_Paypal_Model_Config::REFUND_TYPE_PARTIAL) { - $request['AMT'] = $this->getAmount(); - } - $response = $this->call(self::REFUND_TRANSACTION, $request); - $this->_importFromResponse($this->_refundTransactionResponse, $response); - } - - /** - * ManagePendingTransactionStatus - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_ManagePendingTransactionStatus - */ - public function callManagePendingTransactionStatus() - { - $request = $this->_exportToRequest($this->_managePendingTransactionStatusRequest); - if (isset($request['ACTION'])) { - $request['ACTION'] = $this->_filterPaymentReviewAction($request['ACTION']); - } - $response = $this->call('ManagePendingTransactionStatus', $request); - $this->_importFromResponse($this->_managePendingTransactionStatusResponse, $response); - } - - /** - * getPalDetails call - * @link https://www.x.com/docs/DOC-1300 - * @link https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECButtonIntegration - */ - public function callGetPalDetails() - { - $response = $this->call('getPalDetails', []); - $this->_importFromResponse($this->_getPalDetailsResponse, $response); - } - - /** - * Set Customer BillingA greement call - * - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_SetCustomerBillingAgreement - */ - public function callSetCustomerBillingAgreement() - { - $request = $this->_exportToRequest($this->_customerBillingAgreementRequest); - $response = $this->call('SetCustomerBillingAgreement', $request); - $this->_importFromResponse($this->_customerBillingAgreementResponse, $response); - } - - /** - * Get Billing Agreement Customer Details call - * - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetBillingAgreementCustomerDetails - */ - public function callGetBillingAgreementCustomerDetails() - { - $request = $this->_exportToRequest($this->_billingAgreementCustomerDetailsRequest); - $response = $this->call('GetBillingAgreementCustomerDetails', $request); - $this->_importFromResponse($this->_billingAgreementCustomerDetailsResponse, $response); - } - - /** - * Create Billing Agreement call - * - */ - public function callCreateBillingAgreement() - { - $request = $this->_exportToRequest($this->_createBillingAgreementRequest); - $response = $this->call('CreateBillingAgreement', $request); - $this->_importFromResponse($this->_createBillingAgreementResponse, $response); - } - - /** - * Billing Agreement Update call - * - */ - public function callUpdateBillingAgreement() - { - $request = $this->_exportToRequest($this->_updateBillingAgreementRequest); - try { - $response = $this->call('BillAgreementUpdate', $request); - } catch (Mage_Core_Exception $e) { - if (in_array(10201, $this->_callErrors)) { - $this->setIsBillingAgreementAlreadyCancelled(true); - } - throw $e; - } - $this->_importFromResponse($this->_updateBillingAgreementResponse, $response); - } - - /** - * CreateRecurringPaymentsProfile call - */ - public function callCreateRecurringPaymentsProfile() - { - $request = $this->_exportToRequest($this->_createRecurringPaymentsProfileRequest); - $response = $this->call('CreateRecurringPaymentsProfile', $request); - $this->_importFromResponse($this->_createRecurringPaymentsProfileResponse, $response); - $this->_analyzeRecurringProfileStatus($this->getRecurringProfileStatus(), $this); - } - - /** - * ManageRecurringPaymentsProfileStatus call - */ - public function callManageRecurringPaymentsProfileStatus() - { - $request = $this->_exportToRequest($this->_manageRecurringPaymentsProfileStatusRequest); - if (isset($request['ACTION'])) { - $request['ACTION'] = $this->_filterRecurringProfileActionToNvp($request['ACTION']); - } - try { - $response = $this->call('ManageRecurringPaymentsProfileStatus', $request); - } catch (Mage_Core_Exception $e) { - if ((in_array(11556, $this->_callErrors) && $request['ACTION'] === 'Cancel') - || (in_array(11557, $this->_callErrors) && $request['ACTION'] === 'Suspend') - || (in_array(11558, $this->_callErrors) && $request['ACTION'] === 'Reactivate') - ) { - Mage::throwException(Mage::helper('paypal')->__('Unable to change status. Current status is not correspond to real status.')); - } - throw $e; - } - } - - /** - * GetRecurringPaymentsProfileDetails call - */ - public function callGetRecurringPaymentsProfileDetails(Varien_Object $result) - { - $request = $this->_exportToRequest($this->_getRecurringPaymentsProfileDetailsRequest); - $response = $this->call('GetRecurringPaymentsProfileDetails', $request); - $this->_importFromResponse($this->_getRecurringPaymentsProfileDetailsResponse, $response); - $this->_analyzeRecurringProfileStatus($this->getStatus(), $result); - } - - /** - * Import callback request array into $this public data - * - * @return Varien_Object - */ - public function prepareShippingOptionsCallbackAddress(array $request) - { - $address = new Varien_Object(); - Varien_Object_Mapper::accumulateByMap($request, $address, $this->_callbackRequestMap); - $address->setExportedKeys(array_values($this->_callbackRequestMap)); - $this->_applyStreetAndRegionWorkarounds($address); - return $address; - } - - /** - * Prepare response for shipping options callback - * - * @return string - */ - public function formatShippingOptionsCallback() - { - $response = []; - if (!$this->_exportShippingOptions($response)) { - $response['NO_SHIPPING_OPTION_DETAILS'] = '1'; - } - $response = $this->_addMethodToRequest(self::CALLBACK_RESPONSE, $response); - return $this->_buildQuery($response); - } - - /** - * Add method to request array - * - * @param string $methodName - * @param array $request - * @return array - */ - protected function _addMethodToRequest($methodName, $request) - { - $request['METHOD'] = $methodName; - return $request; - } - - /** - * Do the API call - * - * @param string $methodName - * @return array - * @throws Mage_Core_Exception - */ - public function call($methodName, array $request) - { - $request = $this->_addMethodToRequest($methodName, $request); - $eachCallRequest = $this->_prepareEachCallRequest($methodName); - if ($this->getUseCertAuthentication()) { - if ($key = array_search('SIGNATURE', $eachCallRequest)) { - unset($eachCallRequest[$key]); - } - } - $request = $this->_exportToRequest($eachCallRequest, $request); - $debugData = ['url' => $this->getApiEndpoint(), $methodName => $request]; - - try { - $http = new Varien_Http_Adapter_Curl(); - $config = [ - 'timeout' => 60, - 'verifypeer' => $this->_config->verifyPeer, - ]; - - if ($this->getUseProxy()) { - $config['proxy'] = $this->getProxyHost() . ':' . $this->getProxyPort(); - } - if ($this->getUseCertAuthentication()) { - $config['ssl_cert'] = $this->getApiCertificate(); - } - $http->setConfig($config); - $http->write( - Zend_Http_Client::POST, - $this->getApiEndpoint(), - '1.1', - $this->_headers, - $this->_buildQuery($request), - ); - $response = $http->read(); - } catch (Exception $e) { - $debugData['http_error'] = ['error' => $e->getMessage(), 'code' => $e->getCode()]; - $this->_debug($debugData); - throw $e; - } - - $response = preg_split('/^\r?$/m', $response, 2); - $response = trim($response[1]); - $response = $this->_deformatNVP($response); - - $debugData['response'] = $response; - $this->_debug($debugData); - $response = $this->_postProcessResponse($response); - - // handle transport error - if ($http->getErrno()) { - Mage::logException(new Exception( - sprintf('PayPal NVP CURL connection error #%s: %s', $http->getErrno(), $http->getError()), - )); - $http->close(); - - Mage::throwException(Mage::helper('paypal')->__('Unable to communicate with the PayPal gateway.')); - } - - // cUrl resource must be closed after checking it for errors - $http->close(); - - if (!$this->_validateResponse($methodName, $response)) { - Mage::logException(new Exception( - Mage::helper('paypal')->__("PayPal response hasn't required fields."), - )); - Mage::throwException(Mage::helper('paypal')->__('There was an error processing your order. Please contact us or try again later.')); - } - - $this->_callErrors = []; - if ($this->_isCallSuccessful($response)) { - if ($this->_rawResponseNeeded) { - $this->setRawSuccessResponseData($response); - } - return $response; - } - $this->_handleCallErrors($response); - return $response; - } - - /** - * Setter for 'raw response needed' flag - * - * @param bool $flag - * @return $this - */ - public function setRawResponseNeeded($flag) - { - $this->_rawResponseNeeded = $flag; - return $this; - } - - /** - * Handle logical errors - * - * @param array $response - * @throws Mage_Core_Exception - */ - protected function _handleCallErrors($response) - { - $errors = $this->_extractErrorsFromResponse($response); - $errorsCount = count($errors); - - if (!$errorsCount) { - return; - } - - $exceptionCode = 0; - - if ($errorsCount == 1 && $this->_isProcessableError($errors[0]['code'])) { - $exceptionCode = $errors[0]['code']; - $exceptionClass = 'Mage_Paypal_Model_Api_ProcessableException'; - } else { - $exceptionClass = 'Mage_Core_Exception'; - } - - $errorMessages = []; - - foreach ($errors as $error) { - $errorMessages[] = $error['message']; - $this->_callErrors[] = $error['code']; - } - - $errorMessages = implode(' ', array_values($errorMessages)); - $exceptionLogMessage = sprintf( - 'PayPal NVP gateway errors: %s Correlation ID: %s. Version: %s.', - $errorMessages, - $response['CORRELATIONID'] ?? '', - $response['VERSION'] ?? '', - ); - - $exception = new $exceptionClass($exceptionLogMessage, $exceptionCode); - Mage::logException($exception); - - $exception->setMessage(Mage::helper('paypal')->__('PayPal gateway has rejected request. %s', $errorMessages)); - - throw $exception; - } - - /** - * Format error message from error code, short error message and long error message - * - * @param string $errorCode - * @param string $shortErrorMessage - * @param string $longErrorMessage - * @return string - */ - protected function _formatErrorMessage($errorCode, $shortErrorMessage, $longErrorMessage) - { - $longErrorMessage = preg_replace('/\.$/', '', $longErrorMessage); - $shortErrorMessage = preg_replace('/\.$/', '', $shortErrorMessage); - - return $longErrorMessage ? sprintf('%s (#%s: %s).', $longErrorMessage, $errorCode, $shortErrorMessage) - : sprintf('#%s: %s.', $errorCode, $shortErrorMessage); - } - - /** - * Check whether PayPal error can be processed - * - * @param int $errorCode - * @return bool - */ - protected function _isProcessableError($errorCode) - { - $processableErrorsList = $this->getProcessableErrors(); - - if (!$processableErrorsList || !is_array($processableErrorsList)) { - return false; - } - - return in_array($errorCode, $processableErrorsList); - } - - /** - * Extract errors from PayPal's response and return them in array - * - * @param array $response - * @return array - */ - protected function _extractErrorsFromResponse($response) - { - $errors = []; - - for ($i = 0; isset($response["L_ERRORCODE{$i}"]); $i++) { - $errorCode = $response["L_ERRORCODE{$i}"]; - $errorMessage = $this->_formatErrorMessage( - $errorCode, - $response["L_SHORTMESSAGE{$i}"], - $response["L_LONGMESSAGE{$i}"], - ); - $errors[] = [ - 'code' => $errorCode, - 'message' => $errorMessage, - ]; - } - - return $errors; - } - - /** - * Catch success calls and collect warnings - * - * @param array $response - * @return bool success flag - */ - protected function _isCallSuccessful($response) - { - if (!isset($response['ACK'])) { - return false; - } - - $ack = strtoupper($response['ACK']); - $this->_callWarnings = []; - if ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING') { - // collect warnings - if ($ack == 'SUCCESSWITHWARNING') { - for ($i = 0; isset($response["L_ERRORCODE{$i}"]); $i++) { - $this->_callWarnings[] = $response["L_ERRORCODE{$i}"]; - } - } - return true; - } - return false; - } - - /** - * Validate response array. - * - * @param string $method - * @param array $response - * @return bool - */ - protected function _validateResponse($method, $response) - { - if (isset($this->_requiredResponseParams[$method])) { - foreach ($this->_requiredResponseParams[$method] as $param) { - if (!isset($response[$param])) { - Mage::log("Expected PayPal field not found in NVP Response: $param"); - return false; - } - } - } - return true; - } - - /** - * Parse an NVP response string into an associative array - * @param string $nvpstr - * @return array - */ - protected function _deformatNVP($nvpstr) - { - $intial = 0; - $nvpArray = []; - - $nvpstr = str_contains($nvpstr, "\r\n\r\n") ? substr($nvpstr, strpos($nvpstr, "\r\n\r\n") + 4) : $nvpstr; - - while (strlen($nvpstr)) { - //position of Key - $keypos = strpos($nvpstr, '='); - //position of value - $valuepos = strpos($nvpstr, '&') ? strpos($nvpstr, '&') : strlen($nvpstr); - - /*getting the Key and Value values and storing in a Associative Array*/ - $keyval = substr($nvpstr, $intial, $keypos); - $valval = substr($nvpstr, $keypos + 1, $valuepos - $keypos - 1); - //decoding the response - $nvpArray[urldecode($keyval)] = urldecode($valval); - $nvpstr = substr($nvpstr, $valuepos + 1, strlen($nvpstr)); - } - return $nvpArray; - } - - /** - * NVP doesn't support passing discount total as a separate amount - add it as a line item - * - * @param int $i - * @return bool|void - */ - protected function _exportLineItems(array &$request, $i = 0) - { - if (!$this->_cart) { - return; - } - $this->_cart->isDiscountAsItem(true); - return parent::_exportLineItems($request, $i); - } - - /** - * Create billing and shipping addresses basing on response data - * @param array $data - */ - protected function _exportAddressses($data) - { - $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 - $shippingAddress->addData([ - 'firstname' => $data['SHIPTONAME'], - ]); - $this->setExportedShippingAddress($shippingAddress); - } - } - - /** - * Adopt specified address object to be compatible with Magento - */ - protected function _applyStreetAndRegionWorkarounds(Varien_Object $address) - { - // merge street addresses into 1 - if ($address->hasStreet2()) { - $address->setStreet(implode("\n", [$address->getStreet(), $address->getStreet2()])); - $address->unsStreet2(); - } - // attempt to fetch region_id from directory - if ($address->getCountryId() && $address->getRegion()) { - $regions = Mage::getModel('directory/country')->loadByCode($address->getCountryId())->getRegionCollection() - ->addRegionCodeOrNameFilter($address->getRegion()) - ->setPageSize(1); - foreach ($regions as $region) { - $address->setRegionId($region->getId()); - $address->setExportedKeys(array_merge($address->getExportedKeys(), ['region_id'])); - break; - } - } - } - - /** - * Adopt specified request array to be compatible with Paypal - * Puerto Rico should be as state of USA and not as a country - * - * @param array $request - */ - protected function _applyCountryWorkarounds(&$request) - { - if (isset($request['SHIPTOCOUNTRYCODE']) && $request['SHIPTOCOUNTRYCODE'] == 'PR') { - $request['SHIPTOCOUNTRYCODE'] = 'US'; - $request['SHIPTOSTATE'] = 'PR'; - } - } - - /** - * Prepare request data basing on provided address - * - * @deprecated after 1.4.2.0-beta1, use _importAddresses() instead - * - * @return array - */ - protected function _importAddress(Varien_Object $address, array $to) - { - $this->setAddress($address); - return $this->_importAddresses($to); - } - - /** - * Prepare request data basing on provided addresses - * - * @return array - */ - protected function _importAddresses(array $to) - { - $billingAddress = ($this->getBillingAddress()) ? $this->getBillingAddress() : $this->getAddress(); - $shippingAddress = $this->getAddress(); - - $to = Varien_Object_Mapper::accumulateByMap( - $billingAddress, - $to, - array_merge(array_flip($this->_billingAddressMap), $this->_billingAddressMapRequest), - ); - if ($regionCode = $this->_lookupRegionCodeFromAddress($billingAddress)) { - $to['STATE'] = $regionCode; - } - if (!$this->getSuppressShipping()) { - $to = Varien_Object_Mapper::accumulateByMap($shippingAddress, $to, array_flip($this->_shippingAddressMap)); - if ($regionCode = $this->_lookupRegionCodeFromAddress($shippingAddress)) { - $to['SHIPTOSTATE'] = $regionCode; - } - $this->_importStreetFromAddress($shippingAddress, $to, 'SHIPTOSTREET', 'SHIPTOSTREET2'); - $this->_importStreetFromAddress($billingAddress, $to, 'STREET', 'STREET2'); - $to['SHIPTONAME'] = $shippingAddress->getName(); - } - $this->_applyCountryWorkarounds($to); - return $to; - } - - /** - * Filter for credit card type - * - * @param string $value - * @return string - */ - protected function _filterCcType($value) - { - return $this->_supportedCcTypes[$value] ?? ''; - } - - /** - * Filter for true/false values (converts to boolean) - * - * @param mixed $value - * @return mixed - */ - protected function _filterToBool($value) - { - if ($value === 'false' || $value === '0') { - return false; - } elseif ($value === 'true' || $value === '1') { - return true; - } - return $value; - } - - /** - * Filter for 'AUTOBILLAMT' - * - * @param string $value - * @return string - */ - protected function _filterBillFailedLater($value) - { - return $value ? 'AddToNextBilling' : 'NoAutoBill'; - } - - /** - * Filter for 'BILLINGPERIOD' and 'TRIALBILLINGPERIOD' - * - * @param string $value - * @return string|void - */ - protected function _filterPeriodUnit($value) - { - switch ($value) { - case 'day': - return 'Day'; - case 'week': - return 'Week'; - case 'semi_month': - return 'SemiMonth'; - case 'month': - return 'Month'; - case 'year': - return 'Year'; - } - } - - /** - * Filter for 'FAILEDINITAMTACTION' - * - * @param string $value - * @return string - */ - protected function _filterInitialAmountMayFail($value) - { - return $value ? 'ContinueOnFailure' : 'CancelOnFailure'; - } - - /** - * Filter for billing agreement status - * - * @param string $value - * @return string|void - */ - protected function _filterBillingAgreementStatus($value) - { - switch ($value) { - case 'canceled': - return 'Canceled'; - case 'active': - return 'Active'; - } - } - - /** - * Convert payment status from NVP format to paypal/info model format - * - * @param string $value - * @return string|void - */ - protected function _filterPaymentStatusFromNvpToInfo($value) - { - switch ($value) { - case 'None': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_NONE; - case 'Completed': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_COMPLETED; - case 'Denied': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_DENIED; - case 'Expired': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_EXPIRED; - case 'Failed': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_FAILED; - case 'In-Progress': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_INPROGRESS; - case 'Pending': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_PENDING; - case 'Refunded': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_REFUNDED; - case 'Partially-Refunded': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_REFUNDEDPART; - case 'Reversed': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_REVERSED; - case 'Canceled-Reversal': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_UNREVERSED; - case 'Processed': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_PROCESSED; - case 'Voided': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_VOIDED; - } - } - - /** - * Convert payment review action to NVP-compatible value - * - * @param string $value - * @return string|void - */ - protected function _filterPaymentReviewAction($value) - { - switch ($value) { - case Mage_Paypal_Model_Pro::PAYMENT_REVIEW_ACCEPT: - return 'Accept'; - case Mage_Paypal_Model_Pro::PAYMENT_REVIEW_DENY: - return 'Deny'; - } - } - - /** - * Convert RP management action to NVP format - * - * @param string $value - * @return string|void - */ - protected function _filterRecurringProfileActionToNvp($value) - { - switch ($value) { - case 'cancel': - return 'Cancel'; - case 'suspend': - return 'Suspend'; - case 'activate': - return 'Reactivate'; - } - } - - /** - * Check the obtained RP status in NVP format and specify the profile state - * - * @param string $value - */ - protected function _analyzeRecurringProfileStatus($value, Varien_Object $result) - { - switch ($value) { - case 'ActiveProfile': - case 'Active': - $result->setIsProfileActive(true); - break; - case 'PendingProfile': - $result->setIsProfilePending(true); - break; - case 'CancelledProfile': - case 'Cancelled': - $result->setIsProfileCanceled(true); - break; - case 'SuspendedProfile': - case 'Suspended': - $result->setIsProfileSuspended(true); - break; - case 'ExpiredProfile': - case 'Expired': // ?? - $result->setIsProfileExpired(true); - break; - } - } - - /** - * Return capture type - * - * @return string - */ - protected function _getCaptureCompleteType() - { - return ($this->getIsCaptureComplete()) - ? $this->_captureTypeComplete - : $this->_captureTypeNotcomplete; - } - - /** - * Return each call request without unused fields in case of Express Checkout Unilateral payments - * - * @param string $methodName Current method name - * @return array - */ - protected function _prepareEachCallRequest($methodName) - { - $expressCheckooutMetods = [ - self::SET_EXPRESS_CHECKOUT, self::GET_EXPRESS_CHECKOUT_DETAILS, self::DO_EXPRESS_CHECKOUT_PAYMENT, - ]; - if (!in_array($methodName, $expressCheckooutMetods) || !$this->_config->shouldUseUnilateralPayments()) { - return $this->_eachCallRequest; - } - return array_diff($this->_eachCallRequest, ['USER', 'PWD', 'SIGNATURE']); - } - - /** - * Check the EC request against unilateral payments mode and remove the SUBJECT if needed - * - * @param array $requestFields - */ - protected function _prepareExpressCheckoutCallRequest(&$requestFields) - { - if (!$this->_config->shouldUseUnilateralPayments()) { - if ($key = array_search('SUBJECT', $requestFields)) { - unset($requestFields[$key]); - } - } - } - - /** - * Additional response processing. - * Hack to cut off length from API type response params. - * - * @param array $response - * @return array - */ - protected function _postProcessResponse($response) - { - foreach ($response as $key => $value) { - $pos = strpos($key, '['); - - if ($pos === false) { - continue; - } - - unset($response[$key]); - - if ($pos !== 0) { - $modifiedKey = substr($key, 0, $pos); - $response[$modifiedKey] = $value; - } - } - - return $response; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Api/ProcessableException.php b/app/code/core/Mage/Paypal/Model/Api/ProcessableException.php deleted file mode 100644 index 534cf185a09..00000000000 --- a/app/code/core/Mage/Paypal/Model/Api/ProcessableException.php +++ /dev/null @@ -1,53 +0,0 @@ -getCode()) { - case self::API_INTERNAL_ERROR: - case self::API_UNABLE_PROCESS_PAYMENT_ERROR_CODE: - $message = Mage::helper('paypal')->__("I'm sorry - but we were not able to process your payment. Please try another payment method or contact us so we can assist you."); - break; - case self::API_COUNTRY_FILTER_DECLINE: - case self::API_MAXIMUM_AMOUNT_FILTER_DECLINE: - case self::API_OTHER_FILTER_DECLINE: - $message = Mage::helper('paypal')->__("I'm sorry - but we are not able to complete your transaction. Please contact us so we can assist you."); - break; - default: - $message = $this->getMessage(); - } - - return $message; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Api/Standard.php b/app/code/core/Mage/Paypal/Model/Api/Standard.php deleted file mode 100644 index 0ba7e8094e8..00000000000 --- a/app/code/core/Mage/Paypal/Model/Api/Standard.php +++ /dev/null @@ -1,234 +0,0 @@ - 'business_account', - 'notify_url' => 'notify_url', - 'return' => 'return_url', - 'cancel_return' => 'cancel_url', - 'bn' => 'build_notation_code', - 'paymentaction' => 'payment_action', - // payment - 'invoice' => 'order_id', - 'currency_code' => 'currency_code', - 'amount' => 'amount', - 'shipping' => 'shipping_amount', - 'tax' => 'tax_amount', - 'discount_amount' => 'discount_amount', - // misc - 'item_name' => 'cart_summary', - // page design settings - 'page_style' => 'page_style', - 'cpp_header_image' => 'hdrimg', - 'cpp_headerback_color' => 'hdrbackcolor', - 'cpp_headerborder_color' => 'hdrbordercolor', - 'cpp_payflow_color' => 'payflowcolor', - 'lc' => 'locale', - ]; - protected $_exportToRequestFilters = [ - 'amount' => '_filterAmount', - 'shipping' => '_filterAmount', - 'tax' => '_filterAmount', - 'discount_amount' => '_filterAmount', - ]; - - /** - * Interface for common and "aggregated order" specific fields - * @var array - */ - protected $_commonRequestFields = [ - 'business', 'invoice', 'currency_code', 'paymentaction', 'return', 'cancel_return', 'notify_url', 'bn', - 'page_style', 'cpp_header_image', 'cpp_headerback_color', 'cpp_headerborder_color', 'cpp_payflow_color', - 'amount', 'shipping', 'tax', 'discount_amount', 'item_name', 'lc', - ]; - - /** - * Fields that should be replaced in debug with '***' - * - * @var array - */ - protected $_debugReplacePrivateDataKeys = ['business']; - - /** - * Line items export mapping settings - * @var array - */ - protected $_lineItemTotalExportMap = [ - Mage_Paypal_Model_Cart::TOTAL_SUBTOTAL => 'amount', - Mage_Paypal_Model_Cart::TOTAL_DISCOUNT => 'discount_amount', - Mage_Paypal_Model_Cart::TOTAL_TAX => 'tax', - Mage_Paypal_Model_Cart::TOTAL_SHIPPING => 'shipping', - ]; - protected $_lineItemExportItemsFormat = [ - 'id' => 'item_number_%d', - 'name' => 'item_name_%d', - 'qty' => 'quantity_%d', - 'amount' => 'amount_%d', - ]; - - protected $_lineItemExportItemsFilters = [ - 'qty' => '_filterQty', - ]; - - /** - * Address export to request map - * @var array - */ - protected $_addressMap = [ - 'city' => 'city', - 'country' => 'country_id', - 'email' => 'email', - 'first_name' => 'firstname', - 'last_name' => 'lastname', - 'zip' => 'postcode', - 'state' => 'region', - 'address1' => 'street', - 'address2' => 'street2', - ]; - - /** - * Generate PayPal Standard checkout request fields - * Depending on whether there are cart line items set, will aggregate everything or display items specifically - * Shipping amount in cart line items is implemented as a separate "fake" line item - */ - public function getStandardCheckoutRequest() - { - $request = $this->_exportToRequest($this->_commonRequestFields); - $request['charset'] = 'utf-8'; - - $isLineItems = $this->_exportLineItems($request); - if ($isLineItems) { - $request = array_merge($request, [ - 'cmd' => '_cart', - 'upload' => 1, - ]); - if (isset($request['tax'])) { - $request['tax_cart'] = $request['tax']; - } - if (isset($request['discount_amount'])) { - $request['discount_amount_cart'] = $request['discount_amount']; - } - } else { - $request = array_merge($request, [ - 'cmd' => '_ext-enter', - 'redirect_cmd' => '_xclick', - ]); - } - - // payer address - $this->_importAddress($request); - - return $request; - } - - /** - * Merchant account email getter - * @return string - */ - public function getBusinessAccount() - { - return $this->_getDataOrConfig('business_account'); - } - - /** - * Payment action getter - * @return string - */ - public function getPaymentAction() - { - return strtolower(parent::getPaymentAction()); - } - - /** - * @deprecated after 1.4.1.0 - * - * @param array $request - */ - public function debugRequest($request) {} - - /** - * Add shipping total as a line item. - * For some reason PayPal ignores shipping total variables exactly when line items is enabled - * Note that $i = 1 - * - * @param int $i - * @return bool - */ - protected function _exportLineItems(array &$request, $i = 1) - { - if (!$this->_cart) { - return false; - } - if ($this->getIsLineItemsEnabled()) { - $this->_cart->isShippingAsItem(true); - } - return parent::_exportLineItems($request, $i); - } - - /** - * Import address object, if set, to the request - * - * @param array|Varien_Object $request - */ - protected function _importAddress(&$request) - { - $address = $this->getAddress(); - if (!$address) { - if ($this->getNoShipping()) { - $request['no_shipping'] = 1; - } - return; - } - - $request = Varien_Object_Mapper::accumulateByMap($address, $request, array_flip($this->_addressMap)); - - // Address may come without email info (user is not always required to enter it), so add email from order - if (!$request['email']) { - $order = $this->getOrder(); - if ($order) { - $request['email'] = $order->getCustomerEmail(); - } - } - - $regionCode = $this->_lookupRegionCodeFromAddress($address); - if ($regionCode) { - $request['state'] = $regionCode; - } - $this->_importStreetFromAddress($address, $request, 'address1', 'address2'); - $this->_applyCountryWorkarounds($request); - - $request['address_override'] = 1; - } - - /** - * Adopt specified request array to be compatible with Paypal - * Puerto Rico should be as state of USA and not as a country - * - * @param array $request - */ - protected function _applyCountryWorkarounds(&$request) - { - if (isset($request['country']) && $request['country'] == 'PR') { - $request['country'] = 'US'; - $request['state'] = 'PR'; - } - } -} diff --git a/app/code/core/Mage/Paypal/Model/Bml.php b/app/code/core/Mage/Paypal/Model/Bml.php deleted file mode 100644 index 6bf8b1c8d8c..00000000000 --- a/app/code/core/Mage/Paypal/Model/Bml.php +++ /dev/null @@ -1,38 +0,0 @@ -_salesEntity = $salesEntity; + $this->_quote = $salesEntity; } else { throw new Exception('Invalid sales entity provided.'); } + $this->_validateCurrency(); } - /** - * Getter for the current sales entity - * - * @return Mage_Sales_Model_Order - * @return Mage_Sales_Model_Quote - */ - public function getSalesEntity() - { - return $this->_salesEntity; - } - - /** - * Render and get line items - * By default returns false if the items are invalid - * - * @param bool $bypassValidation - * @return array|false - */ - public function getItems($bypassValidation = false) - { - $this->_render(); - if (!$bypassValidation && !$this->_areItemsValid) { - return false; - } - return $this->_items; - } - - /** - * Render and get totals - * If the totals are invalid for any reason, they will be merged into one amount (subtotal is utilized for it) - * An option to subtract discount from the subtotal is available - * - * @param bool $mergeDiscount - * @return array - */ - public function getTotals($mergeDiscount = false) + protected function _validateCurrency() { - $this->_render(); - - // cut down totals to one total if they are invalid - if (!$this->_areTotalsValid) { - $totals = [ - self::TOTAL_SUBTOTAL => $this->_totals[self::TOTAL_SUBTOTAL] + $this->_totals[self::TOTAL_TAX], - ]; - if (!$this->_isShippingAsItem) { - $totals[self::TOTAL_SUBTOTAL] += $this->_totals[self::TOTAL_SHIPPING]; - } - if (!$this->_isDiscountAsItem) { - $totals[self::TOTAL_SUBTOTAL] -= $this->_totals[self::TOTAL_DISCOUNT]; - } - return $totals; - } elseif ($mergeDiscount) { - $totals = $this->_totals; - unset($totals[self::TOTAL_DISCOUNT]); - if (!$this->_isDiscountAsItem) { - $totals[self::TOTAL_SUBTOTAL] -= $this->_totals[self::TOTAL_DISCOUNT]; - } - return $totals; - } - return $this->_totals; - } + $allowedCurrencies = Mage::getModel('paypal/config')->getAllowedCurrencyCodes(); + $currentCurrency = $this->_quote->getOrderCurrencyCode() + ?: $this->_quote->getQuoteCurrencyCode(); - /** - * Add a line item - * - * @param string $name - * @param numeric $qty - * @param float $amount - * @param string $identifier - * @return Varien_Object - */ - public function addItem($name, $qty, $amount, $identifier = null) - { - $this->_shouldRender = true; - $item = new Varien_Object([ - 'name' => $name, - 'qty' => $qty, - 'amount' => (float) $amount, - ]); - if ($identifier) { - $item->setData('id', $identifier); + if (!in_array($currentCurrency, $allowedCurrencies)) { + throw new Mage_Core_Exception( + Mage::helper('paypal')->__('Selected currency code (%s) is not supported by PayPal', $currentCurrency) + ); } - $this->_items[] = $item; - return $item; + $this->_currency = $currentCurrency; + return $this; } - /** - * Remove item from cart by identifier - * - * @param string $identifier - * @return bool - */ - public function removeItem($identifier) + public function getAllItems() { - foreach ($this->_items as $key => $item) { - if ($item->getId() == $identifier) { - unset($this->_items[$key]); - return true; - } + if (empty($this->_items)) { + $this->_prepareItems(); } - return false; + return $this->_items; } - /** - * Compound the specified amount with the specified total - * - * @param string $code - * @param float $amount - * @param string $lineItemDescription - * @return $this - */ - public function updateTotal($code, $amount, $lineItemDescription = null) + public function getAmounts() { - $this->_shouldRender = true; - if (isset($this->_totals[$code])) { - $this->_totals[$code] += $amount; - if ($lineItemDescription) { - $this->_totalLineItemDescriptions[$code][] = $lineItemDescription; - } + if (empty($this->_totals)) { + $this->_prepareTotals(); } - return $this; + return $this->_totals; } - /** - * Get/Set whether to render the discount total as a line item - * - * @param bool $setValue - * @return bool|$this - */ - public function isDiscountAsItem($setValue = null) + protected function _prepareItems() { - return $this->_totalAsItem('_isDiscountAsItem', $setValue); - } + foreach ($this->_quote->getAllVisibleItems() as $item) { + $taxAmount = $item->getData('tax_amount'); + $qty = $item->getQty(); + $moneyBuilder = MoneyBuilder::init( + $this->_currency, + number_format($item->getCalculationPrice(), 2, '.', '') + ); - /** - * Get/Set whether to render the discount total as a line item - * - * @param bool $setValue - * @return bool|$this - */ - public function isShippingAsItem($setValue = null) - { - return $this->_totalAsItem('_isShippingAsItem', $setValue); - } + $taxMoneyBuilder = ($taxAmount > 0) + ? MoneyBuilder::init($this->_currency, number_format($taxAmount / $qty, 2, '.', '')) + : null; - /** - * (re)Render all items and totals - */ - protected function _render() - { - if (!$this->_shouldRender) { - return; - } + $itemBuilder = ItemBuilder::init($item->getName(), $moneyBuilder->build(), (string) $qty) + ->sku($item->getSku()) + ->category($item->getIsVirtual() ? ItemCategory::DIGITAL_GOODS : ItemCategory::PHYSICAL_GOODS); - // regular items from the sales entity - $this->_items = []; - foreach ($this->_salesEntity->getAllItems() as $item) { - if (!$item->getParentItem()) { - $this->_addRegularItem($item); + if ($taxMoneyBuilder) { + $itemBuilder->tax($taxMoneyBuilder->build()); } - } - $lastRegularItemKey = array_key_last($this->_items); - - // regular totals - $shippingDescription = ''; - if ($this->_salesEntity instanceof Mage_Sales_Model_Order) { - $shippingDescription = $this->_salesEntity->getShippingDescription(); - $this->_totals = [ - self::TOTAL_SUBTOTAL => $this->_salesEntity->getBaseSubtotal(), - self::TOTAL_TAX => $this->_salesEntity->getBaseTaxAmount(), - self::TOTAL_SHIPPING => $this->_salesEntity->getBaseShippingAmount(), - self::TOTAL_DISCOUNT => abs($this->_salesEntity->getBaseDiscountAmount()), - ]; - $this->_applyHiddenTaxWorkaround($this->_salesEntity); - } else { - $address = $this->_salesEntity->getIsVirtual() ? - $this->_salesEntity->getBillingAddress() : $this->_salesEntity->getShippingAddress(); - $shippingDescription = $address->getShippingDescription(); - $this->_totals = [ - self::TOTAL_SUBTOTAL => $this->_salesEntity->getBaseSubtotal(), - self::TOTAL_TAX => $address->getBaseTaxAmount(), - self::TOTAL_SHIPPING => $address->getBaseShippingAmount(), - self::TOTAL_DISCOUNT => abs($address->getBaseDiscountAmount()), - ]; - $this->_applyHiddenTaxWorkaround($address); - } - $originalDiscount = $this->_totals[self::TOTAL_DISCOUNT]; - - // arbitrary items, total modifications - Mage::dispatchEvent('paypal_prepare_line_items', ['paypal_cart' => $this]); - - // distinguish original discount among the others - if ($originalDiscount > 0.0001 && isset($this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT])) { - $this->_totalLineItemDescriptions[self::TOTAL_DISCOUNT][] = Mage::helper('sales')->__('Discount (%s)', Mage::app()->getStore()->convertPrice($originalDiscount, true, false)); - } - - // discount, shipping as items - if ($this->_isDiscountAsItem && $this->_totals[self::TOTAL_DISCOUNT]) { - $this->addItem( - Mage::helper('paypal')->__('Discount'), - 1, - -1.00 * $this->_totals[self::TOTAL_DISCOUNT], - $this->_renderTotalLineItemDescriptions(self::TOTAL_DISCOUNT), - ); - } - $shippingItemId = $this->_renderTotalLineItemDescriptions(self::TOTAL_SHIPPING, $shippingDescription); - if ($this->_isShippingAsItem && (float) $this->_totals[self::TOTAL_SHIPPING]) { - $this->addItem( - Mage::helper('paypal')->__('Shipping'), - 1, - (float) $this->_totals[self::TOTAL_SHIPPING], - $shippingItemId, - ); - } - - // compound non-regular items into subtotal - foreach ($this->_items as $key => $item) { - if ($key > $lastRegularItemKey && $item->getAmount() != 0) { - $this->_totals[self::TOTAL_SUBTOTAL] += $item->getAmount(); + $description = $item->getDescription(); + if ($description) { + $itemBuilder->description(substr($description, 0, 127)); } + $this->_items[] = $itemBuilder->build(); } - $this->_validate(); - // if cart items are invalid, prepare cart for transfer without line items - if (!$this->_areItemsValid) { - $this->removeItem($shippingItemId); - } - - $this->_shouldRender = false; - } - - /** - * Merge multiple descriptions by a total code into a string - * - * @param string $code - * @param string $prepend - * @param string $append - * @param string $glue - * @return string - */ - protected function _renderTotalLineItemDescriptions($code, $prepend = '', $append = '', $glue = '; ') - { - $result = []; - if ($prepend) { - $result[] = $prepend; - } - if (isset($this->_totalLineItemDescriptions[$code])) { - $result = array_merge($this->_totalLineItemDescriptions[$code]); - } - if ($append) { - $result[] = $append; - } - return implode($glue, $result); - } - - /** - * Check the line items and totals according to PayPal business logic limitations - */ - protected function _validate() - { - $this->_areItemsValid = true; - $this->_areTotalsValid = false; - - $referenceAmount = $this->_salesEntity->getBaseGrandTotal(); - - $itemsSubtotal = 0; - foreach ($this->_items as $i) { - $itemsSubtotal = $itemsSubtotal + $i['qty'] * $i['amount']; - } - $sum = $itemsSubtotal + $this->_totals[self::TOTAL_TAX]; - if (!$this->_isShippingAsItem) { - $sum += $this->_totals[self::TOTAL_SHIPPING]; - } - if (!$this->_isDiscountAsItem) { - $sum -= $this->_totals[self::TOTAL_DISCOUNT]; - } - /** - * numbers are intentionally converted to strings because of possible comparison error - * see http://php.net/float - */ - // match sum of all the items and totals to the reference amount - if (sprintf('%.4F', $sum) != sprintf('%.4F', $referenceAmount)) { - $adjustment = $sum - $referenceAmount; - $this->_totals[self::TOTAL_SUBTOTAL] = $this->_totals[self::TOTAL_SUBTOTAL] - $adjustment; - } - - // PayPal requires to have discount less than items subtotal - if (!$this->_isDiscountAsItem) { - $this->_areTotalsValid = round($this->_totals[self::TOTAL_DISCOUNT], 4) < round($itemsSubtotal, 4); - } else { - $this->_areTotalsValid = $itemsSubtotal > 0.00001; - } - - $this->_areItemsValid = $this->_areItemsValid && $this->_areTotalsValid; - } - - /** - * Check whether items are valid - * - * @return bool - */ - public function areItemsValid() - { - return $this->_areItemsValid; - } - - /** - * Add a usual line item with amount and qty - * - * @return Varien_Object - */ - protected function _addRegularItem(Varien_Object $salesItem) - { - if ($this->_salesEntity instanceof Mage_Sales_Model_Order) { - // TODO: nominal item for order - $qty = (int) $salesItem->getQtyOrdered(); - $amount = (float) $salesItem->getBasePrice(); - } else { - $qty = (int) $salesItem->getTotalQty(); - $amount = $salesItem->isNominal() ? 0 : (float) $salesItem->getBaseCalculationPrice(); - } - // workaround in case if item subtotal precision is not compatible with PayPal (.2) - $subAggregatedLabel = ''; - if ($amount - round($amount, 2)) { - $amount = $amount * $qty; - $subAggregatedLabel = ' x' . $qty; - $qty = 1; - } - - // aggregate item price if item qty * price does not match row total - if ($amount * $qty != $salesItem->getBaseRowTotal()) { - $amount = (float) $salesItem->getBaseRowTotal(); - $subAggregatedLabel = ' x' . $qty; - $qty = 1; - } - - return $this->addItem($salesItem->getName() . $subAggregatedLabel, $qty, $amount, $salesItem->getSku()); - } - - /** - * Get/Set for the specified variable. - * If the value changes, the re-rendering is commenced - * - * @param string $var - * @param mixed $setValue - * @return mixed|$this - */ - private function _totalAsItem($var, $setValue = null) - { - if ($setValue !== null) { - if ($setValue != $this->$var) { - $this->_shouldRender = true; - } - $this->$var = $setValue; - return $this; - } - return $this->$var; + return $this; } + protected function _prepareTotals() + { + $this->_quote->collectTotals()->save(); + $shippingAddress = $this->_quote->getShippingAddress(); + $totalDiscount = abs($shippingAddress->getDiscountAmount() ?? 0); + $this->_totals = [ + self::TOTAL_SUBTOTAL => MoneyBuilder::init( + $this->_currency, + number_format($this->_quote->getSubtotal(), 2, '.', '') + )->build(), + self::TOTAL_TAX => MoneyBuilder::init( + $this->_currency, + number_format($shippingAddress->getTaxAmount() ?? 0, 2, '.', '') + )->build(), + self::TOTAL_SHIPPING => MoneyBuilder::init( + $this->_currency, + number_format($shippingAddress->getShippingAmount() ?? 0, 2, '.', '') + )->build(), + self::TOTAL_DISCOUNT => MoneyBuilder::init( + $this->_currency, + number_format($totalDiscount, 2, '.', '') + )->build() + ]; - /** - * Add "hidden" discount and shipping tax - * - * Go ahead, try to understand ]:-> - * - * Tax settings for getting "discount tax": - * - Catalog Prices = Including Tax - * - Apply Customer Tax = After Discount - * - Apply Discount on Prices = Including Tax - * - * Test case for getting "hidden shipping tax": - * - Make sure shipping is taxable (set shipping tax class) - * - Catalog Prices = Including Tax - * - Shipping Prices = Including Tax - * - Apply Customer Tax = After Discount - * - Create a shopping cart price rule with % discount applied to the Shipping Amount - * - run shopping cart and estimate shipping - * - go to PayPal - * - * @param Mage_Core_Model_Abstract $salesEntity - */ - private function _applyHiddenTaxWorkaround($salesEntity) - { - $this->_totals[self::TOTAL_TAX] += (float) $salesEntity->getBaseHiddenTaxAmount(); - $this->_totals[self::TOTAL_TAX] += (float) $salesEntity->getBaseShippingHiddenTaxAmount(); + return $this; } /** - * Check whether any item has negative amount + * Get the quote object associated with this cart. * - * @return bool + * @return Mage_Sales_Model_Quote */ - public function hasNegativeItemAmount() + public function getQuote() { - foreach ($this->_items as $item) { - if ($item->getAmount() < 0) { - return true; - } - } - return false; + return $this->_quote; } } diff --git a/app/code/core/Mage/Paypal/Model/Cert.php b/app/code/core/Mage/Paypal/Model/Cert.php deleted file mode 100644 index 15225ae87c6..00000000000 --- a/app/code/core/Mage/Paypal/Model/Cert.php +++ /dev/null @@ -1,115 +0,0 @@ -_init('paypal/cert'); - } - - /** - * Load model by website id - * - * @param int $websiteId - * @param bool $strictLoad - * @return $this - */ - public function loadByWebsite($websiteId, $strictLoad = true) - { - $this->setWebsiteId($websiteId); - $this->_getResource()->loadByWebsite($this, $strictLoad); - return $this; - } - - /** - * Get path to PayPal certificate file, if file does not exist try to create it - * - * @return string - */ - public function getCertPath() - { - if (!$this->getContent()) { - Mage::throwException(Mage::helper('paypal')->__('PayPal certificate does not exist.')); - } - - $certFileName = sprintf('cert_%s_%s.pem', $this->getWebsiteId(), strtotime($this->getUpdatedAt())); - $certFile = $this->_getBaseDir() . DS . $certFileName; - - if (!file_exists($certFile)) { - $this->_createCertFile($certFile); - } - return $certFile; - } - - /** - * Create physical certificate file based on DB data - * - * @param string $file - */ - protected function _createCertFile($file) - { - $certDir = $this->_getBaseDir(); - if (!is_dir($certDir)) { - $ioAdapter = new Varien_Io_File(); - $ioAdapter->checkAndCreateFolder($certDir); - } else { - $this->_removeOutdatedCertFile(); - } - - file_put_contents($file, Mage::helper('core')->decrypt($this->getContent())); - } - - /** - * Check and remove outdated certificate file by website - */ - protected function _removeOutdatedCertFile() - { - $certDir = $this->_getBaseDir(); - if (is_dir($certDir)) { - $entries = scandir($certDir); - foreach ($entries as $entry) { - if ($entry != '.' && $entry != '..' && str_contains($entry, 'cert_' . $this->getWebsiteId())) { - unlink($certDir . DS . $entry); - } - } - } - } - - /** - * Retrieve base directory for certificate - * - * @return string - */ - protected function _getBaseDir() - { - return Mage::getBaseDir('var') . DS . self::BASEPATH_PAYPAL_CERT; - } - - /** - * Delete assigned certificate file after delete object - * - * @return $this - */ - protected function _afterDelete() - { - $this->_removeOutdatedCertFile(); - return $this; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Config.php b/app/code/core/Mage/Paypal/Model/Config.php index 9cb2e616707..7e416554630 100644 --- a/app/code/core/Mage/Paypal/Model/Config.php +++ b/app/code/core/Mage/Paypal/Model/Config.php @@ -1,247 +1,37 @@ 'WPS', - 'paypal_express' => 'EC', - 'paypal_direct' => 'DP', - 'paypaluk_express' => 'EC', - 'paypaluk_direct' => 'DP', - ]; + const BUTTON_LAYOUT_VERTICAL = 'vertical'; + const BUTTON_LAYOUT_HORIZONTAL = 'horizontal'; - /** - * Style system config map (Express Checkout) - * - * @var array - */ - protected $_ecStyleConfigMap = [ - 'page_style' => 'page_style', - 'paypal_hdrimg' => 'hdrimg', - 'paypal_hdrbordercolor' => 'hdrbordercolor', - 'paypal_hdrbackcolor' => 'hdrbackcolor', - 'paypal_payflowcolor' => 'payflowcolor', - ]; + const BUTTON_LABEL_PAYPAL = 'paypal'; + const BUTTON_LABEL_CHECKOUT = 'checkout'; + const BUTTON_LABEL_BUYNOW = 'buynow'; + const BUTTON_LABEL_PAY = 'pay'; + const BUTTON_LABEL_INSTALLMENT = 'installment'; /** - * Currency codes supported by PayPal methods + * Supported currencies for PayPal transactions + * https://developer.paypal.com/docs/reports/reference/paypal-supported-currencies/ * * @var array */ - protected $_supportedCurrencyCodes = [ + protected $_supportedCurrencies = [ 'AUD', + 'BRL', 'CAD', + 'CNY', 'CZK', 'DKK', 'EUR', @@ -249,1690 +39,80 @@ class Mage_Paypal_Model_Config 'HUF', 'ILS', 'JPY', + 'MYR', 'MXN', - 'NOK', + 'TWD', 'NZD', + 'NOK', + 'PHP', 'PLN', 'GBP', - 'RUB', 'SGD', 'SEK', 'CHF', - 'TWD', 'THB', - 'USD', - 'INR', - ]; - - /** - * Merchant country supported by PayPal - * - * @var array - */ - protected $_supportedCountryCodes = [ - 'AE', - 'AR', - 'AT', - 'AU', - 'BE', - 'BG', - 'BR', - 'CA', - 'CN', - 'CH', - 'CL', - 'CR', - 'CY', - 'CZ', - 'DE', - 'DK', - 'DO', - 'EC', - 'EE', - 'ES', - 'FI', - 'FR', - 'GB', - 'GF', - 'GI', - 'GP', - 'GR', - 'HK', - 'HU', - 'ID', - 'IE', - 'IL', - 'IN', - 'IS', - 'IT', - 'JM', - 'JP', - 'KR', - 'LI', - 'LT', - 'LU', - 'LV', - 'MQ', - 'MT', - 'MX', - 'MY', - 'NL', - 'NO', - 'NZ', - 'PH', - 'PL', - 'PT', - 'RU', - 'RE', - 'RO', - 'SE', - 'SG', - 'SI', - 'SK', - 'SM', - 'TH', - 'TR', - 'TW', - 'US', - 'UY', - 'VE', - 'VN', - 'ZA', - ]; - - /** - * Buyer country supported by PayPal - * - * @var array - */ - protected $_supportedBuyerCountryCodes = [ - 'AF ', - 'AX ', - 'AL ', - 'DZ ', - 'AS ', - 'AD ', - 'AO ', - 'AI ', - 'AQ ', - 'AG ', - 'AR ', - 'AM ', - 'AW ', - 'AU ', - 'AT ', - 'AZ ', - 'BS ', - 'BH ', - 'BD ', - 'BB ', - 'BY ', - 'BE ', - 'BZ ', - 'BJ ', - 'BM ', - 'BT ', - 'BO ', - 'BA ', - 'BW ', - 'BV ', - 'BR ', - 'IO ', - 'BN ', - 'BG ', - 'BF ', - 'BI ', - 'KH ', - 'CM ', - 'CA ', - 'CV ', - 'KY ', - 'CF ', - 'TD ', - 'CL ', - 'CN ', - 'CX ', - 'CC ', - 'CO ', - 'KM ', - 'CG ', - 'CD ', - 'CK ', - 'CR ', - 'CI ', - 'HR ', - 'CU ', - 'CY ', - 'CZ ', - 'DK ', - 'DJ ', - 'DM ', - 'DO ', - 'EC ', - 'EG ', - 'SV ', - 'GQ ', - 'ER ', - 'EE ', - 'ET ', - 'FK ', - 'FO ', - 'FJ ', - 'FI ', - 'FR ', - 'GF ', - 'PF ', - 'TF ', - 'GA ', - 'GM ', - 'GE ', - 'DE ', - 'GH ', - 'GI ', - 'GR ', - 'GL ', - 'GD ', - 'GP ', - 'GU ', - 'GT ', - 'GG ', - 'GN ', - 'GW ', - 'GY ', - 'HT ', - 'HM ', - 'VA ', - 'HN ', - 'HK ', - 'HU ', - 'IS ', - 'IN ', - 'ID ', - 'IR ', - 'IQ ', - 'IE ', - 'IM ', - 'IL ', - 'IT ', - 'JM ', - 'JP ', - 'JE ', - 'JO ', - 'KZ ', - 'KE ', - 'KI ', - 'KP ', - 'KR ', - 'KW ', - 'KG ', - 'LA ', - 'LV ', - 'LB ', - 'LS ', - 'LR ', - 'LY ', - 'LI ', - 'LT ', - 'LU ', - 'MO ', - 'MK ', - 'MG ', - 'MW ', - 'MY ', - 'MV ', - 'ML ', - 'MT ', - 'MH ', - 'MQ ', - 'MR ', - 'MU ', - 'YT ', - 'MX ', - 'FM ', - 'MD ', - 'MC ', - 'MN ', - 'MS ', - 'MA ', - 'MZ ', - 'MM ', - 'NA ', - 'NR ', - 'NP ', - 'NL ', - 'AN ', - 'NC ', - 'NZ ', - 'NI ', - 'NE ', - 'NG ', - 'NU ', - 'NF ', - 'MP ', - 'NO ', - 'OM ', - 'PK ', - 'PW ', - 'PS ', - 'PA ', - 'PG ', - 'PY ', - 'PE ', - 'PH ', - 'PN ', - 'PL ', - 'PT ', - 'PR ', - 'QA ', - 'RE ', - 'RO ', - 'RU ', - 'RW ', - 'SH ', - 'KN ', - 'LC ', - 'PM ', - 'VC ', - 'WS ', - 'SM ', - 'ST ', - 'SA ', - 'SN ', - 'CS ', - 'SC ', - 'SL ', - 'SG ', - 'SK ', - 'SI ', - 'SB ', - 'SO ', - 'ZA ', - 'GS ', - 'ES ', - 'LK ', - 'SD ', - 'SR ', - 'SJ ', - 'SZ ', - 'SE ', - 'CH ', - 'SY ', - 'TW ', - 'TJ ', - 'TZ ', - 'TH ', - 'TL ', - 'TG ', - 'TK ', - 'TO ', - 'TT ', - 'TN ', - 'TR ', - 'TM ', - 'TC ', - 'TV ', - 'UG ', - 'UA ', - 'AE ', - 'GB ', - 'US ', - 'UM ', - 'UY ', - 'UZ ', - 'VU ', - 'VE ', - 'VN ', - 'VG ', - 'VI ', - 'WF ', - 'EH ', - 'YE ', - 'ZM ', - 'ZW', - ]; - - /** - * Locale codes supported by misc images (marks, shortcuts etc) - * - * @var array - * @link https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECButtonIntegration#id089QD0O0TX4__id08AH904I0YK - */ - protected $_supportedImageLocales = [ - 'de_DE', - 'en_AU', - 'en_GB', - 'en_US', - 'es_ES', - 'es_XC', - 'fr_FR', - 'fr_XC', - 'it_IT', - 'ja_JP', - 'nl_NL', - 'pl_PL', - 'zh_CN', - 'zh_XC', + 'USD' ]; - /** - * @var array - */ - protected $_config = []; - - /** - * Set method and store id, if specified - * - * @param array $params - */ - public function __construct($params = []) - { - if ($params) { - $method = array_shift($params); - $this->setMethod($method); - if ($params) { - $storeId = array_shift($params); - $this->setStoreId($storeId); - } - } - } - - /** - * Method code setter - * - * @param string|Mage_Payment_Model_Method_Abstract $method - * @return $this - */ - public function setMethod($method) - { - if ($method instanceof Mage_Payment_Model_Method_Abstract) { - $this->_methodCode = $method->getCode(); - } elseif (is_string($method)) { - $this->_methodCode = $method; - } - return $this; - } - - /** - * Payment method instance code getter - * - * @return string - */ - public function getMethodCode() - { - return $this->_methodCode; - } - - /** - * Store ID setter - * - * @param int $storeId - * @return $this - */ - public function setStoreId($storeId) - { - $this->_storeId = (int) $storeId; - return $this; - } - - /** - * Check whether method active in configuration and supported for merchant country or not - * - * @param string $method Method code - * @return bool - */ - public function isMethodActive($method) - { - if ($this->isMethodSupportedForCountry($method) - && Mage::getStoreConfigFlag("payment/{$method}/active", $this->_storeId) - ) { - return true; - } - return false; - } - - /** - * Check whether method available for checkout or not - * Logic based on merchant country, methods dependence - * - * @param string|null $methodCode Method code - * @return bool - */ - public function isMethodAvailable($methodCode = null) - { - if ($methodCode === null) { - $methodCode = $this->getMethodCode(); - } - - $result = true; - - if (!$this->isMethodActive($methodCode)) { - $result = false; - } - - switch ($methodCode) { - case self::METHOD_WPS: - if (!$this->businessAccount) { - $result = false; - break; - } - // check for direct payments dependence - if ($this->isMethodActive(self::METHOD_WPP_DIRECT) - || $this->isMethodActive(self::METHOD_WPP_PE_DIRECT) - ) { - $result = false; - } - break; - case self::METHOD_WPP_EXPRESS: - // check for direct payments dependence - if ($this->isMethodActive(self::METHOD_WPP_PE_DIRECT)) { - $result = false; - } elseif ($this->isMethodActive(self::METHOD_WPP_DIRECT)) { - $result = true; - } - break; - case self::METHOD_BML: - // check for express payments dependence - if (!$this->isMethodActive(self::METHOD_WPP_EXPRESS)) { - $result = false; - } - break; - case self::METHOD_WPP_PE_EXPRESS: - // check for direct payments dependence - if ($this->isMethodActive(self::METHOD_WPP_PE_DIRECT)) { - $result = true; - } elseif (!$this->isMethodActive(self::METHOD_WPP_PE_DIRECT) - && !$this->isMethodActive(self::METHOD_PAYFLOWPRO) - ) { - $result = false; - } - break; - case self::METHOD_WPP_PE_BML: - // check for express payments dependence - if (!$this->isMethodActive(self::METHOD_WPP_PE_EXPRESS)) { - $result = false; - } - break; - case self::METHOD_BILLING_AGREEMENT: - $result = $this->isWppApiAvailabe(); - break; - case self::METHOD_WPP_DIRECT: - case self::METHOD_WPP_PE_DIRECT: - break; - } - return $result; - } - - /** - * Config field magic getter - * The specified key can be either in camelCase or under_score format - * Tries to map specified value according to set payment method code, into the configuration value - * Sets the values into public class parameters, to avoid redundant calls of this method - * - * @param string $key - * @return string|null - */ - public function __get($key) - { - if (array_key_exists($key, $this->_config)) { - return $this->_config[$key]; - } - - $underscored = strtolower(preg_replace('/(.)([A-Z])/', '$1_$2', $key)); - if (array_key_exists($underscored, $this->_config)) { - return $this->_config[$underscored]; - } - - $value = Mage::getStoreConfig($this->_getSpecificConfigPath($underscored), $this->_storeId); - $value = $this->_prepareValue($underscored, $value); - $this->_config[$key] = $value; - $this->_config[$underscored] = $value; - return $value; - } - - /** - * Perform additional config value preparation and return new value if needed - * - * @param string $key Underscored key - * @param string $value Old value - * @return string Modified value or old value - */ - protected function _prepareValue($key, $value) - { - // Always set payment action as "Sale" for Unilateral payments in EC - if ($key == 'payment_action' - && $value != self::PAYMENT_ACTION_SALE - && $this->_methodCode == self::METHOD_WPP_EXPRESS - && $this->shouldUseUnilateralPayments() - ) { - return self::PAYMENT_ACTION_SALE; - } - return $value; - } - - /** - * Return merchant country codes supported by PayPal - * - * @return array - */ - public function getSupportedMerchantCountryCodes() - { - return $this->_supportedCountryCodes; - } - - /** - * Return buyer country codes supported by PayPal - * - * @return array - */ - public function getSupportedBuyerCountryCodes() - { - return $this->_supportedBuyerCountryCodes; - } - - /** - * Return merchant country code, use default country if it not specified in General settings - * - * @return string - */ - public function getMerchantCountry() - { - $countryCode = Mage::getStoreConfig($this->_mapGeneralFieldset('merchant_country'), $this->_storeId); - if (!$countryCode) { - $countryCode = Mage::helper('core')->getDefaultCountry($this->_storeId); - } - return $countryCode; - } - - /** - * Check whether method supported for specified country or not - * Use $_methodCode and merchant country by default - * - * @return bool - */ - public function isMethodSupportedForCountry($method = null, $countryCode = null) - { - if ($method === null) { - $method = $this->getMethodCode(); - } - if ($countryCode === null) { - $countryCode = $this->getMerchantCountry(); - } - $countryMethods = $this->getCountryMethods($countryCode); - if (in_array($method, $countryMethods)) { - return true; - } - return false; - } - - /** - * Return list of allowed methods for specified country iso code - * - * @param string $countryCode 2-letters iso code - * @return array - */ - public function getCountryMethods($countryCode = null) - { - $countryMethods = [ - 'other' => [ - self::METHOD_WPS, - self::METHOD_WPP_EXPRESS, - self::METHOD_BILLING_AGREEMENT, - ], - 'US' => [ - self::METHOD_PAYFLOWADVANCED, - self::METHOD_WPP_DIRECT, - self::METHOD_WPS, - self::METHOD_PAYFLOWPRO, - self::METHOD_PAYFLOWLINK, - self::METHOD_WPP_EXPRESS, - self::METHOD_BML, - self::METHOD_BILLING_AGREEMENT, - self::METHOD_WPP_PE_EXPRESS, - self::METHOD_WPP_PE_BML, - ], - 'CA' => [ - self::METHOD_WPP_DIRECT, - self::METHOD_WPS, - self::METHOD_PAYFLOWPRO, - self::METHOD_PAYFLOWLINK, - self::METHOD_WPP_EXPRESS, - self::METHOD_BILLING_AGREEMENT, - ], - 'GB' => [ - self::METHOD_WPP_DIRECT, - self::METHOD_WPS, - self::METHOD_WPP_PE_DIRECT, - self::METHOD_HOSTEDPRO, - self::METHOD_WPP_EXPRESS, - self::METHOD_BILLING_AGREEMENT, - self::METHOD_WPP_PE_EXPRESS, - ], - 'AU' => [ - self::METHOD_WPS, - self::METHOD_PAYFLOWPRO, - self::METHOD_HOSTEDPRO, - self::METHOD_WPP_EXPRESS, - self::METHOD_BILLING_AGREEMENT, - ], - 'NZ' => [ - self::METHOD_WPS, - self::METHOD_PAYFLOWPRO, - self::METHOD_WPP_EXPRESS, - self::METHOD_BILLING_AGREEMENT, - ], - 'JP' => [ - self::METHOD_WPS, - self::METHOD_HOSTEDPRO, - self::METHOD_WPP_EXPRESS, - self::METHOD_BILLING_AGREEMENT, - ], - 'FR' => [ - self::METHOD_WPS, - self::METHOD_HOSTEDPRO, - self::METHOD_WPP_EXPRESS, - self::METHOD_BILLING_AGREEMENT, - ], - 'IT' => [ - self::METHOD_WPS, - self::METHOD_HOSTEDPRO, - self::METHOD_WPP_EXPRESS, - self::METHOD_BILLING_AGREEMENT, - ], - 'ES' => [ - self::METHOD_WPS, - self::METHOD_HOSTEDPRO, - self::METHOD_WPP_EXPRESS, - self::METHOD_BILLING_AGREEMENT, - ], - 'HK' => [ - self::METHOD_WPS, - self::METHOD_HOSTEDPRO, - self::METHOD_WPP_EXPRESS, - self::METHOD_BILLING_AGREEMENT, - ], - ]; - if ($countryCode === null) { - return $countryMethods; - } - return $countryMethods[$countryCode] ?? $countryMethods['other']; - } - - /** - * Return start url for PayPal Basic - * - * @param string $token - * @return string - */ - public function getPayPalBasicStartUrl($token) + public function getApiCredentials() { - $params = [ - 'cmd' => '_express-checkout', - 'token' => $token, + return [ + 'client_id' => $this->getConfigData('client_id'), + 'client_secret' => Mage::helper('core')->decrypt( + $this->getConfigData('client_secret') + ), ]; - - if ($this->isOrderReviewStepDisabled()) { - $params['useraction'] = 'commit'; - } - - return $this->getPaypalUrl($params); - } - - /** - * Check whether order review step enabled in configuration - * - * @return bool - */ - public function isOrderReviewStepDisabled() - { - return Mage::getStoreConfigFlag(self::XML_PATH_PAYPAL_EXPRESS_SKIP_ORDER_REVIEW_STEP_FLAG); - } - - /** - * Get url for dispatching customer to express checkout start - * - * @param string $token - * @return string - */ - public function getExpressCheckoutStartUrl($token) - { - return $this->getPaypalUrl([ - 'cmd' => '_express-checkout', - 'token' => $token, - ]); - } - - /** - * Get url for dispatching customer to checkout retrial - * - * @param string $orderId - * @return string - */ - public function getExpressCheckoutOrderUrl($orderId) - { - return $this->getPaypalUrl([ - 'cmd' => '_express-checkout', - 'order_id' => $orderId, - ]); - } - - /** - * Get url that allows to edit checkout details on paypal side - * - * @param string $token - * @return string - */ - public function getExpressCheckoutEditUrl($token) - { - return $this->getPaypalUrl([ - 'cmd' => '_express-checkout', - 'useraction' => 'continue', - 'token' => $token, - ]); } - /** - * Get url for additional actions that PayPal may require customer to do after placing the order. - * For instance, redirecting customer to bank for payment confirmation. - * - * @param string $token - * @return string - */ - public function getExpressCheckoutCompleteUrl($token) + public function isDebugEnabled() { - return $this->getPaypalUrl([ - 'cmd' => '_complete-express-checkout', - 'token' => $token, - ]); + return (bool)$this->getConfigData('debug'); } - /** - * Retrieve url for initialization of billing agreement - * - * @param string $token - * @return string - */ - public function getStartBillingAgreementUrl($token) + public function isSandbox() { - return $this->getPaypalUrl([ - 'cmd' => '_customer-billing-agreement', - 'token' => $token, - ]); + return (bool)$this->getConfigData('sandbox_mode'); } - /** - * PayPal web URL generic getter - * - * @return string - */ - public function getPaypalUrl(array $params = []) + public function getPaymentAction() { - return sprintf( - 'https://www.%spaypal.com/cgi-bin/webscr%s', - $this->sandboxFlag ? 'sandbox.' : '', - $params ? '?' . http_build_query($params) : '', - ); + return $this->getConfigData('payment_action'); } - /** - * Get postback endpoint URL. - * - * @return string - */ - public function getPostbackUrl() + public function getEndpoint() { - return sprintf('https://ipnpb.%spaypal.com/cgi-bin/webscr', $this->sandboxFlag ? 'sandbox.' : ''); + return $this->isSandbox() ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; } - /** - * Whether Express Checkout button should be rendered dynamically - * - * @return bool - */ - public function areButtonsDynamic() + public function getButtonConfiguration() { - return $this->buttonFlavor === self::EC_FLAVOR_DYNAMIC; + return [ + 'shape' => $this->getConfigData('button_shape'), + 'color' => $this->getConfigData('button_color'), + 'layout' => $this->getConfigData('button_layout'), + 'label' => $this->getConfigData('button_label'), + 'message' => (bool)$this->getConfigData('button_message') + ]; } - /** - * Express checkout shortcut pic URL getter - * PayPal will ignore "pal", if there is no total amount specified - * - * @param string $localeCode - * @param float $orderTotal - * @param string $pal encrypted summary about merchant - * @return string - * @see Paypal_Model_Api_Nvp::callGetPalDetails() - */ - public function getExpressCheckoutShortcutImageUrl($localeCode, $orderTotal = null, $pal = null) + public function getMerchantCountry() { - $country = Mage::getStoreConfig(Mage_Paypal_Helper_Data::MERCHANT_COUNTRY_CONFIG_PATH); - if ($country == Mage_Paypal_Helper_Data::US_COUNTRY - && ($this->areButtonsDynamic() || $this->buttonType != self::EC_BUTTON_TYPE_MARK) - ) { - return 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/checkout-logo-medium.png'; - } - if ($this->areButtonsDynamic()) { - return $this->_getDynamicImageUrl(self::EC_BUTTON_TYPE_SHORTCUT, $localeCode, $orderTotal, $pal); - } - if ($this->buttonType === self::EC_BUTTON_TYPE_MARK) { - return $this->getPaymentMarkImageUrl($localeCode); - } - return sprintf( - 'https://www.paypal.com/%s/i/btn/btn_xpressCheckout.gif', - $this->_getSupportedLocaleCode($localeCode), - ); + return $this->getConfigData('merchant_country') + ?: Mage::getStoreConfig('general/country/default'); } - /** - * Get PayPal "mark" image URL - * Supposed to be used on payment methods selection - * $staticSize is applicable for static images only - * - * @param string $localeCode - * @param float $orderTotal - * @param string $pal - * @param string $staticSize - * @return string - */ - public function getPaymentMarkImageUrl($localeCode, $orderTotal = null, $pal = null, $staticSize = null) + public function isActive($store = null) { - $country = Mage::getStoreConfig(Mage_Paypal_Helper_Data::MERCHANT_COUNTRY_CONFIG_PATH); - if ($country == Mage_Paypal_Helper_Data::US_COUNTRY) { - return 'https://www.paypalobjects.com/webstatic/en_US/i/buttons/pp-acceptance-medium.png'; - } - if ($this->areButtonsDynamic()) { - return $this->_getDynamicImageUrl(self::EC_BUTTON_TYPE_MARK, $localeCode, $orderTotal, $pal); - } - - if ($staticSize === null) { - $staticSize = $this->paymentMarkSize; - } - switch ($staticSize) { - case self::PAYMENT_MARK_37X23: - case self::PAYMENT_MARK_50X34: - case self::PAYMENT_MARK_60X38: - case self::PAYMENT_MARK_180X113: - break; - default: - $staticSize = self::PAYMENT_MARK_37X23; - } - return sprintf( - 'https://www.paypal.com/%s/i/logo/PayPal_mark_%s.gif', - $this->_getSupportedLocaleCode($localeCode), - $staticSize, - ); + return (bool)$this->getConfigData('active', $store); } - /** - * Get "What Is PayPal" localized URL - * Supposed to be used with "mark" as popup window - * - * @return string - */ - public function getPaymentMarkWhatIsPaypalUrl(?Mage_Core_Model_Locale $locale = null) + public function getAllowedCurrencyCodes() { - $countryCode = 'US'; - if ($locale !== null) { - $shouldEmulate = ($this->_storeId !== null) && (Mage::app()->getStore()->getId() != $this->_storeId); - if ($shouldEmulate) { - $locale->emulate($this->_storeId); - } - $countryCode = $locale->getLocale()->getRegion(); - if ($shouldEmulate) { - $locale->revert(); - } - } - return sprintf( - 'https://www.paypal.com/%s/cgi-bin/webscr?cmd=xpt/Marketing/popup/OLCWhatIsPayPal-outside', - strtolower($countryCode), - ); + return $this->_supportedCurrencies; } - /** - * Getter for Solution banner images - * - * @param string $localeCode - * @param bool $isVertical - * @param bool $isEcheck - * @return string - */ - public function getSolutionImageUrl($localeCode, $isVertical = false, $isEcheck = false) - { - return sprintf( - 'https://www.paypal.com/%s/i/bnr/%s_solution_PP%s.gif', - $this->_getSupportedLocaleCode($localeCode), - $isVertical ? 'vertical' : 'horizontal', - $isEcheck ? 'eCheck' : '', - ); - } - - /** - * Getter for Payment form logo images - * - * @param string $localeCode - * @return string - */ - public function getPaymentFormLogoUrl($localeCode) - { - $locale = $this->_getSupportedLocaleCode($localeCode); - - $imageType = 'logo'; - $domain = 'paypal.com'; - [, $country] = explode('_', $locale); - $countryPrefix = $country . '/'; - - switch ($locale) { - case 'en_GB': - $imageName = 'horizontal_solution_PP'; - $imageType = 'bnr'; - $countryPrefix = ''; - break; - case 'de_DE': - $imageName = 'lockbox_150x47'; - break; - case 'fr_FR': - $imageName = 'bnr_horizontal_solution_PP_327wx80h'; - $imageType = 'bnr'; - $locale = self::LOCALE_US; - $domain = 'paypalobjects.com'; - break; - case 'it_IT': - $imageName = 'bnr_horizontal_solution_PP_178wx80h'; - $imageType = 'bnr'; - $domain = 'paypalobjects.com'; - break; - default: - $imageName = 'PayPal_mark_60x38'; - $countryPrefix = ''; - break; - } - return sprintf('https://www.%s/%s/%si/%s/%s.gif', $domain, $locale, $countryPrefix, $imageType, $imageName); - } - - /** - * Return supported types for PayPal logo - * - * @return array - */ - public function getAdditionalOptionsLogoTypes() - { - return [ - 'wePrefer_150x60' => Mage::helper('paypal')->__('We prefer PayPal (150 X 60)'), - 'wePrefer_150x40' => Mage::helper('paypal')->__('We prefer PayPal (150 X 40)'), - 'nowAccepting_150x60' => Mage::helper('paypal')->__('Now accepting PayPal (150 X 60)'), - 'nowAccepting_150x40' => Mage::helper('paypal')->__('Now accepting PayPal (150 X 40)'), - 'paymentsBy_150x60' => Mage::helper('paypal')->__('Payments by PayPal (150 X 60)'), - 'paymentsBy_150x40' => Mage::helper('paypal')->__('Payments by PayPal (150 X 40)'), - 'shopNowUsing_150x60' => Mage::helper('paypal')->__('Shop now using (150 X 60)'), - 'shopNowUsing_150x40' => Mage::helper('paypal')->__('Shop now using (150 X 40)'), - ]; - } - - /** - * Return PayPal logo URL with additional options - * - * @param string $localeCode Supported locale code - * @param string|false $type One of supported logo types - * @return string|bool Logo Image URL or false if logo disabled in configuration - */ - public function getAdditionalOptionsLogoUrl($localeCode, $type = false) - { - $configType = Mage::getStoreConfig($this->_mapGenericStyleFieldset('logo'), $this->_storeId); - if (!$configType) { - return false; - } - $type = $type ? $type : $configType; - $locale = $this->_getSupportedLocaleCode($localeCode); - if (!array_key_exists($type, $this->getAdditionalOptionsLogoTypes())) { - $type = self::DEFAULT_LOGO_TYPE; - } - return sprintf('https://www.paypalobjects.com/%s/i/bnr/bnr_%s.gif', $locale, $type); - } - - /** - * BN code getter - * - * @return mixed - */ - public function getBuildNotationCode() - { - return Mage::getStoreConfig('paypal/bncode', $this->_storeId); - } - - /** - * Express Checkout button "flavors" source getter - * - * @return array - */ - public function getExpressCheckoutButtonFlavors() - { - return [ - self::EC_FLAVOR_DYNAMIC => Mage::helper('paypal')->__('Dynamic'), - self::EC_FLAVOR_STATIC => Mage::helper('paypal')->__('Static'), - ]; - } - - /** - * Express Checkout button types source getter - * - * @return array - */ - public function getExpressCheckoutButtonTypes() - { - return [ - self::EC_BUTTON_TYPE_SHORTCUT => Mage::helper('paypal')->__('Shortcut'), - self::EC_BUTTON_TYPE_MARK => Mage::helper('paypal')->__('Acceptance Mark Image'), - ]; - } - - /** - * Payment actions source getter - * - * @return array - */ - public function getPaymentActions() - { - $paymentActions = [ - self::PAYMENT_ACTION_AUTH => Mage::helper('paypal')->__('Authorization'), - self::PAYMENT_ACTION_SALE => Mage::helper('paypal')->__('Sale'), - ]; - if (!is_null($this->_methodCode) && $this->_methodCode == self::METHOD_WPP_EXPRESS) { - $paymentActions[self::PAYMENT_ACTION_ORDER] = Mage::helper('paypal')->__('Order'); - } - return $paymentActions; - } - - /** - * Require Billing Address source getter - * - * @return array - */ - public function getRequireBillingAddressOptions() - { - return [ - self::REQUIRE_BILLING_ADDRESS_ALL => Mage::helper('paypal')->__('Yes'), - self::REQUIRE_BILLING_ADDRESS_NO => Mage::helper('paypal')->__('No'), - self::REQUIRE_BILLING_ADDRESS_VIRTUAL => Mage::helper('paypal')->__('For Virtual Quotes Only'), - ]; - } - - /** - * Mapper from PayPal-specific payment actions to Magento payment actions - * - * @return string|null - */ - public function getPaymentAction() - { - switch ($this->paymentAction) { - case self::PAYMENT_ACTION_AUTH: - return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE; - case self::PAYMENT_ACTION_SALE: - return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE; - case self::PAYMENT_ACTION_ORDER: - return Mage_Payment_Model_Method_Abstract::ACTION_ORDER; - } - return null; - } - - /** - * Returns array of possible Authorization Amounts for Account Verification - * - * @deprecated since 1.6.2.0 - * @return array - */ - public function getAuthorizationAmounts() - { - return []; - } - - /** - * Express Checkout "solution types" source getter - * "sole" = "Express Checkout for Auctions" - PayPal allows guest checkout - * "mark" = "Normal Express Checkout" - PayPal requires to checkout with PayPal buyer account only - * - * @return array - */ - public function getExpressCheckoutSolutionTypes() - { - return [ - self::EC_SOLUTION_TYPE_SOLE => Mage::helper('paypal')->__('Yes'), - self::EC_SOLUTION_TYPE_MARK => Mage::helper('paypal')->__('No'), - ]; - } - - /** - * Retrieve express checkout billing agreement signup options - * - * @return array - */ - public function getExpressCheckoutBASignupOptions() - { - return [ - self::EC_BA_SIGNUP_AUTO => Mage::helper('paypal')->__('Auto'), - self::EC_BA_SIGNUP_ASK => Mage::helper('paypal')->__('Ask Customer'), - self::EC_BA_SIGNUP_NEVER => Mage::helper('paypal')->__('Never'), - ]; - } - - /** - * Whether to ask customer to create billing agreements - * Unilateral payments are incompatible with the billing agreements - * - * @return bool - */ - public function shouldAskToCreateBillingAgreement() - { - return ($this->allow_ba_signup === self::EC_BA_SIGNUP_ASK) && !$this->shouldUseUnilateralPayments(); - } - - /** - * Check whether only Unilateral payments (Accelerated Boarding) possible for Express method or not - * - * @return bool - */ - public function shouldUseUnilateralPayments() - { - return $this->business_account && !$this->isWppApiAvailabe(); - } - - /** - * Check whether WPP API credentials are available for this method - * - * @return bool - */ - public function isWppApiAvailabe() - { - return $this->api_username && $this->api_password && ($this->api_signature || $this->api_cert); - } - - /** - * Payment data delivery methods getter for PayPal Standard - * - * @return array - */ - public function getWpsPaymentDeliveryMethods() - { - return [ - self::WPS_TRANSPORT_IPN => Mage::helper('adminhtml')->__('IPN (Instant Payment Notification) Only'), - ]; - } - - /** - * Return list of supported credit card types by Paypal Direct gateway - * - * @return array - */ - public function getWppCcTypesAsOptionArray() - { - $model = Mage::getModel('payment/source_cctype')->setAllowedTypes(['AE', 'VI', 'MC', 'SM', 'SO', 'DI']); - return $model->toOptionArray(); - } - - /** - * Return list of supported credit card types by Paypal Direct (Payflow Edition) gateway - * - * @return array - */ - public function getWppPeCcTypesAsOptionArray() - { - $model = Mage::getModel('payment/source_cctype')->setAllowedTypes(['VI', 'MC', 'SM', 'SO', 'OT', 'AE']); - return $model->toOptionArray(); - } - - /** - * Return list of supported credit card types by Payflow Pro gateway - * - * @return array - */ - public function getPayflowproCcTypesAsOptionArray() - { - $model = Mage::getModel('payment/source_cctype')->setAllowedTypes(['AE', 'VI', 'MC', 'JCB', 'DI']); - return $model->toOptionArray(); - } - - /** - * Check whether the specified payment method is a CC-based one - * - * @param string $code - * @return bool - */ - public static function getIsCreditCardMethod($code) - { - switch ($code) { - case self::METHOD_WPP_DIRECT: - case self::METHOD_WPP_PE_DIRECT: - case self::METHOD_PAYFLOWPRO: - case self::METHOD_PAYFLOWLINK: - case self::METHOD_PAYFLOWADVANCED: - case self::METHOD_HOSTEDPRO: - return true; - } - return false; - } - - /** - * Check whether specified currency code is supported - * - * @param string $code - * @return bool - */ - public function isCurrencyCodeSupported($code) - { - if (in_array($code, $this->_supportedCurrencyCodes)) { - return true; - } - if ($this->getMerchantCountry() == 'BR' && $code == 'BRL') { - return true; - } - if ($this->getMerchantCountry() == 'MY' && $code == 'MYR') { - return true; - } - return false; - } - - /** - * Export page style current settings to specified object - */ - public function exportExpressCheckoutStyleSettings(Varien_Object $to) - { - foreach ($this->_ecStyleConfigMap as $key => $exportKey) { - if ($this->$key) { - $to->setData($exportKey, $this->$key); - } - } - } - - /** - * Dynamic PayPal image URL getter - * Also can render dynamic Acceptance Mark - * - * @param string $type - * @param string $localeCode - * @param float $orderTotal - * @param string $pal - * @return string - */ - protected function _getDynamicImageUrl($type, $localeCode, $orderTotal, $pal) - { - $params = [ - 'cmd' => '_dynamic-image', - 'buttontype' => $type, - 'locale' => $this->_getSupportedLocaleCode($localeCode), - ]; - if ($orderTotal) { - $params['ordertotal'] = sprintf('%.2F', $orderTotal); - if ($pal) { - $params['pal'] = $pal; - } - } - return sprintf( - 'https://fpdbs%s.paypal.com/dynamicimageweb?%s', - $this->sandboxFlag ? '.sandbox' : '', - http_build_query($params), - ); - } - - /** - * Check whether specified locale code is supported. Fallback to en_US - * - * @param string $localeCode - * @return string - */ - protected function _getSupportedLocaleCode($localeCode = null) - { - if (!$localeCode || !in_array($localeCode, $this->_supportedImageLocales)) { - return self::LOCALE_US; - } - return $localeCode; - } - - /** - * Map any supported payment method into a config path by specified field name - * - * @param string $fieldName - * @return string|null - */ - protected function _getSpecificConfigPath($fieldName) - { - $path = null; - switch ($this->_methodCode) { - case self::METHOD_WPS: - $path = $this->_mapStandardFieldset($fieldName); - break; - case self::METHOD_BML: - $path = $this->_mapBmlFieldset($fieldName); - break; - case self::METHOD_WPP_PE_BML: - $path = $this->_mapBmlUkFieldset($fieldName); - break; - case self::METHOD_WPP_EXPRESS: - case self::METHOD_WPP_PE_EXPRESS: - $path = $this->_mapExpressFieldset($fieldName); - break; - case self::METHOD_WPP_DIRECT: - case self::METHOD_WPP_PE_DIRECT: - $path = $this->_mapDirectFieldset($fieldName); - break; - case self::METHOD_BILLING_AGREEMENT: - case self::METHOD_HOSTEDPRO: - $path = $this->_mapMethodFieldset($fieldName); - break; - } - - if ($path === null) { - switch ($this->_methodCode) { - case self::METHOD_WPP_EXPRESS: - case self::METHOD_BML: - case self::METHOD_WPP_DIRECT: - case self::METHOD_BILLING_AGREEMENT: - case self::METHOD_HOSTEDPRO: - $path = $this->_mapWppFieldset($fieldName); - break; - case self::METHOD_WPP_PE_EXPRESS: - case self::METHOD_WPP_PE_DIRECT: - case self::METHOD_PAYFLOWADVANCED: - case self::METHOD_PAYFLOWLINK: - $path = $this->_mapWpukFieldset($fieldName); - break; - } - } - - if ($path === null) { - $path = $this->_mapGeneralFieldset($fieldName); - } - if ($path === null) { - $path = $this->_mapGenericStyleFieldset($fieldName); - } - return $path; - } - - /** - * Map PayPal Standard config fields - * - * @param string $fieldName - * @return string|null - */ - protected function _mapStandardFieldset($fieldName) - { - switch ($fieldName) { - case 'line_items_summary': - case 'sandbox_flag': - return 'payment/' . self::METHOD_WPS . "/{$fieldName}"; - default: - return $this->_mapMethodFieldset($fieldName); - } - } - - /** - * Map PayPal Express config fields - * - * @param string $fieldName - * @return string|null - */ - protected function _mapExpressFieldset($fieldName) - { - switch ($fieldName) { - case 'transfer_shipping_options': - case 'solution_type': - case 'visible_on_cart': - case 'visible_on_product': - case 'require_billing_address': - case 'authorization_honor_period': - case 'order_valid_period': - case 'child_authorization_number': - case 'allow_ba_signup': - return "payment/{$this->_methodCode}/{$fieldName}"; - default: - return $this->_mapMethodFieldset($fieldName); - } - } - - /** - * Map PayPal Express Bill Me Later config fields - * - * @param string $fieldName - * @return string|null - */ - protected function _mapBmlFieldset($fieldName) - { - switch ($fieldName) { - case 'allow_ba_signup': - return 'payment/' . self::METHOD_WPP_EXPRESS . "/{$fieldName}"; - default: - return $this->_mapExpressFieldset($fieldName); - } - } - - /** - * Map PayPal Express Bill Me Later config fields (Payflow Edition) - * - * @param string $fieldName - * @return string|null - */ - protected function _mapBmlUkFieldset($fieldName) - { - switch ($fieldName) { - case 'allow_ba_signup': - return 'payment/' . self::METHOD_WPP_PE_EXPRESS . "/{$fieldName}"; - default: - return $this->_mapExpressFieldset($fieldName); - } - } - - /** - * Map PayPal Direct config fields - * - * @param string $fieldName - * @return string|null - */ - protected function _mapDirectFieldset($fieldName) - { - switch ($fieldName) { - case 'useccv': - case 'centinel': - case 'centinel_is_mode_strict': - case 'centinel_api_url': - return "payment/{$this->_methodCode}/{$fieldName}"; - default: - return $this->_mapMethodFieldset($fieldName); - } - } - - /** - * Map PayPal Website Payments Pro common config fields - * - * @param string $fieldName - * @return string|null - */ - protected function _mapWppFieldset($fieldName) - { - switch ($fieldName) { - case 'api_authentication': - case 'api_username': - case 'api_password': - case 'api_signature': - case 'api_cert': - case 'sandbox_flag': - case 'use_proxy': - case 'proxy_host': - case 'proxy_port': - case 'button_flavor': - return "paypal/wpp/{$fieldName}"; - default: - return null; - } - } - - /** - * Map PayPal Website Payments Pro common config fields - * - * @param string $fieldName - * @return string|null - */ - protected function _mapWpukFieldset($fieldName) - { - $pathPrefix = 'paypal/wpuk'; - // Use PUMP credentials from Verisign for EC when Direct Payments are unavailable - if ($this->_methodCode == self::METHOD_WPP_PE_EXPRESS - && !$this->isMethodAvailable(self::METHOD_WPP_PE_DIRECT) - ) { - $pathPrefix = 'payment/verisign'; - } elseif ($this->_methodCode == self::METHOD_PAYFLOWADVANCED - || $this->_methodCode == self::METHOD_PAYFLOWLINK - ) { - $pathPrefix = 'payment/' . $this->_methodCode; - } - switch ($fieldName) { - case 'partner': - case 'user': - case 'vendor': - case 'pwd': - case 'sandbox_flag': - case 'use_proxy': - case 'proxy_host': - case 'proxy_port': - return $pathPrefix . '/' . $fieldName; - default: - return null; - } - } - - /** - * Map PayPal common style config fields - * - * @param string $fieldName - * @return string|null - */ - protected function _mapGenericStyleFieldset($fieldName) - { - switch ($fieldName) { - case 'logo': - case 'page_style': - case 'paypal_hdrimg': - case 'paypal_hdrbackcolor': - case 'paypal_hdrbordercolor': - case 'paypal_payflowcolor': - return "paypal/style/{$fieldName}"; - default: - return null; - } - } - - /** - * Map PayPal General Settings - * - * @param string $fieldName - * @return string|null - */ - protected function _mapGeneralFieldset($fieldName) - { - switch ($fieldName) { - case 'business_account': - case 'merchant_country': - return "paypal/general/{$fieldName}"; - default: - return null; - } - } - - /** - * Map PayPal General Settings - * - * @param string $fieldName - * @return string|null - */ - protected function _mapMethodFieldset($fieldName) - { - if (!$this->_methodCode) { - return null; - } - switch ($fieldName) { - case 'active': - case 'title': - case 'payment_action': - case 'allowspecific': - case 'specificcountry': - case 'line_items_enabled': - case 'cctypes': - case 'sort_order': - case 'debug': - case 'verify_peer': - case 'mobile_optimized': - return "payment/{$this->_methodCode}/{$fieldName}"; - default: - return null; - } - } - - /** - * Payment API authentication methods source getter - * - * @return array - */ - public function getApiAuthenticationMethods() - { - return [ - '0' => Mage::helper('paypal')->__('API Signature'), - '1' => Mage::helper('paypal')->__('API Certificate'), - ]; - } - - /** - * Api certificate getter - * - * @return string - */ - public function getApiCertificate() - { - $websiteId = Mage::app()->getStore($this->_storeId)->getWebsiteId(); - return Mage::getModel('paypal/cert')->loadByWebsite($websiteId, false)->getCertPath(); - } - - /** - * Get PublisherId from stored config - * - * @return mixed - */ - public function getBmlPublisherId() - { - return Mage::getStoreConfig('payment/paypal_express_bml/publisher_id', $this->_storeId); - } - - /** - * Get Display option from stored config - * @param string $section - * - * @return mixed - */ - public function getBmlDisplay($section) - { - $display = Mage::getStoreConfig('payment/paypal_express_bml/' . $section . '_display', $this->_storeId); - $ecActive = Mage::getStoreConfig('payment/paypal_express/active', $this->_storeId); - $ecUkActive = Mage::getStoreConfig('payment/paypaluk_express/active', $this->_storeId); - $bmlActive = Mage::getStoreConfig('payment/paypal_express_bml/active', $this->_storeId); - $bmlUkActive = Mage::getStoreConfig('payment/paypaluk_express_bml/active', $this->_storeId); - return (($bmlActive && $ecActive) || ($bmlUkActive && $ecUkActive)) ? $display : 0; - } - - /** - * Get Position option from stored config - * @param string $section - * - * @return mixed - */ - public function getBmlPosition($section) - { - return Mage::getStoreConfig('payment/paypal_express_bml/' . $section . '_position', $this->_storeId); - } - - /** - * Get Size option from stored config - * @param string $section - * - * @return mixed - */ - public function getBmlSize($section) + protected function getConfigData($field, $store = null) { - return Mage::getStoreConfig('payment/paypal_express_bml/' . $section . '_size', $this->_storeId); + return Mage::getStoreConfig('payment/paypal/' . $field, $store); } } diff --git a/app/code/core/Mage/Paypal/Model/Debug.php b/app/code/core/Mage/Paypal/Model/Debug.php new file mode 100644 index 00000000000..a9213e4e34c --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Debug.php @@ -0,0 +1,8 @@ +_init('paypal/debug'); + } +} diff --git a/app/code/core/Mage/Paypal/Model/Direct.php b/app/code/core/Mage/Paypal/Model/Direct.php deleted file mode 100644 index 18ead435263..00000000000 --- a/app/code/core/Mage/Paypal/Model/Direct.php +++ /dev/null @@ -1,379 +0,0 @@ -_pro = $proInstance; - } else { - /** @var Mage_Paypal_Model_Pro $model */ - $model = Mage::getModel($this->_proType); - $this->_pro = $model; - } - $this->_pro->setMethod($this->_code); - } - - /** - * Store setter - * Also updates store ID in config object - * - * @param Mage_Core_Model_Store|int $store - * @return $this - */ - public function setStore($store) - { - $this->setData('store', $store); - if ($store === null) { - $store = Mage::app()->getStore()->getId(); - } - $this->_pro->getConfig()->setStoreId(is_object($store) ? $store->getId() : $store); - return $this; - } - - /** - * Whether method is available for specified currency - * - * @param string $currencyCode - * @return bool - */ - public function canUseForCurrency($currencyCode) - { - return $this->_pro->getConfig()->isCurrencyCodeSupported($currencyCode); - } - - /** - * Payment action getter compatible with payment model - * - * @see Mage_Sales_Model_Payment::place() - * @return string - */ - public function getConfigPaymentAction() - { - return $this->_pro->getConfig()->getPaymentAction(); - } - - /** - * Return available CC types for gateway based on merchant country - * - * @return string - */ - public function getAllowedCcTypes() - { - $ccTypes = explode(',', $this->_pro->getConfig()->cctypes); - $country = $this->_pro->getConfig()->getMerchantCountry(); - - if ($country == 'GB') { - $ccTypes = array_intersect(['SM', 'SO', 'MC', 'DI', 'VI'], $ccTypes); - } elseif ($country == 'CA') { - $ccTypes = array_intersect(['MC', 'VI'], $ccTypes); - } - return implode(',', $ccTypes); - } - - /** - * Check whether payment method can be used - * @param Mage_Sales_Model_Quote|null $quote - * @return bool - */ - public function isAvailable($quote = null) - { - if (parent::isAvailable($quote) && $this->_pro->getConfig()->isMethodAvailable()) { - return true; - } - return false; - } - - /** - * Custom getter for payment configuration - * - * @param string $field - * @param int $storeId - * @return mixed - */ - public function getConfigData($field, $storeId = null) - { - $value = null; - switch ($field) { - case 'cctypes': - $value = $this->getAllowedCcTypes(); - break; - default: - $value = $this->_pro->getConfig()->$field; - } - return $value; - } - - /** - * Authorize payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return $this - */ - public function authorize(Varien_Object $payment, $amount) - { - return $this->_placeOrder($payment, $amount); - } - - /** - * Void payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return $this - */ - public function void(Varien_Object $payment) - { - $this->_pro->void($payment); - return $this; - } - - /** - * Capture payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return $this - */ - public function capture(Varien_Object $payment, $amount) - { - if ($this->_pro->capture($payment, $amount) === false) { - $this->_placeOrder($payment, $amount); - } - return $this; - } - - /** - * Refund capture - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return $this - */ - public function refund(Varien_Object $payment, $amount) - { - $this->_pro->refund($payment, $amount); - return $this; - } - - /** - * Cancel payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return $this - */ - public function cancel(Varien_Object $payment) - { - $this->void($payment); - - return $this; - } - - /** - * Whether payment can be reviewed - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return bool - */ - public function canReviewPayment(Mage_Payment_Model_Info $payment) - { - return parent::canReviewPayment($payment) && $this->_pro->canReviewPayment($payment); - } - - /** - * Attempt to accept a pending payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return bool - */ - public function acceptPayment(Mage_Payment_Model_Info $payment) - { - parent::acceptPayment($payment); - return $this->_pro->reviewPayment($payment, Mage_Paypal_Model_Pro::PAYMENT_REVIEW_ACCEPT); - } - - /** - * Attempt to deny a pending payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return bool - */ - public function denyPayment(Mage_Payment_Model_Info $payment) - { - parent::denyPayment($payment); - return $this->_pro->reviewPayment($payment, Mage_Paypal_Model_Pro::PAYMENT_REVIEW_DENY); - } - - /** - * Set fallback API URL if not defined in configuration - * - * @return Mage_Centinel_Model_Service - */ - public function getCentinelValidator() - { - $validator = parent::getCentinelValidator(); - if (!$validator->getCustomApiEndpointUrl()) { - $validator->setCustomApiEndpointUrl($this->_pro->getConfig()->centinelDefaultApiUrl); - } - return $validator; - } - - /** - * Fetch transaction details info - * - * @param string $transactionId - * @return array - */ - public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId) - { - return $this->_pro->fetchTransactionInfo($payment, $transactionId); - } - - /** - * Place an order with authorization or capture action - * - * @param float $amount - * @return $this - */ - protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount) - { - $order = $payment->getOrder(); - $api = $this->_pro->getApi() - ->setPaymentAction($this->_pro->getConfig()->paymentAction) - ->setIpAddress(Mage::app()->getRequest()->getClientIp(false)) - ->setAmount($amount) - ->setCurrencyCode($order->getBaseCurrencyCode()) - ->setInvNum($order->getIncrementId()) - ->setEmail($order->getCustomerEmail()) - ->setNotifyUrl(Mage::getUrl('paypal/ipn/', ['_store' => $order->getStore()->getStoreId()])) - ->setCreditCardType($payment->getCcType()) - ->setCreditCardNumber($payment->getCcNumber()) - ->setCreditCardExpirationDate( - $this->_getFormattedCcExpirationDate($payment->getCcExpMonth(), $payment->getCcExpYear()), - ) - ->setCreditCardCvv2($payment->getCcCid()) - ->setMaestroSoloIssueNumber($payment->getCcSsIssue()) - ; - if ($payment->getCcSsStartMonth() && $payment->getCcSsStartYear()) { - $year = sprintf('%02d', substr($payment->getCcSsStartYear(), -2, 2)); - $api->setMaestroSoloIssueDate( - $this->_getFormattedCcExpirationDate($payment->getCcSsStartMonth(), $year), - ); - } - if ($this->getIsCentinelValidationEnabled()) { - $this->getCentinelValidator()->exportCmpiData($api); - } - - // add shipping and billing addresses - if ($order->getIsVirtual()) { - $api->setAddress($order->getBillingAddress())->setSuppressShipping(true); - } else { - $api->setAddress($order->getShippingAddress()); - $api->setBillingAddress($order->getBillingAddress()); - } - - // add line items - $api->setPaypalCart(Mage::getModel('paypal/cart', [$order])) - ->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled) - ; - - // call api and import transaction and other payment information - $api->callDoDirectPayment(); - $this->_importResultToPayment($api, $payment); - - try { - $api->callGetTransactionDetails(); - } catch (Mage_Core_Exception $e) { - // if we receive errors, but DoDirectPayment response is Success, then set Pending status for transaction - $payment->setIsTransactionPending(true); - } - $this->_importResultToPayment($api, $payment); - return $this; - } - - /** - * Format credit card expiration date based on month and year values - * Format: mmyyyy - * - * @param string|int $month - * @param string|int $year - * @return string - */ - protected function _getFormattedCcExpirationDate($month, $year) - { - return sprintf('%02d%02d', $month, $year); - } - - /** - * Import direct payment results to payment - * - * @param Mage_Paypal_Model_Api_Nvp $api - * @param Mage_Sales_Model_Order_Payment $payment - */ - protected function _importResultToPayment($api, $payment) - { - $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0); - $this->_pro->importPaymentInfo($api, $payment); - } - - /** - * Check void availability - * - * @return bool - */ - public function canVoid(Varien_Object $payment) - { - if ($payment instanceof Mage_Sales_Model_Order_Invoice - || $payment instanceof Mage_Sales_Model_Order_Creditmemo - ) { - return false; - } - - return $this->_canVoid; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Exception.php b/app/code/core/Mage/Paypal/Model/Exception.php new file mode 100644 index 00000000000..5f6be5e2fcb --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Exception.php @@ -0,0 +1,16 @@ +_debugData = $debugData; + parent::__construct($message); + } + + public function getDebugData() + { + return $this->_debugData; + } +} diff --git a/app/code/core/Mage/Paypal/Model/Express.php b/app/code/core/Mage/Paypal/Model/Express.php deleted file mode 100644 index ea3a27ec7a1..00000000000 --- a/app/code/core/Mage/Paypal/Model/Express.php +++ /dev/null @@ -1,709 +0,0 @@ -_pro = $proInstance; - } else { - /** @var Mage_Paypal_Model_Pro $model */ - $model = Mage::getModel($this->_proType); - $this->_pro = $model; - } - $this->_pro->setMethod($this->_code); - $this->_setApiProcessableErrors(); - } - - /** - * Set processable error codes to API model - * - * @return Mage_Paypal_Model_Api_Nvp - */ - protected function _setApiProcessableErrors() - { - return $this->_pro->getApi()->setProcessableErrors( - [ - Mage_Paypal_Model_Api_ProcessableException::API_INTERNAL_ERROR, - Mage_Paypal_Model_Api_ProcessableException::API_UNABLE_PROCESS_PAYMENT_ERROR_CODE, - Mage_Paypal_Model_Api_ProcessableException::API_DO_EXPRESS_CHECKOUT_FAIL, - Mage_Paypal_Model_Api_ProcessableException::API_UNABLE_TRANSACTION_COMPLETE, - Mage_Paypal_Model_Api_ProcessableException::API_TRANSACTION_EXPIRED, - Mage_Paypal_Model_Api_ProcessableException::API_MAX_PAYMENT_ATTEMPTS_EXCEEDED, - Mage_Paypal_Model_Api_ProcessableException::API_COUNTRY_FILTER_DECLINE, - Mage_Paypal_Model_Api_ProcessableException::API_MAXIMUM_AMOUNT_FILTER_DECLINE, - Mage_Paypal_Model_Api_ProcessableException::API_OTHER_FILTER_DECLINE, - ], - ); - } - - /** - * Store setter - * Also updates store ID in config object - * - * @param Mage_Core_Model_Store|int $store - * @return $this - */ - public function setStore($store) - { - $this->setData('store', $store); - if ($store === null) { - $store = Mage::app()->getStore()->getId(); - } - $this->_pro->getConfig()->setStoreId(is_object($store) ? $store->getId() : $store); - return $this; - } - - /** - * Can be used in regular checkout - * - * @return bool - */ - public function canUseCheckout() - { - if (Mage::getStoreConfigFlag('payment/hosted_pro/active') - && !Mage::getStoreConfigFlag('payment/hosted_pro/display_ec') - ) { - return false; - } - return parent::canUseCheckout(); - } - - /** - * Whether method is available for specified currency - * - * @param string $currencyCode - * @return bool - */ - public function canUseForCurrency($currencyCode) - { - return $this->_pro->getConfig()->isCurrencyCodeSupported($currencyCode); - } - - /** - * Payment action getter compatible with payment model - * - * @see Mage_Sales_Model_Payment::place() - * @return string - */ - public function getConfigPaymentAction() - { - return $this->_pro->getConfig()->getPaymentAction(); - } - - /** - * Check whether payment method can be used - * @param Mage_Sales_Model_Quote|null $quote - * @return bool - */ - public function isAvailable($quote = null) - { - if (parent::isAvailable($quote) && $this->_pro->getConfig()->isMethodAvailable()) { - return true; - } - return false; - } - - /** - * Custom getter for payment configuration - * - * @param string $field - * @param int $storeId - * @return mixed - */ - public function getConfigData($field, $storeId = null) - { - return $this->_pro->getConfig()->$field; - } - - /** - * Order payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @param float $amount - * @return $this - */ - public function order(Varien_Object $payment, $amount) - { - $paypalTransactionData = Mage::getSingleton('checkout/session')->getPaypalTransactionData(); - if (!is_array($paypalTransactionData)) { - $this->_placeOrder($payment, $amount); - } else { - $this->_importToPayment($this->_pro->getApi()->setData($paypalTransactionData), $payment); - } - - $payment->setAdditionalInformation($this->_isOrderPaymentActionKey, true); - - if ($payment->getIsFraudDetected()) { - return $this; - } - - $order = $payment->getOrder(); - $orderTransactionId = $payment->getTransactionId(); - - $api = $this->_callDoAuthorize($amount, $payment, $orderTransactionId); - - $state = Mage_Sales_Model_Order::STATE_PROCESSING; - $status = true; - - $formatedPrice = $order->getBaseCurrency()->formatTxt($amount); - if ($payment->getIsTransactionPending()) { - $message = Mage::helper('paypal')->__('Ordering amount of %s is pending approval on gateway.', $formatedPrice); - $state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW; - } else { - $message = Mage::helper('paypal')->__('Ordered amount of %s.', $formatedPrice); - } - - $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, null, false, $message); - - $this->_pro->importPaymentInfo($api, $payment); - - if ($payment->getIsTransactionPending()) { - $message = Mage::helper('paypal')->__('Authorizing amount of %s is pending approval on gateway.', $formatedPrice); - $state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW; - if ($payment->getIsFraudDetected()) { - $status = Mage_Sales_Model_Order::STATUS_FRAUD; - } - } else { - $message = Mage::helper('paypal')->__('Authorized amount of %s.', $formatedPrice); - } - - $payment->resetTransactionAdditionalInfo(); - - $payment->setTransactionId($api->getTransactionId()); - $payment->setParentTransactionId($orderTransactionId); - - $transaction = $payment->addTransaction( - Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, - null, - false, - $message, - ); - - $order->setState($state, $status); - - $payment->setSkipOrderProcessing(true); - return $this; - } - - /** - * Authorize payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @param float $amount - * @return $this - */ - public function authorize(Varien_Object $payment, $amount) - { - return $this->_placeOrder($payment, $amount); - } - - /** - * Void payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return $this - */ - public function void(Varien_Object $payment) - { - //Switching to order transaction if needed - if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey) - && !$payment->getVoidOnlyAuthorization() - ) { - $orderTransaction = $payment->lookupTransaction( - false, - Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, - ); - if ($orderTransaction) { - $payment->setParentTransactionId($orderTransaction->getTxnId()); - $payment->setTransactionId($orderTransaction->getTxnId() . '-void'); - } - } - $this->_pro->void($payment); - return $this; - } - - /** - * Capture payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @param float $amount - * @return $this - */ - public function capture(Varien_Object $payment, $amount) - { - $authorizationTransaction = $payment->getAuthorizationTransaction(); - $authorizationPeriod = abs((int) $this->getConfigData('authorization_honor_period')); - $maxAuthorizationNumber = abs((int) $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 ($this->_pro->capture($payment, $amount) === false) { - $this->_placeOrder($payment, $amount); - } - - if ($isAuthorizationCreated && isset($transaction)) { - $transaction->setIsClosed(true); - } - - return $this; - } - - /** - * Refund capture - * - * @param Mage_Sales_Model_Order_Payment $payment - * @param float $amount - * @return $this - */ - public function refund(Varien_Object $payment, $amount) - { - $this->_pro->refund($payment, $amount); - return $this; - } - - /** - * Cancel payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return $this - */ - public function cancel(Varien_Object $payment) - { - $this->void($payment); - - return $this; - } - - /** - * Whether payment can be reviewed - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return bool - */ - public function canReviewPayment(Mage_Payment_Model_Info $payment) - { - return parent::canReviewPayment($payment) && $this->_pro->canReviewPayment($payment); - } - - /** - * Attempt to accept a pending payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return bool - */ - public function acceptPayment(Mage_Payment_Model_Info $payment) - { - parent::acceptPayment($payment); - return $this->_pro->reviewPayment($payment, Mage_Paypal_Model_Pro::PAYMENT_REVIEW_ACCEPT); - } - - /** - * Attempt to deny a pending payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return bool - */ - public function denyPayment(Mage_Payment_Model_Info $payment) - { - parent::denyPayment($payment); - return $this->_pro->reviewPayment($payment, Mage_Paypal_Model_Pro::PAYMENT_REVIEW_DENY); - } - - /** - * Checkout redirect URL getter for onepage checkout (hardcode) - * - * @see Mage_Checkout_OnepageController::savePaymentAction() - * @see Mage_Sales_Model_Quote_Payment::getCheckoutRedirectUrl() - * @return string - */ - public function getCheckoutRedirectUrl() - { - return Mage::getUrl('paypal/express/start'); - } - - /** - * Fetch transaction details info - * - * @param string $transactionId - * @return array - */ - public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId) - { - return $this->_pro->fetchTransactionInfo($payment, $transactionId); - } - - /** - * Validate RP data - */ - public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile) - { - return $this->_pro->validateRecurringProfile($profile); - } - - /** - * Submit RP to the gateway - */ - 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); - } - - /** - * Fetch RP details - * - * @param string $referenceId - */ - public function getRecurringProfileDetails($referenceId, Varien_Object $result) - { - return $this->_pro->getRecurringProfileDetails($referenceId, $result); - } - - /** - * Whether can get recurring profile details - */ - public function canGetRecurringProfileDetails() - { - return true; - } - - /** - * Update RP data - */ - public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile) - { - return $this->_pro->updateRecurringProfile($profile); - } - - /** - * Manage status - */ - public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile) - { - return $this->_pro->updateRecurringProfileStatus($profile); - } - - /** - * @inheritDoc - */ - public function assignData($data) - { - $result = parent::assignData($data); - $key = Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT; - if (is_array($data)) { - $this->getInfoInstance()->setAdditionalInformation($key, $data[$key] ?? null); - } elseif ($data instanceof Varien_Object) { - $this->getInfoInstance()->setAdditionalInformation($key, $data->getData($key)); - } - return $result; - } - - /** - * Place an order with authorization or capture action - * - * @param float $amount - * @return $this - */ - protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount) - { - $order = $payment->getOrder(); - - // prepare api call - $token = $payment->getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_TOKEN); - $api = $this->_pro->getApi() - ->setToken($token) - ->setPayerId($payment-> - getAdditionalInformation(Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_PAYER_ID)) - ->setAmount($amount) - ->setPaymentAction($this->_pro->getConfig()->paymentAction) - ->setNotifyUrl(Mage::getUrl('paypal/ipn/')) - ->setInvNum($order->getIncrementId()) - ->setCurrencyCode($order->getBaseCurrencyCode()) - ->setPaypalCart(Mage::getModel('paypal/cart', [$order])) - ->setIsLineItemsEnabled($this->_pro->getConfig()->lineItemsEnabled); - - // call api and get details from it - $api->callDoExpressCheckoutPayment(); - - $this->_importToPayment($api, $payment); - return $this; - } - - /** - * Import payment info to payment - * - * @param Mage_Paypal_Model_Api_Nvp $api - * @param Mage_Sales_Model_Order_Payment $payment - */ - protected function _importToPayment($api, $payment) - { - $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(0) - ->setAdditionalInformation( - Mage_Paypal_Model_Express_Checkout::PAYMENT_INFO_TRANSPORT_REDIRECT, - $api->getRedirectRequired(), - ); - - if ($api->getBillingAgreementId()) { - $payment->setBillingAgreementData([ - 'billing_agreement_id' => $api->getBillingAgreementId(), - 'method_code' => Mage_Paypal_Model_Config::METHOD_BILLING_AGREEMENT, - ]); - } - - $this->_pro->importPaymentInfo($api, $payment); - } - - /** - * Check void availability - * - * @return bool - */ - public function canVoid(Varien_Object $payment) - { - if ($payment instanceof Mage_Sales_Model_Order_Invoice - || $payment instanceof Mage_Sales_Model_Order_Creditmemo - ) { - return false; - } - $info = $this->getInfoInstance(); - if ($info->getAdditionalInformation($this->_isOrderPaymentActionKey)) { - $orderTransaction = $info->lookupTransaction( - false, - Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, - ); - if ($orderTransaction) { - $info->setParentTransactionId($orderTransaction->getTxnId()); - } - } - - return $this->_canVoid; - } - - /** - * Check capture availability - * - * @return bool - */ - public function canCapture() - { - $payment = $this->getInfoInstance(); - $this->_pro->getConfig()->setStoreId($payment->getOrder()->getStore()->getId()); - - if ($payment->getAdditionalInformation($this->_isOrderPaymentActionKey)) { - $orderTransaction = $payment->lookupTransaction( - false, - Mage_Sales_Model_Order_Payment_Transaction::TYPE_ORDER, - ); - if ($orderTransaction->getIsClosed()) { - return false; - } - - $orderValidPeriod = abs((int) $this->getConfigData('order_valid_period')); - - $dateCompass = new DateTime($orderTransaction->getCreatedAt()); - $dateCompass->modify('+' . $orderValidPeriod . ' days'); - $currentDate = new DateTime(); - - if ($currentDate > $dateCompass || $orderValidPeriod == 0) { - return false; - } - } - return $this->_canCapture; - } - - /** - * Call DoAuthorize - * - * @param int $amount - * @param Varien_Object $payment - * @param string $parentTransactionId - * @return Mage_Paypal_Model_Api_Abstract - * @throws Mage_Paypal_Model_Api_ProcessableException - */ - protected function _callDoAuthorize($amount, $payment, $parentTransactionId) - { - $apiData = $this->_pro->getApi()->getData(); - foreach ($apiData as $k => $v) { - if (is_object($v)) { - unset($apiData[$k]); - } - } - Mage::getSingleton('checkout/session')->setPaypalTransactionData($apiData); - $this->_pro->resetApi(); - $api = $this->_setApiProcessableErrors() - ->setAmount($amount) - ->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode()) - ->setTransactionId($parentTransactionId) - ->callDoAuthorization(); - - $payment->setAdditionalInformation( - $this->_authorizationCountKey, - $payment->getAdditionalInformation($this->_authorizationCountKey) + 1, - ); - - return $api; - } - - /** - * Check transaction for expiration in PST - * - * @param int $period - * @return bool - */ - protected function _isTransactionExpired(Mage_Sales_Model_Order_Payment_Transaction $transaction, $period) - { - $period = (int) $period; - if ($period == 0) { - return true; - } - - $transactionClosingDate = new DateTime($transaction->getCreatedAt(), new DateTimeZone('GMT')); - $transactionClosingDate->setTimezone(new DateTimeZone('US/Pacific')); - /** - * 11:49:00 PayPal transactions closing time - */ - $transactionClosingDate->setTime(11, 49, 00); - $transactionClosingDate->modify('+' . $period . ' days'); - - $currentTime = new DateTime(null, new DateTimeZone('US/Pacific')); - - if ($currentTime > $transactionClosingDate) { - return true; - } - - return false; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Express/Checkout.php b/app/code/core/Mage/Paypal/Model/Express/Checkout.php deleted file mode 100644 index b70d94eb6b1..00000000000 --- a/app/code/core/Mage/Paypal/Model/Express/Checkout.php +++ /dev/null @@ -1,1072 +0,0 @@ -_quote = $params['quote']; - } else { - throw new Exception('Quote instance is required.'); - } - if (isset($params['config']) && $params['config'] instanceof Mage_Paypal_Model_Config) { - $this->_config = $params['config']; - } else { - throw new Exception('Config instance is required.'); - } - $this->_customerSession = isset($params['session']) && $params['session'] instanceof Mage_Customer_Model_Session - ? $params['session'] : Mage::getSingleton('customer/session'); - } - - /** - * Checkout with PayPal image URL getter - * Spares API calls of getting "pal" variable, by putting it into cache per store view - * @return string - */ - public function getCheckoutShortcutImageUrl() - { - // get "pal" thing from cache or lookup it via API - $pal = null; - if ($this->_config->areButtonsDynamic()) { - $cacheId = self::PAL_CACHE_ID . Mage::app()->getStore()->getId(); - $pal = Mage::app()->loadCache($cacheId); - if ($pal == -1) { - $pal = null; - } elseif (!$pal) { - $pal = null; - $this->_getApi(); - try { - $this->_api->callGetPalDetails(); - $pal = $this->_api->getPal(); - Mage::app()->saveCache($pal, $cacheId, [Mage_Core_Model_Config::CACHE_TAG]); - } catch (Exception $e) { - Mage::app()->saveCache(-1, $cacheId, [Mage_Core_Model_Config::CACHE_TAG]); - Mage::logException($e); - } - } - } - - return $this->_config->getExpressCheckoutShortcutImageUrl( - Mage::app()->getLocale()->getLocaleCode(), - $this->_quote->getBaseGrandTotal(), - $pal, - ); - } - - /** - * Setter that enables giropay redirects flow - * - * @param string $successUrl - payment success result - * @param string $cancelUrl - payment cancellation result - * @param string $pendingUrl - pending payment result - * @return $this - */ - public function prepareGiropayUrls($successUrl, $cancelUrl, $pendingUrl) - { - $this->_giropayUrls = [$successUrl, $cancelUrl, $pendingUrl]; - return $this; - } - - /** - * Set create billing agreement flag - * - * @param bool $flag - * @return $this - */ - public function setIsBillingAgreementRequested($flag) - { - $this->_isBARequested = $flag; - return $this; - } - - /** - * Setter for customer Id - * - * @param int $id - * @return $this - * @deprecated please use self::setCustomer - */ - public function setCustomerId($id) - { - $this->_customerId = $id; - return $this; - } - - /** - * Set flag that forces to use BillMeLater - * - * @param bool $isBml - */ - public function setIsBml($isBml) - { - $this->_isBml = $isBml; - } - - /** - * Setter for customer - * - * @param Mage_Customer_Model_Customer $customer - * @return $this - */ - public function setCustomer($customer) - { - $this->_quote->assignCustomer($customer); - $this->_customerId = $customer->getId(); - return $this; - } - - /** - * Setter for customer with billing and shipping address changing ability - * - * @param Mage_Customer_Model_Customer $customer - * @param Mage_Sales_Model_Quote_Address $billingAddress - * @param Mage_Sales_Model_Quote_Address $shippingAddress - * @return $this - */ - public function setCustomerWithAddressChange($customer, $billingAddress = null, $shippingAddress = null) - { - $this->_quote->assignCustomerWithAddressChange($customer, $billingAddress, $shippingAddress); - $this->_customerId = $customer->getId(); - return $this; - } - - /** - * Reserve order ID for specified quote and start checkout on PayPal - * - * @param string $returnUrl - * @param string $cancelUrl - * @param bool|null $button - * @return mixed - */ - public function start($returnUrl, $cancelUrl, $button = null) - { - $this->_quote->collectTotals(); - - if (!$this->_quote->getGrandTotal() && !$this->_quote->hasNominalItems()) { - Mage::throwException(Mage::helper('paypal')->__('PayPal does not support processing orders with zero amount. To complete your purchase, proceed to the standard checkout process.')); - } - - $this->_quote->reserveOrderId()->save(); - // prepare API - $this->_getApi(); - $solutionType = $this->_config->getMerchantCountry() == 'DE' - ? Mage_Paypal_Model_Config::EC_SOLUTION_TYPE_MARK : $this->_config->solutionType; - $this->_api->setAmount($this->_quote->getBaseGrandTotal()) - ->setCurrencyCode($this->_quote->getBaseCurrencyCode()) - ->setInvNum($this->_quote->getReservedOrderId()) - ->setReturnUrl($returnUrl) - ->setCancelUrl($cancelUrl) - ->setSolutionType($solutionType) - ->setPaymentAction($this->_config->paymentAction); - - if ($this->_giropayUrls) { - [$successUrl, $cancelUrl, $pendingUrl] = $this->_giropayUrls; - $this->_api->addData([ - 'giropay_cancel_url' => $cancelUrl, - 'giropay_success_url' => $successUrl, - 'giropay_bank_txn_pending_url' => $pendingUrl, - ]); - } - - if ($this->_isBml) { - $this->_api->setFundingSource('BML'); - } - - $this->_setBillingAgreementRequest(); - - if ($this->_config->requireBillingAddress == Mage_Paypal_Model_Config::REQUIRE_BILLING_ADDRESS_ALL) { - $this->_api->setRequireBillingAddress(1); - } - - // suppress or export shipping address - if ($this->_quote->getIsVirtual()) { - if ($this->_config->requireBillingAddress == Mage_Paypal_Model_Config::REQUIRE_BILLING_ADDRESS_VIRTUAL) { - $this->_api->setRequireBillingAddress(1); - } - $this->_api->setSuppressShipping(true); - } else { - $address = $this->_quote->getShippingAddress(); - $isOverriden = 0; - if ($address->validate() === true) { - $isOverriden = 1; - $this->_api->setAddress($address); - } - $this->_quote->getPayment()->setAdditionalInformation( - self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN, - $isOverriden, - ); - $this->_quote->getPayment()->save(); - } - - // add line items - $paypalCart = Mage::getModel('paypal/cart', [$this->_quote]); - $this->_api->setPaypalCart($paypalCart) - ->setIsLineItemsEnabled($this->_config->lineItemsEnabled) - ; - - // add shipping options if needed and line items are available - if ($this->_config->lineItemsEnabled && $this->_config->transferShippingOptions && $paypalCart->getItems()) { - if (!$this->_quote->getIsVirtual() && !$this->_quote->hasNominalItems()) { - if ($options = $this->_prepareShippingOptions($address, true)) { - $this->_api->setShippingOptionsCallbackUrl( - Mage::getUrl('*/*/shippingOptionsCallback', ['quote_id' => $this->_quote->getId()]), - )->setShippingOptions($options); - } - } - } - - // add recurring payment profiles information - if ($profiles = $this->_quote->prepareRecurringPaymentProfiles()) { - foreach ($profiles as $profile) { - $profile->setMethodCode(Mage_Paypal_Model_Config::METHOD_WPP_EXPRESS); - if (!$profile->isValid()) { - Mage::throwException($profile->getValidationErrors(true, true)); - } - } - $this->_api->addRecurringPaymentProfiles($profiles); - } - - $this->_config->exportExpressCheckoutStyleSettings($this->_api); - - // call API and redirect with token - $this->_api->callSetExpressCheckout(); - $token = $this->_api->getToken(); - $this->_redirectUrl = $button ? $this->_config->getExpressCheckoutStartUrl($token) - : $this->_config->getPayPalBasicStartUrl($token); - - $this->_quote->getPayment()->unsAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT); - - // Set flag that we came from Express Checkout button - if (!empty($button)) { - $this->_quote->getPayment()->setAdditionalInformation(self::PAYMENT_INFO_BUTTON, 1); - } elseif ($this->_quote->getPayment()->hasAdditionalInformation(self::PAYMENT_INFO_BUTTON)) { - $this->_quote->getPayment()->unsAdditionalInformation(self::PAYMENT_INFO_BUTTON); - } - - $this->_quote->getPayment()->save(); - return $token; - } - - /** - * Check whether system can skip order review page before placing order - * - * @return bool - */ - public function canSkipOrderReviewStep() - { - $isOnepageCheckout = !$this->_quote->getPayment() - ->getAdditionalInformation(self::PAYMENT_INFO_BUTTON); - return $this->_config->isOrderReviewStepDisabled() && $isOnepageCheckout; - } - - /** - * Update quote when returned from PayPal - * rewrite billing address by paypal - * save old billing address for new customer - * export shipping address in case address absence - * - * @param string $token - */ - public function returnFromPaypal($token) - { - $this->_getApi(); - $this->_api->setToken($token) - ->callGetExpressCheckoutDetails(); - $quote = $this->_quote; - - $this->_ignoreAddressValidation(); - - // import shipping address - $exportedShippingAddress = $this->_api->getExportedShippingAddress(); - if (!$quote->getIsVirtual()) { - $shippingAddress = $quote->getShippingAddress(); - if ($shippingAddress) { - if ($exportedShippingAddress) { - $this->_setExportedAddressData($shippingAddress, $exportedShippingAddress); - - if ($quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_BUTTON) == 1) { - // PayPal doesn't provide detailed shipping info: prefix, middlename, lastname, suffix - $shippingAddress->setPrefix(null); - $shippingAddress->setMiddlename(null); - $shippingAddress->setLastname(null); - $shippingAddress->setSuffix(null); - } - - $shippingAddress->setCollectShippingRates(true); - $shippingAddress->setSameAsBilling(0); - } - - // import shipping method - $code = ''; - if ($this->_api->getShippingRateCode()) { - if ($code = $this->_matchShippingMethodCode($shippingAddress, $this->_api->getShippingRateCode())) { - // possible bug of double collecting rates :-/ - $shippingAddress->setShippingMethod($code)->setCollectShippingRates(true); - } - } - $quote->getPayment()->setAdditionalInformation( - self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD, - $code, - ); - } - } - - // import billing address - $portBillingFromShipping = $quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_BUTTON) == 1 - && $this->_config->requireBillingAddress != Mage_Paypal_Model_Config::REQUIRE_BILLING_ADDRESS_ALL - && !$quote->isVirtual(); - if (isset($shippingAddress) && $portBillingFromShipping) { - $billingAddress = clone $shippingAddress; - $billingAddress->unsAddressId() - ->unsAddressType(); - $data = $billingAddress->getData(); - $data['save_in_address_book'] = 0; - $quote->getBillingAddress()->addData($data); - $quote->getShippingAddress()->setSameAsBilling(1); - } else { - $billingAddress = $quote->getBillingAddress(); - } - $exportedBillingAddress = $this->_api->getExportedBillingAddress(); - $this->_setExportedAddressData($billingAddress, $exportedBillingAddress); - $billingAddress->setCustomerNotes($exportedBillingAddress->getData('note')); - $quote->setBillingAddress($billingAddress); - - // import payment info - $payment = $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) - ; - $quote->collectTotals()->save(); - } - - /** - * Check whether order review has enough data to initialize - * - * @param string $token - * @throws Mage_Core_Exception - */ - public function prepareOrderReview($token = null) - { - $payment = $this->_quote->getPayment(); - if (!$payment || !$payment->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_PAYER_ID)) { - Mage::throwException(Mage::helper('paypal')->__('Payer is not identified.')); - } - $this->_quote->setMayEditShippingAddress( - $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN) != 1, - ); - $this->_quote->setMayEditShippingMethod( - $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_METHOD) == '', - ); - $this->_ignoreAddressValidation(); - $this->_quote->collectTotals()->save(); - } - - /** - * Return callback response with shipping options - * - * @return string - */ - public function getShippingOptionsCallbackResponse(array $request) - { - // prepare debug data - $logger = Mage::getModel('core/log_adapter', 'payment_' . $this->_methodType . '.log'); - $debugData = ['request' => $request, 'response' => []]; - - try { - // obtain addresses - $this->_getApi(); - $address = $this->_api->prepareShippingOptionsCallbackAddress($request); - $quoteAddress = $this->_quote->getShippingAddress(); - - // compare addresses, calculate shipping rates and prepare response - $options = []; - if ($address && $quoteAddress && !$this->_quote->getIsVirtual()) { - foreach ($address->getExportedKeys() as $key) { - $quoteAddress->setDataUsingMethod($key, $address->getData($key)); - } - $quoteAddress->setCollectShippingRates(true)->collectTotals(); - $options = $this->_prepareShippingOptions($quoteAddress, false, true); - } - $response = $this->_api->setShippingOptions($options)->formatShippingOptionsCallback(); - - // log request and response - $debugData['response'] = $response; - $logger->log($debugData); - return $response; - } catch (Exception $e) { - $logger->log($debugData); - throw $e; - } - } - - /** - * Set shipping method to quote, if needed - * @param string $methodCode - */ - public function updateShippingMethod($methodCode) - { - if (!$this->_quote->getIsVirtual() && $shippingAddress = $this->_quote->getShippingAddress()) { - if ($methodCode != $shippingAddress->getShippingMethod()) { - $this->_ignoreAddressValidation(); - $shippingAddress->setShippingMethod($methodCode)->setCollectShippingRates(true); - $this->_quote->collectTotals()->save(); - } - } - } - - /** - * Place the order and recurring payment profiles when customer returned from paypal - * Until this moment all quote data must be valid - * - * @param string $token - * @param string $shippingMethodCode - */ - public function place($token, $shippingMethodCode = null) - { - if ($shippingMethodCode) { - $this->updateShippingMethod($shippingMethodCode); - } - - $isNewCustomer = false; - switch ($this->getCheckoutMethod()) { - case Mage_Checkout_Model_Type_Onepage::METHOD_GUEST: - $this->_prepareGuestQuote(); - break; - case Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER: - $this->_prepareNewCustomerQuote(); - $isNewCustomer = true; - break; - default: - $this->_prepareCustomerQuote(); - break; - } - - $this->_ignoreAddressValidation(); - $this->_quote->collectTotals(); - $service = Mage::getModel('sales/service_quote', $this->_quote); - $service->submitAll(); - $this->_quote->save(); - - if ($isNewCustomer) { - try { - $this->_involveNewCustomer(); - } catch (Exception $e) { - Mage::logException($e); - } - } - - $this->_recurringPaymentProfiles = $service->getRecurringPaymentProfiles(); - // TODO: send recurring profile emails - - /** @var Mage_Sales_Model_Order $order */ - $order = $service->getOrder(); - if (!$order) { - return; - } - $this->_billingAgreement = $order->getPayment()->getBillingAgreement(); - - // commence redirecting to finish payment, if paypal requires it - if ($order->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_REDIRECT)) { - $this->_redirectUrl = $this->_config->getExpressCheckoutCompleteUrl($token); - } - - switch ($order->getState()) { - // even after placement paypal can disallow to authorize/capture, but will wait until bank transfers money - case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT: - // TODO - break; - // regular placement, when everything is ok - case Mage_Sales_Model_Order::STATE_PROCESSING: - case Mage_Sales_Model_Order::STATE_COMPLETE: - case Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW: - $order->queueNewOrderEmail(); - break; - } - $this->_order = $order; - } - - /** - * Make sure addresses will be saved without validation errors - */ - private function _ignoreAddressValidation() - { - $this->_quote->getBillingAddress()->setShouldIgnoreValidation(true); - if (!$this->_quote->getIsVirtual()) { - $this->_quote->getShippingAddress()->setShouldIgnoreValidation(true); - if (!$this->_config->requireBillingAddress && !$this->_quote->getBillingAddress()->getEmail()) { - $this->_quote->getBillingAddress()->setSameAsBilling(1); - } - } - } - - /** - * Determine whether redirect somewhere specifically is required - * - * @return string - */ - public function getRedirectUrl() - { - return $this->_redirectUrl; - } - - /** - * Return recurring payment profiles - * - * @return array - */ - public function getRecurringPaymentProfiles() - { - return $this->_recurringPaymentProfiles; - } - - /** - * Get created billing agreement - * - * @return Mage_Sales_Model_Billing_Agreement|null - */ - public function getBillingAgreement() - { - return $this->_billingAgreement; - } - - /** - * Return order - * - * @return Mage_Sales_Model_Order - */ - public function getOrder() - { - return $this->_order; - } - - /** - * Get checkout method - * - * @return string - */ - public function getCheckoutMethod() - { - if ($this->getCustomerSession()->isLoggedIn()) { - return Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER; - } - if (!$this->_quote->getCheckoutMethod()) { - if (Mage::helper('checkout')->isAllowedGuestCheckout($this->_quote)) { - $this->_quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_GUEST); - } else { - $this->_quote->setCheckoutMethod(Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER); - } - } - return $this->_quote->getCheckoutMethod(); - } - - /** - * Sets address data from exported address - * - * @param Mage_Sales_Model_Quote_Address $address - * @param array $exportedAddress - */ - protected function _setExportedAddressData($address, $exportedAddress) - { - // Exported data is more priority if we came from Express Checkout button - $isButton = (bool) $this->_quote->getPayment()->getAdditionalInformation(self::PAYMENT_INFO_BUTTON); - if (!$isButton) { - foreach ($exportedAddress->getExportedKeys() as $key) { - $oldData = $address->getDataUsingMethod($key); - $isEmpty = null; - if (is_array($oldData)) { - foreach ($oldData as $val) { - if (!empty($val)) { - $isEmpty = false; - break; - } - $isEmpty = true; - } - } - if (empty($oldData) || $isEmpty === true) { - $address->setDataUsingMethod($key, $exportedAddress->getData($key)); - } - } - } else { - foreach ($exportedAddress->getExportedKeys() as $key) { - $data = $exportedAddress->getData($key); - if (!empty($data)) { - $address->setDataUsingMethod($key, $data); - } - } - } - } - - /** - * Set create billing agreement flag to api call - * - * @return $this - */ - 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; - } - - /** - * @return Mage_Paypal_Model_Api_Nvp - */ - protected function _getApi() - { - if ($this->_api === null) { - $this->_api = Mage::getModel($this->_apiType)->setConfigObject($this->_config); - } - return $this->_api; - } - - /** - * Attempt to collect address shipping rates and return them for further usage in instant update API - * Returns empty array if it was impossible to obtain any shipping rate - * If there are shipping rates obtained, the method must return one of them as default. - * - * @param bool $mayReturnEmpty - * @return array - */ - protected function _prepareShippingOptions( - Mage_Sales_Model_Quote_Address $address, - $mayReturnEmpty = false, - $calculateTax = false - ) { - $options = []; - $i = 0; - $iMin = false; - $min = false; - $userSelectedOption = null; - - foreach ($address->getGroupedAllShippingRates() as $group) { - foreach ($group as $rate) { - $amount = (float) $rate->getPrice(); - if ($rate->getErrorMessage()) { - continue; - } - $isDefault = $address->getShippingMethod() === $rate->getCode(); - $amountExclTax = Mage::helper('tax')->getShippingPrice($amount, false, $address); - $amountInclTax = Mage::helper('tax')->getShippingPrice($amount, true, $address); - - $options[$i] = new Varien_Object([ - 'is_default' => $isDefault, - 'name' => trim("{$rate->getCarrier()} - {$rate->getMethodTitle()}", ' -'), - 'code' => $rate->getCode(), - 'amount' => $amountExclTax, - ]); - if ($calculateTax) { - $options[$i]->setTaxAmount( - $amountInclTax - $amountExclTax - + $address->getTaxAmount() - $address->getShippingTaxAmount(), - ); - } - if ($isDefault) { - $userSelectedOption = $options[$i]; - } - if ($min === false || $amountInclTax < $min) { - $min = $amountInclTax; - $iMin = $i; - } - $i++; - } - } - - if ($mayReturnEmpty && is_null($userSelectedOption)) { - $options[] = new Varien_Object([ - 'is_default' => true, - 'name' => Mage::helper('paypal')->__('N/A'), - 'code' => 'no_rate', - 'amount' => 0.00, - ]); - if ($calculateTax) { - $options[$i]->setTaxAmount($address->getTaxAmount()); - } - } elseif (is_null($userSelectedOption) && isset($options[$iMin])) { - $options[$iMin]->setIsDefault(true); - } - - // Magento will transfer only first 10 cheapest shipping options if there are more than 10 available. - if (count($options) > 10) { - usort($options, [get_class($this),'cmpShippingOptions']); - array_splice($options, 10); - // User selected option will be always included in options list - if (!is_null($userSelectedOption) && !in_array($userSelectedOption, $options)) { - $options[9] = $userSelectedOption; - } - } - - return $options; - } - - /** - * Compare two shipping options based on their amounts - * - * This function is used as a callback comparison function in shipping options sorting process - * @see self::_prepareShippingOptions() - * - * @return int - */ - protected static function cmpShippingOptions(Varien_Object $option1, Varien_Object $option2) - { - return $option1->getAmount() <=> $option2->getAmount(); - } - - /** - * Try to find whether the code provided by PayPal corresponds to any of possible shipping rates - * This method was created only because PayPal has issues with returning the selected code. - * If in future the issue is fixed, we don't need to attempt to match it. It would be enough to set the method code - * before collecting shipping rates - * - * @param string $selectedCode - * @return string - */ - protected function _matchShippingMethodCode(Mage_Sales_Model_Quote_Address $address, $selectedCode) - { - $options = $this->_prepareShippingOptions($address, false); - foreach ($options as $option) { - if ($selectedCode === $option['code'] // the proper case as outlined in documentation - || $selectedCode === $option['name'] // workaround: PayPal may return name instead of the code - // workaround: PayPal may concatenate code and name, and return it instead of the code: - || $selectedCode === "{$option['code']} {$option['name']}" - ) { - return $option['code']; - } - } - return ''; - } - - /** - * Prepare quote for guest checkout order submit - * - * @return $this - */ - protected function _prepareGuestQuote() - { - $quote = $this->_quote; - $quote->setCustomerId(null) - ->setCustomerEmail($quote->getBillingAddress()->getEmail()) - ->setCustomerIsGuest(true) - ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID); - return $this; - } - - /** - * Checks if customer with email coming from Express checkout exists - * - * @return int - */ - protected function _lookupCustomerId() - { - return Mage::getModel('customer/customer') - ->setWebsiteId(Mage::app()->getWebsite()->getId()) - ->loadByEmail($this->_quote->getCustomerEmail()) - ->getId(); - } - - /** - * Prepare quote for customer registration and customer order submit - * and restore magento customer data from quote - * - * @return $this - */ - protected function _prepareNewCustomerQuote() - { - $quote = $this->_quote; - $billing = $quote->getBillingAddress(); - $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress(); - - $customerId = $this->_lookupCustomerId(); - if ($customerId && !$this->_customerEmailExists($quote->getCustomerEmail())) { - $this->getCustomerSession()->loginById($customerId); - return $this->_prepareCustomerQuote(); - } - - $customer = $quote->getCustomer(); - /** @var Mage_Customer_Model_Customer $customer */ - $customerBilling = $billing->exportCustomerAddress(); - $customer->addAddress($customerBilling); - $billing->setCustomerAddress($customerBilling); - $customerBilling->setIsDefaultBilling(true); - if ($shipping && !$shipping->getSameAsBilling()) { - $customerShipping = $shipping->exportCustomerAddress(); - $customer->addAddress($customerShipping); - $shipping->setCustomerAddress($customerShipping); - $customerShipping->setIsDefaultShipping(true); - } elseif ($shipping) { - $customerBilling->setIsDefaultShipping(true); - } - /** - * @todo integration with dynamica attributes customer_dob, customer_taxvat, customer_gender - */ - if ($quote->getCustomerDob() && !$billing->getCustomerDob()) { - $billing->setCustomerDob($quote->getCustomerDob()); - } - - if ($quote->getCustomerTaxvat() && !$billing->getCustomerTaxvat()) { - $billing->setCustomerTaxvat($quote->getCustomerTaxvat()); - } - - if ($quote->getCustomerGender() && !$billing->getCustomerGender()) { - $billing->setCustomerGender($quote->getCustomerGender()); - } - - Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer); - $customer->setEmail($quote->getCustomerEmail()); - $customer->setPrefix($quote->getCustomerPrefix()); - $customer->setFirstname($quote->getCustomerFirstname()); - $customer->setMiddlename($quote->getCustomerMiddlename()); - $customer->setLastname($quote->getCustomerLastname()); - $customer->setSuffix($quote->getCustomerSuffix()); - $customer->setPassword($customer->decryptPassword($quote->getPasswordHash())); - $customer->setPasswordHash($customer->hashPassword($customer->getPassword())); - $customer->setPasswordCreatedAt(time()); - $customer->save(); - $quote->setCustomer($customer); - $quote->setPasswordHash(''); - - return $this; - } - - /** - * Prepare quote for customer order submit - * - * @return $this - */ - protected function _prepareCustomerQuote() - { - $quote = $this->_quote; - $billing = $quote->getBillingAddress(); - $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress(); - - $customer = $this->getCustomerSession()->getCustomer(); - if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) { - $customerBilling = $billing->exportCustomerAddress(); - $customer->addAddress($customerBilling); - $billing->setCustomerAddress($customerBilling); - } - if ($shipping && ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) - || (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())) - ) { - $customerShipping = $shipping->exportCustomerAddress(); - $customer->addAddress($customerShipping); - $shipping->setCustomerAddress($customerShipping); - } - - if (isset($customerBilling) && !$customer->getDefaultBilling()) { - $customerBilling->setIsDefaultBilling(true); - } - if ($shipping && isset($customerBilling) && !$customer->getDefaultShipping() && $shipping->getSameAsBilling()) { - $customerBilling->setIsDefaultShipping(true); - } elseif ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) { - $customerShipping->setIsDefaultShipping(true); - } - $quote->setCustomer($customer); - - return $this; - } - - /** - * Involve new customer to system - * - * @return $this - */ - protected function _involveNewCustomer() - { - $customer = $this->_quote->getCustomer(); - if ($customer->isConfirmationRequired()) { - $customer->sendNewAccountEmail('confirmation', '', $this->_quote->getStoreId()); - $url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail()); - $this->getCustomerSession()->addSuccess( - Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please click here.', $url), - ); - } else { - $customer->sendNewAccountEmail('registered', '', $this->_quote->getStoreId()); - $this->getCustomerSession()->loginById($customer->getId()); - } - return $this; - } - - /** - * Get customer session object - * - * @return Mage_Customer_Model_Session - */ - public function getCustomerSession() - { - return $this->_customerSession; - } - - /** - * Check if customer email exists - * - * @param string $email - * @return bool - */ - protected function _customerEmailExists($email) - { - $result = false; - $customer = Mage::getModel('customer/customer'); - $websiteId = Mage::app()->getStore()->getWebsiteId(); - if (!is_null($websiteId)) { - $customer->setWebsiteId($websiteId); - } - $customer->loadByEmail($email); - if (!is_null($customer->getId())) { - $result = true; - } - - return $result; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Hostedpro.php b/app/code/core/Mage/Paypal/Model/Hostedpro.php deleted file mode 100644 index 0b442662aae..00000000000 --- a/app/code/core/Mage/Paypal/Model/Hostedpro.php +++ /dev/null @@ -1,244 +0,0 @@ -_pro->getConfig()->getMerchantCountry(); - } - - /** - * Return iframe template value depending on config - * - * @return string - */ - public function getTemplate() - { - if ($this->getConfigData('mobile_optimized')) { - return self::MOBILE_LAYOUT_TEMPLATE; - } else { - return self::LAYOUT_TEMPLATE; - } - } - - /** - * Do not validate payment form using server methods - * - * @return bool - */ - public function validate() - { - return true; - } - - /** - * Instantiate state and set it to state object - * - * @param string $paymentAction - * @param Varien_Object $stateObject - */ - public function initialize($paymentAction, $stateObject) - { - switch ($paymentAction) { - case Mage_Paypal_Model_Config::PAYMENT_ACTION_AUTH: - case Mage_Paypal_Model_Config::PAYMENT_ACTION_SALE: - $payment = $this->getInfoInstance(); - $order = $payment->getOrder(); - $order->setCanSendNewEmailFlag(false); - $payment->setAmountAuthorized($order->getTotalDue()); - $payment->setBaseAmountAuthorized($order->getBaseTotalDue()); - - $this->_setPaymentFormUrl($payment); - - $stateObject->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT); - $stateObject->setStatus('pending_payment'); - $stateObject->setIsNotified(false); - break; - default: - break; - } - - return $this; - } - - /** - * Sends API request to PayPal to get form URL, then sets this URL to $payment object. - */ - protected function _setPaymentFormUrl(Mage_Payment_Model_Info $payment) - { - $request = $this->_buildFormUrlRequest($payment); - $response = $this->_sendFormUrlRequest($request); - if ($response) { - $payment->setAdditionalInformation('secure_form_url', $response); - } else { - Mage::throwException('Cannot get secure form URL from PayPal'); - } - } - - /** - * Returns request object with needed data for API request to PayPal to get form URL. - * - * @return Mage_Paypal_Model_Hostedpro_Request - */ - protected function _buildFormUrlRequest(Mage_Payment_Model_Info $payment) - { - return $this->_buildBasicRequest() - ->setOrder($payment->getOrder()) - ->setPaymentMethod($this); - } - - /** - * Returns form URL from request to PayPal. - * - * @return string | false - */ - protected function _sendFormUrlRequest(Mage_Paypal_Model_Hostedpro_Request $request) - { - $api = $this->_pro->getApi(); - $response = $api->call(self::BM_BUTTON_METHOD, $request->getRequestData()); - - return $response['EMAILLINK'] ?? false; - } - - /** - * Return request object with basic information - * - * @return Mage_Paypal_Model_Hostedpro_Request - */ - protected function _buildBasicRequest() - { - $request = Mage::getModel('paypal/hostedpro_request'); - $request->setData([ - 'METHOD' => self::BM_BUTTON_METHOD, - 'BUTTONCODE' => self::BM_BUTTON_CODE, - 'BUTTONTYPE' => self::BM_BUTTON_TYPE, - ]); - return $request; - } - - /** - * Get return URL - * - * @param int $storeId - * @return string - */ - public function getReturnUrl($storeId = null) - { - return $this->_getUrl('paypal/hostedpro/return', $storeId); - } - - /** - * Get notify (IPN) URL - * - * @param int $storeId - * @return string - */ - public function getNotifyUrl($storeId = null) - { - return $this->_getUrl('paypal/ipn', $storeId); - } - - /** - * Get cancel URL - * - * @param int $storeId - * @return string - */ - public function getCancelUrl($storeId = null) - { - return $this->_getUrl('paypal/hostedpro/cancel', $storeId); - } - - /** - * Build URL for store - * - * @param string $path - * @param int $storeId - * @param bool $secure - * @return string - */ - protected function _getUrl($path, $storeId, $secure = null) - { - $store = Mage::app()->getStore($storeId); - return Mage::getUrl($path, [ - '_store' => $store, - '_secure' => is_null($secure) ? $store->isCurrentlySecure() : $secure, - ]); - } -} diff --git a/app/code/core/Mage/Paypal/Model/Hostedpro/Request.php b/app/code/core/Mage/Paypal/Model/Hostedpro/Request.php deleted file mode 100644 index af1172e4f21..00000000000 --- a/app/code/core/Mage/Paypal/Model/Hostedpro/Request.php +++ /dev/null @@ -1,224 +0,0 @@ -_data)) { - // insert params to request as additional button variables, - // except special params from _notButtonVars list - $i = 0; - foreach ($this->_data as $key => $value) { - if (in_array($key, $this->_notButtonVars)) { - $requestData[$key] = $value; - } else { - $varKey = sprintf($this->_buttonVarFormat, $i); - $requestData[$varKey] = $key . '=' . $value; - $i++; - } - } - } - - return $requestData; - } - - /** - * Append payment data to request - * - * @param Mage_Paypal_Model_Hostedpro $paymentMethod - * @return $this - */ - public function setPaymentMethod($paymentMethod) - { - $this->_paymentMethod = $paymentMethod; - $requestData = $this->_getPaymentData($paymentMethod); - $this->addData($requestData); - - return $this; - } - - /** - * Append order data to request - * - * @param Mage_Sales_Model_Order $order - * @return $this - */ - public function setOrder($order) - { - $this->_order = $order; - $requestData = $this->_getOrderData($order); - $this->addData($requestData); - - return $this; - } - - /** - * Get peymet request data as array - * - * @return array - */ - protected function _getPaymentData(Mage_Paypal_Model_Hostedpro $paymentMethod) - { - return [ - 'paymentaction' => strtolower($paymentMethod->getConfigData('payment_action')), - 'notify_url' => $paymentMethod->getNotifyUrl(), - 'cancel_return' => $paymentMethod->getCancelUrl(), - 'return' => $paymentMethod->getReturnUrl(), - 'lc' => substr(Mage::app()->getLocale()->getLocaleCode(), -2), //gets language from locale code - - 'template' => $paymentMethod->getTemplate(), - 'showBillingAddress' => 'false', - 'showShippingAddress' => 'true', - 'showBillingEmail' => 'false', - 'showBillingPhone' => 'false', - 'showCustomerName' => 'false', - 'showCardInfo' => 'true', - 'showHostedThankyouPage' => 'false', - ]; - } - - /** - * Get order request data as array - * - * @return array - */ - protected function _getOrderData(Mage_Sales_Model_Order $order) - { - $request = [ - 'subtotal' => $this->_formatPrice($order->getBaseSubtotal()), - 'tax' => $this->_formatPrice($order->getBaseTaxAmount() + $order->getHiddenTaxAmount()), - 'shipping' => $this->_formatPrice($order->getBaseShippingAmount()), - 'invoice' => $order->getIncrementId(), - 'address_override' => 'true', - 'currency_code' => $order->getBaseCurrencyCode(), - 'buyer_email' => $order->getCustomerEmail(), - 'discount' => $this->_formatPrice( - $order->getBaseGiftCardsAmount() - + abs($order->getBaseDiscountAmount()) - + $order->getBaseCustomerBalanceAmount(), - ), - ]; - - // append to request billing address data - if ($billingAddress = $order->getBillingAddress()) { - $request = array_merge($request, $this->_getBillingAddress($billingAddress)); - } - - // append to request shipping address data - if ($shippingAddress = $order->getShippingAddress()) { - $request = array_merge($request, $this->_getShippingAddress($shippingAddress)); - } - - return $request; - } - - /** - * Get shipping address request data - * - * @return array - */ - protected function _getShippingAddress(Varien_Object $address) - { - $request = [ - 'first_name' => $address->getFirstname(), - 'last_name' => $address->getLastname(), - 'city' => $address->getCity(), - 'state' => $address->getRegionCode() ? $address->getRegionCode() : $address->getCity(), - 'zip' => $address->getPostcode(), - 'country' => $address->getCountry(), - ]; - - // convert streets to tow lines format - $street = Mage::helper('customer/address') - ->convertStreetLines($address->getStreet(), 2); - - $request['address1'] = $street[0] ?? ''; - $request['address2'] = $street[1] ?? ''; - - return $request; - } - - /** - * Get billing address request data - * - * @return array - */ - protected function _getBillingAddress(Varien_Object $address) - { - $request = [ - 'billing_first_name' => $address->getFirstname(), - 'billing_last_name' => $address->getLastname(), - 'billing_city' => $address->getCity(), - 'billing_state' => $address->getRegionCode() ? $address->getRegionCode() : $address->getCity(), - 'billing_zip' => $address->getPostcode(), - 'billing_country' => $address->getCountry(), - ]; - - // convert streets to tow lines format - $street = Mage::helper('customer/address') - ->convertStreetLines($address->getStreet(), 2); - - $request['billing_address1'] = $street[0] ?? ''; - $request['billing_address2'] = $street[1] ?? ''; - - return $request; - } - - /** - * Format price string - * - * @param mixed $string - * @return mixed - */ - protected function _formatPrice($string) - { - return sprintf('%.2F', $string); - } -} diff --git a/app/code/core/Mage/Paypal/Model/Info.php b/app/code/core/Mage/Paypal/Model/Info.php deleted file mode 100644 index b7d2e3244f8..00000000000 --- a/app/code/core/Mage/Paypal/Model/Info.php +++ /dev/null @@ -1,682 +0,0 @@ - 'paypal_payer_id', - self::PAYER_EMAIL => 'paypal_payer_email', - self::PAYER_STATUS => 'paypal_payer_status', - self::ADDRESS_ID => 'paypal_address_id', - self::ADDRESS_STATUS => 'paypal_address_status', - self::PROTECTION_EL => 'paypal_protection_eligibility', - self::FRAUD_FILTERS => 'paypal_fraud_filters', - self::CORRELATION_ID => 'paypal_correlation_id', - self::AVS_CODE => 'paypal_avs_code', - self::CVV2_MATCH => 'paypal_cvv2_match', - self::CENTINEL_VPAS => self::CENTINEL_VPAS, - self::CENTINEL_ECI => self::CENTINEL_ECI, - self::BUYER_TAX_ID => self::BUYER_TAX_ID, - self::BUYER_TAX_ID_TYPE => self::BUYER_TAX_ID_TYPE, - ]; - - /** - * System information map - * - * @var array - */ - protected $_systemMap = [ - self::PAYMENT_STATUS => self::PAYMENT_STATUS_GLOBAL, - self::PENDING_REASON => self::PENDING_REASON_GLOBAL, - self::IS_FRAUD => self::IS_FRAUD_GLOBAL, - ]; - - /** - * PayPal payment status possible values - * - * @var string - */ - public const PAYMENTSTATUS_NONE = 'none'; - public const PAYMENTSTATUS_COMPLETED = 'completed'; - public const PAYMENTSTATUS_DENIED = 'denied'; - public const PAYMENTSTATUS_EXPIRED = 'expired'; - public const PAYMENTSTATUS_FAILED = 'failed'; - public const PAYMENTSTATUS_INPROGRESS = 'in_progress'; - public const PAYMENTSTATUS_PENDING = 'pending'; - public const PAYMENTSTATUS_REFUNDED = 'refunded'; - public const PAYMENTSTATUS_REFUNDEDPART = 'partially_refunded'; - public const PAYMENTSTATUS_REVERSED = 'reversed'; - public const PAYMENTSTATUS_UNREVERSED = 'canceled_reversal'; - public const PAYMENTSTATUS_PROCESSED = 'processed'; - public const PAYMENTSTATUS_VOIDED = 'voided'; - - /** - * PayPal payment transaction type - */ - public const TXN_TYPE_ADJUSTMENT = 'adjustment'; - public const TXN_TYPE_NEW_CASE = 'new_case'; - - /** - * PayPal payment reason code when payment_status is Reversed, Refunded, or Canceled_Reversal. - */ - public const PAYMENT_REASON_CODE_REFUND = 'refund'; - - /** - * PayPal order status for Reverse payment status - */ - public const ORDER_STATUS_REVERSED = 'paypal_reversed'; - - /** - * PayPal order status for Canceled Reversal payment status - */ - public const ORDER_STATUS_CANCELED_REVERSAL = 'paypal_canceled_reversal'; - - /** - * Map of payment information available to customer - * - * @var array - */ - protected $_paymentPublicMap = [ - 'paypal_payer_email', - self::BUYER_TAX_ID, - self::BUYER_TAX_ID_TYPE, - ]; - - /** - * Rendered payment map cache - * - * @var array - */ - protected $_paymentMapFull = []; - - /** - * All available payment info getter - * - * @param bool $labelValuesOnly - * @return array - */ - public function getPaymentInfo(Mage_Payment_Model_Info $payment, $labelValuesOnly = false) - { - // collect paypal-specific info - $result = $this->_getFullInfo(array_values($this->_paymentMap), $payment, $labelValuesOnly); - - // add last_trans_id - $label = Mage::helper('paypal')->__('Last Transaction ID'); - $value = $payment->getLastTransId(); - if ($labelValuesOnly) { - $result[$label] = $value; - } else { - $result['last_trans_id'] = ['label' => $label, 'value' => $value]; - } - - return $result; - } - - /** - * Public payment info getter - * - * @param bool $labelValuesOnly - * @return array - */ - public function getPublicPaymentInfo(Mage_Payment_Model_Info $payment, $labelValuesOnly = false) - { - return $this->_getFullInfo($this->_paymentPublicMap, $payment, $labelValuesOnly); - } - - /** - * Grab data from source and map it into payment - * - * @param array|Varien_Object|callback $from - */ - public function importToPayment($from, Mage_Payment_Model_Info $payment) - { - $fullMap = array_merge($this->_paymentMap, $this->_systemMap); - if (is_object($from)) { - $from = [$from, 'getDataUsingMethod']; - } - Varien_Object_Mapper::accumulateByMap($from, [$payment, 'setAdditionalInformation'], $fullMap); - } - - /** - * Grab data from payment and map it into target - * - * @param array|Varien_Object|callback $to - * @return array|Varien_Object - */ - public function &exportFromPayment(Mage_Payment_Model_Info $payment, $to, ?array $map = null) - { - $fullMap = array_merge($this->_paymentMap, $this->_systemMap); - Varien_Object_Mapper::accumulateByMap( - [$payment, 'getAdditionalInformation'], - $to, - $map ? $map : array_flip($fullMap), - ); - return $to; - } - - /** - * Check whether the payment is in review state - * - * @return bool - */ - public static function isPaymentReviewRequired(Mage_Payment_Model_Info $payment) - { - $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL); - if (self::PAYMENTSTATUS_PENDING === $paymentStatus) { - $pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL); - return !in_array($pendingReason, ['authorization', 'order']); - } - return false; - } - - /** - * Check whether fraud order review detected and can be reviewed - * - * @return bool - */ - public static function isFraudReviewAllowed(Mage_Payment_Model_Info $payment) - { - return self::isPaymentReviewRequired($payment) - && $payment->getAdditionalInformation(self::IS_FRAUD_GLOBAL) == 1; - } - - /** - * Check whether the payment is completed - * - * @return bool - */ - public static function isPaymentCompleted(Mage_Payment_Model_Info $payment) - { - $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL); - return self::PAYMENTSTATUS_COMPLETED === $paymentStatus; - } - - /** - * Check whether the payment was processed successfully - * - * @return bool - */ - public static function isPaymentSuccessful(Mage_Payment_Model_Info $payment) - { - $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL); - if (in_array($paymentStatus, [ - self::PAYMENTSTATUS_COMPLETED, self::PAYMENTSTATUS_INPROGRESS, self::PAYMENTSTATUS_REFUNDED, - self::PAYMENTSTATUS_REFUNDEDPART, self::PAYMENTSTATUS_UNREVERSED, self::PAYMENTSTATUS_PROCESSED, - ]) - ) { - return true; - } - $pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL); - return self::PAYMENTSTATUS_PENDING === $paymentStatus - && in_array($pendingReason, ['authorization', 'order']); - } - - /** - * Check whether the payment was processed unsuccessfully or failed - * - * @return bool - */ - public static function isPaymentFailed(Mage_Payment_Model_Info $payment) - { - $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL); - return in_array($paymentStatus, [ - self::PAYMENTSTATUS_DENIED, self::PAYMENTSTATUS_EXPIRED, self::PAYMENTSTATUS_FAILED, - self::PAYMENTSTATUS_REVERSED, self::PAYMENTSTATUS_VOIDED, - ]); - } - - /** - * Explain pending payment reason code - * - * @param string $code - * @return string - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetTransactionDetails - */ - public static function explainPendingReason($code) - { - switch ($code) { - case 'address': - return Mage::helper('paypal')->__('Customer did not include a confirmed address.'); - case 'authorization': - case 'order': - return Mage::helper('paypal')->__('The payment is authorized but not settled.'); - case 'echeck': - return Mage::helper('paypal')->__('The payment eCheck is not yet cleared.'); - case 'intl': - return Mage::helper('paypal')->__('Merchant holds a non-U.S. account and does not have a withdrawal mechanism.'); - case 'multi-currency': // break is intentionally omitted - case 'multi_currency': // break is intentionally omitted - case 'multicurrency': - return Mage::helper('paypal')->__('The payment curency does not match any of the merchant\'s balances currency.'); - case 'paymentreview': - return Mage::helper('paypal')->__('The payment is pending while it is being reviewed by PayPal for risk.'); - case 'unilateral': - return Mage::helper('paypal')->__('The payment is pending because it was made to an email address that is not yet registered or confirmed.'); - case 'verify': - return Mage::helper('paypal')->__('The merchant account is not yet verified.'); - case 'upgrade': - return Mage::helper('paypal')->__('The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status.'); - case 'none': // break is intentionally omitted - case 'other': // break is intentionally omitted - default: - return Mage::helper('paypal')->__('Unknown reason. Please contact PayPal customer service.'); - } - } - - /** - * Explain the refund or chargeback reason code - * - * @param string $code - * @return string - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_html_IPNandPDTVariables - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_GetTransactionDetails - */ - public static function explainReasonCode($code) - { - $comments = [ - 'chargeback' => Mage::helper('paypal')->__('A reversal has occurred on this transaction due to a chargeback by your customer.'), - 'guarantee' => Mage::helper('paypal')->__('A reversal has occurred on this transaction due to your customer triggering a money-back guarantee.'), - 'buyer-complaint' => Mage::helper('paypal')->__('A reversal has occurred on this transaction due to a complaint about the transaction from your customer.'), - 'buyer_complaint' => Mage::helper('paypal')->__('A reversal has occurred on this transaction due to a complaint about the transaction from your customer.'), - 'refund' => Mage::helper('paypal')->__('A reversal has occurred on this transaction because you have given the customer a refund.'), - 'adjustment_reversal' => Mage::helper('paypal')->__('Reversal of an adjustment.'), - 'admin_fraud_reversal' => Mage::helper('paypal')->__('Transaction reversal due to fraud detected by PayPal administrators.'), - 'admin_reversal' => Mage::helper('paypal')->__('Transaction reversal by PayPal administrators.'), - 'chargeback_reimbursement' => Mage::helper('paypal')->__('Reimbursement for a chargeback.'), - 'chargeback_settlement' => Mage::helper('paypal')->__('Settlement of a chargeback.'), - 'unauthorized_spoof' => Mage::helper('paypal')->__('A reversal has occurred on this transaction because of a customer dispute suspecting unauthorized spoof.'), - 'non_receipt' => Mage::helper('paypal')->__('Buyer claims that he did not receive goods or service.'), - 'not_as_described' => Mage::helper('paypal')->__('Buyer claims that the goods or service received differ from merchant’s description of the goods or service.'), - 'unauthorized' => Mage::helper('paypal')->__('Buyer claims that he/she did not authorize transaction.'), - 'adjustment_reimburse' => Mage::helper('paypal')->__('A case that has been resolved and close requires a reimbursement.'), - 'duplicate' => Mage::helper('paypal')->__('Buyer claims that a possible duplicate payment was made to the merchant.'), - 'merchandise' => Mage::helper('paypal')->__('Buyer claims that the received merchandise is unsatisfactory, defective, or damaged.'), - ]; - return (array_key_exists($code, $comments) && !empty($comments[$code])) - ? $comments[$code] - : Mage::helper('paypal')->__('Unknown reason. Please contact PayPal customer service.'); - } - - /** - * Whether a reversal/refund can be disputed with PayPal - * - * @param string $code - * @return bool - */ - public static function isReversalDisputable($code) - { - switch ($code) { - case 'none': - case 'other': - case 'chargeback': - case 'buyer-complaint': - case 'buyer_complaint': - case 'adjustment_reversal': - return true; - case 'guarantee': - case 'refund': - case 'chargeback_reimbursement': - case 'chargeback_settlement': - default: - return false; - } - } - - /** - * Render info item - * - * @param bool $labelValuesOnly - * @return array - */ - protected function _getFullInfo(array $keys, Mage_Payment_Model_Info $payment, $labelValuesOnly) - { - $result = []; - foreach ($keys as $key) { - if (!isset($this->_paymentMapFull[$key])) { - $this->_paymentMapFull[$key] = []; - } - 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; - } - - /** - * Render info item labels - * - * @param string $key - * @return string - */ - protected function _getLabel($key) - { - switch ($key) { - case 'paypal_payer_id': - return Mage::helper('paypal')->__('Payer ID'); - case 'paypal_payer_email': - return Mage::helper('paypal')->__('Payer Email'); - case 'paypal_payer_status': - return Mage::helper('paypal')->__('Payer Status'); - case 'paypal_address_id': - return Mage::helper('paypal')->__('Payer Address ID'); - case 'paypal_address_status': - return Mage::helper('paypal')->__('Payer Address Status'); - case 'paypal_protection_eligibility': - return Mage::helper('paypal')->__('Merchant Protection Eligibility'); - case 'paypal_fraud_filters': - return Mage::helper('paypal')->__('Triggered Fraud Filters'); - case 'paypal_correlation_id': - return Mage::helper('paypal')->__('Last Correlation ID'); - case 'paypal_avs_code': - return Mage::helper('paypal')->__('Address Verification System Response'); - case 'paypal_cvv2_match': - return Mage::helper('paypal')->__('CVV2 Check Result by PayPal'); - case self::BUYER_TAX_ID: - return Mage::helper('paypal')->__('Buyer\'s Tax ID'); - case self::BUYER_TAX_ID_TYPE: - return Mage::helper('paypal')->__('Buyer\'s Tax ID Type'); - case self::CENTINEL_VPAS: - return Mage::helper('paypal')->__('PayPal/Centinel Visa Payer Authentication Service Result'); - case self::CENTINEL_ECI: - return Mage::helper('paypal')->__('PayPal/Centinel Electronic Commerce Indicator'); - } - return ''; - } - - /** - * Get case type label - * - * @param string $key - * @return string - */ - public static function getCaseTypeLabel($key) - { - $labels = [ - 'chargeback' => Mage::helper('paypal')->__('Chargeback'), - 'complaint' => Mage::helper('paypal')->__('Complaint'), - 'dispute' => Mage::helper('paypal')->__('Dispute'), - ]; - return (array_key_exists($key, $labels) && !empty($labels[$key])) ? $labels[$key] : ''; - } - - /** - * Apply a filter upon value getting - * - * @param string $value - * @param string $key - * @return string - */ - protected function _getValue($value, $key) - { - $label = ''; - switch ($key) { - case 'paypal_avs_code': - $label = $this->_getAvsLabel($value); - break; - case 'paypal_cvv2_match': - $label = $this->_getCvv2Label($value); - break; - case self::CENTINEL_VPAS: - $label = $this->_getCentinelVpasLabel($value); - break; - case self::CENTINEL_ECI: - $label = $this->_getCentinelEciLabel($value); - break; - case self::BUYER_TAX_ID_TYPE: - $value = $this->_getBuyerIdTypeValue($value); - // no break - default: - return $value; - } - return sprintf('#%s%s', $value, $value == $label ? '' : ': ' . $label); - } - - /** - * Attempt to convert AVS check result code into label - * - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_AVSResponseCodes - * @param string $value - * @return string - */ - protected function _getAvsLabel($value) - { - switch ($value) { - // Visa, MasterCard, Discover and American Express - case 'A': - case 'YN': - return Mage::helper('paypal')->__('Matched Address only (no ZIP)'); - case 'B': // international "A" - return Mage::helper('paypal')->__('Matched Address only (no ZIP). International'); - case 'N': - return Mage::helper('paypal')->__('No Details matched'); - case 'C': // international "N" - return Mage::helper('paypal')->__('No Details matched. International'); - case 'X': - return Mage::helper('paypal')->__('Exact Match. Address and nine-digit ZIP code'); - case 'D': // international "X" - return Mage::helper('paypal')->__('Exact Match. Address and Postal Code. International'); - case 'F': // UK-specific "X" - return Mage::helper('paypal')->__('Exact Match. Address and Postal Code. UK-specific'); - case 'E': - return Mage::helper('paypal')->__('N/A. Not allowed for MOTO (Internet/Phone) transactions'); - case 'G': - return Mage::helper('paypal')->__('N/A. Global Unavailable'); - case 'I': - return Mage::helper('paypal')->__('N/A. International Unavailable'); - case 'Z': - case 'NY': - return Mage::helper('paypal')->__('Matched five-digit ZIP only (no Address)'); - case 'P': // international "Z" - case 'NY': - return Mage::helper('paypal')->__('Matched Postal Code only (no Address)'); - case 'R': - return Mage::helper('paypal')->__('N/A. Retry'); - case 'S': - return Mage::helper('paypal')->__('N/A. Service not Supported'); - case 'U': - return Mage::helper('paypal')->__('N/A. Unavailable'); - case 'W': - return Mage::helper('paypal')->__('Matched whole nine-didgit ZIP (no Address)'); - case 'Y': - return Mage::helper('paypal')->__('Yes. Matched Address and five-didgit ZIP'); - // Maestro and Solo - case '0': - return Mage::helper('paypal')->__('All the address information matched'); - case '1': - return Mage::helper('paypal')->__('None of the address information matched'); - case '2': - return Mage::helper('paypal')->__('Part of the address information matched'); - case '3': - return Mage::helper('paypal')->__('N/A. The merchant did not provide AVS information'); - case '4': - return Mage::helper('paypal')->__('N/A. Address not checked, or acquirer had no response. Service not available'); - default: - return $value; - } - } - - /** - * Attempt to convert CVV2 check result code into label - * - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_AVSResponseCodes - * @param string $value - * @return string - */ - protected function _getCvv2Label($value) - { - switch ($value) { - // Visa, MasterCard, Discover and American Express - case 'M': - return Mage::helper('paypal')->__('Matched (CVV2CSC)'); - case 'N': - return Mage::helper('paypal')->__('No match'); - case 'P': - return Mage::helper('paypal')->__('N/A. Not processed'); - case 'S': - return Mage::helper('paypal')->__('N/A. Service not supported'); - case 'U': - return Mage::helper('paypal')->__('N/A. Service not available'); - case 'X': - return Mage::helper('paypal')->__('N/A. No response'); - // Maestro and Solo - case '0': - return Mage::helper('paypal')->__('Matched (CVV2)'); - case '1': - return Mage::helper('paypal')->__('No match'); - case '2': - return Mage::helper('paypal')->__('N/A. The merchant has not implemented CVV2 code handling'); - case '3': - return Mage::helper('paypal')->__('N/A. Merchant has indicated that CVV2 is not present on card'); - case '4': - return Mage::helper('paypal')->__('N/A. Service not available'); - default: - return $value; - } - } - - /** - * Attempt to convert centinel VPAS result into label - * - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoDirectPayment - * @param string $value - * @return string - */ - private function _getCentinelVpasLabel($value) - { - switch ($value) { - case '2': - case 'D': - return Mage::helper('paypal')->__('Authenticated, Good Result'); - case '1': - return Mage::helper('paypal')->__('Authenticated, Bad Result'); - case '3': - case '6': - case '8': - case 'A': - case 'C': - return Mage::helper('paypal')->__('Attempted Authentication, Good Result'); - case '4': - case '7': - case '9': - return Mage::helper('paypal')->__('Attempted Authentication, Bad Result'); - case '': - case '0': - case 'B': - return Mage::helper('paypal')->__('No Liability Shift'); - default: - return $value; - } - } - - /** - * Attempt to convert centinel ECI result into label - * - * @link https://cms.paypal.com/us/cgi-bin/?&cmd=_render-content&content_ID=developer/e_howto_api_nvp_r_DoDirectPayment - * @param string $value - * @return string - */ - private function _getCentinelEciLabel($value) - { - switch ($value) { - case '01': - case '07': - return Mage::helper('paypal')->__('Merchant Liability'); - case '02': - case '05': - case '06': - return Mage::helper('paypal')->__('Issuer Liability'); - default: - return $value; - } - } - - /** - * Retrieve buyer id type value based on code received from PayPal (Brazil only) - * - * @param string $code - * @return string - */ - protected function _getBuyerIdTypeValue($code) - { - $value = ''; - switch ($code) { - case self::BUYER_TAX_ID_TYPE_CNPJ: - $value = Mage::helper('paypal')->__('CNPJ'); - break; - case self::BUYER_TAX_ID_TYPE_CPF: - $value = Mage::helper('paypal')->__('CPF'); - break; - } - return $value; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Ipn.php b/app/code/core/Mage/Paypal/Model/Ipn.php deleted file mode 100644 index 1144174ada1..00000000000 --- a/app/code/core/Mage/Paypal/Model/Ipn.php +++ /dev/null @@ -1,819 +0,0 @@ -_request; - } - return $this->_request[$key] ?? null; - } - - /** - * Get ipn data, send verification to PayPal, run corresponding handler - * - * @throws Mage_Core_Exception - */ - public function processIpnRequest(array $request, ?Zend_Http_Client_Adapter_Interface $httpAdapter = null) - { - $this->_request = $request; - $this->_debugData = ['ipn' => $request]; - ksort($this->_debugData['ipn']); - - try { - if (isset($this->_request['txn_type']) && $this->_request['txn_type'] == 'recurring_payment') { - $this->_getRecurringProfile(); - if ($httpAdapter) { - $this->_postBack($httpAdapter); - } - $this->_processRecurringProfile(); - } else { - $this->_getOrder(); - if ($httpAdapter) { - $this->_postBack($httpAdapter); - } - $this->_processOrder(); - } - } catch (Exception $e) { - $this->_debugData['exception'] = $e->getMessage(); - $this->_debug(); - throw $e; - } - $this->_debug(); - } - - /** - * Post back to PayPal to check whether this request is a valid one - * - * @throws Exception - */ - protected function _postBack(Zend_Http_Client_Adapter_Interface $httpAdapter) - { - $postbackQuery = http_build_query($this->_request) . '&cmd=_notify-validate'; - $postbackUrl = $this->_config->getPostbackUrl(); - $this->_debugData['postback_to'] = $postbackUrl; - - $httpAdapter->setConfig(['verifypeer' => $this->_config->verifyPeer]); - $httpAdapter->write( - Zend_Http_Client::POST, - $postbackUrl, - '1.1', - ['Connection: close'], - $postbackQuery, - ); - - try { - $postbackResult = $httpAdapter->read(); - } catch (Exception $e) { - $this->_debugData['http_error'] = ['error' => $e->getMessage(), 'code' => $e->getCode()]; - throw $e; - } - - /* - * Handle errors on PayPal side. - */ - $responseCode = Zend_Http_Response::extractCode($postbackResult); - if (empty($postbackResult) || in_array($responseCode, ['500', '502', '503'])) { - if (empty($postbackResult)) { - $reason = 'Empty response.'; - } else { - $reason = 'Response code: ' . $responseCode . '.'; - } - $this->_debugData['exception'] = 'PayPal IPN postback failure. ' . $reason; - throw new Mage_Paypal_UnavailableException($reason); - } - - $response = preg_split('/^\r?$/m', $postbackResult); - $response = trim(end($response)); - if ($response != 'VERIFIED') { - $this->_debugData['postback'] = $postbackQuery; - $this->_debugData['postback_result'] = $postbackResult; - throw new Exception('PayPal IPN postback failure. See ' . self::DEFAULT_LOG_FILE . ' for details.'); - } - } - - /** - * Load and validate order, instantiate proper configuration - * - * - * @return Mage_Sales_Model_Order - * @throws Exception - * @SuppressWarnings("PHPMD.ExitExpression") - */ - protected function _getOrder() - { - if (empty($this->_order)) { - // get proper order - $id = $this->_request['invoice']; - $this->_order = Mage::getModel('sales/order')->loadByIncrementId($id); - if (!$this->_order->getId()) { - $this->_debugData['exception'] = sprintf('Wrong order ID: "%s".', $id); - $this->_debug(); - Mage::app()->getResponse() - ->setHeader('HTTP/1.1', '503 Service Unavailable') - ->sendResponse(); - exit; - } - // re-initialize config with the method code and store id - $methodCode = $this->_order->getPayment()->getMethod(); - $this->_config = Mage::getModel('paypal/config', [$methodCode, $this->_order->getStoreId()]); - if (!$this->_config->isMethodActive($methodCode) || !$this->_config->isMethodAvailable()) { - throw new Exception(sprintf('Method "%s" is not available.', $methodCode)); - } - - $this->_verifyOrder(); - } - return $this->_order; - } - - /** - * Load recurring profile - * - * @return Mage_Sales_Model_Recurring_Profile - * @throws Exception - */ - protected function _getRecurringProfile() - { - if (empty($this->_recurringProfile)) { - // get proper recurring profile - $internalReferenceId = $this->_request['rp_invoice_id']; - $this->_recurringProfile = Mage::getModel('sales/recurring_profile') - ->loadByInternalReferenceId($internalReferenceId); - if (!$this->_recurringProfile->getId()) { - throw new Exception( - sprintf('Wrong recurring profile INTERNAL_REFERENCE_ID: "%s".', $internalReferenceId), - ); - } - // re-initialize config with the method code and store id - $methodCode = $this->_recurringProfile->getMethodCode(); - $this->_config = Mage::getModel( - 'paypal/config', - [$methodCode, $this->_recurringProfile->getStoreId()], - ); - if (!$this->_config->isMethodActive($methodCode) || !$this->_config->isMethodAvailable()) { - throw new Exception(sprintf('Method "%s" is not available.', $methodCode)); - } - } - return $this->_recurringProfile; - } - - /** - * Validate incoming request data, as PayPal recommends - * - * @throws Exception - * @link https://cms.paypal.com/cgi-bin/marketingweb?cmd=_render-content&content_ID=developer/e_howto_admin_IPNIntro - */ - protected function _verifyOrder() - { - // verify merchant email intended to receive notification - $merchantEmail = $this->_config->businessAccount; - if ($merchantEmail) { - $receiverEmail = $this->getRequestData('business'); - if (!$receiverEmail) { - $receiverEmail = $this->getRequestData('receiver_email'); - } - if (strtolower($merchantEmail) != strtolower($receiverEmail)) { - throw new Exception( - sprintf( - 'Requested %s and configured %s merchant emails do not match.', - $receiverEmail, - $merchantEmail, - ), - ); - } - } - } - - /** - * IPN workflow implementation - * Everything should be added to order comments. In positive processing cases customer will get email notifications. - * Admin will be notified on errors. - */ - protected function _processOrder() - { - $this->_order = null; - $this->_getOrder(); - - $this->_info = Mage::getSingleton('paypal/info'); - try { - // Handle payment_status - $transactionType = $this->_request['txn_type'] ?? null; - switch ($transactionType) { - // handle new case created - case Mage_Paypal_Model_Info::TXN_TYPE_NEW_CASE: - $this->_registerDispute(); - break; - - // handle new adjustment is created - case Mage_Paypal_Model_Info::TXN_TYPE_ADJUSTMENT: - $this->_registerAdjustment(); - break; - - //handle new transaction created - default: - $this->_registerTransaction(); - } - } catch (Mage_Core_Exception $e) { - $comment = $this->_createIpnComment(Mage::helper('paypal')->__('Note: %s', $e->getMessage()), true); - $comment->save(); - throw $e; - } - } - - /** - * Process adjustment notification - */ - protected function _registerAdjustment() - { - $reasonCode = $this->_request['reason_code'] ?? null; - $reasonComment = $this->_info::explainReasonCode($reasonCode); - $notificationAmount = $this->_order->getBaseCurrency()->formatTxt($this->_request['mc_gross']); - /** - * Add IPN comment about registered dispute - */ - $message = Mage::helper('paypal')->__('IPN "%s". A dispute has been resolved and closed. %s Transaction amount %s.', ucfirst($reasonCode), $notificationAmount, $reasonComment); - $this->_order->addStatusHistoryComment($message) - ->setIsCustomerNotified(false) - ->save(); - } - - /** - * Process dispute notification - */ - protected function _registerDispute() - { - $reasonCode = $this->_request['reason_code'] ?? null; - $reasonComment = $this->_info::explainReasonCode($reasonCode); - $caseType = $this->_request['case_type'] ?? null; - $caseTypeLabel = $this->_info::getCaseTypeLabel($caseType); - $caseId = $this->_request['case_id'] ?? null; - /** - * Add IPN comment about registered dispute - */ - $message = Mage::helper('paypal')->__('IPN "%s". Case type "%s". Case ID "%s" %s', ucfirst($caseType), $caseTypeLabel, $caseId, $reasonComment); - $this->_order->addStatusHistoryComment($message) - ->setIsCustomerNotified(false) - ->save(); - } - - /** - * Process regular IPN notifications - */ - protected function _registerTransaction() - { - try { - // Handle payment_status - $paymentStatus = $this->_filterPaymentStatus($this->_request['payment_status']); - switch ($paymentStatus) { - // paid - case Mage_Paypal_Model_Info::PAYMENTSTATUS_COMPLETED: - $this->_registerPaymentCapture(true); - break; - - // the held payment was denied on paypal side - case Mage_Paypal_Model_Info::PAYMENTSTATUS_DENIED: - $this->_registerPaymentDenial(); - break; - - // customer attempted to pay via bank account, but failed - case Mage_Paypal_Model_Info::PAYMENTSTATUS_FAILED: - // cancel order - $this->_registerPaymentFailure(); - break; - - // payment was obtained, but money were not captured yet - case Mage_Paypal_Model_Info::PAYMENTSTATUS_PENDING: - $this->_registerPaymentPending(); - break; - - case Mage_Paypal_Model_Info::PAYMENTSTATUS_PROCESSED: - $this->_registerMasspaymentsSuccess(); - break; - - case Mage_Paypal_Model_Info::PAYMENTSTATUS_REVERSED:// break is intentionally omitted - case Mage_Paypal_Model_Info::PAYMENTSTATUS_UNREVERSED: - $this->_registerPaymentReversal(); - break; - - case Mage_Paypal_Model_Info::PAYMENTSTATUS_REFUNDED: - $this->_registerPaymentRefund(); - break; - - // authorization expire/void - case Mage_Paypal_Model_Info::PAYMENTSTATUS_EXPIRED: // break is intentionally omitted - case Mage_Paypal_Model_Info::PAYMENTSTATUS_VOIDED: - $this->_registerPaymentVoid(); - break; - - default: - throw new Exception("Cannot handle payment status '{$paymentStatus}'."); - } - } catch (Mage_Core_Exception $e) { - $comment = $this->_createIpnComment(Mage::helper('paypal')->__('Note: %s', $e->getMessage()), true); - $comment->save(); - throw $e; - } - } - - /** - * Process notification from recurring profile payments - */ - protected function _processRecurringProfile() - { - $this->_recurringProfile = null; - $this->_getRecurringProfile(); - - try { - // handle payment_status - $paymentStatus = $this->_filterPaymentStatus($this->_request['payment_status']); - - switch ($paymentStatus) { - // paid - case Mage_Paypal_Model_Info::PAYMENTSTATUS_COMPLETED: - $this->_registerRecurringProfilePaymentCapture(); - break; - - default: - throw new Exception("Cannot handle payment status '{$paymentStatus}'."); - } - } catch (Mage_Core_Exception $e) { - throw $e; - } - } - - /** - * Register recurring payment notification, create and process order - */ - protected function _registerRecurringProfilePaymentCapture() - { - $price = $this->getRequestData('mc_gross') - $this->getRequestData('tax') - $this->getRequestData('shipping'); - $productItemInfo = new Varien_Object(); - $type = trim($this->getRequestData('period_type')); - if ($type == 'Trial') { - $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_TRIAL); - } elseif ($type == 'Regular') { - $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR); - } - $productItemInfo->setTaxAmount($this->getRequestData('tax')); - $productItemInfo->setShippingAmount($this->getRequestData('shipping')); - $productItemInfo->setPrice($price); - - $order = $this->_recurringProfile->createOrder($productItemInfo); - - $payment = $order->getPayment(); - $payment->setTransactionId($this->getRequestData('txn_id')) - ->setCurrencyCode($this->getRequestData('mc_currency')) - ->setPreparedMessage($this->_createIpnComment('')) - ->setIsTransactionClosed(0); - $order->save(); - $this->_recurringProfile->addOrderRelation($order->getId()); - $payment->registerCaptureNotification($this->getRequestData('mc_gross')); - $order->save(); - - $invoice = $payment->getCreatedInvoice(); - if ($invoice) { - // notify customer - $message = Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId()); - $order->queueNewOrderEmail()->addStatusHistoryComment($message) - ->setIsCustomerNotified(true) - ->save(); - } - } - - /** - * Process completed payment (either full or partial) - * - * @param bool $skipFraudDetection - */ - protected function _registerPaymentCapture($skipFraudDetection = false) - { - if ($this->getRequestData('transaction_entity') == 'auth') { - return; - } - $parentTransactionId = $this->getRequestData('parent_txn_id'); - $this->_importPaymentInformation(); - $payment = $this->_order->getPayment(); - $payment->setTransactionId($this->getRequestData('txn_id')) - ->setCurrencyCode($this->getRequestData('mc_currency')) - ->setPreparedMessage($this->_createIpnComment('')) - ->setParentTransactionId($parentTransactionId) - ->setShouldCloseParentTransaction($this->getRequestData('auth_status') === 'Completed') - ->setIsTransactionClosed(0) - ->registerCaptureNotification( - $this->getRequestData('mc_gross'), - $skipFraudDetection && $parentTransactionId, - ); - $this->_order->save(); - - // notify customer - $invoice = $payment->getCreatedInvoice(); - if ($invoice && !$this->_order->getEmailSent()) { - $this->_order->queueNewOrderEmail()->addStatusHistoryComment( - Mage::helper('paypal')->__('Notified customer about invoice #%s.', $invoice->getIncrementId()), - ) - ->setIsCustomerNotified(true) - ->save(); - } - } - - /** - * Process denied payment notification - */ - protected function _registerPaymentDenial() - { - $this->_importPaymentInformation(); - /** @var Mage_Sales_Model_Order_Payment $payment */ - $payment = $this->_order->getPayment(); - - $payment->setTransactionId($this->getRequestData('txn_id')) - ->setNotificationResult(true) - ->setIsTransactionClosed(true); - if (!$this->_order->isCanceled()) { - $payment->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_DENY, false); - } else { - $transactionId = Mage::helper('paypal')->getHtmlTransactionId( - $payment->getMethodInstance()->getCode(), - $this->getRequestData('txn_id'), - ); - $comment = Mage::helper('paypal')->__('Transaction ID: "%s"', $transactionId); - $this->_order->addStatusHistoryComment($this->_createIpnComment($comment), false); - } - - $this->_order->save(); - } - - /** - * Treat failed payment as order cancellation - */ - protected function _registerPaymentFailure() - { - $this->_importPaymentInformation(); - - foreach ($this->_order->getInvoiceCollection() as $invoice) { - // phpcs:ignore Ecg.Performance.Loop.ModelLSD - $invoice->cancel()->save(); - } - - $this->_order - ->registerCancellation($this->_createIpnComment(''), false) - ->save(); - } - - /** - * Process a refund or a chargeback - */ - protected function _registerPaymentRefund() - { - $this->_importPaymentInformation(); - $reason = $this->getRequestData('reason_code'); - $isRefundFinal = !$this->_info::isReversalDisputable($reason); - - /** @var Mage_Sales_Model_Order_Payment $payment */ - $payment = $this->_order->getPayment(); - - $amount = $this->_order->getBaseCurrency()->formatTxt($payment->getBaseAmountRefundedOnline()); - - $transactionId = Mage::helper('paypal')->getHtmlTransactionId( - $payment->getMethodInstance()->getCode(), - $this->getRequestData('txn_id'), - ); - $comment = $this->_createIpnComment($this->_info::explainReasonCode($reason)) - . ' ' - . Mage::helper('paypal')->__('Refunded amount of %s. Transaction ID: "%s"', $amount, $transactionId); - - $payment->setPreparedMessage($comment) - ->setTransactionId($this->getRequestData('txn_id')) - ->setParentTransactionId($this->getRequestData('parent_txn_id')) - ->setIsTransactionClosed($isRefundFinal) - ->registerRefundNotification(-1 * (float) $this->getRequestData('mc_gross')); - $this->_order->addStatusHistoryComment($comment, false); - $this->_order->save(); - - // TODO: there is no way to close a capture right now - $creditmemo = $payment->getCreatedCreditmemo(); - if ($creditmemo) { - $creditmemo->sendEmail(); - $this->_order->addStatusHistoryComment( - Mage::helper('paypal')->__('Notified customer about creditmemo #%s.', $creditmemo->getIncrementId()), - ) - ->setIsCustomerNotified(true) - ->save(); - } - } - - /** - * Process payment reversal and cancelled reversal notification - */ - protected function _registerPaymentReversal() - { - $reasonCode = $this->_request['reason_code'] ?? null; - $reasonComment = $this->_info::explainReasonCode($reasonCode); - $notificationAmount = $this->_order - ->getBaseCurrency() - ->formatTxt($this->_request['mc_gross'] + $this->_request['mc_fee']); - $paymentStatus = $this->_filterPaymentStatus($this->_request['payment_status'] ?? null); - $orderStatus = ($paymentStatus == Mage_Paypal_Model_Info::PAYMENTSTATUS_REVERSED) - ? Mage_Paypal_Model_Info::ORDER_STATUS_REVERSED - : Mage_Paypal_Model_Info::ORDER_STATUS_CANCELED_REVERSAL; - /** - * Change order status to PayPal Reversed/PayPal Cancelled Reversal if it is possible. - */ - $transactionId = Mage::helper('paypal')->getHtmlTransactionId( - $this->_config->getMethodCode(), - $this->_request['txn_id'], - ); - $message = Mage::helper('paypal')->__('IPN "%s". %s Transaction amount %s. Transaction ID: "%s"', $this->_request['payment_status'], $reasonComment, $notificationAmount, $transactionId); - $this->_order->setStatus($orderStatus); - $this->_order->save(); - $this->_order->addStatusHistoryComment($message, $orderStatus) - ->setIsCustomerNotified(false) - ->save(); - } - - /** - * Process payment pending notification - * - * @throws Exception - */ - public function _registerPaymentPending() - { - $reason = $this->getRequestData('pending_reason'); - if ($reason === 'authorization') { - $this->_registerPaymentAuthorization(); - return; - } - if ($reason === 'order') { - throw new Exception('The "order" authorizations are not implemented.'); - } - - // case when was placed using PayPal standard - if (Mage_Sales_Model_Order::STATE_PENDING_PAYMENT == $this->_order->getState() - && !$this->getRequestData('transaction_entity') - ) { - $this->_registerPaymentCapture(); - return; - } - - $this->_importPaymentInformation(); - - $this->_order->getPayment() - ->setPreparedMessage($this->_createIpnComment($this->_info::explainPendingReason($reason))) - ->setTransactionId($this->getRequestData('txn_id')) - ->setIsTransactionClosed(0) - ->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, false); - $this->_order->save(); - } - - /** - * Register authorized payment - */ - protected function _registerPaymentAuthorization() - { - $this->_importPaymentInformation(); - - $this->_order->getPayment() - ->setPreparedMessage($this->_createIpnComment('')) - ->setTransactionId($this->getRequestData('txn_id')) - ->setParentTransactionId($this->getRequestData('parent_txn_id')) - ->setCurrencyCode($this->getRequestData('mc_currency')) - ->setIsTransactionClosed(0) - ->registerAuthorizationNotification($this->getRequestData('mc_gross')); - - if (!$this->_order->getEmailSent()) { - $this->_order->queueNewOrderEmail(); - } - $this->_order->save(); - } - - /** - * Process voided authorization - */ - protected function _registerPaymentVoid() - { - $this->_importPaymentInformation(); - - $parentTxnId = $this->getRequestData('transaction_entity') == 'auth' - ? $this->getRequestData('txn_id') : $this->getRequestData('parent_txn_id'); - - $this->_order->getPayment() - ->setPreparedMessage($this->_createIpnComment('')) - ->setParentTransactionId($parentTxnId) - ->registerVoidNotification(); - - $this->_order->save(); - } - - /** - * TODO - * The status "Processed" is used when all Masspayments are successful - */ - protected function _registerMasspaymentsSuccess() - { - $comment = $this->_createIpnComment('', true); - $comment->save(); - } - - /** - * Generate an "IPN" comment with additional explanation. - * Returns the generated comment or order status history object - * - * @param string $comment - * @param bool $addToHistory - * @return string|Mage_Sales_Model_Order_Status_History - */ - protected function _createIpnComment($comment = '', $addToHistory = false) - { - $paymentStatus = $this->getRequestData('payment_status'); - $message = Mage::helper('paypal')->__('IPN "%s".', $paymentStatus); - if ($comment) { - $message .= ' ' . $comment; - } - if ($addToHistory) { - $message = $this->_order->addStatusHistoryComment($message); - $message->setIsCustomerNotified(null); - } - return $message; - } - - /** - * Map payment information from IPN to payment object - * Returns true if there were changes in information - * - * @return bool - */ - protected function _importPaymentInformation() - { - $payment = $this->_order->getPayment(); - $was = $payment->getAdditionalInformation(); - - // collect basic information - $from = []; - foreach ([ - 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, - Mage_Paypal_Model_Info::PAYMENT_STATUS, - Mage_Paypal_Model_Info::PENDING_REASON, - ] as $privateKey => $publicKey - ) { - if (is_int($privateKey)) { - $privateKey = $publicKey; - } - $value = $this->getRequestData($privateKey); - if ($value) { - $from[$publicKey] = $value; - } - } - if (isset($from['payment_status'])) { - $from['payment_status'] = $this->_filterPaymentStatus($this->getRequestData('payment_status')); - } - - // collect fraud filters - $fraudFilters = []; - for ($i = 1; $value = $this->getRequestData("fraud_management_pending_filters_{$i}"); $i++) { - $fraudFilters[] = $value; - } - if ($fraudFilters) { - $from[Mage_Paypal_Model_Info::FRAUD_FILTERS] = $fraudFilters; - } - - $this->_info->importToPayment($from, $payment); - - /** - * Detect pending payment, frauds - * TODO: implement logic in one place - * @see Mage_Paypal_Model_Pro::importPaymentInfo() - */ - if ($this->_info::isPaymentReviewRequired($payment)) { - $payment->setIsTransactionPending(true); - if ($fraudFilters) { - $payment->setIsFraudDetected(true); - } - } - if ($this->_info::isPaymentSuccessful($payment)) { - $payment->setIsTransactionApproved(true); - } elseif ($this->_info::isPaymentFailed($payment)) { - $payment->setIsTransactionDenied(true); - } - - return $was != $payment->getAdditionalInformation(); - } - - /** - * Filter payment status from NVP into paypal/info format - * - * @param string $ipnPaymentStatus - * @return string - */ - protected function _filterPaymentStatus($ipnPaymentStatus) - { - switch ($ipnPaymentStatus) { - case 'Created': // break is intentionally omitted - case 'Completed': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_COMPLETED; - case 'Denied': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_DENIED; - case 'Expired': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_EXPIRED; - case 'Failed': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_FAILED; - case 'Pending': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_PENDING; - case 'Refunded': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_REFUNDED; - case 'Reversed': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_REVERSED; - case 'Canceled_Reversal': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_UNREVERSED; - case 'Processed': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_PROCESSED; - case 'Voided': - return Mage_Paypal_Model_Info::PAYMENTSTATUS_VOIDED; - } - return ''; - // documented in NVP, but not documented in IPN: - //Mage_Paypal_Model_Info::PAYMENTSTATUS_NONE - //Mage_Paypal_Model_Info::PAYMENTSTATUS_INPROGRESS - //Mage_Paypal_Model_Info::PAYMENTSTATUS_REFUNDEDPART - } - - /** - * Log debug data to file - */ - protected function _debug() - { - if ($this->_config && $this->_config->debug) { - $file = $this->_config->getMethodCode() ? "payment_{$this->_config->getMethodCode()}.log" - : self::DEFAULT_LOG_FILE; - Mage::getModel('core/log_adapter', $file)->log($this->_debugData); - } - } -} diff --git a/app/code/core/Mage/Paypal/Model/Method/Agreement.php b/app/code/core/Mage/Paypal/Model/Method/Agreement.php deleted file mode 100644 index 56e6408437a..00000000000 --- a/app/code/core/Mage/Paypal/Model/Method/Agreement.php +++ /dev/null @@ -1,325 +0,0 @@ -_pro = $proInstance; - } else { - $this->_pro = Mage::getModel('paypal/pro'); - } - $this->_pro->setMethod($this->_code); - } - - /** - * Store setter - * Also updates store ID in config object - * - * @param Mage_Core_Model_Store|int $store - * @return $this - */ - public function setStore($store) - { - $this->setData('store', $store); - if ($store === null) { - $store = Mage::app()->getStore()->getId(); - } - $this->_pro->getConfig()->setStoreId(is_object($store) ? $store->getId() : $store); - return $this; - } - - /** - * Init billing agreement - * - * @return $this - */ - public function initBillingAgreementToken(Mage_Payment_Model_Billing_AgreementAbstract $agreement) - { - $api = $this->_pro->getApi() - ->setReturnUrl($agreement->getReturnUrl()) - ->setCancelUrl($agreement->getCancelUrl()) - ->setBillingType($this->_pro->getApi()->getBillingAgreementType()); - - $api->callSetCustomerBillingAgreement(); - $agreement->setRedirectUrl( - $this->_pro->getConfig()->getStartBillingAgreementUrl($api->getToken()), - ); - return $this; - } - - /** - * Retrieve billing agreement customer details by token - * - * @return array - */ - public function getBillingAgreementTokenInfo(Mage_Payment_Model_Billing_AgreementAbstract $agreement) - { - $api = $this->_pro->getApi() - ->setToken($agreement->getToken()); - $api->callGetBillingAgreementCustomerDetails(); - $responseData = [ - 'token' => $api->getData('token'), - 'email' => $api->getData('email'), - 'payer_id' => $api->getData('payer_id'), - 'payer_status' => $api->getData('payer_status'), - ]; - $agreement->addData($responseData); - return $responseData; - } - - /** - * Create billing agreement by token specified in request - * - * @return $this - */ - public function placeBillingAgreement(Mage_Payment_Model_Billing_AgreementAbstract $agreement) - { - $api = $this->_pro->getApi() - ->setToken($agreement->getToken()); - $api->callCreateBillingAgreement(); - $agreement->setBillingAgreementId($api->getData('billing_agreement_id')); - return $this; - } - - /** - * Update billing agreement status - * - * @return $this - */ - public function updateBillingAgreementStatus(Mage_Payment_Model_Billing_AgreementAbstract $agreement) - { - $targetStatus = $agreement->getStatus(); - $api = $this->_pro->getApi() - ->setReferenceId($agreement->getReferenceId()) - ->setBillingAgreementStatus($targetStatus); - try { - $api->callUpdateBillingAgreement(); - } catch (Mage_Core_Exception $e) { - // when BA was already canceled, just pretend that the operation succeeded - if (!(Mage_Sales_Model_Billing_Agreement::STATUS_CANCELED == $targetStatus - && $api->getIsBillingAgreementAlreadyCancelled()) - ) { - throw $e; - } - } - return $this; - } - - /** - * Authorize payment - * - * @param float $amount - * @return $this - */ - public function authorize(Varien_Object $payment, $amount) - { - return $this->_placeOrder($payment, $amount); - } - - /** - * Void payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return $this - */ - public function void(Varien_Object $payment) - { - $this->_pro->void($payment); - return $this; - } - - /** - * Capture payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @param float $amount - * @return $this - */ - public function capture(Varien_Object $payment, $amount) - { - if ($this->_pro->capture($payment, $amount) === false) { - $this->_placeOrder($payment, $amount); - } - return $this; - } - - /** - * Refund capture - * - * @param Mage_Sales_Model_Order_Payment $payment - * @param float $amount - * @return $this - */ - public function refund(Varien_Object $payment, $amount) - { - $this->_pro->refund($payment, $amount); - return $this; - } - - /** - * Cancel payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return $this - */ - public function cancel(Varien_Object $payment) - { - $this->_pro->cancel($payment); - return $this; - } - - /** - * Whether payment can be reviewed - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return bool - */ - public function canReviewPayment(Mage_Payment_Model_Info $payment) - { - return parent::canReviewPayment($payment) && $this->_pro->canReviewPayment($payment); - } - - /** - * Attempt to accept a pending payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return bool - */ - public function acceptPayment(Mage_Payment_Model_Info $payment) - { - parent::acceptPayment($payment); - return $this->_pro->reviewPayment($payment, Mage_Paypal_Model_Pro::PAYMENT_REVIEW_ACCEPT); - } - - /** - * Attempt to deny a pending payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return bool - */ - public function denyPayment(Mage_Payment_Model_Info $payment) - { - parent::denyPayment($payment); - return $this->_pro->reviewPayment($payment, Mage_Paypal_Model_Pro::PAYMENT_REVIEW_DENY); - } - - /** - * Fetch transaction details info - * - * @param string $transactionId - * @return array - */ - public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId) - { - return $this->_pro->fetchTransactionInfo($payment, $transactionId); - } - - /** - * Place an order with authorization or capture action - * - * @param float $amount - * @return $this - */ - protected function _placeOrder(Mage_Sales_Model_Order_Payment $payment, $amount) - { - $order = $payment->getOrder(); - $billingAgreement = Mage::getModel('sales/billing_agreement')->load( - $payment->getAdditionalInformation( - Mage_Sales_Model_Payment_Method_Billing_AgreementAbstract::TRANSPORT_BILLING_AGREEMENT_ID, - ), - ); - - $proConfig = $this->_pro->getConfig(); - $api = $this->_pro->getApi() - ->setReferenceId($billingAgreement->getReferenceId()) - ->setPaymentAction($proConfig->paymentAction) - ->setAmount($amount) - ->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode()) - ->setNotifyUrl(Mage::getUrl('paypal/ipn/')) - ->setPaypalCart(Mage::getModel('paypal/cart', [$order])) - ->setIsLineItemsEnabled($proConfig->lineItemsEnabled) - ->setInvNum($order->getIncrementId()) - ; - - // call api and import transaction and other payment information - $api->callDoReferenceTransaction(); - $this->_pro->importPaymentInfo($api, $payment); - $api->callGetTransactionDetails(); - $this->_pro->importPaymentInfo($api, $payment); - - $payment->setTransactionId($api->getTransactionId()) - ->setIsTransactionClosed(0); - - if ($api->getBillingAgreementId()) { - $order->addRelatedObject($billingAgreement); - $billingAgreement->setIsObjectChanged(true); - $billingAgreement->addOrderRelation($order); - } - - return $this; - } - - protected function _isAvailable($quote) - { - return $this->_pro->getConfig()->isMethodAvailable($this->_code); - } - - /** - * Payment action getter compatible with payment model - * - * @see Mage_Sales_Model_Payment::place() - * @return string - */ - public function getConfigPaymentAction() - { - return $this->_pro->getConfig()->getPaymentAction(); - } -} diff --git a/app/code/core/Mage/Paypal/Model/Mysql4/Cert.php b/app/code/core/Mage/Paypal/Model/Mysql4/Cert.php deleted file mode 100644 index e3d8791a3f4..00000000000 --- a/app/code/core/Mage/Paypal/Model/Mysql4/Cert.php +++ /dev/null @@ -1,16 +0,0 @@ -getSftpCredentials(true); - foreach ($credentials as $config) { - try { - $reports->fetchAndSave($config); - } catch (Exception $e) { - Mage::logException($e); - } - } - } catch (Exception $e) { - Mage::logException($e); - } - } - - /** - * Clean unfinished transaction - * - * @deprecated since 1.6.2.0 - * @return $this - */ - public function cleanTransactions() - { - return $this; - } - - /** - * Save order into registry to use it in the overloaded controller. - * - * @return $this - */ - public function saveOrderAfterSubmit(Varien_Event_Observer $observer) - { - /** @var Mage_Sales_Model_Order $order */ - $order = $observer->getEvent()->getData('order'); - Mage::register('hss_order', $order, true); - - return $this; - } - - /** - * Set data for response of frontend saveOrder action - * - * @return $this - */ - public function setResponseAfterSaveOrder(Varien_Event_Observer $observer) - { - /** @var Mage_Sales_Model_Order $order */ - $order = Mage::registry('hss_order'); - - if ($order && $order->getId()) { - $payment = $order->getPayment(); - if ($payment && in_array($payment->getMethod(), Mage::helper('paypal/hss')->getHssMethods())) { - /** @var Mage_Core_Controller_Varien_Action $controller */ - $controller = $observer->getEvent()->getData('controller_action'); - $result = Mage::helper('core')->jsonDecode( - $controller->getResponse()->getBody('default'), - Zend_Json::TYPE_ARRAY, - ); - - if (empty($result['error'])) { - $controller->loadLayout('checkout_onepage_review'); - $html = $controller->getLayout()->getBlock('paypal.iframe')->toHtml(); - $result['update_section'] = [ - 'name' => 'paypaliframe', - 'html' => $html, - ]; - $result['redirect'] = false; - $result['success'] = false; - $controller->getResponse()->clearHeader('Location'); - $controller->getResponse()->setBody(Mage::helper('core')->jsonEncode($result)); - } - } - } - - return $this; - } - - /** - * Load country dependent PayPal solutions system configuration - */ - public function loadCountryDependentSolutionsConfig(Varien_Event_Observer $observer) - { - $countryCode = Mage::helper('paypal')->getConfigurationCountryCode(); - $paymentGroups = $observer->getEvent()->getConfig()->getNode('sections/payment/groups'); - $paymentsConfigs = $paymentGroups->xpath('paypal_payments/*/backend_config/' . $countryCode); - if ($paymentsConfigs) { - foreach ($paymentsConfigs as $config) { - $parent = $config->getParent()->getParent(); - $parent->extend($config, true); - } - } - - $payments = $paymentGroups->xpath('paypal_payments/*'); - foreach ($payments as $payment) { - if ((int) $payment->include) { - $fields = $paymentGroups->xpath((string) $payment->group . '/fields'); - if (isset($fields[0])) { - $fields[0]->appendChild($payment, true); - } - } - } - } - - /** - * Update transaction with HTML representation of txn_id - */ - public function observeHtmlTransactionId(Varien_Event_Observer $observer) - { - /** @var Varien_Object $transaction */ - $transaction = $observer->getEvent()->getTransaction(); - $transaction->setHtmlTxnId(Mage::helper('paypal')->getHtmlTransactionId( - $observer->getEvent()->getPayment()->getMethodInstance()->getCode(), - $transaction->getTxnId(), - )); - } -} diff --git a/app/code/core/Mage/Paypal/Model/Payflow/Request.php b/app/code/core/Mage/Paypal/Model/Payflow/Request.php deleted file mode 100644 index d5641a90836..00000000000 --- a/app/code/core/Mage/Paypal/Model/Payflow/Request.php +++ /dev/null @@ -1,47 +0,0 @@ -_underscore(substr($method, 3)); - if (isset($args[0]) && (strstr($args[0], '=') || strstr($args[0], '&'))) { - $key .= '[' . strlen($args[0]) . ']'; - } - switch (substr($method, 0, 3)) { - case 'get': - return $this->getData($key, $args[0] ?? null); - - case 'set': - return $this->setData($key, $args[0] ?? null); - - case 'uns': - return $this->unsetData($key); - - case 'has': - return isset($this->_data[$key]); - } - throw new Varien_Exception('Invalid method ' . get_class($this) . '::' . $method . '(' . print_r($args, true) . ')'); - } -} diff --git a/app/code/core/Mage/Paypal/Model/Payflowadvanced.php b/app/code/core/Mage/Paypal/Model/Payflowadvanced.php deleted file mode 100644 index eee6adee684..00000000000 --- a/app/code/core/Mage/Paypal/Model/Payflowadvanced.php +++ /dev/null @@ -1,44 +0,0 @@ - 'billtofirstname', - 'lastname' => 'billtolastname', - 'address' => 'billtostreet', - 'city' => 'billtocity', - 'state' => 'billtostate', - 'zip' => 'billtozip', - 'country' => 'billtocountry', - 'phone' => 'billtophone', - 'email' => 'billtoemail', - 'nametoship' => 'shiptofirstname', - 'addresstoship' => 'shiptostreet', - 'citytoship' => 'shiptocity', - 'statetoship' => 'shiptostate', - 'ziptoship' => 'shiptozip', - 'countrytoship' => 'shiptocountry', - 'phonetoship' => 'shiptophone', - 'emailtoship' => 'shiptoemail', - 'faxtoship' => 'shiptofax', - 'method' => 'tender', - 'cscmatch' => 'cvv2match', - 'type' => 'trxtype', - ]; - - /** - * Payment method code - */ - protected $_code = Mage_Paypal_Model_Config::METHOD_PAYFLOWLINK; - - protected $_formBlockType = 'paypal/payflow_link_form'; - protected $_infoBlockType = 'paypal/payflow_link_info'; - - /** - * Availability options - */ - protected $_canUseInternal = false; - protected $_canUseForMultishipping = false; - protected $_isInitializeNeeded = true; - - /** - * Request & response model - * @var Mage_Paypal_Model_Payflow_Request - */ - protected $_response; - - /** - * Gateway request URL - * @var string - */ - public const TRANSACTION_PAYFLOW_URL = 'https://payflowlink.paypal.com/'; - - /** - * Error message - * @var string - */ - public const RESPONSE_ERROR_MSG = 'Payment error. %s was not found.'; - - /** - * Key for storing secure hash in additional information of payment model - * - * @var string - */ - protected $_secureSilentPostHashKey = 'secure_silent_post_hash'; - - /** - * Do not validate payment form using server methods - * - * @return bool - */ - public function validate() - { - return true; - } - - /** - * Check whether payment method can be used - * - * @param Mage_Sales_Model_Quote|null $quote - * @return bool - */ - public function isAvailable($quote = null) - { - $storeId = Mage::app()->getStore($this->getStore())->getId(); - $config = Mage::getModel('paypal/config')->setStoreId($storeId); - if (Mage_Payment_Model_Method_Abstract::isAvailable($quote) && $config->isMethodAvailable($this->getCode())) { - return true; - } - return false; - } - - /** - * Return iframe template value depending on config - * - * @return string - */ - public function getTemplate() - { - if ($this->getConfigData('mobile_optimized')) { - return self::MOBILE_LAYOUT_TEMPLATE; - } else { - return self::LAYOUT_TEMPLATE; - } - } - - /** - * Instantiate state and set it to state object - * - * @param string $paymentAction - * @param Varien_Object $stateObject - * @return $this - */ - public function initialize($paymentAction, $stateObject) - { - switch ($paymentAction) { - case Mage_Paypal_Model_Config::PAYMENT_ACTION_AUTH: - case Mage_Paypal_Model_Config::PAYMENT_ACTION_SALE: - $payment = $this->getInfoInstance(); - $order = $payment->getOrder(); - $order->setCanSendNewEmailFlag(false); - $payment->setAmountAuthorized($order->getTotalDue()); - $payment->setBaseAmountAuthorized($order->getBaseTotalDue()); - $this->_generateSecureSilentPostHash($payment); - $request = $this->_buildTokenRequest($payment); - $response = $this->_postRequest($request); - $this->_processTokenErrors($response, $payment); - - $order = $payment->getOrder(); - $order->setCanSendNewEmailFlag(false); - - $stateObject->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT); - $stateObject->setStatus('pending_payment'); - $stateObject->setIsNotified(false); - break; - default: - break; - } - return $this; - } - - /** - * Return response model. - * - * @return Mage_Paypal_Model_Payflow_Request - */ - public function getResponse() - { - if (!$this->_response) { - $this->_response = Mage::getModel('paypal/payflow_request'); - } - - return $this->_response; - } - - /** - * Fill response with data. - * - * @return $this - */ - public function setResponseData(array $postData) - { - foreach ($postData as $key => $val) { - $this->getResponse()->setData(strtolower($key), $val); - } - foreach ($this->_responseParamsMappings as $originKey => $key) { - $data = $this->getResponse()->getData($key); - if (isset($data)) { - $this->getResponse()->setData($originKey, $data); - } - } - // process AVS data separately - $avsAddr = $this->getResponse()->getData('avsaddr'); - $avsZip = $this->getResponse()->getData('avszip'); - if (isset($avsAddr) && isset($avsZip)) { - $this->getResponse()->setData('avsdata', $avsAddr . $avsZip); - } - // process Name separately - $firstnameParameter = $this->getResponse()->getData('billtofirstname'); - $lastnameParameter = $this->getResponse()->getData('billtolastname'); - if (isset($firstnameParameter) && isset($lastnameParameter)) { - $this->getResponse()->setData('name', $firstnameParameter . ' ' . $lastnameParameter); - } - - return $this; - } - - /** - * Operate with order using data from $_POST which came from Silent Post Url. - * - * @param array $responseData - * @throws Mage_Core_Exception in case of validation error or order creation error - */ - public function process($responseData) - { - $debugData = [ - 'response' => $responseData, - ]; - $this->_debug($debugData); - - $this->setResponseData($responseData); - $order = $this->_getOrderFromResponse(); - - if ($order) { - $this->_processOrder($order); - } - } - - /** - * Operate with order using information from silent post - */ - protected function _processOrder(Mage_Sales_Model_Order $order) - { - $response = $this->getResponse(); - $payment = $order->getPayment(); - $payment->setTransactionId($response->getPnref()) - ->setIsTransactionClosed(0); - $canSendNewOrderEmail = true; - - if ($response->getResult() == self::RESPONSE_CODE_FRAUDSERVICE_FILTER || - $response->getResult() == self::RESPONSE_CODE_DECLINED_BY_FILTER - ) { - $canSendNewOrderEmail = false; - $fraudMessage = $this->_getFraudMessage() ? - $response->getFraudMessage() : $response->getRespmsg(); - $payment->setIsTransactionPending(true) - ->setIsFraudDetected(true) - ->setAdditionalInformation('paypal_fraud_filters', $fraudMessage); - } - - if ($response->getAvsdata() && strstr(substr($response->getAvsdata(), 0, 2), 'N')) { - $payment->setAdditionalInformation('paypal_avs_code', substr($response->getAvsdata(), 0, 2)); - } - if ($response->getCvv2match() && $response->getCvv2match() != 'Y') { - $payment->setAdditionalInformation('paypal_cvv2_match', $response->getCvv2match()); - } - - switch ($response->getType()) { - case self::TRXTYPE_AUTH_ONLY: - $payment->registerAuthorizationNotification($payment->getBaseAmountAuthorized()); - break; - case self::TRXTYPE_SALE: - $payment->registerCaptureNotification($payment->getBaseAmountAuthorized()); - break; - } - $order->save(); - - try { - if ($canSendNewOrderEmail) { - $order->queueNewOrderEmail(); - } - Mage::getModel('sales/quote') - ->load($order->getQuoteId()) - ->setIsActive(false) - ->save(); - } catch (Exception $e) { - Mage::throwException(Mage::helper('paypal')->__('Can not send new order email.')); - } - } - - /** - * Get fraud message from response - * - * @return string|bool - */ - protected function _getFraudMessage() - { - if ($this->getResponse()->getFpsPrexmldata()) { - $xml = new SimpleXMLElement($this->getResponse()->getFpsPrexmldata()); - $this->getResponse()->setFraudMessage((string) $xml->rule->triggeredMessage); - return $this->getResponse()->getFraudMessage(); - } - - return false; - } - - /** - * Check response from Payflow gateway. - * - * @return false|Mage_Sales_Model_Order in case of validation passed - * @throws Mage_Core_Exception in other cases - */ - protected function _getOrderFromResponse() - { - $response = $this->getResponse(); - - $order = Mage::getModel('sales/order') - ->loadByIncrementId($response->getInvnum()); - - if ($this->_getSecureSilentPostHash($order->getPayment()) != $response->getUser2() - || $this->_code != $order->getPayment()->getMethodInstance()->getCode() - ) { - return false; - } - - if ($response->getResult() != self::RESPONSE_CODE_FRAUDSERVICE_FILTER - && $response->getResult() != self::RESPONSE_CODE_DECLINED_BY_FILTER - && $response->getResult() != self::RESPONSE_CODE_APPROVED - ) { - if ($order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) { - $order->registerCancellation($response->getRespmsg())->save(); - } - Mage::throwException($response->getRespmsg()); - } - - $amountCompared = $response->getAmt() == $order->getPayment()->getBaseAmountAuthorized(); - if (!$order->getId() - || $order->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT - || !$amountCompared - ) { - Mage::throwException($this->_formatStr(self::RESPONSE_ERROR_MSG, 'Order')); - } - - $fetchData = $this->fetchTransactionInfo($order->getPayment(), $response->getPnref()); - if (!isset($fetchData['custref']) || $fetchData['custref'] != $order->getIncrementId()) { - Mage::throwException($this->_formatStr(self::RESPONSE_ERROR_MSG, 'Transaction')); - } - - return $order; - } - - /** - * Build request for getting token - * - * @return Mage_Paypal_Model_Payflow_Request - */ - protected function _buildTokenRequest(Mage_Sales_Model_Order_Payment $payment) - { - $request = $this->_buildBasicRequest($payment); - $request->setCreatesecuretoken('Y') - ->setSecuretokenid($this->_generateSecureTokenId()) - ->setTrxtype($this->_getTrxTokenType()) - ->setAmt($this->_formatStr('%.2F', $payment->getOrder()->getBaseTotalDue())) - ->setCurrency($payment->getOrder()->getBaseCurrencyCode()) - ->setInvnum($payment->getOrder()->getIncrementId()) - ->setCustref($payment->getOrder()->getIncrementId()) - ->setPonum($payment->getOrder()->getId()); - //This is PaPal issue with taxes and shipping - //->setSubtotal($this->_formatStr('%.2F', $payment->getOrder()->getBaseSubtotal())) - //->setTaxamt($this->_formatStr('%.2F', $payment->getOrder()->getBaseTaxAmount())) - //->setFreightamt($this->_formatStr('%.2F', $payment->getOrder()->getBaseShippingAmount())); - - $order = $payment->getOrder(); - if (empty($order)) { - return $request; - } - - $billing = $order->getBillingAddress(); - if (!empty($billing)) { - $request->setFirstname($billing->getFirstname()) - ->setLastname($billing->getLastname()) - ->setStreet(implode(' ', $billing->getStreet())) - ->setCity($billing->getCity()) - ->setState($billing->getRegionCode()) - ->setZip($billing->getPostcode()) - ->setCountry($billing->getCountry()) - ->setEmail($order->getCustomerEmail()); - } - $shipping = $order->getShippingAddress(); - if (!empty($shipping)) { - $this->_applyCountryWorkarounds($shipping); - $request->setShiptofirstname($shipping->getFirstname()) - ->setShiptolastname($shipping->getLastname()) - ->setShiptostreet(implode(' ', $shipping->getStreet())) - ->setShiptocity($shipping->getCity()) - ->setShiptostate($shipping->getRegionCode()) - ->setShiptozip($shipping->getPostcode()) - ->setShiptocountry($shipping->getCountry()); - } - //pass store Id to request - $request->setUser1($order->getStoreId()) - ->setUser2($this->_getSecureSilentPostHash($payment)); - - return $request; - } - - /** - * Get store id from response if exists - * or default - * - * @return int - */ - protected function _getStoreId() - { - $response = $this->getResponse(); - if ($response->getUser1()) { - return (int) $response->getUser1(); - } - - return Mage::app()->getStore($this->getStore())->getId(); - } - - /** - * Return request object with basic information for gateway request - * - * @return Mage_Paypal_Model_Payflow_Request - */ - protected function _buildBasicRequest(Varien_Object $payment) - { - $request = Mage::getModel('paypal/payflow_request'); - $cscEditable = $this->getConfigData('csc_editable'); - $bnCode = Mage::getModel('paypal/config')->getBuildNotationCode(); - $request - ->setUser($this->getConfigData('user', $this->_getStoreId())) - ->setVendor($this->getConfigData('vendor', $this->_getStoreId())) - ->setPartner($this->getConfigData('partner', $this->_getStoreId())) - ->setPwd($this->getConfigData('pwd', $this->_getStoreId())) - ->setVerbosity($this->getConfigData('verbosity', $this->_getStoreId())) - ->setData('BNCODE', $bnCode) - ->setTender(self::TENDER_CC) - ->setCancelurl($this->_getCallbackUrl('cancelPayment')) - ->setErrorurl($this->_getCallbackUrl('returnUrl')) - ->setSilentpost('TRUE') - ->setSilentposturl($this->_getCallbackUrl('silentPost')) - ->setReturnurl($this->_getCallbackUrl('returnUrl')) - ->setTemplate($this->getTemplate()) - ->setDisablereceipt('TRUE') - ->setCscrequired($cscEditable && $this->getConfigData('csc_required') ? 'TRUE' : 'FALSE') - ->setCscedit($cscEditable ? 'TRUE' : 'FALSE') - ->setEmailcustomer($this->getConfigData('email_confirmation') ? 'TRUE' : 'FALSE') - ->setUrlmethod($this->getConfigData('url_method')); - return $request; - } - - /** - * Get payment action code - * - * @return string - */ - protected function _getTrxTokenType() - { - switch ($this->getConfigData('payment_action')) { - case Mage_Paypal_Model_Config::PAYMENT_ACTION_AUTH: - return self::TRXTYPE_AUTH_ONLY; - case Mage_Paypal_Model_Config::PAYMENT_ACTION_SALE: - return self::TRXTYPE_SALE; - } - return ''; - } - - /** - * Return unique value for secure token id - * - * @return string - */ - protected function _generateSecureTokenId() - { - return Mage::helper('core')->uniqHash(); - } - - /** - * Format values - * - * @param mixed $format - * @param mixed $string - * @return string - */ - protected function _formatStr($format, $string) - { - return sprintf($format, $string); - } - - /** - * If response is failed throw exception - * Set token data in payment object - * - * @param Varien_Object $response - * @param Mage_Payment_Model_Info|Mage_Sales_Model_Order_Payment $payment - * @throws Mage_Core_Exception - */ - protected function _processTokenErrors($response, $payment) - { - if (!$response->getSecuretoken() && - $response->getResult() != self::RESPONSE_CODE_APPROVED && - $response->getResult() != self::RESPONSE_CODE_FRAUDSERVICE_FILTER - ) { - Mage::throwException($response->getRespmsg()); - } else { - $payment->setAdditionalInformation('secure_token_id', $response->getSecuretokenid()) - ->setAdditionalInformation('secure_token', $response->getSecuretoken()); - } - } - - /** - * Return secure hash value for silent post request - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return string - */ - protected function _getSecureSilentPostHash($payment) - { - return $payment->getAdditionalInformation($this->_secureSilentPostHashKey); - } - - /** - * Generate end return new secure hash value - * - * @param Mage_Payment_Model_Info $payment - * @return string - */ - protected function _generateSecureSilentPostHash($payment) - { - $secureHash = md5(Mage::helper('core')->getRandomString(10)); - $payment->setAdditionalInformation($this->_secureSilentPostHashKey, $secureHash); - return $secureHash; - } - - /** - * Add transaction with correct transaction Id - * - * @deprecated since 1.6.2.0 - * @param Varien_Object $payment - * @param string $txnId - */ - protected function _addTransaction($payment, $txnId) {} - - /** - * Initialize request - * - * @deprecated since 1.6.2.0 - * @param mixed $amount - * @return $this - */ - protected function _initialize(Varien_Object $payment, $amount) - { - return $this; - } - - /** - * Check whether order review has enough data to initialize - * - * @deprecated since 1.6.2.0 - * @param string $token - */ - public function prepareOrderReview($token = null) {} - - /** - * Additional authorization logic for Account Verification - * - * @deprecated since 1.6.2.0 - * @param mixed $amount - * @param Mage_Paypal_Model_Payment_Transaction $transaction - * @param string $txnId - * @return $this - */ - protected function _authorize(Varien_Object $payment, $amount, $transaction, $txnId) - { - return $this; - } - - /** - * Operate with order or quote using information from silent post - * - * @deprecated since 1.6.2.0 - */ - protected function _process(Varien_Object $document) {} - - /** - * Check Transaction - * - * @deprecated since 1.6.2.0 - * @param Mage_Paypal_Model_Payment_Transaction $transaction - * @param mixed $amount - * @return $this - */ - protected function _checkTransaction($transaction, $amount) - { - return $this; - } - - /** - * Check response from Payflow gateway. - * - * @deprecated since 1.6.2.0 - * @return null - */ - protected function _getDocumentFromResponse() - { - return null; - } - - /** - * Get callback controller - * - * @return string - */ - public function getCallbackController() - { - return $this->_callbackController; - } - - /** - * Get callback url - * - * @param string $actionName - * @return string - */ - protected function _getCallbackUrl($actionName) - { - $request = Mage::app()->getRequest(); - if ($request->getParam('website')) { - $website = Mage::getModel('core/website')->load($request->getParam('website')); - $secure = Mage::getStoreConfigFlag( - Mage_Core_Model_Url::XML_PATH_SECURE_IN_FRONT, - $website->getDefaultStore(), - ); - $path = $secure - ? Mage_Core_Model_Store::XML_PATH_SECURE_BASE_LINK_URL - : Mage_Core_Model_Store::XML_PATH_UNSECURE_BASE_LINK_URL; - $websiteUrl = Mage::getStoreConfig($path, $website->getDefaultStore()); - } else { - $secure = Mage::getStoreConfigFlag(Mage_Core_Model_Url::XML_PATH_SECURE_IN_FRONT); - $websiteUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK, $secure); - } - - return $websiteUrl . 'paypal/' . $this->getCallbackController() . '/' . $actionName; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Payflowpro.php b/app/code/core/Mage/Paypal/Model/Payflowpro.php deleted file mode 100644 index 5a1e7432f96..00000000000 --- a/app/code/core/Mage/Paypal/Model/Payflowpro.php +++ /dev/null @@ -1,552 +0,0 @@ - 'MPIVENDOR3DS', - 'centinel_authstatus' => 'AUTHSTATUS3DS', - 'centinel_cavv' => 'CAVV', - 'centinel_eci' => 'ECI', - 'centinel_xid' => 'XID', - ]; - - /** - * Check whether payment method can be used - * - * @param Mage_Sales_Model_Quote|null $quote - * @return bool - */ - public function isAvailable($quote = null) - { - $storeId = Mage::app()->getStore($this->getStore())->getId(); - $config = Mage::getModel('paypal/config')->setStoreId($storeId); - if (parent::isAvailable($quote) && $config->isMethodAvailable($this->getCode())) { - return true; - } - return false; - } - - /** - * Payment action getter compatible with payment model - * - * @see Mage_Sales_Model_Payment::place() - * @return string - */ - public function getConfigPaymentAction() - { - switch ($this->getConfigData('payment_action')) { - case Mage_Paypal_Model_Config::PAYMENT_ACTION_AUTH: - return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE; - case Mage_Paypal_Model_Config::PAYMENT_ACTION_SALE: - return Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE; - } - return ''; - } - - /** - * Authorize payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return $this - */ - public function authorize(Varien_Object $payment, $amount) - { - $request = $this->_buildPlaceRequest($payment, $amount); - $request->setTrxtype(self::TRXTYPE_AUTH_ONLY); - $this->_setReferenceTransaction($payment, $request); - $response = $this->_postRequest($request); - $this->_processErrors($response); - - switch ($response->getResultCode()) { - case self::RESPONSE_CODE_APPROVED: - $payment->setTransactionId($response->getPnref())->setIsTransactionClosed(0); - break; - case self::RESPONSE_CODE_FRAUDSERVICE_FILTER: - $payment->setTransactionId($response->getPnref())->setIsTransactionClosed(0); - $payment->setIsTransactionPending(true); - $payment->setIsFraudDetected(true); - break; - } - return $this; - } - - /** - * Get capture amount - * - * @param float $amount - * @return float - */ - protected function _getCaptureAmount($amount) - { - $infoInstance = $this->getInfoInstance(); - $amountToPay = round($amount, 2); - $authorizedAmount = round($infoInstance->getAmountAuthorized(), 2); - return $amountToPay != $authorizedAmount ? $amountToPay : 0; - } - - /** - * Capture payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return $this - */ - public function capture(Varien_Object $payment, $amount) - { - if ($payment->getReferenceTransactionId()) { - $request = $this->_buildPlaceRequest($payment, $amount); - $request->setTrxtype(self::TRXTYPE_SALE); - $request->setOrigid($payment->getReferenceTransactionId()); - } elseif ($payment->getParentTransactionId()) { - $request = $this->_buildBasicRequest($payment); - $request->setOrigid($payment->getParentTransactionId()); - $captureAmount = $this->_getCaptureAmount($amount); - if ($captureAmount) { - $request->setAmt($captureAmount); - } - $trxType = $this->getInfoInstance()->hasAmountPaid() ? self::TRXTYPE_SALE : self::TRXTYPE_DELAYED_CAPTURE; - $request->setTrxtype($trxType); - } else { - $request = $this->_buildPlaceRequest($payment, $amount); - $request->setTrxtype(self::TRXTYPE_SALE); - } - - $response = $this->_postRequest($request); - $this->_processErrors($response); - - switch ($response->getResultCode()) { - case self::RESPONSE_CODE_APPROVED: - $payment->setTransactionId($response->getPnref())->setIsTransactionClosed(0); - break; - case self::RESPONSE_CODE_FRAUDSERVICE_FILTER: - $payment->setTransactionId($response->getPnref())->setIsTransactionClosed(0); - $payment->setIsTransactionPending(true); - $payment->setIsFraudDetected(true); - break; - } - return $this; - } - - /** - * Void payment - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return $this - */ - public function void(Varien_Object $payment) - { - $request = $this->_buildBasicRequest($payment); - $request->setTrxtype(self::TRXTYPE_DELAYED_VOID); - $request->setOrigid($payment->getParentTransactionId()); - $response = $this->_postRequest($request); - $this->_processErrors($response); - - if ($response->getResultCode() == self::RESPONSE_CODE_APPROVED) { - $payment->setTransactionId($response->getPnref()) - ->setIsTransactionClosed(1) - ->setShouldCloseParentTransaction(1); - } - - return $this; - } - - /** - * Check void availability - * - * @return bool - */ - public function canVoid(Varien_Object $payment) - { - if ($payment instanceof Mage_Sales_Model_Order_Invoice - || $payment instanceof Mage_Sales_Model_Order_Creditmemo - ) { - return false; - } - if ($payment->getAmountPaid()) { - $this->_canVoid = false; - } - - return $this->_canVoid; - } - - /** - * Attempt to void the authorization on cancelling - * - * @return $this|false - */ - public function cancel(Varien_Object $payment) - { - if (!$payment->getOrder()->getInvoiceCollection()->count()) { - return $this->void($payment); - } - - return false; - } - - /** - * Refund capture - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return $this - */ - public function refund(Varien_Object $payment, $amount) - { - $request = $this->_buildBasicRequest($payment); - $request->setTrxtype(self::TRXTYPE_CREDIT); - $request->setOrigid($payment->getParentTransactionId()); - $request->setAmt(round((float) $amount, 2)); - $response = $this->_postRequest($request); - $this->_processErrors($response); - - if ($response->getResultCode() == self::RESPONSE_CODE_APPROVED) { - $payment->setTransactionId($response->getPnref()) - ->setIsTransactionClosed(1); - $payment->setShouldCloseParentTransaction(!$payment->getCreditmemo()->getInvoice()->canRefund()); - } - return $this; - } - - /** - * Fetch transaction details info - * - * @param string $transactionId - * @return array - */ - public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId) - { - $request = $this->_buildBasicRequest($payment); - $request->setTrxtype(self::TRXTYPE_DELAYED_INQUIRY); - $request->setOrigid($transactionId); - $response = $this->_postRequest($request); - - $this->_processErrors($response); - - if (!self::_isTransactionUnderReview($response->getOrigresult())) { - $payment->setTransactionId($response->getOrigpnref()) - ->setIsTransactionClosed(0); - if ($response->getOrigresult() == self::RESPONSE_CODE_APPROVED) { - $payment->setIsTransactionApproved(true); - } elseif ($response->getOrigresult() == self::RESPONSE_CODE_DECLINED_BY_MERCHANT) { - $payment->setIsTransactionDenied(true); - } - } - - $rawData = $response->getData(); - return ($rawData) ? $rawData : []; - } - - /** - * Check whether the transaction is in payment review status - * - * @param string $status - * @return bool - */ - protected static function _isTransactionUnderReview($status) - { - if (in_array($status, [self::RESPONSE_CODE_APPROVED, self::RESPONSE_CODE_DECLINED_BY_MERCHANT])) { - return false; - } - return true; - } - - /** - * Getter for URL to perform Payflow requests, based on test mode by default - * - * @param bool $testMode Ability to specify test mode using - * @return string - */ - protected function _getTransactionUrl($testMode = null) - { - $testMode = is_null($testMode) ? $this->getConfigData('sandbox_flag') : (bool) $testMode; - if ($testMode) { - return self::TRANSACTION_URL_TEST_MODE; - } - return self::TRANSACTION_URL; - } - - /** - * Post request to gateway and return response - * - * @return Varien_Object - */ - protected function _postRequest(Varien_Object $request) - { - $debugData = ['request' => $request->getData()]; - - $client = new Varien_Http_Client(); - $result = new Varien_Object(); - - $_config = [ - 'maxredirects' => 5, - 'timeout' => 30, - 'verifypeer' => $this->getConfigData('verify_peer'), - ]; - - //checking proxy - $_isProxy = $this->getConfigData('use_proxy', false); - if ($_isProxy) { - $_config['proxy'] = $this->getConfigData('proxy_host') - . ':' - . $this->getConfigData('proxy_port');//http://proxy.shr.secureserver.net:3128', - $_config['httpproxytunnel'] = true; - $_config['proxytype'] = CURLPROXY_HTTP; - } - - $client->setUri($this->_getTransactionUrl()) - ->setConfig($_config) - ->setMethod(Zend_Http_Client::POST) - ->setParameterPost($request->getData()) - ->setHeaders('X-VPS-VIT-CLIENT-CERTIFICATION-ID: 33baf5893fc2123d8b191d2d011b7fdc') - ->setHeaders('X-VPS-Request-ID: ' . $request->getRequestId()) - ->setHeaders('X-VPS-CLIENT-TIMEOUT: ' . $this->_clientTimeout); - - try { - /** - * we are sending request to payflow pro without url encoding - * so we set up _urlEncodeBody flag to false - */ - $response = $client->setUrlEncodeBody(false)->request(); - } catch (Exception $e) { - $result->setResponseCode(-1) - ->setResponseReasonCode($e->getCode()) - ->setResponseReasonText($e->getMessage()); - - $debugData['result'] = $result->getData(); - $this->_debug($debugData); - throw $e; - } - - $response = strstr($response->getBody(), 'RESULT'); - $valArray = explode('&', $response); - - foreach ($valArray as $val) { - $valArray2 = explode('=', $val); - $result->setData(strtolower($valArray2[0]), $valArray2[1]); - } - - $result->setResultCode($result->getResult()) - ->setRespmsg($result->getRespmsg()); - - $debugData['result'] = $result->getData(); - $this->_debug($debugData); - - return $result; - } - - /** - * Return request object with information for 'authorization' or 'sale' action - * - * @param Mage_Sales_Model_Order_Payment $payment - * @param float $amount - * @return Varien_Object - */ - protected function _buildPlaceRequest(Varien_Object $payment, $amount) - { - $request = $this->_buildBasicRequest($payment); - $request->setAmt(round($amount, 2)); - $request->setAcct($payment->getCcNumber()); - $request->setExpdate(sprintf('%02d', $payment->getCcExpMonth()) . substr($payment->getCcExpYear(), -2, 2)); - $request->setCvv2($payment->getCcCid()); - - if ($this->getIsCentinelValidationEnabled()) { - $params = []; - $params = $this->getCentinelValidator()->exportCmpiData($params); - /** @var Varien_Object $request */ - $request = Varien_Object_Mapper::accumulateByMap($params, $request, $this->_centinelFieldMap); - } - - $order = $payment->getOrder(); - if (!empty($order)) { - $orderIncrementId = $order->getIncrementId(); - - $request->setCurrency($order->getBaseCurrencyCode()) - ->setInvnum($orderIncrementId) - ->setPonum($order->getId()) - ->setComment1($orderIncrementId); - - $customerId = $order->getCustomerId(); - if ($customerId) { - $request->setCustref($customerId); - } - - $billing = $order->getBillingAddress(); - if (!empty($billing)) { - $request->setFirstname($billing->getFirstname()) - ->setLastname($billing->getLastname()) - ->setStreet(implode(' ', $billing->getStreet())) - ->setCity($billing->getCity()) - ->setState($billing->getRegionCode()) - ->setZip($billing->getPostcode()) - ->setCountry($billing->getCountry()) - ->setEmail($payment->getOrder()->getCustomerEmail()); - } - $shipping = $order->getShippingAddress(); - if (!empty($shipping)) { - $this->_applyCountryWorkarounds($shipping); - $request->setShiptofirstname($shipping->getFirstname()) - ->setShiptolastname($shipping->getLastname()) - ->setShiptostreet(implode(' ', $shipping->getStreet())) - ->setShiptocity($shipping->getCity()) - ->setShiptostate($shipping->getRegionCode()) - ->setShiptozip($shipping->getPostcode()) - ->setShiptocountry($shipping->getCountry()); - } - } - return $request; - } - - /** - * Return request object with basic information for gateway request - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return Varien_Object - */ - protected function _buildBasicRequest(Varien_Object $payment) - { - $request = new Varien_Object(); - $bnCode = Mage::getModel('paypal/config')->getBuildNotationCode(); - $request - ->setUser($this->getConfigData('user')) - ->setVendor($this->getConfigData('vendor')) - ->setPartner($this->getConfigData('partner')) - ->setPwd($this->getConfigData('pwd')) - ->setVerbosity($this->getConfigData('verbosity')) - ->setData('BNCODE', $bnCode) - ->setTender(self::TENDER_CC) - ->setRequestId($this->_generateRequestId()); - return $request; - } - - /** - * Return unique value for request - * - * @return string - */ - protected function _generateRequestId() - { - return Mage::helper('core')->uniqHash(); - } - - /** - * If response is failed throw exception - * - * @throws Mage_Core_Exception - */ - protected function _processErrors(Varien_Object $response) - { - if ($response->getResultCode() == self::RESPONSE_CODE_VOID_ERROR) { - throw new Mage_Paypal_Exception(Mage::helper('paypal')->__('You cannot void a verification transaction')); - } elseif ($response->getResultCode() != self::RESPONSE_CODE_APPROVED - && $response->getResultCode() != self::RESPONSE_CODE_FRAUDSERVICE_FILTER - ) { - Mage::throwException($response->getRespmsg()); - } - } - - /** - * Adopt specified address object to be compatible with Paypal - * Puerto Rico should be as state of USA and not as a country - */ - protected function _applyCountryWorkarounds(Varien_Object $address) - { - if ($address->getCountry() == 'PR') { - $address->setCountry('US'); - $address->setRegionCode('PR'); - } - } - - /** - * Set reference transaction data into request - * - * @param Varien_Object $request - * @return $this - */ - protected function _setReferenceTransaction(Varien_Object $payment, $request) - { - return $this; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Payment/Transaction.php b/app/code/core/Mage/Paypal/Model/Payment/Transaction.php deleted file mode 100644 index 390329b61ec..00000000000 --- a/app/code/core/Mage/Paypal/Model/Payment/Transaction.php +++ /dev/null @@ -1,219 +0,0 @@ -_init('paypal/payment_transaction'); - parent::_construct(); - } - - /** - * Transaction ID setter - * @param string $txnId - * @return $this - */ - public function setTxnId($txnId) - { - $this->_verifyTxnId($txnId); - return $this->setData('txn_id', $txnId); - } - - /** - * Check object before loading by by specified transaction ID - * @param string $txnId - * @return $this - */ - protected function _beforeLoadByTxnId($txnId) - { - Mage::dispatchEvent( - $this->_eventPrefix . '_load_by_txn_id_before', - $this->_getEventData() + ['txn_id' => $txnId], - ); - return $this; - } - - /** - * Load self by specified transaction ID. Requires the valid payment object to be set - * @param string $txnId - * @return $this - */ - public function loadByTxnId($txnId) - { - $this->_beforeLoadByTxnId($txnId); - $this->getResource()->loadObjectByTxnId( - $this, - $txnId, - ); - $this->_afterLoadByTxnId(); - return $this; - } - - /** - * Check object after loading by by specified transaction ID - * - * @return $this - */ - protected function _afterLoadByTxnId() - { - Mage::dispatchEvent($this->_eventPrefix . '_load_by_txn_id_after', $this->_getEventData()); - return $this; - } - - /** - * Additional information setter - * Updates data inside the 'additional_information' array - * Doesn't allow to set arrays - * - * @param string $key - * @param mixed $value - * @return $this - * @throws Mage_Core_Exception - */ - public function setAdditionalInformation($key, $value) - { - if (is_object($value)) { - Mage::throwException(Mage::helper('paypal')->__('Payment transactions disallow storing objects.')); - } - $info = $this->_getData('additional_information'); - if (!$info) { - $info = []; - } - $info[$key] = $value; - return $this->setData('additional_information', $info); - } - - /** - * Getter for entire additional_information value or one of its element by key - * @param string $key - * @return array|null|mixed - */ - public function getAdditionalInformation($key = null) - { - $info = $this->_getData('additional_information'); - if (!$info) { - $info = []; - } - if ($key) { - return $info[$key] ?? null; - } - return $info; - } - - /** - * Unsetter for entire additional_information value or one of its element by key - * @param string $key - * @return $this - */ - public function unsAdditionalInformation($key = null) - { - if ($key) { - $info = $this->_getData('additional_information'); - if (is_array($info)) { - unset($info[$key]); - } - } else { - $info = []; - } - return $this->setData('additional_information', $info); - } - - /** - * Setter/Getter whether transaction is supposed to prevent exceptions on saving - * - * @param bool|null $setFailsafe - * @return bool|$this - */ - public function isFailsafe($setFailsafe = null) - { - if ($setFailsafe === null) { - return $this->_isFailsafe; - } - $this->_isFailsafe = (bool) $setFailsafe; - return $this; - } - - /** - * Verify data required for saving - * @return $this - */ - protected function _beforeSave() - { - if (!$this->getId()) { - $this->setCreatedAt(Mage::getModel('core/date')->gmtDate()); - } - return parent::_beforeSave(); - } - - /** - * Check whether specified transaction ID is valid - * @param string $txnId - * @throws Mage_Core_Exception - */ - protected function _verifyTxnId($txnId) - { - if ($txnId !== null && strlen($txnId) == 0) { - Mage::throwException(Mage::helper('paypal')->__('Transaction ID must not be empty.')); - } - } - - /** - * Make sure this object is a valid transaction - * TODO for more restriction we can check for data consistency - * @throws Mage_Core_Exception - */ - protected function _verifyThisTransactionExists() - { - if (!$this->getId()) { - Mage::throwException(Mage::helper('paypal')->__('This operation requires an existing transaction object.')); - } - } -} diff --git a/app/code/core/Mage/Paypal/Model/Paypal.php b/app/code/core/Mage/Paypal/Model/Paypal.php new file mode 100644 index 00000000000..9927efcd89d --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Paypal.php @@ -0,0 +1,920 @@ +_validateQuoteForPayment($quote); + + $quote->reserveOrderId()->save(); + $api = $this->_getApi(); + $orderRequest = $this->_buildOrderRequest($quote, $quote->getReservedOrderId()); + + $response = $api->createOrder($quote, $orderRequest); + $result = $response->getResult(); + + if ($response->isError()) { + throw new Mage_Core_Exception($result['message'] ?? 'Error creating PayPal order'); + } + + $this->_updatePaymentWithOrderInfo($quote->getPayment(), $response); + + return [ + 'success' => true, + 'id' => $result->getId(), + ]; + } catch (Exception $e) { + Mage::logException($e); + return [ + 'success' => false, + 'error' => $e->getMessage() + ]; + } + } + + /** + * Capture PayPal payment via API + * + * @param string $orderId PayPal order ID + * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote + * @throws Mage_Core_Exception + */ + public function captureOrder(string $orderId, Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote): void + { + $api = $this->_getApi(); + $response = $api->captureOrder($orderId, $quote); + $result = $response->getResult(); + + if ($response->isError()) { + $this->_handleApiError($response, 'Capture failed'); + } + $captureId = $this->_extractCaptureId($result); + $this->_updatePaymentAfterCapture($quote->getPayment(), $response, $captureId); + $quote->collectTotals()->save(); + } + + /** + * Authorize PayPal payment via API + * + * @param string $orderId PayPal order ID + * @param Mage_Sales_Model_Quote $quote + * @throws Mage_Core_Exception + */ + public function authorizePayment(string $orderId, Mage_Sales_Model_Quote $quote): void + { + $api = $this->_getApi(); + $response = $api->authorizeOrder($orderId, $quote); + $result = $response->getResult(); + + if ($response->isError()) { + $this->_handleApiError($response, 'Authorization failed'); + } + + $this->_updatePaymentAfterAuthorization($quote->getPayment(), $response); + $quote->collectTotals()->save(); + + $authorization = $result->getPurchaseUnits()[0]->getPayments()->getAuthorizations()[0]; + $this->_addOrderComment($quote, 'authorized', $authorization->getId()); + } + + /** + * Reauthorize a payment after the initial authorization has expired + * + * @param string $orderId PayPal order ID + * @param Mage_Sales_Model_Order $order Magento order + * @return array{success: bool, authorization_id?: string, error?: string} + */ + public function reauthorizePayment(string $orderId, Mage_Sales_Model_Order $order): array + { + try { + $api = $this->_getApi(); + $response = $api->reAuthorizeOrder($orderId, $order); + $result = $response->getResult(); + + if ($response->isError()) { + $this->_handleApiError($response, 'Reauthorization failed'); + } + + $authorization = $result->getPurchaseUnits()[0]->getPayments()->getAuthorizations()[0]; + $authorizationId = $authorization->getId(); + $expirationTime = $authorization->getExpirationTime(); + + $payment = $order->getPayment(); + $payment->setAdditionalInformation([ + self::PAYPAL_PAYMENT_STATUS => $authorization->getStatus(), + self::PAYPAL_PAYMENT_AUTHORIZATION_ID => $authorizationId, + self::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME => $expirationTime, + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->_prepareRawDetails($response->getBody()) + ])->getShouldCloseParentTransaction(); + $payment->save(); + + $transaction = Mage::getModel('sales/order_payment_transaction'); + $transaction->setOrderPaymentObject($payment) + ->setTxnId($authorizationId) + ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH) + ->setIsClosed(0) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->_prepareRawDetails($response->getBody()) + ); + $transaction->save(); + + $storeTimezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE); + $date = new DateTime($expirationTime, new DateTimeZone('UTC')); + $date->setTimezone(new DateTimeZone($storeTimezone)); + + $order->addStatusHistoryComment( + Mage::helper('paypal')->__( + 'PayPal payment has been reauthorized. New authorization ID: %s. Expires on: %s', + $authorizationId, + $date->format('Y-m-d H:i:s') + ), + false + )->save(); + + return [ + 'success' => true, + 'authorization_id' => $authorizationId + ]; + } catch (Exception $e) { + Mage::logException($e); + return [ + 'success' => false, + 'error' => $e->getMessage() + ]; + } + } + + /** + * Validate payment method information object + */ + public function validate(): static + { + parent::validate(); + return $this; + } + + /** + * Refund payment method + * + * @param Varien_Object $payment Payment object + * @param float $amount Refund amount + * @return static + * @throws Mage_Core_Exception + */ + public function refund(Varien_Object $payment, $amount): static + { + try { + if (is_string($amount)) { + $amount = (float)$amount; + } + $response = $this->_getApi()->refundCapturedPayment( + $payment->getParentTransactionId(), + $amount, + $payment->getOrder()->getOrderCurrencyCode(), + $payment->getOrder() + ); + + if ($response->isError()) { + throw new Mage_Core_Exception($response->getResult()->getMessage()); + } + + $result = $response->getResult(); + $this->_updatePaymentAfterRefund($payment, $result); + $this->_createRefundTransaction($payment, $response, $amount); + } catch (Exception $e) { + Mage::logException($e); + throw new Mage_Core_Exception( + Mage::helper('paypal')->__('Refund error: %s', $e->getMessage()) + ); + } + + return $this; + } + + /** + * Capture payment method + * + * @param Varien_Object $payment Payment object + * @param float $amount Capture amount + * @return static + * @throws Mage_Core_Exception + */ + public function capture(Varien_Object $payment, $amount): static + { + $addInfo = $payment->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS); + if (is_array($addInfo) && isset($addInfo['intent'])) { + if ($addInfo['intent'] === CheckoutPaymentIntent::CAPTURE) { + return $this; + } + } + $order = $payment->getOrder(); + $authorizationId = $payment->getAdditionalInformation(self::PAYPAL_PAYMENT_AUTHORIZATION_ID); + + if (!$authorizationId) { + throw new Mage_Core_Exception( + Mage::helper('paypal')->__(self::ERROR_NO_AUTHORIZATION_ID) + ); + } + + $api = $this->_getApi(); + $response = $api->captureAuthorizedPayment($authorizationId, $order); + + if ($response->isError()) { + $this->_handleApiError($response, 'Capture failed'); + } + + $this->_updatePaymentAfterAuthorizedCapture($payment, $response, $authorizationId); + $this->_createCaptureTransaction($payment, $response, $authorizationId); + + return $this; + } + + /** + * Void payment method + * + * @param Varien_Object $payment Payment object + * @return static + * @throws Mage_Core_Exception + */ + public function void(Varien_Object $payment): static + { + // PayPal will handle void transaction + $transactionId = str_contains($payment->getTransactionId(), '-void') + ? str_replace('-void', '', $payment->getTransactionId()) + : $payment->getTransactionId(); + + try { + $response = $this->_getApi()->voidPayment($transactionId, $payment->getOrder()); + + if ($response->isError()) { + throw new Mage_Core_Exception($response->getResult()->getMessage()); + } + + $this->_updatePaymentAfterVoid($payment); + $this->_createVoidTransaction($payment, $response); + $payment->getOrder()->addStatusHistoryComment( + Mage::helper('paypal')->__('PayPal payment voided successfully. Transaction ID: %s', $transactionId), + false + )->save(); + } catch (Exception $e) { + Mage::logException($e); + throw new Mage_Core_Exception( + Mage::helper('paypal')->__('Void error: %s', $e->getMessage()) + ); + } + + return $this; + } + + /** + * Cancel payment method + * + * @param Varien_Object $payment Payment object + * @return static + * @throws Mage_Core_Exception + */ + public function cancel(Varien_Object $payment): static + { + if ($payment->getIsTransactionClosed() && $payment->getShouldCloseParentTransaction()) { + return $this; + } + $this->void($payment); + return $this; + } + + /** + * Check if payment method is available + * + * @param Mage_Sales_Model_Quote|null $quote + * @return bool + */ + public function isAvailable($quote = null): bool + { + if (!$this->getConfigData('client_id') || !$this->getConfigData('client_secret')) { + return false; + } + + $this->_handleMultishippingNotification($quote); + + return parent::isAvailable($quote); + } + + /** + * Get PayPal API instance + */ + private function _getApi(): Mage_Paypal_Model_Api + { + return Mage::getSingleton('paypal/api'); + } + + /** + * Handle API error response + * + * @param ApiResponse $response API response + * @param string $defaultMessage Default error message + * @throws Mage_Core_Exception + */ + private function _handleApiError(ApiResponse $response, string $defaultMessage): never + { + $errorMsg = $this->_extractErrorMessage($response, $defaultMessage); + throw new Mage_Core_Exception($errorMsg); + } + + /** + * Get current quote + */ + private function _getQuote(): Mage_Sales_Model_Quote + { + return Mage::getSingleton('checkout/session')->getQuote(); + } + + /** + * Validate quote for PayPal payment processing + * + * @param Mage_Sales_Model_Quote $quote + * @throws Mage_Core_Exception + */ + private function _validateQuoteForPayment(Mage_Sales_Model_Quote $quote): void + { + $quote->collectTotals(); + + if (!$quote->getGrandTotal() && !$quote->hasNominalItems()) { + throw new Mage_Core_Exception( + Mage::helper('paypal')->__(self::ERROR_ZERO_AMOUNT) + ); + } + } + + /** + * Update payment object with PayPal order information + * + * @param Mage_Sales_Model_Quote_Payment $payment + * @param ApiResponse $response + */ + private function _updatePaymentWithOrderInfo(Mage_Sales_Model_Quote_Payment $payment, ApiResponse $response): void + { + $result = $response->getResult(); + $payment->setPaypalCorrelationId($result->getId()) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->_prepareRawDetails($response->getBody()) + ) + ->save(); + } + + /** + * Build a purchase unit using PayPal SDK builders + * + * @param Mage_Sales_Model_Quote $quote + * @param string|null $referenceId Optional reference ID + * @return object The built purchase unit object + */ + private function _buildPurchaseUnit(Mage_Sales_Model_Quote $quote, ?string $referenceId = null): object + { + $cart = Mage::getModel('paypal/cart', [$quote]); + $totals = $cart->getAmounts(); + $currency = $quote->getOrderCurrencyCode() ?: $quote->getQuoteCurrencyCode(); + $items = $cart->getAllItems(); + // Amount check + $taxCalculated = 0.00; + $taxDifference = 0.00; + $taxAmount = 0.00; + if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_TAX])) { + $taxAmount = (float) $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->getValue(); + } + foreach ($items as $item) { + /** + * @var PaypalServerSdkLib\Models\Item $item + */ + if ($item->getTax()) { + $qty = (int) $item->getQuantity(); + $taxValue = (float) $item->getTax()->getValue(); + $taxCalculated += $taxValue * $qty; + } + } + if ($taxCalculated !== $taxAmount) { + $taxDifference = round($taxAmount - $taxCalculated, 2); + $taxAmount = $taxCalculated; + } + if ($taxDifference < 0) { + if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_TAX])) { + $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->setValue( + number_format($taxCalculated, 2, '.', '') + ); + } + if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT])) { + $totalDiscount = (float) $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]->getValue(); + $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]->setValue( + number_format(abs($taxDifference) + $totalDiscount, 2, '.', '') + ); + } else { + $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT] = MoneyBuilder::init( + $currency, + number_format(abs($taxDifference), 2, '.', '') + )->build(); + } + } else { + $moneyBuilder = MoneyBuilder::init( + $currency, + number_format(abs($taxDifference), 2, '.', '') + ); + $itemBuilder = ItemBuilder::init(Mage::helper('paypal')->__('Rounding'), $moneyBuilder->build(), '1') + ->sku(Mage::helper('paypal')->__('Rounding')) + ->category(ItemCategory::DIGITAL_GOODS); + $items[] = $itemBuilder->build(); + if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_TAX])) { + $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->setValue( + number_format($taxCalculated, 2, '.', '') + ); + } + } + $breakdown = $this->_buildAmountBreakdown($totals); + $amount = $this->_buildAmountWithBreakdown($currency, $quote->getGrandTotal(), $breakdown); + $purchaseUnitBuilder = PurchaseUnitRequestBuilder::init($amount); + if (!empty($items)) { + $purchaseUnitBuilder->items($items); + } + $purchaseUnitBuilder->referenceId($referenceId ?: (string)$quote->getId()); + $purchaseUnitBuilder->invoiceId($referenceId ?: (string)$quote->getId()); + return $purchaseUnitBuilder->build(); + } + + /** + * Build amount breakdown from cart totals + * + * @param array $totals Cart totals + * @return object Built breakdown object + */ + private function _buildAmountBreakdown(array $totals): object + { + $breakdownBuilder = AmountBreakdownBuilder::init(); + + if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_SUBTOTAL])) { + $breakdownBuilder->itemTotal($totals[Mage_Paypal_Model_Cart::TOTAL_SUBTOTAL]); + } + + if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_TAX])) { + $breakdownBuilder->taxTotal($totals[Mage_Paypal_Model_Cart::TOTAL_TAX]); + } + + if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_SHIPPING])) { + $breakdownBuilder->shipping($totals[Mage_Paypal_Model_Cart::TOTAL_SHIPPING]); + } + + if ( + isset($totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]) && + $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]->getValue() > 0 + ) { + $breakdownBuilder->discount($totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]); + } + + return $breakdownBuilder->build(); + } + + /** + * Build amount with breakdown + * + * @param string $currency + * @param float $totalAmount + * @param object $breakdown Built breakdown object + * @return object + */ + private function _buildAmountWithBreakdown(string $currency, float $totalAmount, object $breakdown): object + { + $formattedTotal = number_format($totalAmount, 2, '.', ''); + + return AmountWithBreakdownBuilder::init($currency, $formattedTotal) + ->breakdown($breakdown) + ->build(); + } + + /** + * Build a complete PayPal order request using SDK builders + * + * @param Mage_Sales_Model_Quote $quote + * @param string|null $referenceId Optional reference ID + * @return object The built order request object + */ + private function _buildOrderRequest(Mage_Sales_Model_Quote $quote, ?string $referenceId = null): object + { + $purchaseUnit = $this->_buildPurchaseUnit($quote, $referenceId); + $orderRequestBuilder = OrderRequestBuilder::init( + $this->_getPaymentIntent(), + [$purchaseUnit] + ); + + $payer = $this->_buildPayerFromBillingAddress($quote); + if ($payer !== null) { + $orderRequestBuilder->payer($payer); + } + + return $orderRequestBuilder->build(); + } + + /** + * Build payer object from billing address + * + * @param Mage_Sales_Model_Quote $quote + * @return object|null + */ + private function _buildPayerFromBillingAddress(Mage_Sales_Model_Quote $quote): ?object + { + $billingAddress = $quote->getBillingAddress(); + + if ($billingAddress->validate() !== true) { + return null; + } + + $name = NameBuilder::init() + ->givenName($billingAddress->getFirstname()) + ->surname($billingAddress->getLastname()) + ->build(); + + $address = AddressBuilder::init($billingAddress->getCountryId()) + ->addressLine1($billingAddress->getStreetLine(1)) + ->addressLine2($billingAddress->getStreetLine(2)) + ->adminArea2($billingAddress->getCity()) + ->adminArea1($billingAddress->getRegionCode()) + ->postalCode($billingAddress->getPostcode()) + ->build(); + + return PayerBuilder::init() + ->emailAddress($quote->getEmail()) + ->name($name) + ->address($address) + ->build(); + } + + /** + * Get payment intent based on payment action configuration + */ + private function _getPaymentIntent(): string + { + // Always use capture for multishipping orders + if ($this->_getQuote()?->getIsMultiShipping()) { + return CheckoutPaymentIntent::CAPTURE; + } + + $paymentAction = Mage::getSingleton('paypal/config')->getPaymentAction(); + + return $paymentAction === strtolower(CheckoutPaymentIntent::AUTHORIZE) + ? CheckoutPaymentIntent::AUTHORIZE + : CheckoutPaymentIntent::CAPTURE; + } + + /** + * Extract capture ID from API result + * + * @param mixed $result API result + * @return string|null + */ + private function _extractCaptureId(mixed $result): ?string + { + if ( + !method_exists($result, 'getPurchaseUnits') || + !is_array($result->getPurchaseUnits()) || + empty($result->getPurchaseUnits()) + ) { + return null; + } + + $purchaseUnit = $result->getPurchaseUnits()[0]; + $payments = $purchaseUnit->getPayments(); + + if ( + !method_exists($payments, 'getCaptures') || + !is_array($payments->getCaptures()) || + empty($payments->getCaptures()) + ) { + return null; + } + + return $payments->getCaptures()[0]->getId(); + } + + /** + * Update payment object after successful capture + * + * @param Mage_Sales_Model_Quote_Payment|Mage_Sales_Model_Order_Payment $payment + * @param ApiResponse $response API result + * @param string $orderId PayPal order ID + * @param string $captureId Capture ID + */ + private function _updatePaymentAfterCapture( + Mage_Sales_Model_Quote_Payment|Mage_Sales_Model_Order_Payment $payment, + ApiResponse $response, + string $captureId + ): void { + $result = $response->getResult(); + $payment->setMethod($this->_code) + ->setPaypalCorrelationId($captureId) + ->setTransactionId($captureId) + ->setIsTransactionClosed(true) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->_prepareRawDetails($response->getBody()) + ); + $paymentSource = $result->getPaymentSource(); + if ($paymentSource->getPaypal() instanceof PaypalWalletResponse) { + $paypalWallet = $paymentSource->getPaypal(); + $payment->setPaypalPayerId($paypalWallet->getAccountId()) + ->setPaypalPayerStatus($paypalWallet->getAccountStatus()); + } + + $payment->save(); + } + + /** + * Update payment object after successful authorization + * + * @param Mage_Sales_Model_Quote_Payment $payment + * @param ApiResponse $response API result + */ + private function _updatePaymentAfterAuthorization(Mage_Sales_Model_Quote_Payment $payment, ApiResponse $response): void + { + $result = $response->getResult(); + $authorization = $result->getPurchaseUnits()[0]->getPayments()->getAuthorizations()[0]; + $paymentSource = $result->getPaymentSource(); + + if ($paymentSource->getPaypal() instanceof PaypalWalletResponse) { + $paypalWallet = $paymentSource->getPaypal(); + $payment->setPaypalPayerId($paypalWallet->getAccountId()) + ->setPaypalPayerStatus($paypalWallet->getAccountStatus()); + } + + $payment->setAdditionalInformation([ + self::PAYPAL_PAYMENT_STATUS => $authorization->getStatus(), + self::PAYPAL_PAYMENT_AUTHORIZATION_ID => $authorization->getId(), + self::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME => $authorization->getExpirationTime(), + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->_prepareRawDetails($response->getBody()) + ]); + $payment->save(); + } + + /** + * Add order status comment + * + * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote + * @param string $action Action performed (captured, authorized, etc.) + * @param string|null $transactionId Transaction ID + */ + private function _addOrderComment( + Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote, + string $action, + ?string $transactionId + ): void { + if ($quote instanceof Mage_Sales_Model_Order && $transactionId) { + $message = match ($action) { + 'captured' => 'PayPal payment captured successfully. Capture ID: %s', + 'authorized' => 'PayPal payment authorized successfully. Authorization ID: %s', + default => 'PayPal payment %s successfully. Transaction ID: %s' + }; + + $quote->addStatusHistoryComment( + Mage::helper('paypal')->__($message, $transactionId), + false + ); + } + } + + /** + * Update payment after refund + * + * @param Varien_Object $payment Payment object + * @param Refund $result API result + */ + private function _updatePaymentAfterRefund(Varien_Object $payment, Refund $result): void + { + $payment->setTransactionId($result->getId()) + ->setIsTransactionClosed(1) + ->setShouldCloseParentTransaction(1) + ->setSkipTransactionCreation(true); + } + + /** + * Create refund transaction record + * + * @param Varien_Object $payment Payment object + * @param ApiResponse $response API result + * @param float $amount Refund amount + */ + private function _createRefundTransaction(Varien_Object $payment, ApiResponse $response, float $amount): void + { + $result = $response->getResult(); + $transaction = Mage::getModel('sales/order_payment_transaction'); + $transaction->setOrderPaymentObject($payment) + ->setTxnId($result->getId()) + ->setParentTxnId($payment->getParentTransactionId()) + ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND) + ->setIsClosed(1) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->_prepareRawDetails($response->getBody()) + ); + + $transaction->save(); + } + + /** + * Update payment after authorized capture + * + * @param Varien_Object $payment Payment object + * @param ApiResponse $response + * @param string $authorizationId Authorization ID + */ + private function _updatePaymentAfterAuthorizedCapture(Varien_Object $payment, ApiResponse $response, string $authorizationId): void + { + $result = $response->getResult(); + $captureId = $result->getId(); + $payment->setTransactionId($captureId) + ->setParentTransactionId($authorizationId) + ->setIsTransactionClosed(true) + ->setShouldCloseParentTransaction(true) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->_prepareRawDetails($response->getBody()) + ); + } + + /** + * Create capture transaction record + * + * @param Varien_Object $payment Payment object + * @param ApiResponse $response + * @param string $authorizationId Authorization ID + */ + private function _createCaptureTransaction(Varien_Object $payment, ApiResponse $response, string $authorizationId): void + { + $result = $response->getResult(); + $transaction = Mage::getModel('sales/order_payment_transaction'); + $transaction->setOrderPaymentObject($payment) + ->setTxnId($result->getId()) + ->setParentTxnId($authorizationId) + ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE) + ->setIsClosed(1) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->_prepareRawDetails($response->getBody()) + ); + + $transaction->save(); + } + + /** + * Update payment after void + * + * @param Varien_Object $payment Payment object + */ + private function _updatePaymentAfterVoid(Varien_Object $payment): void + { + $payment->setIsTransactionClosed(1) + ->setShouldCloseParentTransaction(1) + ->setSkipTransactionCreation(true); + } + + /** + * Create void transaction record + * + * @param Varien_Object $payment Payment object + * @param ApiResponse $response API response + */ + private function _createVoidTransaction(Varien_Object $payment, ApiResponse $response): void + { + $transaction = Mage::getModel('sales/order_payment_transaction'); + $result = $response->getResult(); + $transaction->setOrderPaymentObject($payment) + ->setTxnId($payment->getTransactionId()) + ->setParentTxnId($result->getId()) + ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID) + ->setIsClosed(1) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->_prepareRawDetails($response->getBody()) + ); + $transaction->save(); + + $parentTxn = $transaction->loadByTxnId($result->getId()); + if ($parentTxn->getId()) { + $parentTxn->setIsClosed(1); + $parentTxn->save(); + } + } + + /** + * Handle multishipping notification + * + * @param Mage_Sales_Model_Quote|null $quote + */ + private function _handleMultishippingNotification(?Mage_Sales_Model_Quote $quote): void + { + if ( + $quote?->getIsMultiShipping() && + Mage::getSingleton('paypal/config')->getPaymentAction() === strtolower(CheckoutPaymentIntent::AUTHORIZE) + ) { + Mage::getSingleton('core/session')->addNotice( + Mage::helper('paypal')->__( + 'PayPal will process multishipping orders as immediate capture regardless of your authorization setting.' + ) + ); + } + } + + /** + * Extract error message from API response + * + * @param ApiResponse $response API response + * @param string $defaultMessage Default error message + * @return string + */ + private function _extractErrorMessage(ApiResponse $response, string $defaultMessage): string + { + $result = $response->getResult(); + + return match (true) { + is_array($result) && isset($result['message']) => $result['message'] ?: $defaultMessage, + is_object($result) && method_exists($result, 'getMessage') => $result->getMessage() ?: $defaultMessage, + is_string($result) => $result ?: $defaultMessage, + default => $defaultMessage + }; + } + + /** + * Prepare raw details for storage + * + * @param string $details JSON details object + * @return array + */ + private function _prepareRawDetails(string $details): array + { + $decoded = json_decode($details, true); + if (isset($decoded['links'])) { + unset($decoded['links']); + } + return array_map( + fn($v) => is_array($v) ? json_encode($v) : $v, + $decoded ?? [] + ); + } +} diff --git a/app/code/core/Mage/Paypal/Model/Pro.php b/app/code/core/Mage/Paypal/Model/Pro.php deleted file mode 100644 index 34b6376a42c..00000000000 --- a/app/code/core/Mage/Paypal/Model/Pro.php +++ /dev/null @@ -1,449 +0,0 @@ -_config === null) { - $params = [$code]; - if ($storeId !== null) { - $params[] = $storeId; - } - - /** @var Mage_Paypal_Model_Config $model */ - $model = Mage::getModel($this->_configType, $params); - $this->_config = $model; - } else { - $this->_config->setMethod($code); - if ($storeId !== null) { - $this->_config->setStoreId($storeId); - } - } - return $this; - } - - /** - * Config instance setter - * - * @param int $storeId - * @return $this - */ - public function setConfig(Mage_Paypal_Model_Config $instace, $storeId = null) - { - $this->_config = $instace; - if ($storeId !== null) { - $this->_config->setStoreId($storeId); - } - return $this; - } - - /** - * Config instance getter - * - * @return Mage_Paypal_Model_Config - */ - public function getConfig() - { - return $this->_config; - } - - /** - * 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 ($this->_api === null) { - $this->_api = Mage::getModel($this->_apiType); - } - $this->_api->setConfigObject($this->_config); - return $this->_api; - } - - /** - * Destroy existing NVP Api object - * - * @return $this - */ - public function resetApi() - { - $this->_api = null; - - return $this; - } - - /** - * Instantiate and return info model - * - * @return Mage_Paypal_Model_Info - */ - public function getInfo() - { - if ($this->_infoInstance === null) { - $this->_infoInstance = Mage::getModel('paypal/info'); - } - return $this->_infoInstance; - } - - /** - * Transfer transaction/payment information from API instance to order payment - * - * @param Mage_Paypal_Model_Api_Abstract $from - * @return $this - */ - public function importPaymentInfo(Varien_Object $from, Mage_Payment_Model_Info $to) - { - // update PayPal-specific payment information in the payment object - $this->getInfo()->importToPayment($from, $to); - - /** - * Detect payment review and/or frauds - * PayPal pro API returns fraud results only in the payment call response - */ - if ($from->getDataUsingMethod(Mage_Paypal_Model_Info::IS_FRAUD)) { - $to->setIsTransactionPending(true); - $to->setIsFraudDetected(true); - } elseif ($this->getInfo()->isPaymentReviewRequired($to)) { - $to->setIsTransactionPending(true); - } - - // give generic info about transaction state - if ($this->getInfo()->isPaymentSuccessful($to)) { - $to->setIsTransactionApproved(true); - } elseif ($this->getInfo()->isPaymentFailed($to)) { - $to->setIsTransactionDenied(true); - } - - return $this; - } - - /** - * Void transaction - */ - public function void(Varien_Object $payment) - { - if ($authTransactionId = $this->_getParentTransactionId($payment)) { - $api = $this->getApi(); - $api->setPayment($payment)->setAuthorizationId($authTransactionId)->callDoVoid(); - $this->importPaymentInfo($api, $payment); - } else { - Mage::throwException(Mage::helper('paypal')->__('Authorization transaction is required to void.')); - } - } - - /** - * Attempt to capture payment - * Will return false if the payment is not supposed to be captured - * - * @param float $amount - * @return false|null - */ - public function capture(Varien_Object $payment, $amount) - { - $authTransactionId = $this->_getParentTransactionId($payment); - if (!$authTransactionId) { - return false; - } - $api = $this->getApi() - ->setAuthorizationId($authTransactionId) - ->setIsCaptureComplete($payment->getShouldCloseParentTransaction()) - ->setAmount($amount) - ->setCurrencyCode($payment->getOrder()->getBaseCurrencyCode()) - ->setInvNum($payment->getOrder()->getIncrementId()) - // TODO: pass 'NOTE' to API - ; - - $api->callDoCapture(); - $this->_importCaptureResultToPayment($api, $payment); - } - - /** - * Refund a capture transaction - * - * @param float $amount - */ - public function refund(Varien_Object $payment, $amount) - { - $captureTxnId = $this->_getParentTransactionId($payment); - if ($captureTxnId) { - $api = $this->getApi(); - $order = $payment->getOrder(); - $api->setPayment($payment) - ->setTransactionId($captureTxnId) - ->setAmount($amount) - ->setCurrencyCode($order->getBaseCurrencyCode()) - ; - $canRefundMore = $payment->getCreditmemo()->getInvoice()->canRefund(); - $isFullRefund = !$canRefundMore - && (((float) $order->getBaseTotalOnlineRefunded() + (float) $order->getBaseTotalOfflineRefunded()) == 0); - $api->setRefundType($isFullRefund ? Mage_Paypal_Model_Config::REFUND_TYPE_FULL - : Mage_Paypal_Model_Config::REFUND_TYPE_PARTIAL); - $api->callRefundTransaction(); - $this->_importRefundResultToPayment($api, $payment, $canRefundMore); - } else { - Mage::throwException(Mage::helper('paypal')->__('Impossible to issue a refund transaction because the capture transaction does not exist.')); - } - } - - /** - * Cancel payment - */ - public function cancel(Varien_Object $payment) - { - if (!$payment->getOrder()->getInvoiceCollection()->count()) { - $this->void($payment); - } - } - - /** - * - * @param Mage_Sales_Model_Order_Payment $payment - * @return bool - */ - public function canReviewPayment(Mage_Payment_Model_Info $payment) - { - return Mage_Paypal_Model_Info::isPaymentReviewRequired($payment); - } - - /** - * Perform the payment review - * - * @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; - } - - /** - * Fetch transaction details info - * - * @param string $transactionId - * @return array - */ - public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId) - { - $api = $this->getApi() - ->setTransactionId($transactionId) - ->setRawResponseNeeded(true); - $api->callGetTransactionDetails(); - $this->importPaymentInfo($api, $payment); - $data = $api->getRawSuccessResponseData(); - return ($data) ? $data : []; - } - - /** - * Validate RP data - * - * @throws Mage_Core_Exception - */ - public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile) - { - $errors = []; - if (strlen($profile->getSubscriberName()) > 32) { // up to 32 single-byte chars - $errors[] = Mage::helper('paypal')->__('Subscriber name is too long.'); - } - $refId = $profile->getInternalReferenceId(); // up to 127 single-byte alphanumeric - if (strlen($refId) > 127) { // || !preg_match('/^[a-z\d\s]+$/i', $refId) - $errors[] = Mage::helper('paypal')->__('Merchant reference ID format is not supported.'); - } - $scheduleDescr = $profile->getScheduleDescription(); // up to 127 single-byte alphanumeric - if (strlen($refId) > 127) { // || !preg_match('/^[a-z\d\s]+$/i', $scheduleDescr) - $errors[] = Mage::helper('paypal')->__('Schedule description is too long.'); - } - if ($errors) { - Mage::throwException(implode(' ', $errors)); - } - } - - /** - * Submit RP to the gateway - * - * @throws Mage_Core_Exception - */ - public function submitRecurringProfile( - Mage_Payment_Model_Recurring_Profile $profile, - Mage_Payment_Model_Info $paymentInfo - ) { - $api = $this->getApi(); - Varien_Object_Mapper::accumulateByMap($profile, $api, [ - 'token', // EC fields - // TODO: DP fields - // profile fields - 'subscriber_name', 'start_datetime', 'internal_reference_id', 'schedule_description', - 'suspension_threshold', 'bill_failed_later', 'period_unit', 'period_frequency', 'period_max_cycles', - 'billing_amount' => 'amount', 'trial_period_unit', 'trial_period_frequency', 'trial_period_max_cycles', - 'trial_billing_amount', 'currency_code', 'shipping_amount', 'tax_amount', 'init_amount', 'init_may_fail', - ]); - $api->callCreateRecurringPaymentsProfile(); - $profile->setReferenceId($api->getRecurringProfileId()); - if ($api->getIsProfileActive()) { - $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE); - } elseif ($api->getIsProfilePending()) { - $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_PENDING); - } - } - - /** - * Fetch RP details - * - * @param string $referenceId - */ - public function getRecurringProfileDetails($referenceId, Varien_Object $result) - { - $api = $this->getApi(); - $api->setRecurringProfileId($referenceId) - ->callGetRecurringPaymentsProfileDetails($result) - ; - } - - /** - * Update RP data - */ - public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile) {} - - /** - * Manage status - */ - public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile) - { - $api = $this->getApi(); - $action = null; - switch ($profile->getNewState()) { - case Mage_Sales_Model_Recurring_Profile::STATE_CANCELED: - $action = 'cancel'; - break; - case Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED: - $action = 'suspend'; - break; - case Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE: - $action = 'activate'; - break; - } - $state = $profile->getState(); - $api->setRecurringProfileId($profile->getReferenceId()) - ->setIsAlreadyCanceled($state == Mage_Sales_Model_Recurring_Profile::STATE_CANCELED) - ->setIsAlreadySuspended($state == Mage_Sales_Model_Recurring_Profile::STATE_SUSPENDED) - ->setIsAlreadyActive($state == Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE) - ->setAction($action) - ->callManageRecurringPaymentsProfileStatus() - ; - } - - /** - * Import capture results to payment - * - * @param Mage_Paypal_Model_Api_Nvp $api - * @param Mage_Sales_Model_Order_Payment $payment - */ - protected function _importCaptureResultToPayment($api, $payment) - { - $payment->setTransactionId($api->getTransactionId())->setIsTransactionClosed(false); - $this->importPaymentInfo($api, $payment); - } - - /** - * 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->getRefundTransactionId()) - ->setIsTransactionClosed(1) // refund initiated by merchant - ->setShouldCloseParentTransaction(!$canRefundMore) - ; - $this->importPaymentInfo($api, $payment); - } - - /** - * Parent transaction id getter - * - * @return string - */ - protected function _getParentTransactionId(Varien_Object $payment) - { - return $payment->getParentTransactionId() ? $payment->getParentTransactionId() : $payment->getLastTransId(); - } -} diff --git a/app/code/core/Mage/Paypal/Model/Report/Settlement.php b/app/code/core/Mage/Paypal/Model/Report/Settlement.php deleted file mode 100644 index 241e6563299..00000000000 --- a/app/code/core/Mage/Paypal/Model/Report/Settlement.php +++ /dev/null @@ -1,432 +0,0 @@ - [ - 'section_columns' => [ - '' => 0, - 'TransactionID' => 1, - 'InvoiceID' => 2, - 'PayPalReferenceID' => 3, - 'PayPalReferenceIDType' => 4, - 'TransactionEventCode' => 5, - 'TransactionInitiationDate' => 6, - 'TransactionCompletionDate' => 7, - 'TransactionDebitOrCredit' => 8, - 'GrossTransactionAmount' => 9, - 'GrossTransactionCurrency' => 10, - 'FeeDebitOrCredit' => 11, - 'FeeAmount' => 12, - 'FeeCurrency' => 13, - 'CustomField' => 14, - 'ConsumerID' => 15, - ], - 'rowmap' => [ - 'TransactionID' => 'transaction_id', - 'InvoiceID' => 'invoice_id', - 'PayPalReferenceID' => 'paypal_reference_id', - 'PayPalReferenceIDType' => 'paypal_reference_id_type', - 'TransactionEventCode' => 'transaction_event_code', - 'TransactionInitiationDate' => 'transaction_initiation_date', - 'TransactionCompletionDate' => 'transaction_completion_date', - 'TransactionDebitOrCredit' => 'transaction_debit_or_credit', - 'GrossTransactionAmount' => 'gross_transaction_amount', - 'GrossTransactionCurrency' => 'gross_transaction_currency', - 'FeeDebitOrCredit' => 'fee_debit_or_credit', - 'FeeAmount' => 'fee_amount', - 'FeeCurrency' => 'fee_currency', - 'CustomField' => 'custom_field', - 'ConsumerID' => 'consumer_id', - ], - ], - 'new' => [ - 'section_columns' => [ - '' => 0, - 'Transaction ID' => 1, - 'Invoice ID' => 2, - 'PayPal Reference ID' => 3, - 'PayPal Reference ID Type' => 4, - 'Transaction Event Code' => 5, - 'Transaction Initiation Date' => 6, - 'Transaction Completion Date' => 7, - 'Transaction Debit or Credit' => 8, - 'Gross Transaction Amount' => 9, - 'Gross Transaction Currency' => 10, - 'Fee Debit or Credit' => 11, - 'Fee Amount' => 12, - 'Fee Currency' => 13, - 'Custom Field' => 14, - 'Consumer ID' => 15, - 'Payment Tracking ID' => 16, - 'Store ID' => 17, - ], - 'rowmap' => [ - 'Transaction ID' => 'transaction_id', - 'Invoice ID' => 'invoice_id', - 'PayPal Reference ID' => 'paypal_reference_id', - 'PayPal Reference ID Type' => 'paypal_reference_id_type', - 'Transaction Event Code' => 'transaction_event_code', - 'Transaction Initiation Date' => 'transaction_initiation_date', - 'Transaction Completion Date' => 'transaction_completion_date', - 'Transaction Debit or Credit' => 'transaction_debit_or_credit', - 'Gross Transaction Amount' => 'gross_transaction_amount', - 'Gross Transaction Currency' => 'gross_transaction_currency', - 'Fee Debit or Credit' => 'fee_debit_or_credit', - 'Fee Amount' => 'fee_amount', - 'Fee Currency' => 'fee_currency', - 'Custom Field' => 'custom_field', - 'Consumer ID' => 'consumer_id', - 'Payment Tracking ID' => 'payment_tracking_id', - 'Store ID' => 'store_id', - ], - ], - ]; - - protected function _construct() - { - $this->_init('paypal/report_settlement'); - } - - /** - * Stop saving process if file with same report date, account ID and last modified date was already ferched - * - * @return Mage_Core_Model_Abstract - */ - protected function _beforeSave() - { - $this->_dataSaveAllowed = true; - if ($this->getId()) { - if ($this->getLastModified() == $this->getReportLastModified()) { - $this->_dataSaveAllowed = false; - } - } - $this->setLastModified($this->getReportLastModified()); - return parent::_beforeSave(); - } - - /** - * Goes to specified host/path and fetches reports from there. - * Save reports to database. - * - * @param array $config SFTP credentials - * @return int Number of report rows that were fetched and saved successfully - * - * @SuppressWarnings("PHPMD.ErrorControlOperator") - */ - public function fetchAndSave($config) - { - $connection = new Varien_Io_Sftp(); - $connection->open([ - 'host' => $config['hostname'], - 'username' => $config['username'], - 'password' => $config['password'], - ]); - $connection->cd($config['path']); - $fetched = 0; - $listing = $this->_filterReportsList($connection->rawls()); - foreach ($listing as $filename => $attributes) { - $localCsv = tempnam(Mage::getConfig()->getOptions()->getTmpDir(), 'PayPal_STL'); - if ($connection->read($filename, $localCsv)) { - if (!is_writable($localCsv)) { - Mage::throwException(Mage::helper('paypal')->__('Cannot create target file for reading reports.')); - } - - $encoded = file_get_contents($localCsv); - $csvFormat = 'new'; - - $fileEncoding = mb_detect_encoding($encoded); - - if (self::FILES_OUT_CHARSET != $fileEncoding) { - $decoded = @iconv($fileEncoding, self::FILES_OUT_CHARSET . '//IGNORE', $encoded); - file_put_contents($localCsv, $decoded); - $csvFormat = 'old'; - } - - // Set last modified date, this value will be overwritten during parsing - if (isset($attributes['mtime'])) { - $lastModified = new Zend_Date($attributes['mtime']); - $this->setReportLastModified($lastModified->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)); - } - - $this->setReportDate($this->_fileNameToDate($filename)) - ->setFilename($filename) - ->parseCsv($localCsv, $csvFormat); - - if ($this->getAccountId()) { - $this->save(); - } - - if ($this->_dataSaveAllowed) { - $fetched += count($this->_rows); - } - // clean object and remove parsed file - $this->unsetData(); - unlink($localCsv); - } - } - return $fetched; - } - - /** - * Parse CSV file and collect report rows - * - * @param string $localCsv Path to CSV file - * @param string $format CSV format(column names) - * @return $this - */ - public function parseCsv($localCsv, $format = 'new') - { - $this->_rows = []; - - $sectionColumns = $this->_csvColumns[$format]['section_columns']; - $rowMap = $this->_csvColumns[$format]['rowmap']; - - $flippedSectionColumns = array_flip($sectionColumns); - $fp = fopen($localCsv, 'r'); - while ($line = fgetcsv($fp)) { - if (empty($line)) { // The line was empty, so skip it. - continue; - } - $lineType = $line[0]; - switch ($lineType) { - case 'RH': // Report header. - $lastModified = new Zend_Date($line[1]); - $this->setReportLastModified($lastModified->toString(Varien_Date::DATETIME_INTERNAL_FORMAT)); - //$this->setAccountId($columns[2]); -- probably we'll just take that from the section header... - break; - case 'FH': // File header. - // Nothing interesting here, move along - break; - case 'SH': // Section header. - $this->setAccountId($line[3]); - $this->loadByAccountAndDate(); - break; - case 'CH': // Section columns. - // In case ever the column order is changed, we will have the items recorded properly - // anyway. We have named, not numbered columns. - for ($i = 1; $i < count($line); $i++) { - $sectionColumns[$line[$i]] = $i; - } - $flippedSectionColumns = array_flip($sectionColumns); - break; - case 'SB': // Section body. - $bodyItem = []; - for ($i = 1; $i < count($line); $i++) { - $bodyItem[$rowMap[$flippedSectionColumns[$i]]] = $line[$i]; - } - $this->_rows[] = $bodyItem; - break; - case 'SC': // Section records count. - case 'RC': // Report records count. - case 'SF': // Section footer. - case 'FF': // File footer. - case 'RF': // Report footer. - // Nothing to see here, move along - break; - } - } - return $this; - } - - /** - * Load report by unique key (account + report date) - * - * @return $this - */ - public function loadByAccountAndDate() - { - $this->getResource()->loadByAccountAndDate($this, $this->getAccountId(), $this->getReportDate()); - return $this; - } - - /** - * Return collected rows for further processing. - * - * @return array - */ - public function getRows() - { - return $this->_rows; - } - - /** - * Return name for row column - * - * @param string $field Field name in row model - * @return string - */ - public function getFieldLabel($field) - { - switch ($field) { - case 'report_date': - return Mage::helper('paypal')->__('Report Date'); - case 'account_id': - return Mage::helper('paypal')->__('Merchant Account'); - case 'transaction_id': - return Mage::helper('paypal')->__('Transaction ID'); - case 'invoice_id': - return Mage::helper('paypal')->__('Invoice ID'); - case 'paypal_reference_id': - return Mage::helper('paypal')->__('PayPal Reference ID'); - case 'paypal_reference_id_type': - return Mage::helper('paypal')->__('PayPal Reference ID Type'); - case 'transaction_event_code': - return Mage::helper('paypal')->__('Event Code'); - case 'transaction_event': - return Mage::helper('paypal')->__('Event'); - case 'transaction_initiation_date': - return Mage::helper('paypal')->__('Initiation Date'); - case 'transaction_completion_date': - return Mage::helper('paypal')->__('Completion Date'); - case 'transaction_debit_or_credit': - return Mage::helper('paypal')->__('Debit or Credit'); - case 'gross_transaction_amount': - return Mage::helper('paypal')->__('Gross Amount'); - case 'fee_debit_or_credit': - return Mage::helper('paypal')->__('Fee Debit or Credit'); - case 'fee_amount': - return Mage::helper('paypal')->__('Fee Amount'); - case 'custom_field': - return Mage::helper('paypal')->__('Custom'); - default: - return $field; - } - } - - /** - * Iterate through website configurations and collect all SFTP configurations - * Filter config values if necessary - * - * @param bool $automaticMode Whether to skip settings with disabled Automatic Fetching or not - * @return array - */ - public function getSftpCredentials($automaticMode = false) - { - $configs = []; - $uniques = []; - foreach (Mage::app()->getStores() as $store) { - /*@var $store Mage_Core_Model_Store */ - $active = (bool) $store->getConfig('paypal/fetch_reports/active'); - if (!$active && $automaticMode) { - continue; - } - $cfg = [ - 'hostname' => $store->getConfig('paypal/fetch_reports/ftp_ip'), - 'path' => $store->getConfig('paypal/fetch_reports/ftp_path'), - 'username' => $store->getConfig('paypal/fetch_reports/ftp_login'), - 'password' => $store->getConfig('paypal/fetch_reports/ftp_password'), - 'sandbox' => $store->getConfig('paypal/fetch_reports/ftp_sandbox'), - ]; - if (empty($cfg['username']) || empty($cfg['password'])) { - continue; - } - if (empty($cfg['hostname']) || $cfg['sandbox']) { - $cfg['hostname'] = $cfg['sandbox'] ? self::SANDBOX_REPORTS_HOSTNAME : self::REPORTS_HOSTNAME; - } - if (empty($cfg['path']) || $cfg['sandbox']) { - $cfg['path'] = self::REPORTS_PATH; - } - // avoid duplicates - if (in_array(serialize($cfg), $uniques)) { - continue; - } - $uniques[] = serialize($cfg); - $configs[] = $cfg; - } - return $configs; - } - - /** - * Converts a filename to date of report. - * - * @param string $filename - * @return string - */ - protected function _fileNameToDate($filename) - { - // Currently filenames look like STL-YYYYMMDD, so that is what we care about. - $dateSnippet = substr(basename($filename), 4, 8); - return substr($dateSnippet, 0, 4) . '-' . substr($dateSnippet, 4, 2) . '-' . substr($dateSnippet, 6, 2); - } - - /** - * Filter SFTP file list by filename format - * - * @param array $list List of files as per $connection->rawls() - * @return array Trimmed down list of files - */ - protected function _filterReportsList($list) - { - $result = []; - $pattern = '/^STL-(\d{8,8})\.(\d{2,2})\.(.{3,3})\.CSV$/'; - foreach ($list as $filename => $data) { - if (preg_match($pattern, $filename)) { - $result[$filename] = $data; - } - } - return $result; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Report/Settlement/Row.php b/app/code/core/Mage/Paypal/Model/Report/Settlement/Row.php deleted file mode 100644 index c6d26712932..00000000000 --- a/app/code/core/Mage/Paypal/Model/Report/Settlement/Row.php +++ /dev/null @@ -1,266 +0,0 @@ - label - * - * @var array - */ - protected static $_eventList = []; - - /** - * Casted amount keys registry - * - * @var array - */ - protected $_castedAmounts = []; - - protected function _construct() - { - $this->_init('paypal/report_settlement_row'); - } - - /** - * Return description of Reference ID Type - * If no code specified, return full list of codes with their description - * - * @param string|null $code - * @return string|array - */ - public function getReferenceType($code = null) - { - $types = [ - 'TXN' => Mage::helper('paypal')->__('Transaction ID'), - 'ODR' => Mage::helper('paypal')->__('Order ID'), - 'SUB' => Mage::helper('paypal')->__('Subscription ID'), - 'PAP' => Mage::helper('paypal')->__('Preapproved Payment ID'), - ]; - if ($code === null) { - asort($types); - return $types; - } - return $types[$code] ?? $code; - } - - /** - * Get native description for transaction code - * - * @param string $code - * @return string - */ - public function getTransactionEvent($code) - { - $this->_generateEventLabels(); - return self::$_eventList[$code] ?? $code; - } - - /** - * Get full list of codes with their description - * - * @return array - */ - public function &getTransactionEvents() - { - $this->_generateEventLabels(); - return self::$_eventList; - } - - /** - * Return description of "Debit or Credit" value - * If no code specified, return full list of codes with their description - * - * @param string|null $code - * @return string|array - */ - public function getDebitCreditText($code = null) - { - $options = [ - 'CR' => Mage::helper('paypal')->__('Credit'), - 'DR' => Mage::helper('paypal')->__('Debit'), - ]; - if ($code === null) { - return $options; - } - return $options[$code] ?? $code; - } - - /** - * Invoke casting some amounts - * - * @param mixed $key - * @param mixed $index - * @return mixed - */ - public function getData($key = '', $index = null) - { - $this->_castAmount('fee_amount', 'fee_debit_or_credit'); - $this->_castAmount('gross_transaction_amount', 'transaction_debit_or_credit'); - return parent::getData($key, $index); - } - - /** - * Cast amounts of the specified keys - * - * PayPal settlement reports contain amounts in cents, hence the values need to be divided by 100 - * Also if the "credit" value is detected, it will be casted to negative amount - * - * @param string $key - * @param string $creditKey - */ - public function _castAmount($key, $creditKey) - { - if (isset($this->_castedAmounts[$key]) || !isset($this->_data[$key]) || !isset($this->_data[$creditKey])) { - return; - } - if (empty($this->_data[$key])) { - return; - } - $amount = $this->_data[$key] / 100; - if ($this->_data[$creditKey] === 'CR') { - $amount = -1 * $amount; - } - $this->_data[$key] = $amount; - $this->_castedAmounts[$key] = true; - } - - /** - * Fill/translate and sort all event codes/labels - */ - protected function _generateEventLabels() - { - if (!self::$_eventList) { - self::$_eventList = [ - 'T0000' => Mage::helper('paypal')->__('General: received payment of a type not belonging to the other T00xx categories'), - 'T0001' => Mage::helper('paypal')->__('Mass Pay Payment'), - 'T0002' => Mage::helper('paypal')->__('Subscription Payment, either payment sent or payment received'), - 'T0003' => Mage::helper('paypal')->__('Preapproved Payment (BillUser API), either sent or received'), - 'T0004' => Mage::helper('paypal')->__('eBay Auction Payment'), - 'T0005' => Mage::helper('paypal')->__('Direct Payment API'), - 'T0006' => Mage::helper('paypal')->__('Express Checkout APIs'), - 'T0007' => Mage::helper('paypal')->__('Website Payments Standard Payment'), - 'T0008' => Mage::helper('paypal')->__('Postage Payment to either USPS or UPS'), - 'T0009' => Mage::helper('paypal')->__('Gift Certificate Payment: purchase of Gift Certificate'), - 'T0010' => Mage::helper('paypal')->__('Auction Payment other than through eBay'), - 'T0011' => Mage::helper('paypal')->__('Mobile Payment (made via a mobile phone)'), - 'T0012' => Mage::helper('paypal')->__('Virtual Terminal Payment'), - 'T0100' => Mage::helper('paypal')->__('General: non-payment fee of a type not belonging to the other T01xx categories'), - 'T0101' => Mage::helper('paypal')->__('Fee: Web Site Payments Pro Account Monthly'), - 'T0102' => Mage::helper('paypal')->__('Fee: Foreign ACH Withdrawal'), - 'T0103' => Mage::helper('paypal')->__('Fee: WorldLink Check Withdrawal'), - 'T0104' => Mage::helper('paypal')->__('Fee: Mass Pay Request'), - 'T0200' => Mage::helper('paypal')->__('General Currency Conversion'), - 'T0201' => Mage::helper('paypal')->__('User-initiated Currency Conversion'), - 'T0202' => Mage::helper('paypal')->__('Currency Conversion required to cover negative balance'), - 'T0300' => Mage::helper('paypal')->__('General Funding of PayPal Account '), - 'T0301' => Mage::helper('paypal')->__('PayPal Balance Manager function of PayPal account'), - 'T0302' => Mage::helper('paypal')->__('ACH Funding for Funds Recovery from Account Balance'), - 'T0303' => Mage::helper('paypal')->__('EFT Funding (German banking)'), - 'T0400' => Mage::helper('paypal')->__('General Withdrawal from PayPal Account'), - 'T0401' => Mage::helper('paypal')->__('AutoSweep'), - 'T0500' => Mage::helper('paypal')->__('General: Use of PayPal account for purchasing as well as receiving payments'), - 'T0501' => Mage::helper('paypal')->__('Virtual PayPal Debit Card Transaction'), - 'T0502' => Mage::helper('paypal')->__('PayPal Debit Card Withdrawal from ATM'), - 'T0503' => Mage::helper('paypal')->__('Hidden Virtual PayPal Debit Card Transaction'), - 'T0504' => Mage::helper('paypal')->__('PayPal Debit Card Cash Advance'), - 'T0600' => Mage::helper('paypal')->__('General: Withdrawal from PayPal Account'), - 'T0700' => Mage::helper('paypal')->__('General (Purchase with a credit card)'), - 'T0701' => Mage::helper('paypal')->__('Negative Balance'), - 'T0800' => Mage::helper('paypal')->__('General: bonus of a type not belonging to the other T08xx categories'), - 'T0801' => Mage::helper('paypal')->__('Debit Card Cash Back'), - 'T0802' => Mage::helper('paypal')->__('Merchant Referral Bonus'), - 'T0803' => Mage::helper('paypal')->__('Balance Manager Account Bonus'), - 'T0804' => Mage::helper('paypal')->__('PayPal Buyer Warranty Bonus'), - 'T0805' => Mage::helper('paypal')->__('PayPal Protection Bonus'), - 'T0806' => Mage::helper('paypal')->__('Bonus for first ACH Use'), - 'T0900' => Mage::helper('paypal')->__('General Redemption'), - 'T0901' => Mage::helper('paypal')->__('Gift Certificate Redemption'), - 'T0902' => Mage::helper('paypal')->__('Points Incentive Redemption'), - 'T0903' => Mage::helper('paypal')->__('Coupon Redemption'), - 'T0904' => Mage::helper('paypal')->__('Reward Voucher Redemption'), - 'T1000' => Mage::helper('paypal')->__('General. Product no longer supported'), - 'T1100' => Mage::helper('paypal')->__('General: reversal of a type not belonging to the other T11xx categories'), - 'T1101' => Mage::helper('paypal')->__('ACH Withdrawal'), - 'T1102' => Mage::helper('paypal')->__('Debit Card Transaction'), - 'T1103' => Mage::helper('paypal')->__('Reversal of Points Usage'), - 'T1104' => Mage::helper('paypal')->__('ACH Deposit (Reversal)'), - 'T1105' => Mage::helper('paypal')->__('Reversal of General Account Hold'), - 'T1106' => Mage::helper('paypal')->__('Account-to-Account Payment, initiated by PayPal'), - 'T1107' => Mage::helper('paypal')->__('Payment Refund initiated by merchant'), - 'T1108' => Mage::helper('paypal')->__('Fee Reversal'), - 'T1110' => Mage::helper('paypal')->__('Hold for Dispute Investigation'), - 'T1111' => Mage::helper('paypal')->__('Reversal of hold for Dispute Investigation'), - 'T1200' => Mage::helper('paypal')->__('General: adjustment of a type not belonging to the other T12xx categories'), - 'T1201' => Mage::helper('paypal')->__('Chargeback'), - 'T1202' => Mage::helper('paypal')->__('Reversal'), - 'T1203' => Mage::helper('paypal')->__('Charge-off'), - 'T1204' => Mage::helper('paypal')->__('Incentive'), - 'T1205' => Mage::helper('paypal')->__('Reimbursement of Chargeback'), - 'T1300' => Mage::helper('paypal')->__('General (Authorization)'), - 'T1301' => Mage::helper('paypal')->__('Reauthorization'), - 'T1302' => Mage::helper('paypal')->__('Void'), - 'T1400' => Mage::helper('paypal')->__('General (Dividend)'), - 'T1500' => Mage::helper('paypal')->__('General: temporary hold of a type not belonging to the other T15xx categories'), - 'T1501' => Mage::helper('paypal')->__('Open Authorization'), - 'T1502' => Mage::helper('paypal')->__('ACH Deposit (Hold for Dispute or Other Investigation)'), - 'T1503' => Mage::helper('paypal')->__('Available Balance'), - 'T1600' => Mage::helper('paypal')->__('Funding'), - 'T1700' => Mage::helper('paypal')->__('General: Withdrawal to Non-Bank Entity'), - 'T1701' => Mage::helper('paypal')->__('WorldLink Withdrawal'), - 'T1800' => Mage::helper('paypal')->__('Buyer Credit Payment'), - 'T1900' => Mage::helper('paypal')->__('General Adjustment without businessrelated event'), - 'T2000' => Mage::helper('paypal')->__('General (Funds Transfer from PayPal Account to Another)'), - 'T2001' => Mage::helper('paypal')->__('Settlement Consolidation'), - 'T9900' => Mage::helper('paypal')->__('General: event not yet categorized'), - ]; - asort(self::$_eventList); - } - } -} diff --git a/app/code/core/Mage/Paypal/Model/Resource/Cert.php b/app/code/core/Mage/Paypal/Model/Resource/Cert.php deleted file mode 100644 index 83683eb6816..00000000000 --- a/app/code/core/Mage/Paypal/Model/Resource/Cert.php +++ /dev/null @@ -1,59 +0,0 @@ -_init('paypal/cert', 'cert_id'); - } - - /** - * Set date of last update - * - * @return Mage_Core_Model_Resource_Db_Abstract - */ - protected function _beforeSave(Mage_Core_Model_Abstract $object) - { - $object->setUpdatedAt($this->formatDate(Mage::getSingleton('core/date')->gmtDate())); - return parent::_beforeSave($object); - } - - /** - * Load model by website id - * - * @param Mage_Paypal_Model_Cert $object - * @param bool $strictLoad - * @return Mage_Paypal_Model_Cert - */ - public function loadByWebsite($object, $strictLoad = true) - { - $adapter = $this->_getReadAdapter(); - $select = $adapter->select()->from(['main_table' => $this->getMainTable()]); - - if ($strictLoad) { - $select->where('main_table.website_id =?', $object->getWebsiteId()); - } else { - $select->where('main_table.website_id IN(0, ?)', $object->getWebsiteId()) - ->order('main_table.website_id DESC') - ->limit(1); - } - - $data = $adapter->fetchRow($select); - if ($data) { - $object->setData($data); - } - return $object; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Resource/Debug.php b/app/code/core/Mage/Paypal/Model/Resource/Debug.php new file mode 100644 index 00000000000..fed1894fba0 --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Resource/Debug.php @@ -0,0 +1,9 @@ +_init('paypal/debug', 'entity_id'); + } + +} diff --git a/app/code/core/Mage/Paypal/Model/Resource/Debug/Collection.php b/app/code/core/Mage/Paypal/Model/Resource/Debug/Collection.php new file mode 100644 index 00000000000..02d2998e71e --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Resource/Debug/Collection.php @@ -0,0 +1,69 @@ +_init('paypal/debug'); + } + + /** + * Add filter by quote ID + * + * @param int $quoteId + * @return $this + */ + public function addQuoteIdFilter($quoteId) + { + $this->addFieldToFilter('quote_id', $quoteId); + return $this; + } + + /** + * Add filter by transaction ID + * + * @param string $transactionId + * @return $this + */ + public function addTransactionIdFilter($transactionId) + { + $this->addFieldToFilter('transaction_id', $transactionId); + return $this; + } + + /** + * Add filter by action + * + * @param string $action + * @return $this + */ + public function addActionFilter($action) + { + $this->addFieldToFilter('action', $action); + return $this; + } + + /** + * Add date range filter + * + * @param string $from + * @param string $to + * @return $this + */ + public function addDateRangeFilter($from, $to) + { + if ($from) { + $this->addFieldToFilter('created_at', ['gteq' => $from]); + } + if ($to) { + $this->addFieldToFilter('created_at', ['lteq' => $to]); + } + return $this; + } + + protected function _initSelect() + { + parent::_initSelect(); + $this->getSelect()->order('created_at DESC'); + return $this; + } +} diff --git a/app/code/core/Mage/Paypal/Model/Resource/Payment/Transaction.php b/app/code/core/Mage/Paypal/Model/Resource/Payment/Transaction.php deleted file mode 100644 index 86cee095adc..00000000000 --- a/app/code/core/Mage/Paypal/Model/Resource/Payment/Transaction.php +++ /dev/null @@ -1,122 +0,0 @@ - [null, []], - ]; - - /** - * Initialize main table and the primary key field name - * - */ - protected function _construct() - { - $this->_init('paypal/payment_transaction', 'transaction_id'); - } - - /** - * @see Mage_Core_Model_Resource_Abstract::_unserializeField() - */ - protected function _unserializeField(Varien_Object $object, $field, $defaultValue = null) - { - $value = $object->getData($field); - if (empty($value)) { - $object->setData($field, $defaultValue); - } elseif (!is_array($value) && !is_object($value)) { - $unserializedValue = false; - try { - $unserializedValue = Mage::helper('core/unserializeArray') - ->unserialize($value); - } catch (Exception $e) { - Mage::logException($e); - } - $object->setData($field, $unserializedValue); - } - } - - /** - * Load the transaction object by specified txn_id - * - * @param string $txnId - */ - public function loadObjectByTxnId(Mage_Paypal_Model_Payment_Transaction $transaction, $txnId) - { - $select = $this->_getLoadByUniqueKeySelect($txnId); - $data = $this->_getWriteAdapter()->fetchRow($select); - $transaction->setData($data); - $this->unserializeFields($transaction); - $this->_afterLoad($transaction); - } - - /** - * Serialize additional information, if any - * - * @param Mage_Paypal_Model_Payment_Transaction $transaction - * @return $this - */ - protected function _beforeSave(Mage_Core_Model_Abstract $transaction) - { - $txnId = $transaction->getData('txn_id'); - $idFieldName = $this->getIdFieldName(); - - // make sure unique key won't cause trouble - if ($transaction->isFailsafe()) { - $autoincrementId = (int) $this->_lookupByTxnId($txnId, $idFieldName); - if ($autoincrementId) { - $transaction->setData($idFieldName, $autoincrementId)->isObjectNew(false); - } - } - - return parent::_beforeSave($transaction); - } - - /** - * Load cell/row by specified unique key parts - * - * @param string $txnId - * @param array|string|object $columns - * @param bool $isRow - * @return array|string - */ - private function _lookupByTxnId($txnId, $columns, $isRow = false) - { - $select = $this->_getLoadByUniqueKeySelect($txnId, $columns); - if ($isRow) { - return $this->_getWriteAdapter()->fetchRow($select); - } - return $this->_getWriteAdapter()->fetchOne($select); - } - - /** - * Get select object for loading transaction by the unique key of order_id, payment_id, txn_id - * - * @param string $txnId - * @param string|array|Zend_Db_Expr $columns - * @return Varien_Db_Select - */ - private function _getLoadByUniqueKeySelect($txnId, $columns = '*') - { - return $this->_getWriteAdapter()->select() - ->from($this->getMainTable(), $columns) - ->where('txn_id = ?', $txnId); - } -} diff --git a/app/code/core/Mage/Paypal/Model/Resource/Payment/Transaction/Collection.php b/app/code/core/Mage/Paypal/Model/Resource/Payment/Transaction/Collection.php deleted file mode 100644 index 8c8cfb623e7..00000000000 --- a/app/code/core/Mage/Paypal/Model/Resource/Payment/Transaction/Collection.php +++ /dev/null @@ -1,77 +0,0 @@ -_init('paypal/payment_transaction'); - parent::_construct(); - } - - /** - * CreatedAt filter setter - * - * @param string $date - * @return $this - */ - public function addCreatedBeforeFilter($date) - { - $this->_createdBefore = $date; - return $this; - } - - /** - * Prepare filters - * - * @return $this - */ - protected function _beforeLoad() - { - parent::_beforeLoad(); - - if ($this->isLoaded()) { - return $this; - } - - // filters - if ($this->_createdBefore) { - $this->getSelect()->where('main_table.created_at < ?', $this->_createdBefore); - } - return $this; - } - - /** - * Unserialize additional_information in each item - * - * @return $this - */ - protected function _afterLoad() - { - foreach ($this->_items as $item) { - $this->getResource()->unserializeFields($item); - } - return parent::_afterLoad(); - } -} diff --git a/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement.php b/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement.php deleted file mode 100644 index ccdbfde4ab1..00000000000 --- a/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement.php +++ /dev/null @@ -1,105 +0,0 @@ -_init('paypal/settlement_report', 'report_id'); - $this->_rowsTable = $this->getTable('paypal/settlement_report_row'); - } - - /** - * Save report rows collected in settlement model - * - * @param Mage_Paypal_Model_Report_Settlement $object - * @return $this - */ - protected function _afterSave(Mage_Core_Model_Abstract $object) - { - $rows = $object->getRows(); - if (is_array($rows)) { - $adapter = $this->_getWriteAdapter(); - $reportId = (int) $object->getId(); - $adapter->beginTransaction(); - try { - if ($reportId) { - $adapter->delete($this->_rowsTable, ['report_id = ?' => $reportId]); - } - /** @var Mage_Core_Model_Date $date */ - $date = Mage::getSingleton('core/date'); - - foreach (array_keys($rows) as $key) { - /* - * Converting dates - */ - $completionDate = new Zend_Date($rows[$key]['transaction_completion_date']); - $rows[$key]['transaction_completion_date'] = $date->date(null, $completionDate->getTimestamp()); - $initiationDate = new Zend_Date($rows[$key]['transaction_initiation_date']); - $rows[$key]['transaction_initiation_date'] = $date->date(null, $initiationDate->getTimestamp()); - /* - * Converting numeric - */ - $rows[$key]['fee_amount'] = (float) $rows[$key]['fee_amount']; - /* - * Setting reportId - */ - $rows[$key]['report_id'] = $reportId; - } - if (!empty($rows)) { - $adapter->insertMultiple($this->_rowsTable, $rows); - } - $adapter->commit(); - } catch (Exception $e) { - $adapter->rollBack(); - } - } - - return $this; - } - - /** - * Check if report with same account and report date already fetched - * - * @param string $accountId - * @param string $reportDate - * @return $this - */ - public function loadByAccountAndDate(Mage_Paypal_Model_Report_Settlement $report, $accountId, $reportDate) - { - $adapter = $this->_getReadAdapter(); - $select = $adapter->select() - ->from($this->getMainTable()) - ->where('account_id = :account_id') - ->where('report_date = :report_date'); - - $data = $adapter->fetchRow($select, [':account_id' => $accountId, ':report_date' => $reportDate]); - if ($data) { - $report->addData($data); - } - - return $this; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement/Row.php b/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement/Row.php deleted file mode 100644 index 5fefce9516d..00000000000 --- a/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement/Row.php +++ /dev/null @@ -1,21 +0,0 @@ -_init('paypal/settlement_report_row', 'row_id'); - } -} diff --git a/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement/Row/Collection.php b/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement/Row/Collection.php deleted file mode 100644 index 319884af038..00000000000 --- a/app/code/core/Mage/Paypal/Model/Resource/Report/Settlement/Row/Collection.php +++ /dev/null @@ -1,54 +0,0 @@ -_init('paypal/report_settlement_row'); - } - - /** - * Join reports info table - * - * @return $this - */ - protected function _initSelect() - { - parent::_initSelect(); - $this->getSelect() - ->join( - ['report' => $this->getTable('paypal/settlement_report')], - 'report.report_id = main_table.report_id', - ['report.account_id', 'report.report_date'], - ); - return $this; - } - - /** - * Filter items collection by account ID - * - * @param string $accountId - * @return $this - */ - public function addAccountFilter($accountId) - { - $this->getSelect()->where('report.account_id = ?', $accountId); - return $this; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Resource/Setup.php b/app/code/core/Mage/Paypal/Model/Resource/Setup.php index b880552d0c9..a9059182633 100644 --- a/app/code/core/Mage/Paypal/Model/Resource/Setup.php +++ b/app/code/core/Mage/Paypal/Model/Resource/Setup.php @@ -12,4 +12,4 @@ * * @package Mage_Paypal */ -class Mage_Paypal_Model_Resource_Setup extends Mage_Sales_Model_Resource_Setup {} +class Mage_Paypal_Model_Resource_Setup extends Mage_Sales_Model_Resource_Setup {} \ No newline at end of file diff --git a/app/code/core/Mage/Paypal/Model/Session.php b/app/code/core/Mage/Paypal/Model/Session.php deleted file mode 100644 index fe44973935a..00000000000 --- a/app/code/core/Mage/Paypal/Model/Session.php +++ /dev/null @@ -1,22 +0,0 @@ -init('paypal'); - } -} diff --git a/app/code/core/Mage/Paypal/Model/Standard.php b/app/code/core/Mage/Paypal/Model/Standard.php deleted file mode 100644 index b19f21c9bd5..00000000000 --- a/app/code/core/Mage/Paypal/Model/Standard.php +++ /dev/null @@ -1,199 +0,0 @@ -getConfig()->isCurrencyCodeSupported($currencyCode); - } - - /** - * Get paypal session namespace - * - * @return Mage_Paypal_Model_Session - */ - public function getSession() - { - return Mage::getSingleton('paypal/session'); - } - - /** - * Get checkout session namespace - * - * @return Mage_Checkout_Model_Session - */ - public function getCheckout() - { - return Mage::getSingleton('checkout/session'); - } - - /** - * Get current quote - * - * @return Mage_Sales_Model_Quote - */ - public function getQuote() - { - return $this->getCheckout()->getQuote(); - } - - /** - * Create main block for standard form - * - */ - public function createFormBlock($name) - { - return $this->getLayout()->createBlock('paypal/standard_form', $name) - ->setMethod('paypal_standard') - ->setPayment($this->getPayment()) - ->setTemplate('paypal/standard/form.phtml'); - } - - /** - * Return Order place redirect url - * - * @return string - */ - public function getOrderPlaceRedirectUrl() - { - return Mage::getUrl('paypal/standard/redirect', ['_secure' => true]); - } - - /** - * Return form field array - * - * @return array - */ - public function getStandardCheckoutFormFields() - { - $orderIncrementId = $this->getCheckout()->getLastRealOrderId(); - $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId); - /** @var Mage_Paypal_Model_Api_Standard $api */ - $api = Mage::getModel('paypal/api_standard')->setConfigObject($this->getConfig()); - $api->setOrderId($orderIncrementId) - ->setCurrencyCode($order->getBaseCurrencyCode()) - //->setPaymentAction() - ->setOrder($order) - ->setNotifyUrl(Mage::getUrl('paypal/ipn/')) - ->setReturnUrl(Mage::getUrl('paypal/standard/success')) - ->setCancelUrl(Mage::getUrl('paypal/standard/cancel')); - - // export address - $isOrderVirtual = $order->getIsVirtual(); - $address = $isOrderVirtual ? $order->getBillingAddress() : $order->getShippingAddress(); - if ($isOrderVirtual) { - $api->setNoShipping(true); - } elseif ($address->validate()) { - $api->setAddress($address); - } - - // add cart totals and line items - $api->setPaypalCart(Mage::getModel('paypal/cart', [$order])) - ->setIsLineItemsEnabled($this->_config->lineItemsEnabled) - ; - $api->setCartSummary($this->_getAggregatedCartSummary()); - $api->setLocale($api->getLocaleCode()); - return $api->getStandardCheckoutRequest(); - } - - /** - * Instantiate state and set it to state object - * @param string $paymentAction - * @param Varien_Object $stateObject - */ - public function initialize($paymentAction, $stateObject) - { - $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT; - $stateObject->setState($state); - $stateObject->setStatus('pending_payment'); - $stateObject->setIsNotified(false); - - return $this; - } - - /** - * Config instance getter - * @return Mage_Paypal_Model_Config - */ - public function getConfig() - { - if ($this->_config === null) { - $params = [$this->_code]; - if ($store = $this->getStore()) { - $params[] = is_object($store) ? $store->getId() : $store; - } - $this->_config = Mage::getModel('paypal/config', $params); - } - return $this->_config; - } - - /** - * Check whether payment method can be used - * @param Mage_Sales_Model_Quote|null $quote - * @return bool - */ - public function isAvailable($quote = null) - { - if (parent::isAvailable($quote) && $this->getConfig()->isMethodAvailable()) { - return true; - } - return false; - } - - /** - * Custom getter for payment configuration - * - * @param string $field - * @param int $storeId - * @return mixed - */ - public function getConfigData($field, $storeId = null) - { - return $this->getConfig()->$field; - } - - /** - * Aggregated cart summary label getter - * - * @return string - */ - private function _getAggregatedCartSummary() - { - if ($this->_config->lineItemsSummary) { - return $this->_config->lineItemsSummary; - } - return Mage::app()->getStore($this->getStore())->getFrontendName(); - } -} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Backend/Cert.php b/app/code/core/Mage/Paypal/Model/System/Config/Backend/Cert.php deleted file mode 100644 index 77f41272544..00000000000 --- a/app/code/core/Mage/Paypal/Model/System/Config/Backend/Cert.php +++ /dev/null @@ -1,58 +0,0 @@ -getValue(); - if (is_array($value) && !empty($value['delete'])) { - $this->setValue(''); - Mage::getModel('paypal/cert')->loadByWebsite($this->getScopeId())->delete(); - } - - if (!isset($_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value'])) { - return $this; - } - $tmpPath = $_FILES['groups']['tmp_name'][$this->getGroupId()]['fields'][$this->getField()]['value']; - if ($tmpPath && file_exists($tmpPath)) { - if (!filesize($tmpPath)) { - Mage::throwException(Mage::helper('paypal')->__('PayPal certificate file is empty.')); - } - $this->setValue($_FILES['groups']['name'][$this->getGroupId()]['fields'][$this->getField()]['value']); - $content = Mage::helper('core')->encrypt(file_get_contents($tmpPath)); - Mage::getModel('paypal/cert')->loadByWebsite($this->getScopeId()) - ->setContent($content) - ->save(); - } - return $this; - } - - /** - * Process object after delete data - * - * @return $this - */ - protected function _afterDelete() - { - Mage::getModel('paypal/cert')->loadByWebsite($this->getScopeId())->delete(); - return $this; - } -} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Backend/Cron.php b/app/code/core/Mage/Paypal/Model/System/Config/Backend/Cron.php deleted file mode 100644 index 685bf8b4daf..00000000000 --- a/app/code/core/Mage/Paypal/Model/System/Config/Backend/Cron.php +++ /dev/null @@ -1,40 +0,0 @@ -load('paypal/fetch_reports/time', 'path')->getValue()); - if (Mage::getModel('core/config_data')->load('paypal/fetch_reports/active', 'path')->getValue()) { - $interval = Mage::getModel('core/config_data')->load(self::CRON_MODEL_PATH_INTERVAL, 'path')->getValue(); - $cronExprString = "{$time[1]} {$time[0]} */{$interval} * *"; - } - - Mage::getModel('core/config_data') - ->load(self::CRON_STRING_PATH, 'path') - ->setValue($cronExprString) - ->setPath(self::CRON_STRING_PATH) - ->save(); - - return parent::_afterSave(); - } -} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Backend/MerchantCountry.php b/app/code/core/Mage/Paypal/Model/System/Config/Backend/MerchantCountry.php index 08ee4a80092..31dc76299a1 100644 --- a/app/code/core/Mage/Paypal/Model/System/Config/Backend/MerchantCountry.php +++ b/app/code/core/Mage/Paypal/Model/System/Config/Backend/MerchantCountry.php @@ -1,42 +1,12 @@ getValue(); - if (empty($value)) { - if ($this->getWebsite()) { - $defaultCountry = Mage::app()->getWebsite($this->getWebsite()) - ->getConfig(Mage_Core_Helper_Data::XML_PATH_DEFAULT_COUNTRY); - } else { - $defaultCountry = Mage::helper('core')->getDefaultCountry($this->getStore()); - } - $this->setValue($defaultCountry); + $value = $this->getValue(); + if (!$value) { + $this->setValue(Mage::getStoreConfig('general/country/default')); } - return $this; + return parent::_beforeSave(); } -} +} \ No newline at end of file diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/AuthorizationAmounts.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/AuthorizationAmounts.php deleted file mode 100644 index 8140ca5d62f..00000000000 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/AuthorizationAmounts.php +++ /dev/null @@ -1,27 +0,0 @@ - Mage::helper('paypal')->__('Header (center)'), - '1' => Mage::helper('paypal')->__('Sidebar (right)'), - ]; - } - - /** - * Bml positions source getter for Catalog Category Page - * - * @return array - */ - public function getBmlPositionsCCP() - { - return [ - '0' => Mage::helper('paypal')->__('Header (center)'), - '1' => Mage::helper('paypal')->__('Sidebar (right)'), - ]; - } - - /** - * Bml positions source getter for Catalog Product Page - * - * @return array - */ - public function getBmlPositionsCPP() - { - return [ - '0' => Mage::helper('paypal')->__('Header (center)'), - '1' => Mage::helper('paypal')->__('Near Paypal Credit checkout button'), - ]; - } - - /** - * Bml positions source getter for Checkout Cart Page - * - * @return array - */ - public function getBmlPositionsCheckout() - { - return [ - '0' => Mage::helper('paypal')->__('Header (center)'), - '1' => Mage::helper('paypal')->__('Near Paypal Credit checkout button'), - ]; - } -} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/BmlSize.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/BmlSize.php deleted file mode 100644 index 4fca9430925..00000000000 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/BmlSize.php +++ /dev/null @@ -1,151 +0,0 @@ - Mage::helper('paypal')->__('190 x 100'), - '234x60' => Mage::helper('paypal')->__('234 x 60'), - '300x50' => Mage::helper('paypal')->__('300 x 50'), - '468x60' => Mage::helper('paypal')->__('468 x 60'), - '728x90' => Mage::helper('paypal')->__('728 x 90'), - '800x66' => Mage::helper('paypal')->__('800 x 66'), - ]; - } - - /** - * Options getter for Home Page and position Sidebar (right) - * - * @return array - */ - public function getBmlSizeHPS() - { - return [ - '120x90' => Mage::helper('paypal')->__('120 x 90'), - '190x100' => Mage::helper('paypal')->__('190 x 100'), - '234x60' => Mage::helper('paypal')->__('234 x 60'), - '120x240' => Mage::helper('paypal')->__('120 x 240'), - '120x600' => Mage::helper('paypal')->__('120 x 600'), - '234x400' => Mage::helper('paypal')->__('234 x 400'), - '250x250' => Mage::helper('paypal')->__('250 x 250'), - ]; - } - - /** - * Options getter for Catalog Category Page and position Center - * - * @return array - */ - public function getBmlSizeCCPC() - { - return [ - '190x100' => Mage::helper('paypal')->__('190 x 100'), - '234x60' => Mage::helper('paypal')->__('234 x 60'), - '300x50' => Mage::helper('paypal')->__('300 x 50'), - '468x60' => Mage::helper('paypal')->__('468 x 60'), - '728x90' => Mage::helper('paypal')->__('728 x 90'), - '800x66' => Mage::helper('paypal')->__('800 x 66'), - ]; - } - - /** - * Options getter for Catalog Category Page and position Sidebar (right) - * - * @return array - */ - public function getBmlSizeCCPS() - { - return [ - '120x90' => Mage::helper('paypal')->__('120 x 90'), - '190x100' => Mage::helper('paypal')->__('190 x 100'), - '234x60' => Mage::helper('paypal')->__('234 x 60'), - '120x240' => Mage::helper('paypal')->__('120 x 240'), - '120x600' => Mage::helper('paypal')->__('120 x 600'), - '234x400' => Mage::helper('paypal')->__('234 x 400'), - '250x250' => Mage::helper('paypal')->__('250 x 250'), - ]; - } - - /** - * Options getter for Catalog Product Page and position Center - * - * @return array - */ - public function getBmlSizeCPPC() - { - return [ - '190x100' => Mage::helper('paypal')->__('190 x 100'), - '234x60' => Mage::helper('paypal')->__('234 x 60'), - '300x50' => Mage::helper('paypal')->__('300 x 50'), - '468x60' => Mage::helper('paypal')->__('468 x 60'), - '728x90' => Mage::helper('paypal')->__('728 x 90'), - '800x66' => Mage::helper('paypal')->__('800 x 66'), - ]; - } - - /** - * Options getter for Catalog Product Page and position Near Bill Me Later checkout button - * - * @return array - */ - public function getBmlSizeCPPN() - { - return [ - '120x90' => Mage::helper('paypal')->__('120 x 90'), - '190x100' => Mage::helper('paypal')->__('190 x 100'), - '234x60' => Mage::helper('paypal')->__('234 x 60'), - '120x240' => Mage::helper('paypal')->__('120 x 240'), - '120x600' => Mage::helper('paypal')->__('120 x 600'), - '234x400' => Mage::helper('paypal')->__('234 x 400'), - '250x250' => Mage::helper('paypal')->__('250 x 250'), - ]; - } - - /** - * Options getter for Checkout Cart Page and position Center - * - * @return array - */ - public function getBmlSizeCheckoutC() - { - return [ - '234x60' => Mage::helper('paypal')->__('234 x 60'), - '300x50' => Mage::helper('paypal')->__('300 x 50'), - '468x60' => Mage::helper('paypal')->__('468 x 60'), - '728x90' => Mage::helper('paypal')->__('728 x 90'), - '800x66' => Mage::helper('paypal')->__('800 x 66'), - ]; - } - - /** - * Options getter for Checkout Cart Page and position Near Bill Me Later checkout button - * - * @return array - */ - public function getBmlSizeCheckoutN() - { - return [ - '234x60' => Mage::helper('paypal')->__('234 x 60'), - '300x50' => Mage::helper('paypal')->__('300 x 50'), - '468x60' => Mage::helper('paypal')->__('468 x 60'), - ]; - } -} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonColors.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonColors.php new file mode 100644 index 00000000000..522d627a55a --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonColors.php @@ -0,0 +1,29 @@ + Mage_Paypal_Model_Config::BUTTON_COLOR_GOLD, + 'label' => Mage::helper('paypal')->__('Gold') + ], + [ + 'value' => Mage_Paypal_Model_Config::BUTTON_COLOR_BLUE, + 'label' => Mage::helper('paypal')->__('Blue') + ], + [ + 'value' => Mage_Paypal_Model_Config::BUTTON_COLOR_SILVER, + 'label' => Mage::helper('paypal')->__('Silver') + ], + [ + 'value' => Mage_Paypal_Model_Config::BUTTON_COLOR_WHITE, + 'label' => Mage::helper('paypal')->__('White') + ], + [ + 'value' => Mage_Paypal_Model_Config::BUTTON_COLOR_BLACK, + 'label' => Mage::helper('paypal')->__('Black') + ] + ]; + } +} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLabels.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLabels.php new file mode 100644 index 00000000000..137e3d32774 --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLabels.php @@ -0,0 +1,29 @@ + Mage_Paypal_Model_Config::BUTTON_LABEL_PAYPAL, + 'label' => Mage::helper('paypal')->__('PayPal (Recommended)') + ], + [ + 'value' => Mage_Paypal_Model_Config::BUTTON_LABEL_CHECKOUT, + 'label' => Mage::helper('paypal')->__('Checkout') + ], + [ + 'value' => Mage_Paypal_Model_Config::BUTTON_LABEL_BUYNOW, + 'label' => Mage::helper('paypal')->__('Buy Now') + ], + [ + 'value' => Mage_Paypal_Model_Config::BUTTON_LABEL_PAY, + 'label' => Mage::helper('paypal')->__('Pay with PayPal') + ], + [ + 'value' => Mage_Paypal_Model_Config::BUTTON_LABEL_INSTALLMENT, + 'label' => Mage::helper('paypal')->__('PayPal Installment') + ] + ]; + } +} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLayouts.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLayouts.php new file mode 100644 index 00000000000..25279a39498 --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLayouts.php @@ -0,0 +1,17 @@ + Mage_Paypal_Model_Config::BUTTON_LAYOUT_VERTICAL, + 'label' => Mage::helper('paypal')->__('Vertical') + ], + [ + 'value' => Mage_Paypal_Model_Config::BUTTON_LAYOUT_HORIZONTAL, + 'label' => Mage::helper('paypal')->__('Horizontal') + ] + ]; + } +} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonShapes.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonShapes.php new file mode 100644 index 00000000000..f23fb08f50a --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonShapes.php @@ -0,0 +1,21 @@ + Mage_Paypal_Model_Config::BUTTON_SHAPE_RECT, + 'label' => Mage::helper('paypal')->__('Rectangle') + ], + [ + 'value' => Mage_Paypal_Model_Config::BUTTON_SHAPE_PILL, + 'label' => Mage::helper('paypal')->__('Pill') + ], + [ + 'value' => Mage_Paypal_Model_Config::BUTTON_SHAPE_SHARP, + 'label' => Mage::helper('paypal')->__('Sharp') + ] + ]; + } +} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/BuyerCountry.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/BuyerCountry.php deleted file mode 100644 index 7066b47e52a..00000000000 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/BuyerCountry.php +++ /dev/null @@ -1,25 +0,0 @@ -getSupportedBuyerCountryCodes(); - return Mage::getResourceModel('directory/country_collection') - ->addCountryCodeFilter($supported, 'iso2') - ->loadData() - ->toOptionArray($isMultiselect ? false : Mage::helper('adminhtml')->__('--Please Select--')); - } -} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/FetchingSchedule.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/FetchingSchedule.php deleted file mode 100644 index 83ddd18c4a0..00000000000 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/FetchingSchedule.php +++ /dev/null @@ -1,29 +0,0 @@ - Mage::helper('paypal')->__('Daily'), - 3 => Mage::helper('paypal')->__('Every 3 days'), - 7 => Mage::helper('paypal')->__('Every 7 days'), - 10 => Mage::helper('paypal')->__('Every 10 days'), - 14 => Mage::helper('paypal')->__('Every 14 days'), - 30 => Mage::helper('paypal')->__('Every 30 days'), - 40 => Mage::helper('paypal')->__('Every 40 days'), - ]; - } -} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/Logo.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/Logo.php deleted file mode 100644 index 32e94224fd9..00000000000 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/Logo.php +++ /dev/null @@ -1,22 +0,0 @@ - Mage::helper('paypal')->__('No Logo')]; - return $result + Mage::getModel('paypal/config')->getAdditionalOptionsLogoTypes(); - } -} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php index 93fea12a7fe..e4a7385b3ab 100644 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php @@ -1,25 +1,66 @@ getSupportedMerchantCountryCodes(); - return Mage::getResourceModel('directory/country_collection') - ->addCountryCodeFilter($supported, 'iso2') - ->loadData() - ->toOptionArray($isMultiselect ? false : Mage::helper('adminhtml')->__('--Please Select--')); + $countries = Mage::getSingleton('adminhtml/system_config_source_country') + ->toOptionArray(false); + + // Filter to only PayPal supported countries + $supportedCountries = [ + 'AU', // Australia + 'AT', // Austria + 'BE', // Belgium + 'BR', // Brazil + 'CA', // Canada + 'CN', // China + 'CZ', // Czech Republic + 'DK', // Denmark + 'FI', // Finland + 'FR', // France + 'DE', // Germany + 'GR', // Greece + 'HK', // Hong Kong + 'HU', // Hungary + 'IN', // India + 'ID', // Indonesia + 'IE', // Ireland + 'IL', // Israel + 'IT', // Italy + 'JP', // Japan + 'LU', // Luxembourg + 'MY', // Malaysia + 'MX', // Mexico + 'NL', // Netherlands + 'NZ', // New Zealand + 'NO', // Norway + 'PH', // Philippines + 'PL', // Poland + 'PT', // Portugal + 'RU', // Russia + 'SG', // Singapore + 'SK', // Slovakia + 'KR', // South Korea + 'ES', // Spain + 'SE', // Sweden + 'CH', // Switzerland + 'TW', // Taiwan + 'TH', // Thailand + 'TR', // Turkey + 'AE', // United Arab Emirates + 'GB', // United Kingdom + 'US', // United States + 'VN', // Vietnam + ]; + + return array_filter($countries, function($country) use ($supportedCountries) { + return in_array($country['value'], $supportedCountries); + }); } -} +} \ No newline at end of file diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions.php index 4c52c4dbd7c..e1513abf105 100644 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions.php +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions.php @@ -1,25 +1,21 @@ getPaymentActions(); + return [ + [ + 'value' => strtolower(CheckoutPaymentIntent::AUTHORIZE), + 'label' => Mage::helper('paypal')->__('Authorize') + ], + [ + 'value' => strtolower(CheckoutPaymentIntent::CAPTURE), + 'label' => Mage::helper('paypal')->__('Capture') + ] + ]; } } diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions/Express.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions/Express.php deleted file mode 100644 index e76fe4c6830..00000000000 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions/Express.php +++ /dev/null @@ -1,26 +0,0 @@ -setMethod(Mage_Paypal_Model_Config::METHOD_WPP_EXPRESS); - return $configModel->getPaymentActions(); - } -} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/RequireBillingAddress.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/RequireBillingAddress.php deleted file mode 100644 index 325226316e6..00000000000 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/RequireBillingAddress.php +++ /dev/null @@ -1,28 +0,0 @@ -getRequireBillingAddressOptions(); - } -} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/UrlMethod.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/UrlMethod.php deleted file mode 100644 index 3ce0cb9f03f..00000000000 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/UrlMethod.php +++ /dev/null @@ -1,27 +0,0 @@ - 'GET', 'label' => 'GET'], - ['value' => 'POST', 'label' => 'POST'], - ]; - } -} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/YesnoShortcut.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/YesnoShortcut.php deleted file mode 100644 index df9aac37252..00000000000 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/YesnoShortcut.php +++ /dev/null @@ -1,27 +0,0 @@ - 1, 'label' => Mage::helper('paypal')->__('Yes (PayPal recommends this option)')], - ['value' => 0, 'label' => Mage::helper('paypal')->__('No')], - ]; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Validator/Api.php b/app/code/core/Mage/Paypal/Model/Validator/Api.php new file mode 100644 index 00000000000..5ca6ffab140 --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Validator/Api.php @@ -0,0 +1,28 @@ +isSuccess()) { + $message = 'PayPal API Error: ' . $response->getError(); + Mage::log($message, Zend_Log::ERR, 'paypal.log', true); + + if (Mage::getStoreConfigFlag('payment/paypal/debug')) { + $quote = $order->getQuote(); + $quoteId = $quote ? $quote->getId() : $order->getQuoteId(); + + Mage::getModel('paypal/debug')->log( + $quoteId, + 'validation_error', + 'Validation Error', + $response->getError(), + null, + null + ); + } + + throw new Mage_Paypal_Model_Exception($message); + } + return true; + } +} diff --git a/app/code/core/Mage/Paypal/Model/Validator/Payment.php b/app/code/core/Mage/Paypal/Model/Validator/Payment.php new file mode 100644 index 00000000000..236448c5a43 --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Validator/Payment.php @@ -0,0 +1,69 @@ +_supportedCurrencies)) { + $message = sprintf('Currency "%s" is not supported by PayPal', $currencyCode); + Mage::log($message, Zend_Log::ERR, 'paypal.log', true); + throw new Mage_Paypal_Model_Exception($message); + } + return true; + } + + public function validateAmount($amount) + { + if ($amount <= 0) { + Mage::log('Invalid payment amount', Zend_Log::ERR, 'paypal.log', true); + throw new Mage_Paypal_Model_Exception('Invalid payment amount'); + } + return true; + } + + public function validateTotal($calculatedTotal, $orderTotal) + { + $epsilon = 0.00001; + if (abs($calculatedTotal - $orderTotal) > $epsilon) { + $message = 'Total amount mismatch'; + Mage::log($message . sprintf(' (calculated: %s, order: %s)', + $calculatedTotal, + $orderTotal + ), Zend_Log::ERR, 'paypal.log', true); + throw new Mage_Paypal_Model_Exception($message); + } + return true; + } +} diff --git a/app/code/core/Mage/Paypal/Model/Webhook/Log.php b/app/code/core/Mage/Paypal/Model/Webhook/Log.php new file mode 100644 index 00000000000..07084251417 --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Webhook/Log.php @@ -0,0 +1,20 @@ +_init('paypal/webhook_log'); + } + + /** + * Clean old log entries + * + * @param int $days Number of days to keep + * @return $this + */ + public function clean($days = 30) + { + $this->getResource()->clean($days); + return $this; + } +} \ No newline at end of file diff --git a/app/code/core/Mage/Paypal/UnavailableException.php b/app/code/core/Mage/Paypal/UnavailableException.php deleted file mode 100644 index cb61b23a2fb..00000000000 --- a/app/code/core/Mage/Paypal/UnavailableException.php +++ /dev/null @@ -1,13 +0,0 @@ -loadLayout() + ->_setActiveMenu('report/paypal/debug') + ->_addBreadcrumb( + Mage::helper('paypal')->__('Reports'), + Mage::helper('paypal')->__('PayPal Debug Log') + ); + return $this; + } + + public function indexAction() + { + $this->_initAction() + ->_addContent($this->getLayout()->createBlock('paypal/adminhtml_debug')) + ->renderLayout(); + } + + public function gridAction() + { + $this->loadLayout(); + $this->getResponse()->setBody( + $this->getLayout()->createBlock('paypal/adminhtml_debug_grid')->toHtml() + ); + } + + public function massDeleteAction() + { + $debugIds = $this->getRequest()->getParam('debug'); + if (!is_array($debugIds)) { + $this->_getSession()->addError($this->__('Please select log(s) to delete.')); + } else { + try { + foreach ($debugIds as $debugId) { + Mage::getModel('paypal/debug')->load($debugId)->delete(); + } + $this->_getSession()->addSuccess( + $this->__('Total of %d record(s) have been deleted.', count($debugIds)) + ); + } catch (Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } + } + $this->_redirect('*/*/index'); + } + + public function deleteAllAction() + { + try { + $collection = Mage::getModel('paypal/debug')->getCollection(); + foreach ($collection as $item) { + $item->delete(); + } + $this->_getSession()->addSuccess($this->__('All debug logs have been deleted.')); + } catch (Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } + $this->_redirect('*/*/index'); + } + + protected function _isAllowed() + { + return Mage::getSingleton('admin/session')->isAllowed('report/paypal/debug'); + } +} diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php deleted file mode 100644 index 69df8641ea3..00000000000 --- a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/ReportsController.php +++ /dev/null @@ -1,120 +0,0 @@ -_initAction() - ->_addContent($this->getLayout()->createBlock('paypal/adminhtml_settlement_report')) - ->renderLayout(); - } - - /** - * Ajax callback for grid actions - */ - public function gridAction() - { - $this->loadLayout(); - $this->getResponse()->setBody( - $this->getLayout()->createBlock('paypal/adminhtml_settlement_report_grid')->toHtml(), - ); - } - - /** - * View transaction details action - */ - public function detailsAction() - { - $rowId = $this->getRequest()->getParam('id'); - $row = Mage::getModel('paypal/report_settlement_row')->load($rowId); - if (!$row->getId()) { - $this->_redirect('*/*/'); - return; - } - Mage::register('current_transaction', $row); - $this->_initAction() - ->_title($this->__('View Transaction')) - ->_addContent($this->getLayout()->createBlock('paypal/adminhtml_settlement_details', 'settlementDetails')) - ->renderLayout(); - } - - /** - * Forced fetch reports action - */ - public function fetchAction() - { - try { - $reports = Mage::getModel('paypal/report_settlement'); - /** @var Mage_Paypal_Model_Report_Settlement $reports */ - $credentials = $reports->getSftpCredentials(); - if (empty($credentials)) { - Mage::throwException(Mage::helper('paypal')->__('Nothing to fetch because of an empty configuration.')); - } - foreach ($credentials as $config) { - try { - $fetched = $reports->fetchAndSave($config); - $this->_getSession()->addSuccess( - Mage::helper('paypal')->__("Fetched %s report rows from '%s@%s'.", $fetched, $config['username'], $config['hostname']), - ); - } catch (Exception $e) { - $this->_getSession()->addError( - Mage::helper('paypal')->__("Failed to fetch reports from '%s@%s'.", $config['username'], $config['hostname']), - ); - Mage::logException($e); - } - } - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - } catch (Exception $e) { - Mage::logException($e); - } - $this->_redirect('*/*/index'); - } - - /** - * Initialize titles, navigation - * @return $this - */ - protected function _initAction() - { - $this->_title($this->__('Reports'))->_title($this->__('Sales'))->_title($this->__('PayPal Settlement Reports')); - $this->loadLayout() - ->_setActiveMenu('report/salesroot/paypal_settlement_reports') - ->_addBreadcrumb(Mage::helper('paypal')->__('Reports'), Mage::helper('paypal')->__('Reports')) - ->_addBreadcrumb(Mage::helper('paypal')->__('Sales'), Mage::helper('paypal')->__('Sales')) - ->_addBreadcrumb(Mage::helper('paypal')->__('PayPal Settlement Reports'), Mage::helper('paypal')->__('PayPal Settlement Reports')); - return $this; - } - - /** - * @inheritDoc - */ - protected function _isAllowed() - { - $action = strtolower($this->getRequest()->getActionName()); - switch ($action) { - case 'index': - case 'details': - return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/paypal_settlement_reports/view'); - case 'fetch': - return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/paypal_settlement_reports/fetch'); - default: - return Mage::getSingleton('admin/session')->isAllowed('report/salesroot/paypal_settlement_reports'); - } - } -} diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php new file mode 100644 index 00000000000..7ba82da0dad --- /dev/null +++ b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php @@ -0,0 +1,89 @@ + + */ +class Mage_Paypal_Adminhtml_Paypal_TransactionController extends Mage_Adminhtml_Controller_Action +{ + /** + * Reauthorize a payment + */ + public function reauthorizeAction() + { + $orderId = $this->getRequest()->getParam('order_id'); + if (!$orderId) { + $this->_getSession()->addError($this->__('Order ID is required')); + $this->_redirect('*/sales_order/'); + return; + } + + try { + $order = Mage::getModel('sales/order')->load($orderId); + if (!$order->getId()) { + throw new Exception($this->__('Order not found')); + } + + $payment = $order->getPayment(); + if ($payment->getMethod() !== 'paypal') { + throw new Exception($this->__('This order was not placed using PayPal')); + } + + $authorizationId = $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID); + if (!$authorizationId) { + throw new Exception($this->__('This order does not have a PayPal authorization')); + } + + $paypalModel = Mage::getModel('paypal/paypal'); + $result = $paypalModel->reauthorizePayment($authorizationId, $order); + + if ($result['success']) { + $this->_getSession()->addSuccess($this->__('Payment has been successfully reauthorized. New authorization ID: %s', $result['authorization_id'])); + } else { + throw new Exception($result['error'] ?? $this->__('Failed to reauthorize payment')); + } + } catch (Exception $e) { + $this->_getSession()->addError($e->getMessage()); + } + + $this->_redirect('*/sales_order/view', ['order_id' => $orderId]); + } + + /** + * Check if the current user is allowed to access this controller + * + * @return bool + */ + protected function _isAllowed() + { + return true; + } +} diff --git a/app/code/core/Mage/Paypal/controllers/BmlController.php b/app/code/core/Mage/Paypal/controllers/BmlController.php deleted file mode 100644 index e4563fd3c05..00000000000 --- a/app/code/core/Mage/Paypal/controllers/BmlController.php +++ /dev/null @@ -1,27 +0,0 @@ -_forward('start', 'express', 'paypal', [ - 'bml' => 1, - 'button' => $this->getRequest()->getParam('button'), - ]); - } -} diff --git a/app/code/core/Mage/Paypal/controllers/ExpressController.php b/app/code/core/Mage/Paypal/controllers/ExpressController.php deleted file mode 100644 index f3572501839..00000000000 --- a/app/code/core/Mage/Paypal/controllers/ExpressController.php +++ /dev/null @@ -1,35 +0,0 @@ -_getCheckout(); - //TODO: some actions with order - if ($session->getLastRealOrderId()) { - $this->_redirect('checkout/onepage/success'); - } - } - - /** - * When a customer cancel payment from gateway. - */ - public function cancelAction() - { - $gotoSection = $this->_cancelPayment(); - $redirectBlock = $this->_getIframeBlock() - ->setGotoSection($gotoSection) - ->setTemplate('paypal/hss/redirect.phtml'); - //TODO: clarify return logic whether customer will be returned in iframe or in parent window - $this->getResponse()->setBody($redirectBlock->toHtml()); - } - - /** - * Cancel order, return quote to customer - * - * @param string $errorMsg - * @return false|string - */ - protected function _cancelPayment($errorMsg = '') - { - $gotoSection = false; - /** @var Mage_Paypal_Helper_Checkout $helper */ - $helper = Mage::helper('paypal/checkout'); - $helper->cancelCurrentOrder($errorMsg); - if ($helper->restoreQuote()) { - $gotoSection = 'payment'; - } - return $gotoSection; - } - - /** - * Get frontend checkout session object - * - * @return Mage_Checkout_Model_Session - */ - protected function _getCheckout() - { - return Mage::getSingleton('checkout/session'); - } - - /** - * Get iframe block - * - * @return Mage_Paypal_Block_Hosted_Pro_Iframe - */ - protected function _getIframeBlock() - { - $this->loadLayout('paypal_hosted_pro_iframe'); - /** @var Mage_Paypal_Block_Hosted_Pro_Iframe $block */ - $block = $this->getLayout()->getBlock('hosted.pro.iframe'); - return $block; - } -} diff --git a/app/code/core/Mage/Paypal/controllers/IpnController.php b/app/code/core/Mage/Paypal/controllers/IpnController.php deleted file mode 100644 index bacb5ece04b..00000000000 --- a/app/code/core/Mage/Paypal/controllers/IpnController.php +++ /dev/null @@ -1,40 +0,0 @@ -getRequest()->isPost()) { - return; - } - - try { - $data = $this->getRequest()->getPost(); - Mage::getModel('paypal/ipn')->processIpnRequest($data, new Varien_Http_Adapter_Curl()); - } catch (Mage_Paypal_UnavailableException $e) { - Mage::logException($e); - $this->getResponse()->setHeader('HTTP/1.1', '503 Service Unavailable')->sendResponse(); - exit; - } catch (Exception $e) { - Mage::logException($e); - $this->getResponse()->setHttpResponseCode(500); - } - } -} diff --git a/app/code/core/Mage/Paypal/controllers/PayflowController.php b/app/code/core/Mage/Paypal/controllers/PayflowController.php deleted file mode 100644 index f97066bc67d..00000000000 --- a/app/code/core/Mage/Paypal/controllers/PayflowController.php +++ /dev/null @@ -1,132 +0,0 @@ -_cancelPayment(); - $redirectBlock = $this->_getIframeBlock() - ->setGotoSection($gotoSection) - ->setTemplate('paypal/payflowlink/redirect.phtml'); - $this->getResponse()->setBody($redirectBlock->toHtml()); - } - - /** - * When a customer return to website from payflow gateway. - */ - public function returnUrlAction() - { - $redirectBlock = $this->_getIframeBlock() - ->setTemplate('paypal/payflowlink/redirect.phtml'); - - $session = $this->_getCheckout(); - if ($session->getLastRealOrderId()) { - $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId()); - - if ($order && $order->getIncrementId() == $session->getLastRealOrderId()) { - $allowedOrderStates = [ - Mage_Sales_Model_Order::STATE_PROCESSING, - Mage_Sales_Model_Order::STATE_COMPLETE, - ]; - if (in_array($order->getState(), $allowedOrderStates)) { - $session->unsLastRealOrderId(); - $redirectBlock->setGotoSuccessPage(true); - } else { - $gotoSection = $this->_cancelPayment( - Mage::helper('core') - ->stripTags( - (string) $this->getRequest()->getParam('RESPMSG'), - ), - ); - $redirectBlock->setGotoSection($gotoSection); - $redirectBlock->setErrorMsg($this->__('Payment has been declined. Please try again.')); - } - } - } - - $this->getResponse()->setBody($redirectBlock->toHtml()); - } - - /** - * Submit transaction to Payflow getaway into iframe - */ - public function formAction() - { - $this->getResponse()->setHeader('P3P', 'CP="CAO PSA OUR"'); - $this->getResponse() - ->setBody($this->_getIframeBlock()->toHtml()); - } - - /** - * Get response from PayPal by silent post method - */ - public function silentPostAction() - { - $data = $this->getRequest()->getPost(); - if (isset($data['INVNUM'])) { - /** @var Mage_Paypal_Model_Payflowlink $paymentModel */ - $paymentModel = Mage::getModel('paypal/payflowlink'); - try { - $paymentModel->process($data); - } catch (Exception $e) { - Mage::logException($e); - } - } - } - - /** - * Cancel order, return quote to customer - * - * @param string $errorMsg - * @return false|string - */ - protected function _cancelPayment($errorMsg = '') - { - $gotoSection = false; - /** @var Mage_Paypal_Helper_Checkout $helper */ - $helper = Mage::helper('paypal/checkout'); - $helper->cancelCurrentOrder($errorMsg); - if ($helper->restoreQuote()) { - $gotoSection = 'payment'; - } - return $gotoSection; - } - - /** - * Get frontend checkout session object - * - * @return Mage_Checkout_Model_Session - */ - protected function _getCheckout() - { - return Mage::getSingleton('checkout/session'); - } - - /** - * Get iframe block - * - * @return Mage_Paypal_Block_Payflow_Link_Iframe - */ - protected function _getIframeBlock() - { - $this->loadLayout('paypal_payflow_link_iframe'); - /** @var Mage_Paypal_Block_Payflow_Link_Iframe $block */ - $block = $this->getLayout()->getBlock('payflow.link.iframe'); - return $block; - } -} diff --git a/app/code/core/Mage/Paypal/controllers/PayflowadvancedController.php b/app/code/core/Mage/Paypal/controllers/PayflowadvancedController.php deleted file mode 100644 index c1ae5cd2cf7..00000000000 --- a/app/code/core/Mage/Paypal/controllers/PayflowadvancedController.php +++ /dev/null @@ -1,152 +0,0 @@ -_cancelPayment(); - $redirectBlock = $this->_getIframeBlock() - ->setGotoSection($gotoSection) - ->setTemplate('paypal/payflowadvanced/redirect.phtml'); - $this->getResponse()->setBody($redirectBlock->toHtml()); - } - - /** - * When a customer return to website from payflow gateway. - */ - public function returnUrlAction() - { - $redirectBlock = $this->_getIframeBlock() - ->setTemplate('paypal/payflowadvanced/redirect.phtml'); - - $session = $this->_getCheckout(); - if ($session->getLastRealOrderId()) { - $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId()); - - if ($order && $order->getIncrementId() == $session->getLastRealOrderId()) { - $allowedOrderStates = [ - Mage_Sales_Model_Order::STATE_PROCESSING, - Mage_Sales_Model_Order::STATE_COMPLETE, - ]; - if (in_array($order->getState(), $allowedOrderStates)) { - $session->unsLastRealOrderId(); - $redirectBlock->setGotoSuccessPage(true); - } else { - $gotoSection = $this->_cancelPayment( - Mage::helper('core') - ->stripTags( - (string) $this->getRequest()->getParam('RESPMSG'), - ), - ); - $redirectBlock->setGotoSection($gotoSection); - $redirectBlock->setErrorMsg($this->__('Payment has been declined. Please try again.')); - } - } - } - - $this->getResponse()->setBody($redirectBlock->toHtml()); - } - - /** - * Submit transaction to Payflow getaway into iframe - */ - public function formAction() - { - $this->getResponse() - ->setBody($this->_getIframeBlock()->toHtml()); - } - - /** - * Get response from PayPal by silent post method - */ - public function silentPostAction() - { - $data = $this->getRequest()->getPost(); - if (isset($data['INVNUM'])) { - /** @var Mage_Paypal_Model_Payflowadvanced $paymentModel */ - $paymentModel = Mage::getModel('paypal/payflowadvanced'); - try { - $paymentModel->process($data); - } catch (Exception $e) { - Mage::logException($e); - } - } - } - - /** - * Cancel order, return quote to customer - * - * @param string $errorMsg - * @return bool|string - */ - protected function _cancelPayment($errorMsg = '') - { - $gotoSection = false; - /** @var Mage_Paypal_Helper_Checkout $helper */ - $helper = Mage::helper('paypal/checkout'); - $helper->cancelCurrentOrder($errorMsg); - if ($helper->restoreQuote()) { - $gotoSection = 'payment'; - } - return $gotoSection; - } - - /** - * Get frontend checkout session object - * - * @return Mage_Checkout_Model_Session - */ - protected function _getCheckout() - { - return Mage::getSingleton('checkout/session'); - } - - /** - * Get iframe block - * - * @return Mage_Paypal_Block_Payflow_Advanced_Iframe - */ - protected function _getIframeBlock() - { - $this->loadLayout('paypal_payflow_advanced_iframe'); - /** @var Mage_Paypal_Block_Payflow_Advanced_Iframe $block */ - $block = $this->getLayout()->getBlock('payflow.advanced.iframe'); - return $block; - } -} diff --git a/app/code/core/Mage/Paypal/controllers/PaymentController.php b/app/code/core/Mage/Paypal/controllers/PaymentController.php new file mode 100644 index 00000000000..fd29b64a7b3 --- /dev/null +++ b/app/code/core/Mage/Paypal/controllers/PaymentController.php @@ -0,0 +1,487 @@ +getRequest()->isAjax()) { + throw new Mage_Core_Exception('Invalid request'); + } + + if (!$this->getRequest()->isPost() || !$this->getRequest()->getParam('form_key')) { + Mage::throwException(Mage::helper('core')->__('Invalid form key')); + } + + if (!$this->_getQuote()->hasItems() || $this->_getQuote()->getHasError()) { + $this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden'); + Mage::throwException(Mage::helper('paypal')->__('Unable to initialize Express Checkout.')); + } + + if (!$this->_getQuote()->getQuoteCurrencyCode()) { + $this->_getQuote()->setQuoteCurrencyCode(Mage::app()->getStore()->getCurrentCurrencyCode()); + $this->_getQuote()->save(); + } + + if ($this->_getQuote()->getIsMultiShipping()) { + $this->_getQuote()->setIsMultiShipping(false); + $this->_getQuote()->removeAllAddresses(); + } + + $customer = Mage::getSingleton('customer/session')->getCustomer(); + $quoteCheckoutMethod = Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod(); + if ($customer && $customer->getId()) { + $this->_getQuote()->assignCustomerWithAddressChange($customer, $this->_getQuote()->getBillingAddress(), $this->_getQuote()->getShippingAddress()); + } elseif ((!$quoteCheckoutMethod + || $quoteCheckoutMethod != Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER) + && !Mage::helper('checkout')->isAllowedGuestCheckout( + $this->_getQuote(), + $this->_getQuote()->getStoreId() + ) + ) { + Mage::getSingleton('core/session')->addNotice( + Mage::helper('paypal')->__('To proceed to Checkout, please log in using your email address.') + ); + $this->_redirectLogin(); + Mage::getSingleton('customer/session') + ->setBeforeAuthUrl(Mage::getUrl('*/*/*', ['_current' => true])); + return; + } + + $result = $this->_getPaypal()->create($this->_getQuote()); + + $this->getResponse() + ->setHeader('Content-Type', 'application/json') + ->setBody(Mage::helper('core')->jsonEncode($result)); + } catch (Exception $e) { + Mage::logException($e); + + $this->getResponse() + ->setHeader('Content-Type', 'application/json') + ->setBody(Mage::helper('core')->jsonEncode([ + 'success' => false, + 'error' => $e->getMessage() + ])); + } + } + + /** + * Process PayPal payment (authorize or capture based on configuration) + */ + public function processAction() + { + try { + $orderId = $this->getRequest()->getParam('order_id'); + $paymentAction = Mage::getSingleton('paypal/config')->getPaymentAction(); + + if (!$orderId) { + throw new Exception('PayPal order ID is required'); + } + if (!$this->getRequest()->isPost() || !$this->getRequest()->getParam('form_key')) { + Mage::throwException(Mage::helper('core')->__('Invalid form key')); + } + + if ($paymentAction === strtolower(CheckoutPaymentIntent::AUTHORIZE)) { + $this->_getPaypal()->authorizePayment($orderId, $this->_getQuote()); + } else { + $this->_getPaypal()->captureOrder($orderId, $this->_getQuote()); + } + + $this->getResponse() + ->setHeader('Content-Type', 'application/json')->setBody(Mage::helper('core')->jsonEncode([ + 'success' => true + ])); + } catch (Exception $e) { + Mage::logException($e); + + $this->getResponse() + ->setHeader('Content-Type', 'application/json')->setBody(Mage::helper('core')->jsonEncode([ + 'success' => false, + 'message' => $e->getMessage() + ])); + } + } + + public function placeOrderAction() + { + try { + $isNewCustomer = false; + switch (Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod()) { + case Mage_Checkout_Model_Type_Onepage::METHOD_GUEST: + $this->_prepareGuestQuote(); + break; + case Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER: + $this->_prepareNewCustomerQuote(); + $isNewCustomer = true; + break; + default: + $this->_prepareCustomerQuote(); + break; + } + $this->_ignoreAddressValidation(); + $this->_quote->collectTotals(); + $session = $this->_getCheckoutSession(); + $service = Mage::getModel('sales/service_quote', $this->_getQuote()); + + $service->submitAll(); + $this->_quote->save(); + if ($isNewCustomer) { + try { + $this->_involveNewCustomer(); + } catch (Exception $e) { + Mage::logException($e); + } + } + + /** @var Mage_Sales_Model_Order $order */ + $order = $service->getOrder(); + if (!$order) { + return; + } + + $quotePayment = $this->_quote->getPayment(); + $orderPayment = $order->getPayment(); + $orderPayment->setQuotePaymentId($quotePayment->getId()) + ->setLastTransId($quotePayment->getPaypalCorrelationId()); + foreach ($quotePayment->getAdditionalInformation() as $key => $value) { + $orderPayment->setAdditionalInformation($key, $value); + } + $orderPayment->save(); + + $paymentAction = Mage::getSingleton('paypal/config')->getPaymentAction(); + $isAuthorize = ($paymentAction === strtolower(PaypalServerSdkLib\Models\CheckoutPaymentIntent::AUTHORIZE)); + $transaction = Mage::getModel('sales/order_payment_transaction'); + foreach ($orderPayment->getAdditionalInformation() as $key => $value) { + $transaction->setAdditionalInformation($key, $value); + } + if ($isAuthorize) { + $transaction->setOrderPaymentObject($orderPayment) + ->setTxnId($orderPayment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID)) + ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH) + ->setIsClosed(false); + $storeTimezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE); + $expirationTime = $orderPayment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME); + + $date = new DateTime($expirationTime, new DateTimeZone('UTC')); + $date->setTimezone(new DateTimeZone($storeTimezone)); + + $order->addStatusHistoryComment( + Mage::helper('paypal')->__('Paypal payment has been authorized, capture is required before date ' . $date->format('Y-m-d H:i:s')), + false + ); + $order->setState( + Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, + true, + Mage::helper('paypal')->__('Payment has been authorized. Capture is required.') + )->save(); + } else { + $order->addStatusHistoryComment( + Mage::helper('paypal')->__('PayPal payment captured successfully. Capture ID: %s', $transaction->getTxnId()), + false + ); + $transaction->setOrderPaymentObject($orderPayment) + ->setTxnId($quotePayment->getPaypalCorrelationId()) + ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE) + ->setIsClosed($orderPayment->getIsTransactionClosed()); + } + $transaction->save(); + + if (!$isAuthorize && $order->canInvoice()) { + $invoice = $order->prepareInvoice(); + $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE); + $invoice->register()->setIsPaid(true)->setIsTransactionPending(false)->setTransactionId($transaction->getTxnId()); + Mage::getModel('core/resource_transaction') + ->addObject($invoice) + ->addObject($order) + ->save(); + } + + $session->clearHelperData(); + $session->setLastQuoteId($this->_quote->getId()) + ->setLastSuccessQuoteId($this->_quote->getId()) + ->setLastOrderId($order->getId()) + ->setLastRealOrderId($order->getIncrementId()); + $order->queueNewOrderEmail(); + + $this->_redirect('checkout/onepage/success'); + return; + } catch (Exception $e) { + Mage::logException($e); + + Mage::helper('checkout')->sendPaymentFailedEmail($this->_quote, $e->getMessage()); + $session->addError($e->getMessage()); + $this->_redirect('checkout/cart'); + } + } + + /** + * Return checkout session object + * + * @return Mage_Checkout_Model_Session + */ + protected function _getCheckoutSession() + { + return Mage::getSingleton('checkout/session'); + } + + /** + * Return checkout quote object + * + * @return Mage_Sales_Model_Quote + */ + private function _getQuote() + { + if (!$this->_quote) { + $this->_quote = $this->_getCheckoutSession()->getQuote(); + } + return $this->_quote; + } + + /** + * Return PayPal model + * + * @return Mage_Paypal_Model_Paypal + */ + private function _getPaypal() + { + if (!$this->_paypal) { + $this->_paypal = Mage::getModel('paypal/paypal'); + } + return $this->_paypal; + } + + /** + * Prepare quote for guest checkout order submit + * + * @return $this + */ + protected function _prepareGuestQuote() + { + $quote = $this->_quote; + $quote->setCustomerEmail($quote->getBillingAddress()->getEmail()) + ->setCustomerIsGuest(true) + ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID); + return $this; + } + + /** + * Prepare quote for customer registration and customer order submit + * and restore magento customer data from quote + * + * @return $this + */ + protected function _prepareNewCustomerQuote() + { + $quote = $this->_quote; + $billing = $quote->getBillingAddress(); + $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress(); + + $customerId = $this->_lookupCustomerId(); + if ($customerId && !$this->_customerEmailExists($quote->getCustomerEmail())) { + $this->getCustomerSession()->loginById($customerId); + return $this->_prepareCustomerQuote(); + } + + $customer = $quote->getCustomer(); + /** @var Mage_Customer_Model_Customer $customer */ + $customerBilling = $billing->exportCustomerAddress(); + $customer->addAddress($customerBilling); + $billing->setCustomerAddress($customerBilling); + $customerBilling->setIsDefaultBilling(true); + if ($shipping && !$shipping->getSameAsBilling()) { + $customerShipping = $shipping->exportCustomerAddress(); + $customer->addAddress($customerShipping); + $shipping->setCustomerAddress($customerShipping); + $customerShipping->setIsDefaultShipping(true); + } elseif ($shipping) { + $customerBilling->setIsDefaultShipping(true); + } + /** + * @todo integration with dynamica attributes customer_dob, customer_taxvat, customer_gender + */ + if ($quote->getCustomerDob() && !$billing->getCustomerDob()) { + $billing->setCustomerDob($quote->getCustomerDob()); + } + + if ($quote->getCustomerTaxvat() && !$billing->getCustomerTaxvat()) { + $billing->setCustomerTaxvat($quote->getCustomerTaxvat()); + } + + if ($quote->getCustomerGender() && !$billing->getCustomerGender()) { + $billing->setCustomerGender($quote->getCustomerGender()); + } + + Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer); + $customer->setEmail($quote->getCustomerEmail()); + $customer->setPrefix($quote->getCustomerPrefix()); + $customer->setFirstname($quote->getCustomerFirstname()); + $customer->setMiddlename($quote->getCustomerMiddlename()); + $customer->setLastname($quote->getCustomerLastname()); + $customer->setSuffix($quote->getCustomerSuffix()); + $customer->setPassword($customer->decryptPassword($quote->getPasswordHash())); + $customer->setPasswordHash($customer->hashPassword($customer->getPassword())); + $customer->setPasswordCreatedAt(time()); + $customer->save(); + $quote->setCustomer($customer); + $quote->setPasswordHash(''); + + return $this; + } + + /** + * Prepare quote for customer order submit + * + * @return $this + */ + protected function _prepareCustomerQuote() + { + $quote = $this->_getQuote(); + $billing = $quote->getBillingAddress(); + $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress(); + + $customer = $this->getCustomerSession()->getCustomer(); + if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) { + $customerBilling = $billing->exportCustomerAddress(); + $customer->addAddress($customerBilling); + $billing->setCustomerAddress($customerBilling); + } + if ( + $shipping && ((!$shipping->getCustomerId() && !$shipping->getSameAsBilling()) + || (!$shipping->getSameAsBilling() && $shipping->getSaveInAddressBook())) + ) { + $customerShipping = $shipping->exportCustomerAddress(); + $customer->addAddress($customerShipping); + $shipping->setCustomerAddress($customerShipping); + } + + if (isset($customerBilling) && !$customer->getDefaultBilling()) { + $customerBilling->setIsDefaultBilling(true); + } + if ($shipping && isset($customerBilling) && !$customer->getDefaultShipping() && $shipping->getSameAsBilling()) { + $customerBilling->setIsDefaultShipping(true); + } elseif ($shipping && isset($customerShipping) && !$customer->getDefaultShipping()) { + $customerShipping->setIsDefaultShipping(true); + } + $quote->setCustomer($customer); + + return $this; + } + + /** + * Get customer session object + * + * @return Mage_Customer_Model_Session + */ + public function getCustomerSession() + { + if (is_null($this->_customerSession)) { + $this->_customerSession = Mage::getSingleton('customer/session'); + } + return $this->_customerSession; + } + + /** + * Check if customer email exists + * + * @param string $email + * @return bool + */ + protected function _customerEmailExists($email) + { + $result = false; + $customer = Mage::getModel('customer/customer'); + $websiteId = Mage::app()->getStore()->getWebsiteId(); + if (!is_null($websiteId)) { + $customer->setWebsiteId($websiteId); + } + $customer->loadByEmail($email); + if (!is_null($customer->getId())) { + $result = true; + } + + return $result; + } + + /** + * Checks if customer with email coming from Express checkout exists + * + * @return int + */ + protected function _lookupCustomerId() + { + return Mage::getModel('customer/customer') + ->setWebsiteId(Mage::app()->getWebsite()->getId()) + ->loadByEmail($this->_quote->getCustomerEmail()) + ->getId(); + } + + /** + * Make sure addresses will be saved without validation errors + */ + private function _ignoreAddressValidation() + { + $this->_quote->getBillingAddress()->setShouldIgnoreValidation(true); + if (!$this->_quote->getIsVirtual()) { + $this->_quote->getShippingAddress()->setShouldIgnoreValidation(true); + } + } + + /** + * Redirect to login page + * + */ + protected function _redirectLogin() + { + $this->setFlag('', 'no-dispatch', true); + $this->getResponse()->setRedirect( + Mage::helper('core/url')->addRequestParam( + Mage::helper('customer')->getLoginUrl(), + ['context' => 'checkout'] + ) + ); + } + + /** + * Involve new customer to system + * + * @return $this + */ + protected function _involveNewCustomer() + { + $customer = $this->_quote->getCustomer(); + if ($customer->isConfirmationRequired()) { + $customer->sendNewAccountEmail('confirmation', '', $this->_quote->getStoreId()); + $url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail()); + $this->getCustomerSession()->addSuccess( + Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please click here.', $url) + ); + } else { + $customer->sendNewAccountEmail('registered', '', $this->_quote->getStoreId()); + $this->getCustomerSession()->loginById($customer->getId()); + } + return $this; + } +} diff --git a/app/code/core/Mage/Paypal/controllers/StandardController.php b/app/code/core/Mage/Paypal/controllers/StandardController.php deleted file mode 100644 index f5c143e38dc..00000000000 --- a/app/code/core/Mage/Paypal/controllers/StandardController.php +++ /dev/null @@ -1,98 +0,0 @@ -_order; - } - - /** - * Send expire header to ajax response - * - * @SuppressWarnings("PHPMD.ExitExpression") - */ - protected function _expireAjax() - { - if (!Mage::getSingleton('checkout/session')->getQuote()->hasItems()) { - $this->getResponse()->setHeader('HTTP/1.1', '403 Session Expired'); - exit; - } - } - - /** - * Get singleton with PayPal standard order transaction information - * - * @return Mage_Paypal_Model_Standard - */ - public function getStandard() - { - return Mage::getSingleton('paypal/standard'); - } - - /** - * When a customer chooses Paypal on Checkout/Payment page - * - */ - public function redirectAction() - { - $session = Mage::getSingleton('checkout/session'); - $session->setPaypalStandardQuoteId($session->getQuoteId()); - $this->getResponse()->setBody($this->getLayout()->createBlock('paypal/standard_redirect')->toHtml()); - $session->unsQuoteId(); - $session->unsRedirectUrl(); - } - - /** - * When a customer cancel payment from paypal. - */ - public function cancelAction() - { - $session = Mage::getSingleton('checkout/session'); - $session->setQuoteId($session->getPaypalStandardQuoteId(true)); - if ($session->getLastRealOrderId()) { - $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId()); - if ($order->getId()) { - $order->cancel()->save(); - } - Mage::helper('paypal/checkout')->restoreQuote(); - } - $this->_redirect('checkout/cart'); - } - - /** - * when paypal returns - * The order information at this point is in POST - * variables. However, you don't want to "process" the order until you - * get validation from the IPN. - */ - public function successAction() - { - $session = Mage::getSingleton('checkout/session'); - $session->setQuoteId($session->getPaypalStandardQuoteId(true)); - Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save(); - $this->_redirect('checkout/onepage/success', ['_secure' => true]); - } -} diff --git a/app/code/core/Mage/Paypal/data/paypal_setup/data-install-1.6.0.5.php b/app/code/core/Mage/Paypal/data/paypal_setup/data-install-1.6.0.5.php deleted file mode 100644 index bf64ceac2d9..00000000000 --- a/app/code/core/Mage/Paypal/data/paypal_setup/data-install-1.6.0.5.php +++ /dev/null @@ -1,36 +0,0 @@ -getConnection(); -$installer->startSetup(); -$data = [ - ['paypal_reversed', 'PayPal Reversed'], - ['paypal_canceled_reversal', 'PayPal Canceled Reversal'], -]; -$connection = $installer->getConnection()->insertArray( - $installer->getTable('sales/order_status'), - ['status', 'label'], - $data, -); -/** - * Set default value for "skip order review page" option for Express Checkout for new installations - */ -$ecSkipOrderReviewStepFlagPath = 'payment/paypal_express/skip_order_review_step'; -Mage::getConfig()->saveConfig($ecSkipOrderReviewStepFlagPath, '1'); - -/** - * Set default value for "Mobile Optimized" option for Payflow Link/Advanced/Hosted Pro for new installations - */ -$paymentCode = ['payflow_link', 'payflow_advanced', 'hosted_pro']; -foreach ($paymentCode as $value) { - Mage::getConfig()->saveConfig("payment/{$value}/mobile_optimized", '1'); -} -$installer->endSetup(); diff --git a/app/code/core/Mage/Paypal/data/paypal_setup/data-upgrade-1.6.0.2-1.6.0.3.php b/app/code/core/Mage/Paypal/data/paypal_setup/data-upgrade-1.6.0.2-1.6.0.3.php deleted file mode 100644 index 2863283e993..00000000000 --- a/app/code/core/Mage/Paypal/data/paypal_setup/data-upgrade-1.6.0.2-1.6.0.3.php +++ /dev/null @@ -1,23 +0,0 @@ -getConnection(); -$installer->startSetup(); -$data = [ - ['paypal_reversed', 'PayPal Reversed'], - ['paypal_canceled_reversal', 'PayPal Canceled Reversal'], -]; -$connection = $installer->getConnection()->insertArray( - $installer->getTable('sales/order_status'), - ['status', 'label'], - $data, -); -$installer->endSetup(); diff --git a/app/code/core/Mage/Paypal/data/paypal_setup/data-upgrade-1.6.0.4-1.6.0.5.php b/app/code/core/Mage/Paypal/data/paypal_setup/data-upgrade-1.6.0.4-1.6.0.5.php deleted file mode 100644 index 54d66a528d6..00000000000 --- a/app/code/core/Mage/Paypal/data/paypal_setup/data-upgrade-1.6.0.4-1.6.0.5.php +++ /dev/null @@ -1,14 +0,0 @@ -saveConfig($ecSkipOrderReviewStepFlagPath, '0'); diff --git a/app/code/core/Mage/Paypal/data/paypal_setup/data-upgrade-1.6.0.5-1.6.0.6.php b/app/code/core/Mage/Paypal/data/paypal_setup/data-upgrade-1.6.0.5-1.6.0.6.php deleted file mode 100644 index 308f6de79b5..00000000000 --- a/app/code/core/Mage/Paypal/data/paypal_setup/data-upgrade-1.6.0.5-1.6.0.6.php +++ /dev/null @@ -1,30 +0,0 @@ -getConnection(); -$select = $connection->select() - ->from( - ['config' => $installer->getTable('core/config_data')], - ['scope_id' => 'config.scope_id'], - ) - ->where('config.path=?', 'paypal/general/merchant_country') - ->where('config.value<>?', 'US'); - -$result = $connection->fetchAll($select); -foreach ($result as $row) { - $connection->delete( - $installer->getTable('core/config_data'), - 'path LIKE "%express_bml%"' - . $connection->quoteInto(' AND scope_id = ?', $row['scope_id']), - ); -} - -$installer->endSetup(); diff --git a/app/code/core/Mage/Paypal/etc/adminhtml.xml b/app/code/core/Mage/Paypal/etc/adminhtml.xml index 2bbaff0612d..c8d30fe5e87 100644 --- a/app/code/core/Mage/Paypal/etc/adminhtml.xml +++ b/app/code/core/Mage/Paypal/etc/adminhtml.xml @@ -1,25 +1,19 @@ - - + + PayPal + 100 - - PayPal Settlement Reports - adminhtml/paypal_reports - 100 - + + Debug Log + adminhtml/paypal_debug + 10 + - + @@ -31,34 +25,33 @@ - - PayPal - + + + + PayPal Settings + + + - + + PayPal + 100 - - PayPal Settlement Reports - - - View - - - Fetch - - - + + Debug Log + 10 + - + - + \ No newline at end of file diff --git a/app/code/core/Mage/Paypal/etc/config.xml b/app/code/core/Mage/Paypal/etc/config.xml index 7bb8813f960..c584ab50be8 100644 --- a/app/code/core/Mage/Paypal/etc/config.xml +++ b/app/code/core/Mage/Paypal/etc/config.xml @@ -10,20 +10,10 @@ - 1.6.0.6 + 2.0.0.0 - - - - - paypal/observer - observeHtmlTransactionId - - - - Mage_Paypal_Model @@ -31,76 +21,63 @@ Mage_Paypal_Model_Resource - paypal_mysql4 - - paypal_api_debug
-
- - paypal_settlement_report
-
- - paypal_settlement_report_row
-
- - paypal_cert
-
- - paypal_payment_transaction
-
+ + paypal_debug
+
- - - - Mage_Paypal - Mage_Paypal_Model_Resource_Setup - - - Mage_Paypal_Block + + + Mage_Paypal_Helper + + - - - - - + + + 1 + + + 1 + + - - - - - SM - Switch/Maestro - 60 - - - SO - Solo - 61 - - - - PayPal + + + + Mage_Paypal + Mage_Paypal_Model_Resource_Setup + + + core_setup + + + + + core_write + + + + + core_read + + +
- - /paypal/express - /paypal/standard - /paypal/ipn - standard @@ -124,44 +101,10 @@ paypal.xml - - bml.xml - - - paypal/express/callbackshippingoptions - - - - - - paypal/observer - saveOrderAfterSubmit - - - - - - - paypal/observer - setResponseAfterSaveOrder - - - - - - - - - paypal/observer - loadCountryDependentSolutionsConfig - - - - @@ -172,157 +115,6 @@ - - - Magento_Cart_Community - - - - - - dynamic - - - - - - - - - 1 - - - - - - paypal/express - PayPal Express Checkout - Authorization - Mark - 1 - 1 - 1 - never - paypal - 3 - 29 - 1 - 1 - 1 - - - paypal/bml - Paypal Credit - paypal - - - paypal/direct - PayPal Payments Pro - Authorization - VI,MC - 1 - paypal - 1 - - - paypal/standard - PayPal Website Payments Standard - Sale - 1 - paypal - 1 - - - PayPal Express Checkout Payflow Edition - Authorization - 1 - 1 - 1 - paypal - 1 - - - PayPal Payments Pro Payflow Edition - Authorization - VI,MC,AE - 1 - paypal - 1 - - - paypal/payflowpro - Payflow Pro - Authorization - AE,VI - 1 - C - MEDIUM - - - paypal - 1 - - - 1 - 1 - paypal/method_agreement - PayPal Billing Agreement - paypal - 1 - - - paypal/payflowlink - Authorization - HIGH - - paypal - Credit Card - 1 - 1 - GET - 0 - 1 - 0 - - - paypal/payflowadvanced - Authorization - HIGH - - paypal - Credit Card - PayPal - PayPal - PayPal - 1 - 1 - GET - 0 - 1 - 0 - - - paypal/hostedpro - Payment by cards or by PayPal account - Authorization - paypal - 0 - 1 - 0 - - - - - - - - paypal/observer::fetchReports - - - - @@ -334,4 +126,21 @@ -
+ + + + paypal/paypal + PayPal + 0 + 1 + capture + 0 + rect + gold + vertical + paypal + 1 + + + + \ No newline at end of file diff --git a/app/code/core/Mage/Paypal/etc/system.xml b/app/code/core/Mage/Paypal/etc/system.xml index b0afeeed0e6..a6726bf42f2 100644 --- a/app/code/core/Mage/Paypal/etc/system.xml +++ b/app/code/core/Mage/Paypal/etc/system.xml @@ -8,30 +8,22 @@ */ --> - + - - paypal/adminhtml_system_config_fieldset_hint - https://www.paypal-marketing.com/emarketing/partner/na/merchantlineup/home.page#mainTab=checkoutlineup&subTab=newlineup - 0 + + 1 1 1 - - - - paypal-config + 10 1 - 5 - 1 - 1 - paypal/adminhtml_system_config_fieldset_location + Accept payments with PayPal Express Checkout. - paypal/general/merchant_country - If not specified, Default Country from General Config will be used + If not specified, Default Country from General Config will be + used select paypal/adminhtml_system_config_field_country paypal/system_config_source_merchantCountry @@ -40,4301 +32,159 @@ 1 5 + + + select + adminhtml/system_config_source_yesno + 10 + 1 + 1 + If you want to use PayPal Express Checkout, you must complete + the settings below. + express_checkout_settings + + + + + text + 20 + 1 + 1 + Learn more about PayPal API credentials]]> + + 1 + + 1 + + + + obscure + adminhtml/system_config_backend_encrypted + 30 + 1 + 1 + Learn more about PayPal API credentials]]> + + 1 + + 1 + + + + select + adminhtml/system_config_source_yesno + 40 + 1 + 1 + Enable this option to use the PayPal Sandbox environment for + testing. + + 1 + + 1 + + + + select + paypal/system_config_source_paymentActions + 50 + 1 + 1 + Select whether to authorize or capture the payment immediately. + Note: Authorization is not supported for multishipping orders and + will automatically use capture instead.

When using + Authorize, funds are reserved for up to 29 days, but it's best to + capture within 3 days.
+ + 1 + + 1 +
+ + + select + adminhtml/system_config_source_yesno + 60 + 1 + 1 + Enable this option to log PayPal API requests and responses. + + 1 + + 1 + + + + select + paypal/system_config_source_buttonShapes + 70 + 1 + 1 + Learn more about PayPal button shapes]]> + + 1 + + 1 + + + + select + paypal/system_config_source_buttonColors + 80 + 1 + 1 + Learn more about PayPal button colors]]> + + 1 + + 1 + + + + select + paypal/system_config_source_buttonLayouts + 90 + 1 + 1 + Learn more about PayPal button layouts]]> + + 1 + + 1 + + + + select + paypal/system_config_source_buttonLabels + 100 + 1 + 1 + + Learn more about PayPal button labels]]> + + + 1 + + 1 + + + + select + adminhtml/system_config_source_yesno + 110 + 1 + 1 + Learn more about PayPal button messages]]> + + 1 + + 1 +
-
- - - - 1 - 10 - 1 - 1 - 1 - complex - paypal/adminhtml_system_config_fieldset_group - Choose a secure bundled payment solution for your business. - https://www.paypal-marketing.com/emarketing/partner/na/merchantlineup/home.page#mainTab=checkoutlineup&subTab=newlineup - - - - - 15 - 1 - 1 - 1 - complex - paypal/adminhtml_system_config_fieldset_group - Process payments using your own internet merchant account. - https://merchant.paypal.com/cgi-bin/marketingweb?cmd=_render-content&content_ID=merchant/payment_gateway - - - - - 20 - 1 - 1 - 1 - 1 - complex - paypal/adminhtml_system_config_fieldset_group - Add another payment method to your existing solution or as a stand-alone option. - Select a Payment Solution - https://merchant.paypal.com/cgi-bin/marketingweb?cmd=_render-content&content_ID=merchant/express_checkout - - - - - 10 - 1 - 1 - 1 - 1 - complex - paypal/adminhtml_system_config_fieldset_group - Add another payment method to your existing solution or as a stand-alone option. - Select a Payment Solution - https://www.paypal-marketing.com/emarketing/partner/na/merchantlineup/home.page#mainTab=checkoutlineup&subTab=newlineup - - - - - - - 1 - 1 - 1 - 30 - pp-method-general - paypal/adminhtml_system_config_fieldset_payment - https://www.paypal.com/webapps/mpp/referral/paypal-payments-advanced?partner_id=NB9WWHYEMVUMS - Accept payments with a PCI-compliant checkout that keeps customers on your site. - paypal_group_all_in_one - payment/payflow_advanced/active - - - 1 - - - - - - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 10 - - - - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 10 - - - - payment/payflow_advanced/partner - 10 - 1 - 1 - - - - payment/payflow_advanced/vendor - 20 - 1 - 1 - - - - PayPal recommends that you set up an additional User on your account at manager.paypal.com - PayPal recommends you set up an additional User on your account at manager.paypal.com, instead of entering your admin username and password here. This will enhance your security and prevent service interruptions if you later change your password. If you do not want to set up an additional User, you can re-enter your Merchant Login here. - payment/payflow_advanced/user - 30 - 1 - 1 - - - - payment/payflow_advanced/pwd - obscure - adminhtml/system_config_backend_encrypted - 40 - 1 - 1 - - - - payment/payflow_advanced/sandbox_flag - select - adminhtml/system_config_source_yesno - 50 - 1 - 1 - 1 - - - - payment/payflow_advanced/use_proxy - select - adminhtml/system_config_source_yesno - 60 - 1 - 1 - - - - payment/payflow_advanced/proxy_host - 70 - 1 - 1 - 1 - - - - payment/payflow_advanced/proxy_port - 80 - 1 - 1 - 1 - - - paypal/adminhtml_system_config_payflowlink_advanced - 1 - 1 - 1 - 90 - - - - - - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 20 - - - - Don't have a PayPal account? Simply enter your email address. - paypal/general/business_account - 1 - 1 - 10 - validate-email - 1 - - - - paypal/wpp/api_authentication - select - paypal/config::getApiAuthenticationMethods - 20 - 1 - 1 - 1 - - - - paypal/wpp/api_username - obscure - adminhtml/system_config_backend_encrypted - 30 - 1 - 1 - 1 - - - - paypal/wpp/api_password - obscure - adminhtml/system_config_backend_encrypted - 40 - 1 - 1 - 1 - - - - paypal/wpp/api_signature - adminhtml/system_config_backend_encrypted - obscure - 50 - 1 - 1 - 0 - 1 - - - - paypal/wpp/api_cert - file - paypal/system_config_backend_cert - 60 - 1 - 1 - 1 - 1 - - - - Get Credentials from PayPal - - Sandbox Credentials - - paypal/adminhtml_system_config_apiWizard - 70 - 1 - 1 - - - - paypal/wpp/sandbox_flag - select - adminhtml/system_config_source_yesno - 80 - 1 - 1 - 1 - - - - paypal/wpp/use_proxy - select - adminhtml/system_config_source_yesno - 90 - 1 - 1 - 1 - - - - paypal/wpp/proxy_host - 100 - 1 - 1 - 1 - 1 - - - - paypal/wpp/proxy_port - 110 - 1 - 1 - 1 - 1 - - - - - - payment/payflow_advanced/active - select - adminhtml/system_config_source_yesno - 30 - 1 - 1 - Both section above must be complete. - express,payments_advanced - paypal-enabler - - - Learn More]]> - - 31 - required_settings_enable_payflow_advanced - - - - - Why Advertise Financing?
- Give your sales a boost when you advertise financing.
PayPal helps turn browsers into buyers with financing - from Paypal Credit®. Your customers have more time to pay, while you get paid up front – at no additional cost to you. - Use PayPal’s free banner ads that let you advertise Paypal Credit® financing as a payment option when your customers check out with PayPal. - The PayPal Advertising Program has been shown to generate additional purchases as well as increase consumer's average purchase sizes by 15% - or more. See Details.]]> -
- 1 - 1 - 32 - - - - - - 1 - 1 - 1 - 20 - - - - - - payment/paypal_express_bml/homepage_size - select - paypal/system_config_source_bmlSize::getBmlSizeHPH - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeHPS - 1 - - - - - - 1 - 1 - 1 - 30 - - - - - - payment/paypal_express_bml/categorypage_size - select - paypal/system_config_source_bmlSize::getBmlSizeCCPC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCCPS - 1 - - - - - - - 1 - 1 - 1 - 40 - - - - - - payment/paypal_express_bml/productpage_size - select - paypal/system_config_source_bmlSize::getBmlSizeCPPC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCPPN - 1 - - - - - - - 1 - 1 - 1 - 50 - - - - - - payment/paypal_express_bml/checkout_size - select - paypal/system_config_source_bmlSize::getBmlSizeCheckoutC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCheckoutN - 1 - 1 - - - - - -
-
-
- - - - 1 - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 20 - - - <label>Title</label> - <comment>It is recommended to set this value to "Debit or Credit Card" per store views.</comment> - <config_path>payment/payflow_advanced/title</config_path> - <sort_order>10</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - - - - payment/payflow_advanced/sort_order - 20 - 1 - 1 - 1 - validate-number - - - - payment/payflow_advanced/payment_action - select - paypal/system_config_source_paymentActions - 30 - 1 - 1 - - - - config-advanced - 1 - 1 - 1 - 40 - - - - payment/payflow_advanced/allowspecific - select - adminhtml/system_config_source_payment_allspecificcountries - 20 - 1 - 1 - - - - payment/payflow_advanced/specificcountry - multiselect - paypal/system_config_source_buyerCountry - 25 - 1 - 1 - 1 - - - - payment/payflow_advanced/debug - select - adminhtml/system_config_source_yesno - 30 - 1 - 1 - - - - payment/payflow_advanced/verify_peer - select - adminhtml/system_config_source_yesno - 35 - 1 - 1 - - - - payment/payflow_advanced/csc_editable - select - adminhtml/system_config_source_yesno - 40 - 1 - 1 - - - - payment/payflow_advanced/csc_required - select - adminhtml/system_config_source_yesno - 50 - 1 - 1 - 1 - - - - payment/payflow_advanced/email_confirmation - select - adminhtml/system_config_source_yesno - 60 - 1 - 1 - - - - payment/payflow_advanced/url_method - select - paypal/system_config_source_urlMethod - 70 - 1 - 1 - - - - payment/payflow_advanced/mobile_optimized - select - adminhtml/system_config_source_yesno - 75 - 1 - 1 - - - - 1 - 1 - 1 - 80 - - - - - payment/paypal_billing_agreement/active - select - adminhtml/system_config_source_yesno - 10 - 1 - 1 - 1 - - - <label>Title</label> - <config_path>payment/paypal_billing_agreement/title</config_path> - <sort_order>20</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <shared>1</shared> - - - - payment/paypal_billing_agreement/sort_order - 30 - 1 - 1 - 1 - validate-number - 1 - - - - payment/paypal_billing_agreement/payment_action - select - paypal/system_config_source_paymentActions - 40 - 1 - 1 - 1 - - - - payment/paypal_billing_agreement/allowspecific - select - adminhtml/system_config_source_payment_allspecificcountries - 50 - 1 - 1 - 1 - - - - payment/paypal_billing_agreement/specificcountry - multiselect - paypal/system_config_source_buyerCountry - 60 - 1 - 1 - 1 - 1 - - - - payment/paypal_billing_agreement/debug - select - adminhtml/system_config_source_yesno - 70 - 1 - 1 - 1 - - - - payment/paypal_billing_agreement/verify_peer - select - adminhtml/system_config_source_yesno - 75 - 1 - 1 - 1 - - - - payment/paypal_billing_agreement/line_items_enabled - select - adminhtml/system_config_source_yesno - 80 - 1 - 1 - 1 - - - - payment/paypal_billing_agreement/allow_billing_agreement_wizard - select - adminhtml/system_config_source_yesno - 90 - 1 - 1 - 1 - - - - - - 1 - 1 - 90 - - - - adminhtml/system_config_form_field_heading - 10 - 1 - 1 - - - - paypal/fetch_reports/ftp_login - obscure - adminhtml/system_config_backend_encrypted - 20 - 1 - 1 - 1 - - - - paypal/fetch_reports/ftp_password - obscure - adminhtml/system_config_backend_encrypted - 30 - 1 - 1 - 1 - - - - paypal/fetch_reports/ftp_sandbox - select - adminhtml/system_config_source_yesno - 40 - 1 - 1 - 1 - - - - By default it is "reports.paypal.com". - Use colon to specify port. For example: "test.example.com:5224". - paypal/fetch_reports/ftp_ip - 50 - 1 - 1 - 0 - 1 - - - - By default it is "/ppreports/outgoing". - paypal/fetch_reports/ftp_path - 60 - 1 - 1 - 0 - 1 - - - - adminhtml/system_config_form_field_heading - 70 - 1 - 1 - 1 - - - - paypal/fetch_reports/active - select - adminhtml/system_config_source_yesno - 80 - 1 - 1 - 1 - - - - PayPal retains reports for 45 days. - paypal/fetch_reports/schedule - select - paypal/system_config_source_fetchingSchedule - 90 - 1 - 1 - - - - paypal/fetch_reports/time - time - 100 - 1 - 1 - - - - - - 1 - 1 - 1 - 100 - - - - Displays on catalog pages and homepage. - paypal/style/logo - select - paypal/system_config_source_logo - 10 - 1 - 1 - 1 - 1 - - - - adminhtml/system_config_form_field_heading - 20 - 1 - 1 - 1 - 1 - - - - paypal/style/page_style - - 30 - 1 - 1 - 1 - 1 - - - - paypal/style/paypal_hdrimg - https is highly encouraged.]]> - 40 - 1 - 1 - 1 - 1 - - - - paypal/style/paypal_hdrbackcolor - - 50 - 1 - 1 - 1 - 1 - - - - paypal/style/paypal_hdrbordercolor - 2-pixel perimeter around the header space. - 60 - 1 - 1 - 1 - 1 - - - - paypal/style/paypal_payflowcolor - - 70 - 1 - 1 - 1 - 1 - - - - - - - - - - 1 - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 30 - - - <label>Title</label> - <comment>It is recommended to set this value to "PayPal" per store views.</comment> - <config_path>payment/paypal_express/title</config_path> - <sort_order>10</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <shared>1</shared> - - - - payment/paypal_express/sort_order - 20 - 1 - 1 - 1 - validate-number - 1 - - - - payment/paypal_express/payment_action - select - paypal/system_config_source_paymentActions_express - 30 - 1 - 1 - 1 - - - - payment/paypal_express/visible_on_product - select - adminhtml/system_config_source_yesno - 40 - 1 - 1 - 1 - 1 - - - - Specifies what the Authorization Honor Period is on the merchant’s PayPal account. It must mirror the setting in PayPal. - payment/paypal_express/authorization_honor_period - 50 - 1 - 1 - 1 - Order - - - - Specifies what the Order Valid Period is on the merchant’s PayPal account. It must mirror the setting in PayPal. - payment/paypal_express/order_valid_period - 60 - 1 - 1 - 1 - Order - - - - The default number of child authorizations in your PayPal account is 1. To do multiple authorizations please contact PayPal to request an increase. - payment/paypal_express/child_authorization_number - 70 - 1 - 1 - 1 - Order - - - - config-advanced - 1 - 1 - 1 - 80 - - - - payment/paypal_express/visible_on_cart - Also affects mini-shopping cart. - select - paypal/system_config_source_yesnoShortcut - 5 - 1 - 1 - 1 - 1 - - - - payment/paypal_express/allowspecific - select - adminhtml/system_config_source_payment_allspecificcountries - 10 - 1 - 1 - 1 - - - - payment/paypal_express/specificcountry - multiselect - paypal/system_config_source_buyerCountry - 20 - 1 - 1 - 1 - 1 - - - - payment/paypal_express/debug - select - adminhtml/system_config_source_yesno - 30 - 1 - 1 - 1 - - - - payment/paypal_express/verify_peer - select - adminhtml/system_config_source_yesno - 35 - 1 - 1 - 1 - - - - payment/paypal_express/line_items_enabled - select - adminhtml/system_config_source_yesno - 40 - 1 - 1 - 1 - - - - payment/paypal_express/transfer_shipping_options - If this option is enabled, customer can change shipping address and shipping method on PayPal website. In live mode works via HTTPS protocol only. - Notice that PayPal can handle up to 10 shipping options. That is why Magento will transfer only first 10 cheapest shipping options if there are more than 10 available. - select - adminhtml/system_config_source_yesno - 50 - 1 - 1 - 1 - 1 - - - - paypal/wpp/button_flavor - select - paypal/config::getExpressCheckoutButtonFlavors - 60 - 1 - 1 - 1 - 1 - - - - Ability for buyer to purchase without PayPal account. - payment/paypal_express/solution_type - select - paypal/adminhtml_system_config_field_solutionType - paypal/config::getExpressCheckoutSolutionTypes - 70 - 1 - 1 - 1 - - - - This feature needs be enabled first for the merchant account through PayPal technical support. - payment/paypal_express/require_billing_address - select - paypal/system_config_source_requireBillingAddress - 80 - 1 - 1 - 1 - - - - Whether to create a billing agreement, if there are no active billing agreements available. - - payment/paypal_express/allow_ba_signup - select - paypal/config::getExpressCheckoutBASignupOptions - 90 - 1 - 1 - 1 - - - - payment/paypal_express/skip_order_review_step - select - adminhtml/system_config_source_yesno - 95 - 1 - 1 - 1 - - - - - -
-
- - - 1 - 1 - 1 - 40 - paypal_payment_solutions - pp-method-general - paypal/adminhtml_system_config_fieldset_payment - Accept payments with a completely customizable checkout. - payment/paypal_direct/active - https://www.paypal.com/webapps/mpp/referral/website-payments-pro?partner_id=NB9WWHYEMVUMS - - - 1 - 10 - - - 1 - paypal_group_all_in_one - pp-general-uk - 20 - https://www.paypal-business.co.uk/process-online-payments-with-paypal/index.htm - http://www.youtube.com/watch?v=LBe-TW87eGI&list=PLF18B1094ABCD7CE8&index=1&feature=plpp_video - Accept payments with a completely customizable checkout page. - - - - 1 - paypal_group_all_in_one - - - - - - - - Learn More]]> - - 21 - wpp_required_settings_enable_wpp - - - - - Why Advertise Financing?
- Give your sales a boost when you advertise financing.
PayPal helps turn browsers into buyers with financing - from Paypal Credit®. Your customers have more time to pay, while you get paid up front – at no additional cost to you. - Use PayPal’s free banner ads that let you advertise Paypal Credit® financing as a payment option when your customers check out with PayPal. - The PayPal Advertising Program has been shown to generate additional purchases as well as increase consumer's average purchase sizes by 15% - or more. See Details.]]> -
- 1 - 1 - 22 - - - - - - 1 - 1 - 1 - 20 - - - - - - payment/paypal_express_bml/homepage_size - select - paypal/system_config_source_bmlSize::getBmlSizeHPH - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeHPS - 1 - - - - - - 1 - 1 - 1 - 30 - - - - - - payment/paypal_express_bml/categorypage_size - select - paypal/system_config_source_bmlSize::getBmlSizeCCPC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCCPS - 1 - - - - - - - 1 - 1 - 1 - 40 - - - - - - payment/paypal_express_bml/productpage_size - select - paypal/system_config_source_bmlSize::getBmlSizeCPPC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCPPN - 1 - - - - - - - 1 - 1 - 1 - 50 - - - - - - payment/paypal_express_bml/checkout_size - select - paypal/system_config_source_bmlSize::getBmlSizeCheckoutC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCheckoutN - 1 - 1 - - - - - -
-
-
- - - -
-
-
- - - - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 10 - - - - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 10 - - - - - - - - - - - - - - - - - - payment/paypal_direct/active - select - adminhtml/system_config_source_yesno - 20 - 1 - 1 - wpp_and_express_checkout - paypal-enabler - - - - - - - - 1 - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 20 - - - <label>Title</label> - <comment>It is recommended to set this value to "Debit or Credit Card" per store views.</comment> - <config_path>payment/paypal_direct/title</config_path> - <sort_order>10</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - - - - payment/paypal_direct/sort_order - 20 - 1 - 1 - 1 - validate-number - - - - payment/paypal_direct/payment_action - select - paypal/system_config_source_paymentActions - 30 - 1 - 1 - - - - adminhtml/system_config_form_field_heading - 40 - 1 - 1 - - - - http://www.paypal.com/amexupdate.]]> - payment/paypal_direct/cctypes - multiselect - paypal/config::getWppCcTypesAsOptionArray - 50 - 1 - 1 - - - - config-advanced - 1 - 1 - 1 - 60 - - - - payment/paypal_direct/allowspecific - select - adminhtml/system_config_source_payment_allspecificcountries - 20 - 1 - 1 - - - - payment/paypal_direct/specificcountry - multiselect - paypal/system_config_source_buyerCountry - 25 - 1 - 1 - 1 - - - - payment/paypal_direct/debug - select - adminhtml/system_config_source_yesno - 30 - 1 - 1 - - - - payment/paypal_direct/verify_peer - select - adminhtml/system_config_source_yesno - 35 - 1 - 1 - - - - payment/paypal_direct/line_items_enabled - select - adminhtml/system_config_source_yesno - 40 - 1 - 1 - - - - payment/paypal_direct/useccv - select - adminhtml/system_config_source_yesno - 50 - 1 - 1 - - - - adminhtml/system_config_form_field_heading - 55 - 1 - 1 - - - - payment/paypal_direct/centinel - select - adminhtml/system_config_source_yesno - 60 - 1 - 1 - - - - payment/paypal_direct/centinel_is_mode_strict - Severe Validation Removes Chargeback Liability on Merchant - select - adminhtml/system_config_source_yesno - 65 - 1 - 1 - 1 - - - - payment/paypal_direct/centinel_api_url - If empty, a default value will be used. Custom URL may be provided by CardinalCommerce agreement. - adminhtml/system_config_source_yesno - 70 - 1 - 1 - 1 - - - - 1 - 1 - 1 - 80 - - - - <sort_order extends="//paypal_payments/payflow_advanced//billing_agreement/*/sort_order" /> - <payment_action extends="//paypal_payments/payflow_advanced//billing_agreement/*/payment_action" /> - <allowspecific extends="//paypal_payments/payflow_advanced//billing_agreement/*/allowspecific" /> - <specificcountry extends="//paypal_payments/payflow_advanced//billing_agreement/*/specificcountry" /> - <debug extends="//paypal_payments/payflow_advanced//billing_agreement/*/debug" /> - <verify_peer extends="//paypal_payments/payflow_advanced//billing_agreement/*/verify_peer" /> - <line_items_enabled extends="//paypal_payments/payflow_advanced//billing_agreement/*/line_items_enabled" /> - <allow_billing_agreement_wizard extends="//paypal_payments/payflow_advanced//billing_agreement/*/allow_billing_agreement_wizard" /> - </fields> - </wpp_billing_agreement> - <wpp_settlement_report type="group" translate="label"> - <label>Settlement Report Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>90</sort_order> - <fields> - <heading_sftp extends="//paypal_payments/payflow_advanced//settlement_report/*/heading_sftp" /> - <settlement_reports_ftp_login extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_login" /> - <settlement_reports_ftp_password extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_password" /> - <settlement_reports_ftp_sandbox extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_sandbox" /> - <settlement_reports_ftp_ip extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_ip" /> - <settlement_reports_ftp_path extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_path" /> - <heading_schedule extends="//paypal_payments/payflow_advanced//settlement_report/*/heading_schedule" /> - <settlement_reports_active extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_active" /> - <settlement_reports_schedule extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_schedule" /> - <settlement_reports_time extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_time" /> - </fields> - </wpp_settlement_report> - <wpp_frontend type="group" translate="label"> - <label>Frontend Experience Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>100</sort_order> - <fields> - <logo extends="//paypal_payments/payflow_advanced//frontend/*/logo" /> - <paypal_pages extends="//paypal_payments/payflow_advanced//frontend/*/paypal_pages" /> - <page_style extends="//paypal_payments/payflow_advanced//frontend/*/page_style" /> - <paypal_hdrimg extends="//paypal_payments/payflow_advanced//frontend/*/paypal_hdrimg" /> - <paypal_hdrbackcolor extends="//paypal_payments/payflow_advanced//frontend/*/paypal_hdrbackcolor" /> - <paypal_hdrbordercolor extends="//paypal_payments/payflow_advanced//frontend/*/paypal_hdrbordercolor" /> - <paypal_payflowcolor extends="//paypal_payments/payflow_advanced//frontend/*/paypal_payflowcolor" /> - </fields> - </wpp_frontend> - </fields> - </wpp_settings_advanced> - </fields> - </wpp_settings> - - <wpp_settings_express_checkout type="group" translate="label"> - <label>Basic Settings - PayPal Express Checkout</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>30</sort_order> - <fields> - <title extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/title" /> - <sort_order extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/sort_order" /> - <payment_action extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/payment_action" /> - <visible_on_product extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/visible_on_product" /> - <authorization_honor_period extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/authorization_honor_period" /> - <order_valid_period extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/order_valid_period" /> - <child_authorization_number extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/child_authorization_number" /> - - <wpp_settings_express_checkout_advanced type="group" translate="label"> - <label>Advanced Settings</label> - <frontend_class>config-advanced</frontend_class> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>80</sort_order> - <fields> - <visible_on_cart extends="//paypal_payments/payflow_advanced//settings_express_checkout//visible_on_cart" /> - <allowspecific extends="//paypal_payments/payflow_advanced//settings_express_checkout//allowspecific" /> - <specificcountry extends="//paypal_payments/payflow_advanced//settings_express_checkout//specificcountry" /> - <debug extends="//paypal_payments/payflow_advanced//settings_express_checkout//debug" /> - <verify_peer extends="//paypal_payments/payflow_advanced//settings_express_checkout//verify_peer" /> - <line_items_enabled extends="//paypal_payments/payflow_advanced//settings_express_checkout//line_items_enabled" /> - <transfer_shipping_options extends="//paypal_payments/payflow_advanced//settings_express_checkout//transfer_shipping_options" /> - <button_flavor extends="//paypal_payments/payflow_advanced//settings_express_checkout//button_flavor" /> - <solution_type extends="//paypal_payments/payflow_advanced//settings_express_checkout//solution_type" /> - <require_billing_address extends="//paypal_payments/payflow_advanced//settings_express_checkout//require_billing_address" /> - <allow_ba_signup extends="//paypal_payments/payflow_advanced//settings_express_checkout//allow_ba_signup" /> - <skip_order_review_step extends="//paypal_payments/payflow_advanced//settings_express_checkout//skip_order_review_step" /> - </fields> - </wpp_settings_express_checkout_advanced> - </fields> - </wpp_settings_express_checkout> - </fields> - </wpp> - <wps type="group" translate="label comment"> - <label>Website Payments Standard</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>50</sort_order> - <group>paypal_payment_solutions</group> - <include>1</include> - <frontend_class>pp-method-general</frontend_class> - <frontend_model>paypal/adminhtml_system_config_fieldset_deprecated</frontend_model> - <was_enabled_path>payment/paypal_standard/was_active</was_enabled_path> - <comment>Accept credit card and PayPal payments securely.</comment> - <activity_path>payment/paypal_standard/active</activity_path> - <learn_more_link>https://www.paypal.com/webapps/mpp/referral/website-payments-standard?partner_id=NB9WWHYEMVUMS</learn_more_link> - <backend_config> - <AU> - <sort_order>20</sort_order> - </AU> - <CA> - <sort_order>20</sort_order> - </CA> - <US translate="label"> - <label>Payments Standard</label> - <group>paypal_group_all_in_one</group> - <fields> - <settings_payments_standart translate="label"> - <label>Basic Settings - PayPal Payments Standard</label> - </settings_payments_standart> - </fields> - </US> - <GB translate="comment"> - <group>paypal_group_all_in_one</group> - <frontend_class>pp-general-uk</frontend_class> - <sort_order>10</sort_order> - <learn_more_link>https://www.paypal-business.co.uk/accept-online-payments-with-paypal/index.htm</learn_more_link> - <demo_link>http://www.youtube.com/watch?v=mdPjvziH_rk&list=PLF18B1094ABCD7CE8&index=6&feature=plpp_video</demo_link> - <comment>Accept credit cards, debit cards and PayPal payments securely.</comment> - </GB> - </backend_config> - <fields> - <wps_required_settings type="group" translate="label"> - <label>Required PayPal Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>10</sort_order> - <fields> - <business_account extends="//paypal_payments/payflow_advanced//business_account" /> - <enable_wps translate="label"> - <label>Enable this Solution</label> - <config_path>payment/paypal_standard/active</config_path> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>20</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <requires>wps_required_settings_business_account</requires> - <frontend_class>paypal-enabler paypal-ec-conflicts</frontend_class> - </enable_wps> - </fields> - </wps_required_settings> - <settings_payments_standart type="group" translate="label"> - <label>Basic Settings - PayPal Website Payments Standard</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>20</sort_order> - <fields> - <title translate="label comment"> - <label>Title</label> - <comment>It is recommended to set this value to "PayPal" per store views.</comment> - <config_path>payment/paypal_standard/title</config_path> - <sort_order>10</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - - - - payment/paypal_standard/sort_order - 20 - 1 - 1 - 1 - validate-number - - - - payment/paypal_standard/payment_action - select - paypal/system_config_source_paymentActions - 30 - 1 - 1 - - - - config-advanced - 1 - 1 - 40 - - - - payment/paypal_standard/allowspecific - select - adminhtml/system_config_source_payment_allspecificcountries - 10 - 1 - 1 - - - - payment/paypal_standard/specificcountry - multiselect - paypal/system_config_source_buyerCountry - 20 - 1 - 1 - 1 - - - - payment/paypal_standard/sandbox_flag - select - adminhtml/system_config_source_yesno - 30 - 1 - 1 - - - - payment/paypal_standard/line_items_enabled - select - adminhtml/system_config_source_yesno - 40 - 1 - 1 - - - - payment/paypal_standard/line_items_summary - Uses store frontend name by default. - 50 - 1 - 1 - 1 - 0 - - - - payment/paypal_standard/debug - select - adminhtml/system_config_source_yesno - 60 - 1 - 1 - - - - payment/paypal_standard/verify_peer - select - adminhtml/system_config_source_yesno - 70 - 1 - 1 - - - - - - - - - - 1 - 1 - 1 - 50 - paypal_payment_solutions - 1 - pp-method-general - paypal/adminhtml_system_config_fieldset_pathDependent - payment/paypal_standard/active - Add PayPal as an additional payment method to your checkout page. - payment/paypal_wps_express/active - https://www.paypal.com/webapps/mpp/referral/paypal-express-checkout?partner_id=NB9WWHYEMVUMS - - - 20 - - - 20 - - - - paypal_group_all_in_one - - - - - - - - wps_express_checkout_required_enable_wps_express_checkout - - - - - Why Advertise Financing?
- Give your sales a boost when you advertise financing.
PayPal helps turn browsers into buyers with financing - from Paypal Credit®. Your customers have more time to pay, while you get paid up front – at no additional cost to you. - Use PayPal’s free banner ads that let you advertise Paypal Credit® financing as a payment option when your customers check out with PayPal. - The PayPal Advertising Program has been shown to generate additional purchases as well as increase consumer's average purchase sizes by 15% - or more. See Details.]]> -
- 1 - 1 - 32 - - - - - - 1 - 1 - 1 - 20 - - - - - - payment/paypal_express_bml/homepage_size - select - paypal/system_config_source_bmlSize::getBmlSizeHPH - 1 - 1 - 30 - 1 - 0 - - - 1 - - - - - - 1 - 1 - 1 - 30 - - - - - - payment/paypal_express_bml/categorypage_size - select - paypal/system_config_source_bmlSize::getBmlSizeCCPC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCCPS - 1 - - - - - - - 1 - 1 - 1 - 40 - - - - - - payment/paypal_express_bml/productpage_size - select - paypal/system_config_source_bmlSize::getBmlSizeCPPC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCPPN - 1 - - - - - - - 1 - 1 - 1 - 50 - - - - - - payment/paypal_express_bml/checkout_size - select - paypal/system_config_source_bmlSize::getBmlSizeCheckoutC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCheckoutN - 1 - 1 - - - - -
-
-
- - - -
-
- - https://www.paypal-business.co.uk/add-paypal-to-online-shop/index.htm - http://www.youtube.com/watch?v=WgnfZ2Bj6hQ - Add PayPal as an additional payment method to your checkout page to increase your sales. - -
- - - - 1 - 1 - 10 - paypal/adminhtml_system_config_fieldset_expanded - - - - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 10 - - - - - - - - - - - - - - - - - payment/paypal_wps_express/active - select - adminhtml/system_config_source_yesno - 20 - 1 - 1 - 1 - wps_express_checkout_required_express_checkout - paypal-enabler - - - - - - 1 - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 20 - - - <sort_order extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/sort_order" /> - <payment_action extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/payment_action" /> - <visible_on_product extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/visible_on_product" /> - <authorization_honor_period extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/authorization_honor_period" /> - <order_valid_period extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/order_valid_period" /> - <child_authorization_number extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/child_authorization_number" /> - - <settings_wps_express_advanced type="group" translate="label"> - <label>Advanced Settings</label> - <frontend_class>config-advanced</frontend_class> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>80</sort_order> - <fields> - <visible_on_cart extends="//paypal_payments/payflow_advanced//settings_express_checkout//visible_on_cart" /> - <allowspecific extends="//paypal_payments/payflow_advanced//settings_express_checkout//allowspecific" /> - <specificcountry extends="//paypal_payments/payflow_advanced//settings_express_checkout//specificcountry" /> - <debug extends="//paypal_payments/payflow_advanced//settings_express_checkout//debug" /> - <verify_peer extends="//paypal_payments/payflow_advanced//settings_express_checkout//verify_peer" /> - <line_items_enabled extends="//paypal_payments/payflow_advanced//settings_express_checkout//line_items_enabled" /> - <transfer_shipping_options extends="//paypal_payments/payflow_advanced//settings_express_checkout//transfer_shipping_options" /> - <button_flavor extends="//paypal_payments/payflow_advanced//settings_express_checkout//button_flavor" /> - <solution_type extends="//paypal_payments/payflow_advanced//settings_express_checkout//solution_type" /> - <require_billing_address extends="//paypal_payments/payflow_advanced//settings_express_checkout//require_billing_address" /> - <allow_ba_signup extends="//paypal_payments/payflow_advanced//settings_express_checkout//allow_ba_signup" /> - <skip_order_review_step extends="//paypal_payments/payflow_advanced//settings_express_checkout//skip_order_review_step" /> - - <wps_express_billing_agreement type="group" translate="label"> - <label>PayPal Billing Agreement Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>100</sort_order> - <fields> - <active extends="//paypal_payments/payflow_advanced//billing_agreement/*/active" /> - <title extends="//paypal_payments/payflow_advanced//billing_agreement/*/title" /> - <sort_order extends="//paypal_payments/payflow_advanced//billing_agreement/*/sort_order" /> - <payment_action extends="//paypal_payments/payflow_advanced//billing_agreement/*/payment_action" /> - <allowspecific extends="//paypal_payments/payflow_advanced//billing_agreement/*/allowspecific" /> - <specificcountry extends="//paypal_payments/payflow_advanced//billing_agreement/*/specificcountry" /> - <debug extends="//paypal_payments/payflow_advanced//billing_agreement/*/debug" /> - <verify_peer extends="//paypal_payments/payflow_advanced//billing_agreement/*/verify_peer" /> - <line_items_enabled extends="//paypal_payments/payflow_advanced//billing_agreement/*/line_items_enabled" /> - <allow_billing_agreement_wizard extends="//paypal_payments/payflow_advanced//billing_agreement/*/allow_billing_agreement_wizard" /> - </fields> - </wps_express_billing_agreement> - <wps_express_settlement_report type="group" translate="label"> - <label>Settlement Report Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>110</sort_order> - <fields> - <heading_sftp extends="//paypal_payments/payflow_advanced//settlement_report/*/heading_sftp" /> - <settlement_reports_ftp_login extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_login" /> - <settlement_reports_ftp_password extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_password" /> - <settlement_reports_ftp_sandbox extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_sandbox" /> - <settlement_reports_ftp_ip extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_ip" /> - <settlement_reports_ftp_path extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_path" /> - <heading_schedule extends="//paypal_payments/payflow_advanced//settlement_report/*/heading_schedule" /> - <settlement_reports_active extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_active" /> - <settlement_reports_schedule extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_schedule" /> - <settlement_reports_time extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_time" /> - </fields> - </wps_express_settlement_report> - <wps_express_frontend type="group" translate="label"> - <label>Frontend Experience Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>120</sort_order> - <fields> - <logo extends="//paypal_payments/payflow_advanced//frontend/*/logo" /> - <paypal_pages extends="//paypal_payments/payflow_advanced//frontend/*/paypal_pages" /> - <page_style extends="//paypal_payments/payflow_advanced//frontend/*/page_style" /> - <paypal_hdrimg extends="//paypal_payments/payflow_advanced//frontend/*/paypal_hdrimg" /> - <paypal_hdrbackcolor extends="//paypal_payments/payflow_advanced//frontend/*/paypal_hdrbackcolor" /> - <paypal_hdrbordercolor extends="//paypal_payments/payflow_advanced//frontend/*/paypal_hdrbordercolor" /> - <paypal_payflowcolor extends="//paypal_payments/payflow_advanced//frontend/*/paypal_payflowcolor" /> - </fields> - </wps_express_frontend> - </fields> - </settings_wps_express_advanced> - </fields> - </settings_wps_express> - </fields> - </wps_express> - <paypal_verisign type="group" translate="label comment"> - <label>Payflow Pro</label> - <frontend_model>paypal/adminhtml_system_config_fieldset_payment</frontend_model> - <frontend_class>pp-method-payflow</frontend_class> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>10</sort_order> - <group>paypal_payment_solutions</group> - <comment>Connect your merchant account with a fully customizable gateway that lets customers pay without leaving your site.</comment> - <activity_path>payment/verisign/active</activity_path> - <learn_more_link>https://www.paypal.com/webapps/mpp/referral/paypal-payflow-pro?partner_id=NB9WWHYEMVUMS</learn_more_link> - <paypal_ec_separate>1</paypal_ec_separate> - <backend_config> - <CA> - <include>1</include> - <sort_order>30</sort_order> - </CA> - <AU> - <include>1</include> - <sort_order>20</sort_order> - </AU> - <NZ> - <include>1</include> - <sort_order>20</sort_order> - </NZ> - </backend_config> - <fields> - <paypal_payflow_required type="group" translate="label"> - <label>Required PayPal Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>10</sort_order> - <fields> - <paypal_payflow_api_settings type="group" translate="label"> - <label>Payflow Pro</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>10</sort_order> - <fields> - <partner translate="label"> - <label>Partner</label> - <config_path>payment/verisign/partner</config_path> - <sort_order>20</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - </partner> - <user translate="label"> - <label>User</label> - <config_path>payment/verisign/user</config_path> - <frontend_type>obscure</frontend_type> - <backend_model>adminhtml/system_config_backend_encrypted</backend_model> - <sort_order>30</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - </user> - <vendor translate="label"> - <label>Vendor</label> - <config_path>payment/verisign/vendor</config_path> - <sort_order>40</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - </vendor> - <pwd translate="label"> - <label>Password</label> - <config_path>payment/verisign/pwd</config_path> - <frontend_type>obscure</frontend_type> - <backend_model>adminhtml/system_config_backend_encrypted</backend_model> - <sort_order>50</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - </pwd> - <sandbox_flag translate="label"> - <label>Test Mode</label> - <config_path>payment/verisign/sandbox_flag</config_path> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>60</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - </sandbox_flag> - <use_proxy translate="label"> - <label>Use Proxy</label> - <config_path>payment/verisign/use_proxy</config_path> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>70</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - </use_proxy> - <proxy_host translate="label"> - <label>Proxy Host</label> - <config_path>payment/verisign/proxy_host</config_path> - <sort_order>80</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <depends><use_proxy>1</use_proxy></depends> - </proxy_host> - <proxy_port translate="label"> - <label>Proxy Port</label> - <config_path>payment/verisign/proxy_port</config_path> - <sort_order>90</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <depends><use_proxy>1</use_proxy></depends> - </proxy_port> - </fields> - </paypal_payflow_api_settings> - <enable_paypal_payflow translate="label"> - <label>Enable this Solution</label> - <config_path>payment/verisign/active</config_path> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>20</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <requires>paypal_payflow_api_settings</requires> - <frontend_class>paypal-enabler paypal-ec-separate</frontend_class> - </enable_paypal_payflow> - </fields> - </paypal_payflow_required> - <settings_paypal_payflow type="group" translate="label"> - <label>Basic Settings - PayPal Payflow Pro</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>20</sort_order> - <fields> - <title translate="label comment"> - <label>Title</label> - <comment>It is recommended to set this value to "Debit or Credit Card" per store views.</comment> - <config_path>payment/verisign/title</config_path> - <sort_order>10</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - - - - payment/verisign/sort_order - 20 - 1 - 1 - 1 - validate-number - - - - payment/verisign/payment_action - select - paypal/system_config_source_paymentActions - 30 - 1 - 1 - - - - adminhtml/system_config_form_field_heading - 40 - 1 - 1 - - - - http://www.paypal.com/amexupdate.]]> - payment/verisign/cctypes - multiselect - paypal/config::getPayflowproCcTypesAsOptionArray - 50 - 1 - 1 - - - - config-advanced - 1 - 1 - 1 - 60 - - - - payment/verisign/allowspecific - select - 10 - adminhtml/system_config_source_payment_allspecificcountries - 1 - 1 - - - - payment/verisign/specificcountry - multiselect - 20 - paypal/system_config_source_buyerCountry - 1 - 1 - 1 - - - - payment/verisign/debug - select - adminhtml/system_config_source_yesno - 30 - 1 - 1 - - - - payment/verisign/verify_peer - select - adminhtml/system_config_source_yesno - 35 - 1 - 1 - - - - payment/verisign/useccv - select - adminhtml/system_config_source_yesno - 40 - 1 - 1 - - - - adminhtml/system_config_form_field_heading - 50 - 1 - 1 - - - - payment/verisign/centinel - select - adminhtml/system_config_source_yesno - 60 - 1 - 1 - - - - payment/verisign/centinel_is_mode_strict - Severe validation removes chargeback liability on merchant. - select - adminhtml/system_config_source_yesno - 70 - 1 - 1 - 1 - - - - payment/verisign/centinel_api_url - A value is required for live mode. Refer to your CardinalCommerce agreement. - adminhtml/system_config_source_yesno - 80 - 1 - 1 - 1 - - - - 1 - 1 - 90 - - - - - - - - - - - - - - - - - - - - - - 0 - - - 0 - - - 0 - - - 1 - paypal_payment_gateways - - - - - - - 10 - not-required - - - - - - paypal-enabler paypal-ec-pe - - - - Learn More]]> - - payment/paypaluk_express_bml/active - select - adminhtml/system_config_source_yesno - 21 - 1 - 1 - 1 - paypal-bml - paypal_payflow_required_enable_paypal_payflow - - - - - Why Advertise Financing?
- Give your sales a boost when you advertise financing.
PayPal helps turn browsers into buyers with financing - from Paypal Credit®. Your customers have more time to pay, while you get paid up front – at no additional cost to you. - Use PayPal’s free banner ads that let you advertise Paypal Credit® financing as a payment option when your customers check out with PayPal. - The PayPal Advertising Program has been shown to generate additional purchases as well as increase consumer's average purchase sizes by 15% - or more. See Details.]]> -
- 1 - 1 - 22 - - - - - - 1 - 1 - 1 - 20 - - - - - - payment/paypal_express_bml/homepage_size - select - paypal/system_config_source_bmlSize::getBmlSizeHPH - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeHPS - 1 - - - - - - 1 - 1 - 1 - 30 - - - - - - payment/paypal_express_bml/categorypage_size - select - paypal/system_config_source_bmlSize::getBmlSizeCCPC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCCPS - 1 - - - - - - - 1 - 1 - 1 - 40 - - - - - - payment/paypal_express_bml/productpage_size - select - paypal/system_config_source_bmlSize::getBmlSizeCPPC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCPPN - 1 - - - - - - - 1 - 1 - 1 - 50 - - - - - - payment/paypal_express_bml/checkout_size - select - paypal/system_config_source_bmlSize::getBmlSizeCheckoutC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCheckoutN - 1 - 1 - - - - - -
- -
-
-
-
- - 0 - -
- - - - 1 - 1 - 10 - - - - - - - - - - - - - 1 - 1 - 1 - 100 - - - - - - - - - - - - - - - - - 1 - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 30 - - - payment/paypaluk_express/active - select - paypal/adminhtml_system_config_field_hidden - paypal-ec-payflow-enabler - adminhtml/system_config_source_yesno - 1 - 1 - - - <label>Title</label> - <config_path>payment/paypaluk_express/title</config_path> - <sort_order>10</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - - - - payment/paypaluk_express/sort_order - 20 - 1 - 1 - 1 - validate-number - - - - payment/paypaluk_express/payment_action - select - paypal/system_config_source_paymentActions - 30 - 1 - 1 - - - - payment/paypaluk_express/visible_on_product - select - adminhtml/system_config_source_yesno - 50 - 1 - 1 - 1 - - - - config-advanced - 1 - 1 - 60 - - - - Also affects mini-shopping cart. - payment/paypaluk_express/visible_on_cart - select - paypal/system_config_source_yesnoShortcut - 5 - 1 - 1 - 1 - - - - payment/paypaluk_express/allowspecific - select - 10 - adminhtml/system_config_source_payment_allspecificcountries - 1 - 1 - - - - payment/paypaluk_express/specificcountry - multiselect - 20 - paypal/system_config_source_buyerCountry - 1 - 1 - 1 - - - - payment/paypaluk_express/debug - select - adminhtml/system_config_source_yesno - 30 - 1 - 1 - - - - payment/paypaluk_express/verify_peer - select - adminhtml/system_config_source_yesno - 35 - 1 - 1 - - - - payment/paypaluk_express/line_items_enabled - select - adminhtml/system_config_source_yesno - 40 - 1 - 1 - - - - - - -
- - - 1 - 1 - 1 - 20 - paypal_payment_solutions - paypal/adminhtml_system_config_fieldset_payment - pp-method-payflow - Connect your merchant account with a PCI-compliant gateway that lets customers pay without leaving your site. - payment/payflow_link/active - https://www.paypal.com/webapps/mpp/referral/paypal-payflow-link?partner_id=NB9WWHYEMVUMS - - - 1 - 40 - - - 1 - paypal_payment_gateways - - - - - Learn More]]> - - 41 - payflow_link_required_enable_express_checkout - - - - - Why Advertise Financing?
- Give your sales a boost when you advertise financing.
PayPal helps turn browsers into buyers with financing - from Paypal Credit®. Your customers have more time to pay, while you get paid up front – at no additional cost to you. - Use PayPal’s free banner ads that let you advertise Paypal Credit® financing as a payment option when your customers check out with PayPal. - The PayPal Advertising Program has been shown to generate additional purchases as well as increase consumer's average purchase sizes by 15% - or more. See Details.]]> -
- 1 - 1 - 42 - - - - - - 1 - 1 - 1 - 20 - - - - - - payment/paypal_express_bml/homepage_size - select - paypal/system_config_source_bmlSize::getBmlSizeHPH - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeHPS - 1 - - - - - - 1 - 1 - 1 - 30 - - - - - - payment/paypal_express_bml/categorypage_size - select - paypal/system_config_source_bmlSize::getBmlSizeCCPC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCCPS - 1 - - - - - - - 1 - 1 - 1 - 40 - - - - - - payment/paypal_express_bml/productpage_size - select - paypal/system_config_source_bmlSize::getBmlSizeCPPC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCPPN - 1 - - - - - - - 1 - 1 - 1 - 50 - - - - - - payment/paypal_express_bml/checkout_size - select - paypal/system_config_source_bmlSize::getBmlSizeCheckoutC - 1 - 1 - 30 - 1 - 0 - - - paypal/system_config_source_bmlSize::getBmlSizeCheckoutN - 1 - 1 - - - - - -
-
-
-
-
-
- - - - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 10 - - - - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 10 - - - - payment/payflow_link/partner - 10 - 1 - 1 - - - - payment/payflow_link/vendor - 20 - 1 - 1 - - - - If you do not have multiple users set up on your account, please re-enter your Vendor/Merchant Login here. - payment/payflow_link/user - 30 - 1 - 1 - - - - payment/payflow_link/pwd - obscure - adminhtml/system_config_backend_encrypted - 40 - 1 - 1 - - - - payment/payflow_link/sandbox_flag - select - adminhtml/system_config_source_yesno - 50 - 1 - 1 - - - - payment/payflow_link/use_proxy - select - adminhtml/system_config_source_yesno - 60 - 1 - 1 - - - - payment/payflow_link/proxy_host - 70 - 1 - 1 - 1 - - - - payment/payflow_link/proxy_port - 80 - 1 - 1 - 1 - - - paypal/adminhtml_system_config_payflowlink_info - 1 - 1 - 1 - 90 - - - - - - payment/payflow_link/active - select - adminhtml/system_config_source_yesno - 20 - 1 - 1 - payflow_link_payflow_link - paypal-enabler paypal-ec-independent - - - - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 30 - - - - - - - - - - - - - - - - - payment/paypal_express/active - select - adminhtml/system_config_source_yesno - 40 - 1 - 1 - 1 - payflow_link_required_enable_payflow_link,payflow_link_express_checkout - paypal-enabler paypal-ec-enabler - - - - - - - 1 - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 20 - - - <label>Title</label> - <comment>It is recommended to set this value to "Debit or Credit Card" per store views.</comment> - <config_path>payment/payflow_link/title</config_path> - <sort_order>10</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - - - - payment/payflow_link/sort_order - 20 - 1 - 1 - 1 - validate-number - - - - payment/payflow_link/payment_action - select - paypal/system_config_source_paymentActions - 30 - 1 - 1 - - - - config-advanced - 1 - 1 - 1 - 40 - - - - payment/payflow_link/allowspecific - select - adminhtml/system_config_source_payment_allspecificcountries - 10 - 1 - 1 - - - - payment/payflow_link/specificcountry - multiselect - paypal/system_config_source_buyerCountry - 20 - 1 - 1 - 1 - - - - payment/payflow_link/debug - select - adminhtml/system_config_source_yesno - 30 - 1 - 1 - - - - payment/payflow_link/verify_peer - select - adminhtml/system_config_source_yesno - 35 - 1 - 1 - - - - payment/payflow_link/csc_editable - select - adminhtml/system_config_source_yesno - 40 - 1 - 1 - - - - payment/payflow_link/csc_required - select - adminhtml/system_config_source_yesno - 50 - 1 - 1 - 1 - - - - payment/payflow_link/email_confirmation - select - adminhtml/system_config_source_yesno - 60 - 1 - 1 - - - - payment/payflow_link/url_method - select - paypal/system_config_source_urlMethod - 70 - 1 - 1 - - - - payment/payflow_link/mobile_optimized - select - adminhtml/system_config_source_yesno - 75 - 1 - 1 - - - - 1 - 1 - 80 - - - - - - - - - - - - - - - - 1 - 1 - 1 - 90 - - - - - - - - - - - - - - - - - 1 - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 30 - - - <sort_order extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/sort_order" /> - <payment_action extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/payment_action" /> - <visible_on_product extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/visible_on_product" /> - <authorization_honor_period extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/authorization_honor_period" /> - <order_valid_period extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/order_valid_period" /> - <child_authorization_number extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/child_authorization_number" /> - - <settings_payflow_link_express_checkout_advanced type="group" translate="label"> - <label>Advanced Settings</label> - <frontend_class>config-advanced</frontend_class> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>80</sort_order> - <fields> - <visible_on_cart extends="//paypal_payments/payflow_advanced//settings_express_checkout//visible_on_cart" /> - <allowspecific extends="//paypal_payments/payflow_advanced//settings_express_checkout//allowspecific" /> - <specificcountry extends="//paypal_payments/payflow_advanced//settings_express_checkout//specificcountry" /> - <debug extends="//paypal_payments/payflow_advanced//settings_express_checkout//debug" /> - <verify_peer extends="//paypal_payments/payflow_advanced//settings_express_checkout//verify_peer" /> - <line_items_enabled extends="//paypal_payments/payflow_advanced//settings_express_checkout//line_items_enabled" /> - <transfer_shipping_options extends="//paypal_payments/payflow_advanced//settings_express_checkout//transfer_shipping_options" /> - <button_flavor extends="//paypal_payments/payflow_advanced//settings_express_checkout//button_flavor" /> - <solution_type extends="//paypal_payments/payflow_advanced//settings_express_checkout//solution_type" /> - <require_billing_address extends="//paypal_payments/payflow_advanced//settings_express_checkout//require_billing_address" /> - <allow_ba_signup extends="//paypal_payments/payflow_advanced//settings_express_checkout//allow_ba_signup" /> - <skip_order_review_step extends="//paypal_payments/payflow_advanced//settings_express_checkout//skip_order_review_step" /> - - <payflow_link_billing_agreement type="group" translate="label"> - <label>PayPal Billing Agreement Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>100</sort_order> - <fields> - <active extends="//paypal_payments/payflow_advanced//billing_agreement/*/active" /> - <title extends="//paypal_payments/payflow_advanced//billing_agreement/*/title" /> - <sort_order extends="//paypal_payments/payflow_advanced//billing_agreement/*/sort_order" /> - <payment_action extends="//paypal_payments/payflow_advanced//billing_agreement/*/payment_action" /> - <allowspecific extends="//paypal_payments/payflow_advanced//billing_agreement/*/allowspecific" /> - <specificcountry extends="//paypal_payments/payflow_advanced//billing_agreement/*/specificcountry" /> - <debug extends="//paypal_payments/payflow_advanced//billing_agreement/*/debug" /> - <verify_peer extends="//paypal_payments/payflow_advanced//billing_agreement/*/verify_peer" /> - <line_items_enabled extends="//paypal_payments/payflow_advanced//billing_agreement/*/line_items_enabled" /> - <allow_billing_agreement_wizard extends="//paypal_payments/payflow_advanced//billing_agreement/*/allow_billing_agreement_wizard" /> - </fields> - </payflow_link_billing_agreement> - </fields> - </settings_payflow_link_express_checkout_advanced> - </fields> - </settings_payflow_link_express_checkout> - </fields> - </payflow_link> - <payments_pro_payflow_edition type="group" translate="label comment"> - <label>Website Payments Pro Payflow Edition (Includes Express Checkout)</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>40</sort_order> - <group>paypal_group_all_in_one</group> - <frontend_class>pp-general-uk</frontend_class> - <frontend_model>paypal/adminhtml_system_config_fieldset_deprecated</frontend_model> - <was_enabled_path>payment/paypaluk_direct/was_active</was_enabled_path> - <activity_path>payment/paypaluk_direct/active</activity_path> - <comment>Accept payments in your shopping cart. PayPal will process your card payments through the Payflow Gateway.</comment> - <backend_config> - <GB> - <include>1</include> - </GB> - </backend_config> - <fields> - <pp_pe_required_settings type="group" translate="label"> - <label>Required Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>10</sort_order> - <fields> - <pp_pe_api_settings type="group" translate="label"> - <label>Website Payments Pro Payflow Edition and Express Checkout</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>10</sort_order> - <fields> - <business_account extends="//paypal_payments/payflow_advanced//business_account" translate="label"> - <sort_order>10</sort_order> - <frontend_class>not-required</frontend_class> - <label>Email Associated with PayPal Merchant Account (Optional)</label> - </business_account> - <partner translate="label"> - <label>Partner</label> - <config_path>paypal/wpuk/partner</config_path> - <sort_order>20</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - </partner> - <user translate="label"> - <label>User</label> - <frontend_type>obscure</frontend_type> - <config_path>paypal/wpuk/user</config_path> - <backend_model>adminhtml/system_config_backend_encrypted</backend_model> - <sort_order>30</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - </user> - <vendor translate="label"> - <label>Vendor</label> - <config_path>paypal/wpuk/vendor</config_path> - <sort_order>40</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - </vendor> - <pwd translate="label"> - <label>Password</label> - <config_path>paypal/wpuk/pwd</config_path> - <frontend_type>obscure</frontend_type> - <backend_model>adminhtml/system_config_backend_encrypted</backend_model> - <sort_order>50</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - </pwd> - <sandbox_flag translate="label"> - <label>Test Mode</label> - <config_path>paypal/wpuk/sandbox_flag</config_path> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>60</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - </sandbox_flag> - <use_proxy translate="label"> - <label>API Uses Proxy</label> - <config_path>paypal/wpuk/use_proxy</config_path> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>70</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - </use_proxy> - <proxy_host translate="label"> - <label>Proxy Host</label> - <config_path>paypal/wpuk/proxy_host</config_path> - <sort_order>80</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <depends><use_proxy>1</use_proxy></depends> - </proxy_host> - <proxy_port translate="label"> - <label>Proxy Port</label> - <config_path>paypal/wpuk/proxy_port</config_path> - <sort_order>90</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <depends><use_proxy>1</use_proxy></depends> - </proxy_port> - </fields> - </pp_pe_api_settings> - <enable_pp_pe translate="label"> - <label>Enable this Solution</label> - <config_path>payment/paypaluk_direct/active</config_path> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>20</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <requires>pp_pe_api_settings</requires> - <frontend_class>paypal-enabler paypal-ec-pe</frontend_class> - </enable_pp_pe> - - </fields> - </pp_pe_required_settings> - <settings_pp_pe type="group" translate="label"> - <label>Basic Settings - PayPal Website Payments Pro Payflow Edition</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>20</sort_order> - <fields> - <title translate="label comment"> - <label>Title</label> - <comment>It is recommended to set this value to "Debit or Credit Card" per store views.</comment> - <config_path>payment/paypaluk_direct/title</config_path> - <sort_order>10</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - - - - payment/paypaluk_direct/sort_order - 20 - 1 - 1 - 1 - validate-number - - - - payment/paypaluk_direct/payment_action - select - paypal/system_config_source_paymentActions - 30 - 1 - 1 - - - - adminhtml/system_config_form_field_heading - 40 - 1 - 1 - - - - - payment/paypaluk_direct/cctypes - multiselect - paypal/config::getWppPeCcTypesAsOptionArray - 50 - 1 - 1 - - - - config-advanced - 1 - 1 - 1 - 60 - - - - payment/paypaluk_direct/allowspecific - select - adminhtml/system_config_source_payment_allspecificcountries - 10 - 1 - 1 - - - - payment/paypaluk_direct/specificcountry - multiselect - paypal/system_config_source_buyerCountry - 20 - 1 - 1 - 1 - - - - payment/paypaluk_direct/debug - select - adminhtml/system_config_source_yesno - 30 - 1 - 1 - - - - payment/paypaluk_direct/verify_peer - select - adminhtml/system_config_source_yesno - 35 - 1 - 1 - - - - payment/paypaluk_direct/line_items_enabled - select - adminhtml/system_config_source_yesno - 37 - 1 - 1 - - - - payment/paypaluk_direct/useccv - select - adminhtml/system_config_source_yesno - 40 - 1 - 1 - - - - adminhtml/system_config_form_field_heading - 50 - 1 - 1 - - - - payment/paypaluk_direct/centinel - select - adminhtml/system_config_source_yesno - 60 - 1 - 1 - - - - payment/paypaluk_direct/centinel_is_mode_strict - Severe Validation Removes Chargeback Liability on Merchant - select - adminhtml/system_config_source_yesno - 70 - 1 - 1 - 1 - - - - payment/paypaluk_direct/centinel_api_url - If empty, a default value will be used. Custom URL may be provided by CardinalCommerce agreement. - adminhtml/system_config_source_yesno - 80 - 1 - 1 - 1 - - - - 1 - 1 - 90 - - - - - - - - - - - - - - - - 1 - 1 - 1 - 100 - - - - - - - - - - - - - - - - - 1 - 1 - 1 - paypal/adminhtml_system_config_fieldset_expanded - 30 - - - - <sort_order extends="//paypal_payments/paypal_verisign_with_express_checkout//paypal_payflow_express_checkout/*/sort_order" /> - <payment_action extends="//paypal_payments/paypal_verisign_with_express_checkout//paypal_payflow_express_checkout/*/payment_action" /> - <visible_on_product extends="//paypal_payments/paypal_verisign_with_express_checkout//paypal_payflow_express_checkout/*/visible_on_product" /> - <pp_pe_express_checkout_advanced type="group" extends="//paypal_payments/paypal_verisign_with_express_checkout//paypal_payflow_express_checkout_advanced" /> - </fields> - </settings_pp_pe_express_checkout> - </fields> - </payments_pro_payflow_edition> - <payments_pro_hosted_solution type="group" translate="label comment"> - <label>Website Payments Pro Hosted Solution</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>20</sort_order> - <group>paypal_payment_solutions</group> - <frontend_class>pp-method-general</frontend_class> - <frontend_model>paypal/adminhtml_system_config_fieldset_payment</frontend_model> - <activity_path>payment/hosted_pro/active</activity_path> - <comment>Accept payments with a PCI compliant checkout that keeps customers on your site.</comment> - <paypal_ec_separate>1</paypal_ec_separate> - <backend_config> - <JP translate="label"> - <label>Website Payments Plus</label> - <include>1</include> - <fields> - <pphs_required_settings> - <fields> - <pphs_required_settings_pphs translate="label"> - <label>Website Payments Plus</label> - </pphs_required_settings_pphs> - </fields> - </pphs_required_settings> - <pphs_settings translate="label"> - <label>Basic Settings - PayPal Website Payments Plus</label> - </pphs_settings> - </fields> - </JP> - <FR translate="label"> - <label>Integral Evolution</label> - <include>1</include> - <fields> - <pphs_required_settings> - <fields> - <pphs_required_settings_pphs translate="label"> - <label>Integral Evolution</label> - </pphs_required_settings_pphs> - </fields> - </pphs_required_settings> - <pphs_settings translate="label"> - <label>Basic Settings - PayPal Integral Evolution</label> - </pphs_settings> - </fields> - </FR> - <IT translate="label"> - <label>Pro</label> - <include>1</include> - <fields> - <pphs_required_settings> - <fields> - <pphs_required_settings_pphs translate="label"> - <label>PayPal Pro</label> - </pphs_required_settings_pphs> - </fields> - </pphs_required_settings> - <pphs_settings translate="label"> - <label>Basic Settings - PayPal Pro</label> - </pphs_settings> - </fields> - </IT> - <ES translate="label"> - <label>Pasarela integral</label> - <include>1</include> - <fields> - <pphs_required_settings> - <fields> - <pphs_required_settings_pphs translate="label"> - <label>Pasarela integral</label> - </pphs_required_settings_pphs> - </fields> - </pphs_required_settings> - <pphs_settings translate="label"> - <label>Basic Settings - PayPal Pasarela integral</label> - </pphs_settings> - </fields> - </ES> - <HK> - <include>1</include> - </HK> - <AU> - <include>1</include> - <sort_order>30</sort_order> - </AU> - </backend_config> - <fields> - <pphs_required_settings type="group" translate="label"> - <label>Required PayPal Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>10</sort_order> - <fields> - <pphs_required_settings_pphs type="group" translate="label"> - <label>Payments Pro Hosted Solution</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>10</sort_order> - <fields> - <business_account extends="//paypal_payments/payflow_advanced//business_account" /> - <api_authentication extends="//paypal_payments/payflow_advanced//api_authentication" /> - <api_username extends="//paypal_payments/payflow_advanced//api_username" /> - <api_password extends="//paypal_payments/payflow_advanced//api_password" /> - <api_signature extends="//paypal_payments/payflow_advanced//api_signature" /> - <api_cert extends="//paypal_payments/payflow_advanced//api_cert" /> - <api_wizard extends="//paypal_payments/payflow_advanced//api_wizard" /> - <sandbox_flag extends="//paypal_payments/payflow_advanced//express//sandbox_flag" /> - <use_proxy extends="//paypal_payments/payflow_advanced//express//use_proxy" /> - <proxy_host extends="//paypal_payments/payflow_advanced//express//proxy_host" /> - <proxy_port extends="//paypal_payments/payflow_advanced//express//proxy_port" /> - </fields> - </pphs_required_settings_pphs> - <pphs_enable translate="label"> - <label>Enable this Solution</label> - <config_path>payment/hosted_pro/active</config_path> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>20</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <requires>pphs_required_settings_pphs</requires> - <frontend_class>paypal-enabler paypal-ec-separate</frontend_class> - </pphs_enable> - </fields> - </pphs_required_settings> - <pphs_settings type="group" translate="label"> - <label>Basic Settings - PayPal Payments Pro Hosted Solution</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>20</sort_order> - <fields> - <title translate="label comment"> - <label>Title</label> - <comment>It is recommended to set this value to "PayPal" per store views.</comment> - <config_path>payment/hosted_pro/title</config_path> - <sort_order>10</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - - - - payment/hosted_pro/sort_order - 20 - 1 - 1 - 1 - validate-number - - - - payment/hosted_pro/payment_action - select - paypal/system_config_source_paymentActions - 30 - 1 - 1 - - - - payment/hosted_pro/display_ec - select - adminhtml/system_config_source_yesno - 40 - 1 - 1 - - - - config-advanced - 1 - 1 - 1 - 50 - - - - payment/hosted_pro/allowspecific - select - adminhtml/system_config_source_payment_allspecificcountries - 10 - 1 - 1 - - - - payment/hosted_pro/specificcountry - multiselect - paypal/system_config_source_buyerCountry - 20 - 1 - 1 - 1 - - - - payment/hosted_pro/debug - select - adminhtml/system_config_source_yesno - 30 - 1 - 1 - - - - payment/hosted_pro/verify_peer - select - adminhtml/system_config_source_yesno - 35 - 1 - 1 - - - - payment/hosted_pro/mobile_optimized - select - adminhtml/system_config_source_yesno - 37 - 1 - 1 - - - - 1 - 1 - 45 - - - - - - - - - - - - - - - - - - - - - - 30 - paypal_group_all_in_one - pp-general-uk - https://cms.paypal.com/cms_content/GB/en_GB/files/developer/HostedSolution.pdf - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - 1 - - - - - paypal-enabler - - - - - - - - - - - - - - - - - - - - - - 1 - 1 - 1 - 40 - - - - <sort_order extends="//paypal_payments/payflow_advanced//billing_agreement/*/sort_order" /> - <payment_action extends="//paypal_payments/payflow_advanced//billing_agreement/*/payment_action" /> - <allowspecific extends="//paypal_payments/payflow_advanced//billing_agreement/*/allowspecific" /> - <specificcountry extends="//paypal_payments/payflow_advanced//billing_agreement/*/specificcountry" /> - <debug extends="//paypal_payments/payflow_advanced//billing_agreement/*/debug" /> - <verify_peer extends="//paypal_payments/payflow_advanced//billing_agreement/*/verify_peer" /> - <line_items_enabled extends="//paypal_payments/payflow_advanced//billing_agreement/*/line_items_enabled" /> - <allow_billing_agreement_wizard extends="//paypal_payments/payflow_advanced//billing_agreement/*/allow_billing_agreement_wizard" /> - </fields> - </pphs_billing_agreement> - <pphs_frontend type="group" translate="label"> - <label>Frontend Experience Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>50</sort_order> - <fields> - <logo extends="//paypal_payments/payflow_advanced//frontend/*/logo" /> - <paypal_pages extends="//paypal_payments/payflow_advanced//frontend/*/paypal_pages" /> - <page_style extends="//paypal_payments/payflow_advanced//frontend/*/page_style" /> - <paypal_hdrimg extends="//paypal_payments/payflow_advanced//frontend/*/paypal_hdrimg" /> - <paypal_hdrbackcolor extends="//paypal_payments/payflow_advanced//frontend/*/paypal_hdrbackcolor" /> - <paypal_hdrbordercolor extends="//paypal_payments/payflow_advanced//frontend/*/paypal_hdrbordercolor" /> - <paypal_payflowcolor extends="//paypal_payments/payflow_advanced//frontend/*/paypal_payflowcolor" /> - </fields> - </pphs_frontend> - </fields> - </pphs_settings_advanced> - </fields> - </pphs_settings> - <pphs_settings_express_checkout type="group" translate="label"> - <label>Basic Settings - PayPal Express Checkout</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>30</sort_order> - <fields> - <title extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/title" /> - <sort_order extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/sort_order" /> - <payment_action extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/payment_action" /> - <visible_on_product extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/visible_on_product" /> - <authorization_honor_period extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/authorization_honor_period" /> - <order_valid_period extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/order_valid_period" /> - <child_authorization_number extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/child_authorization_number" /> - - <pphs_settings_express_checkout_advanced type="group" translate="label"> - <label>Advanced Settings</label> - <frontend_class>config-advanced</frontend_class> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>80</sort_order> - <fields> - <visible_on_cart extends="//paypal_payments/payflow_advanced//settings_express_checkout//visible_on_cart" /> - <allowspecific extends="//paypal_payments/payflow_advanced//settings_express_checkout//allowspecific" /> - <specificcountry extends="//paypal_payments/payflow_advanced//settings_express_checkout//specificcountry" /> - <debug extends="//paypal_payments/payflow_advanced//settings_express_checkout//debug" /> - <verify_peer extends="//paypal_payments/payflow_advanced//settings_express_checkout//verify_peer" /> - <line_items_enabled extends="//paypal_payments/payflow_advanced//settings_express_checkout//line_items_enabled" /> - <transfer_shipping_options extends="//paypal_payments/payflow_advanced//settings_express_checkout//transfer_shipping_options" /> - <button_flavor extends="//paypal_payments/payflow_advanced//settings_express_checkout//button_flavor" /> - <solution_type extends="//paypal_payments/payflow_advanced//settings_express_checkout//solution_type" /> - <require_billing_address extends="//paypal_payments/payflow_advanced//settings_express_checkout//require_billing_address" /> - <allow_ba_signup extends="//paypal_payments/payflow_advanced//settings_express_checkout//allow_ba_signup" /> - <skip_order_review_step extends="//paypal_payments/payflow_advanced//settings_express_checkout//skip_order_review_step" /> - </fields> - </pphs_settings_express_checkout_advanced> - </fields> - </pphs_settings_express_checkout> - </fields> - </payments_pro_hosted_solution_with_express_checkout> - <express_checkout type="group" translate="label comment"> - <label>Express Checkout</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>60</sort_order> - <group>paypal_payment_solutions</group> - <frontend_model>paypal/adminhtml_system_config_fieldset_payment</frontend_model> - <frontend_class>pp-method-express</frontend_class> - <include>1</include> - <comment>Add PayPal as an additional payment method to your checkout page.</comment> - <activity_path>payment/paypal_express/active</activity_path> - <learn_more_link>https://www.paypal.com/webapps/mpp/referral/paypal-express-checkout?partner_id=NB9WWHYEMVUMS</learn_more_link> - <backend_config> - <US> - <group>paypal_alternative_payment_methods</group> - <fields> - <express_checkout_required> - <fields> - <enable_express_checkout_bml translate="label comment"> - <label>Enable Paypal Credit</label> - <comment><![CDATA[PayPal Express Checkout lets you give customers access to financing through Paypal Credit® - at no additional cost to you. - You get paid up front, even though customers have more time to pay. A pre-integrated payment button lets customers pay quickly with Paypal Credit®. - <a href="https://www.paypal.com/webapps/mpp/promotional-financing" target="_blank">Learn More</a>]]> - </comment> - <config_path>payment/paypal_express_bml/active</config_path> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>21</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <shared>1</shared> - <requires>express_checkout_required_enable_express_checkout</requires> - <frontend_class>paypal-bml</frontend_class> - </enable_express_checkout_bml> - <advertise_bml type="group" translate="label comment"> - <label>Advertise Paypal Credit</label> - <comment> - <![CDATA[<a href="https://financing.paypal.com/ppfinportal/content/whyUseFinancing" target="_blank">Why Advertise Financing?</a><br/> - <strong>Give your sales a boost when you advertise financing.</strong><br/>PayPal helps turn browsers into buyers with financing - from Paypal Credit®. Your customers have more time to pay, while you get paid up front – at no additional cost to you. - Use PayPal’s free banner ads that let you advertise Paypal Credit® financing as a payment option when your customers check out with PayPal. - The PayPal Advertising Program has been shown to generate additional purchases as well as increase consumer's average purchase sizes by 15% - or more. <a href="https://financing.paypal.com/ppfinportal/content/forrester" target="_blank">See Details</a>.]]> - </comment> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>30</sort_order> - <fields> - <bml_publisher_id translate="label comment tooltip"> - <label>Publisher ID</label> - <comment><![CDATA[Required to display a banner]]></comment> - <config_path>payment/paypal_express_bml/publisher_id</config_path> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>10</sort_order> - <shared>1</shared> - </bml_publisher_id> - <bml_wizard translate="button_label"> - <label></label> - <button_label>Get Publisher ID from PayPal</button_label> - <button_url><![CDATA[https://financing.paypal.com/ppfinportal/cart/index?dcp=4eff8563b9cc505e0b9afaff3256705081553c79]]></button_url> - <frontend_model>paypal/adminhtml_system_config_bmlApiWizard</frontend_model> - <sort_order>15</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - </bml_wizard> - <settings_bml_homepage type="group" translate="label"> - <label>Home Page</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>20</sort_order> - <fields> - <bml_homepage_display translate="label"> - <label>Display</label> - <config_path>payment/paypal_express_bml/homepage_display</config_path> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_yesno</source_model> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>10</sort_order> - <shared>1</shared> - </bml_homepage_display> - <bml_homepage_position translate="label"> - <label>Position</label> - <config_path>payment/paypal_express_bml/homepage_position</config_path> - <frontend_type>select</frontend_type> - <source_model>paypal/system_config_source_bmlPosition::getBmlPositionsHP</source_model> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>20</sort_order> - <shared>1</shared> - </bml_homepage_position> - <bml_homepage_size1 translate="label"> - <label>Size</label> - <config_path>payment/paypal_express_bml/homepage_size</config_path> - <frontend_type>select</frontend_type> - <source_model>paypal/system_config_source_bmlSize::getBmlSizeHPH</source_model> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>30</sort_order> - <shared>1</shared> - <depends><bml_homepage_position>0</bml_homepage_position></depends> - </bml_homepage_size1> - <bml_homepage_size2 extends="//paypal_payments/express_checkout//bml_homepage_size1"> - <source_model>paypal/system_config_source_bmlSize::getBmlSizeHPS</source_model> - <depends><bml_homepage_position>1</bml_homepage_position></depends> - </bml_homepage_size2> - </fields> - </settings_bml_homepage> - <settings_bml_categorypage type="group" translate="label"> - <label>Catalog Category Page</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>30</sort_order> - <fields> - <bml_categorypage_display translate="label"> - <label>Display</label> - <config_path>payment/paypal_express_bml/categorypage_display</config_path> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_yesno</source_model> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>10</sort_order> - <shared>1</shared> - </bml_categorypage_display> - <bml_categorypage_position translate="label"> - <label>Position</label> - <config_path>payment/paypal_express_bml/categorypage_position</config_path> - <frontend_type>select</frontend_type> - <source_model>paypal/system_config_source_bmlPosition::getBmlPositionsCCP</source_model> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>20</sort_order> - <shared>1</shared> - </bml_categorypage_position> - <bml_categorypage_size1 translate="label"> - <label>Size</label> - <config_path>payment/paypal_express_bml/categorypage_size</config_path> - <frontend_type>select</frontend_type> - <source_model>paypal/system_config_source_bmlSize::getBmlSizeCCPC</source_model> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>30</sort_order> - <shared>1</shared> - <depends><bml_categorypage_position>0</bml_categorypage_position></depends> - </bml_categorypage_size1> - <bml_categorypage_size2 extends="//paypal_payments/express_checkout//bml_categorypage_size1"> - <source_model>paypal/system_config_source_bmlSize::getBmlSizeCCPS</source_model> - <depends><bml_categorypage_position>1</bml_categorypage_position></depends> - </bml_categorypage_size2> - </fields> - </settings_bml_categorypage> - <settings_bml_productpage type="group" translate="label"> - <label>Catalog Product Page</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>40</sort_order> - <fields> - <bml_productpage_display translate="label"> - <label>Display</label> - <config_path>payment/paypal_express_bml/productpage_display</config_path> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_yesno</source_model> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>10</sort_order> - <shared>1</shared> - </bml_productpage_display> - <bml_productpage_position translate="label"> - <label>Position</label> - <config_path>payment/paypal_express_bml/productpage_position</config_path> - <frontend_type>select</frontend_type> - <source_model>paypal/system_config_source_bmlPosition::getBmlPositionsCPP</source_model> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>20</sort_order> - <shared>1</shared> - </bml_productpage_position> - <bml_productpage_size1 translate="label"> - <label>Size</label> - <config_path>payment/paypal_express_bml/productpage_size</config_path> - <frontend_type>select</frontend_type> - <source_model>paypal/system_config_source_bmlSize::getBmlSizeCPPC</source_model> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>30</sort_order> - <shared>1</shared> - <depends><bml_productpage_position>0</bml_productpage_position></depends> - </bml_productpage_size1> - <bml_productpage_size2 extends="//paypal_payments/express_checkout//bml_productpage_size1"> - <source_model>paypal/system_config_source_bmlSize::getBmlSizeCPPN</source_model> - <depends><bml_productpage_position>1</bml_productpage_position></depends> - </bml_productpage_size2> - </fields> - </settings_bml_productpage> - <settings_bml_checkout type="group" translate="label"> - <label>Checkout Cart Page</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>50</sort_order> - <fields> - <bml_checkout_display translate="label"> - <label>Display</label> - <config_path>payment/paypal_express_bml/checkout_display</config_path> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_yesno</source_model> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>10</sort_order> - <shared>1</shared> - </bml_checkout_display> - <bml_checkout_position translate="label"> - <label>Position</label> - <config_path>payment/paypal_express_bml/checkout_position</config_path> - <frontend_type>select</frontend_type> - <source_model>paypal/system_config_source_bmlPosition::getBmlPositionsCheckout</source_model> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>20</sort_order> - <shared>1</shared> - </bml_checkout_position> - <bml_checkout_size1 translate="label"> - <label>Size</label> - <config_path>payment/paypal_express_bml/checkout_size</config_path> - <frontend_type>select</frontend_type> - <source_model>paypal/system_config_source_bmlSize::getBmlSizeCheckoutC</source_model> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>30</sort_order> - <shared>1</shared> - <depends><bml_checkout_position>0</bml_checkout_position></depends> - </bml_checkout_size1> - <bml_checkout_size2 extends="//paypal_payments/express_checkout//bml_checkout_size1"> - <source_model>paypal/system_config_source_bmlSize::getBmlSizeCheckoutN</source_model> - <shared>1</shared> - <depends><bml_checkout_position>1</bml_checkout_position></depends> - </bml_checkout_size2> - </fields> - </settings_bml_checkout> - </fields> - </advertise_bml> - </fields> - </express_checkout_required> - </fields> - </US> - <GB translate="comment"> - <group>paypal_alternative_payment_methods</group> - <learn_more_link>https://www.paypal-business.co.uk/add-paypal-to-online-shop/index.htm</learn_more_link> - <demo_link>http://www.youtube.com/watch?v=WgnfZ2Bj6hQ</demo_link> - <comment>Add PayPal as an additional payment method to your checkout page to increase your sales.</comment> - </GB> - </backend_config> - <fields> - <express_checkout_required type="group" translate="label"> - <label>Required PayPal Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>10</sort_order> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <fields> - <express_checkout_required_express_checkout type="group" translate="label"> - <label>Express Checkout</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>10</sort_order> - <fields> - <business_account extends="//paypal_payments/payflow_advanced//business_account" /> - <api_authentication extends="//paypal_payments/payflow_advanced//api_authentication" /> - <api_username extends="//paypal_payments/payflow_advanced//api_username" /> - <api_password extends="//paypal_payments/payflow_advanced//api_password" /> - <api_signature extends="//paypal_payments/payflow_advanced//api_signature" /> - <api_cert extends="//paypal_payments/payflow_advanced//api_cert" /> - <api_wizard extends="//paypal_payments/payflow_advanced//api_wizard" /> - <sandbox_flag extends="//paypal_payments/payflow_advanced//express//sandbox_flag" /> - <use_proxy extends="//paypal_payments/payflow_advanced//express//use_proxy" /> - <proxy_host extends="//paypal_payments/payflow_advanced//express//proxy_host" /> - <proxy_port extends="//paypal_payments/payflow_advanced//express//proxy_port" /> - </fields> - </express_checkout_required_express_checkout> - <enable_express_checkout translate="label"> - <label>Enable this Solution</label> - <config_path>payment/paypal_express/active</config_path> - <frontend_type>select</frontend_type> - <source_model>adminhtml/system_config_source_yesno</source_model> - <sort_order>20</sort_order> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <shared>1</shared> - <requires>express_checkout_required_express_checkout</requires> - <frontend_class>paypal-enabler paypal-ec-enabler</frontend_class> - </enable_express_checkout> - - </fields> - </express_checkout_required> - <settings_ec type="group" translate="label"> - <label>Basic Settings - PayPal Express Checkout</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <frontend_model>paypal/adminhtml_system_config_fieldset_expanded</frontend_model> - <sort_order>20</sort_order> - <fields> - <title extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/title" /> - <sort_order extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/sort_order" /> - <payment_action extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/payment_action" /> - <visible_on_product extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/visible_on_product" /> - <authorization_honor_period extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/authorization_honor_period" /> - <order_valid_period extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/order_valid_period" /> - <child_authorization_number extends="//paypal_payments/payflow_advanced//settings_express_checkout/*/child_authorization_number" /> - - <settings_ec_advanced type="group" translate="label"> - <label>Advanced Settings</label> - <frontend_class>config-advanced</frontend_class> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>80</sort_order> - <fields> - <visible_on_cart extends="//paypal_payments/payflow_advanced//settings_express_checkout//visible_on_cart" /> - <allowspecific extends="//paypal_payments/payflow_advanced//settings_express_checkout//allowspecific" /> - <specificcountry extends="//paypal_payments/payflow_advanced//settings_express_checkout//specificcountry" /> - <debug extends="//paypal_payments/payflow_advanced//settings_express_checkout//debug" /> - <verify_peer extends="//paypal_payments/payflow_advanced//settings_express_checkout//verify_peer" /> - <line_items_enabled extends="//paypal_payments/payflow_advanced//settings_express_checkout//line_items_enabled" /> - <transfer_shipping_options extends="//paypal_payments/payflow_advanced//settings_express_checkout//transfer_shipping_options" /> - <button_flavor extends="//paypal_payments/payflow_advanced//settings_express_checkout//button_flavor" /> - <solution_type extends="//paypal_payments/payflow_advanced//settings_express_checkout//solution_type" /> - <require_billing_address extends="//paypal_payments/payflow_advanced//settings_express_checkout//require_billing_address" /> - <allow_ba_signup extends="//paypal_payments/payflow_advanced//settings_express_checkout//allow_ba_signup" /> - <skip_order_review_step extends="//paypal_payments/payflow_advanced//settings_express_checkout//skip_order_review_step" /> - - <express_checkout_billing_agreement type="group" translate="label"> - <label>PayPal Billing Agreement Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>100</sort_order> - <fields> - <active extends="//paypal_payments/payflow_advanced//billing_agreement/*/active" /> - <title extends="//paypal_payments/payflow_advanced//billing_agreement/*/title" /> - <sort_order extends="//paypal_payments/payflow_advanced//billing_agreement/*/sort_order" /> - <payment_action extends="//paypal_payments/payflow_advanced//billing_agreement/*/payment_action" /> - <allowspecific extends="//paypal_payments/payflow_advanced//billing_agreement/*/allowspecific" /> - <specificcountry extends="//paypal_payments/payflow_advanced//billing_agreement/*/specificcountry" /> - <debug extends="//paypal_payments/payflow_advanced//billing_agreement/*/debug" /> - <verify_peer extends="//paypal_payments/payflow_advanced//billing_agreement/*/verify_peer" /> - <line_items_enabled extends="//paypal_payments/payflow_advanced//billing_agreement/*/line_items_enabled" /> - <allow_billing_agreement_wizard extends="//paypal_payments/payflow_advanced//billing_agreement/*/allow_billing_agreement_wizard" /> - </fields> - </express_checkout_billing_agreement> - <express_checkout_settlement_report type="group" translate="label"> - <label>Settlement Report Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <sort_order>110</sort_order> - <fields> - <heading_sftp extends="//paypal_payments/payflow_advanced//settlement_report/*/heading_sftp" /> - <settlement_reports_ftp_login extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_login" /> - <settlement_reports_ftp_password extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_password" /> - <settlement_reports_ftp_sandbox extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_sandbox" /> - <settlement_reports_ftp_ip extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_ip" /> - <settlement_reports_ftp_path extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_ftp_path" /> - <heading_schedule extends="//paypal_payments/payflow_advanced//settlement_report/*/heading_schedule" /> - <settlement_reports_active extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_active" /> - <settlement_reports_schedule extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_schedule" /> - <settlement_reports_time extends="//paypal_payments/payflow_advanced//settlement_report/*/settlement_reports_time" /> - </fields> - </express_checkout_settlement_report> - <express_checkout_frontend type="group" translate="label"> - <label>Frontend Experience Settings</label> - <show_in_default>1</show_in_default> - <show_in_website>1</show_in_website> - <show_in_store>1</show_in_store> - <sort_order>120</sort_order> - <fields> - <logo extends="//paypal_payments/payflow_advanced//frontend/*/logo" /> - <paypal_pages extends="//paypal_payments/payflow_advanced//frontend/*/paypal_pages" /> - <page_style extends="//paypal_payments/payflow_advanced//frontend/*/page_style" /> - <paypal_hdrimg extends="//paypal_payments/payflow_advanced//frontend/*/paypal_hdrimg" /> - <paypal_hdrbackcolor extends="//paypal_payments/payflow_advanced//frontend/*/paypal_hdrbackcolor" /> - <paypal_hdrbordercolor extends="//paypal_payments/payflow_advanced//frontend/*/paypal_hdrbordercolor" /> - <paypal_payflowcolor extends="//paypal_payments/payflow_advanced//frontend/*/paypal_payflowcolor" /> - </fields> - </express_checkout_frontend> - </fields> - </settings_ec_advanced> - </fields> - </settings_ec> - </fields> - </express_checkout> - </paypal_payments> + </paypal> </groups> </payment> </sections> -</config> +</config> \ No newline at end of file diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/install-1.6.0.0.php b/app/code/core/Mage/Paypal/sql/paypal_setup/install-1.6.0.0.php deleted file mode 100644 index 36cd7e0b2cc..00000000000 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/install-1.6.0.0.php +++ /dev/null @@ -1,156 +0,0 @@ -<?php - -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Open Software License (OSL 3.0) - * @package Mage_Paypal - */ - -/** @var Mage_Paypal_Model_Resource_Setup $installer */ -$installer = $this; -$installer->startSetup(); - -/** - * Create table 'paypal/settlement_report' - */ -$table = $installer->getConnection() - ->newTable($installer->getTable('paypal/settlement_report')) - ->addColumn('report_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - ], 'Report Id') - ->addColumn('report_date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ - ], 'Report Date') - ->addColumn('account_id', Varien_Db_Ddl_Table::TYPE_TEXT, 64, [ - ], 'Account Id') - ->addColumn('filename', Varien_Db_Ddl_Table::TYPE_TEXT, 24, [ - ], 'Filename') - ->addColumn('last_modified', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ - ], 'Last Modified') - ->addIndex( - $installer->getIdxName('paypal/settlement_report', ['report_date', 'account_id'], Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE), - ['report_date', 'account_id'], - ['type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE], - ) - ->setComment('Paypal Settlement Report Table'); -$installer->getConnection()->createTable($table); - -/** - * Create table 'paypal/settlement_report_row' - */ -$table = $installer->getConnection() - ->newTable($installer->getTable('paypal/settlement_report_row')) - ->addColumn('row_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - ], 'Row Id') - ->addColumn('report_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'unsigned' => true, - 'nullable' => false, - ], 'Report Id') - ->addColumn('transaction_id', Varien_Db_Ddl_Table::TYPE_TEXT, 19, [ - ], 'Transaction Id') - ->addColumn('invoice_id', Varien_Db_Ddl_Table::TYPE_TEXT, 127, [ - ], 'Invoice Id') - ->addColumn('paypal_reference_id', Varien_Db_Ddl_Table::TYPE_TEXT, 19, [ - ], 'Paypal Reference Id') - ->addColumn('paypal_reference_id_type', Varien_Db_Ddl_Table::TYPE_TEXT, 3, [ - ], 'Paypal Reference Id Type') - ->addColumn('transaction_event_code', Varien_Db_Ddl_Table::TYPE_TEXT, 5, [ - ], 'Transaction Event Code') - ->addColumn('transaction_initiation_date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ - ], 'Transaction Initiation Date') - ->addColumn('transaction_completion_date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ - ], 'Transaction Completion Date') - ->addColumn('transaction_debit_or_credit', Varien_Db_Ddl_Table::TYPE_TEXT, 2, [ - 'nullable' => false, - 'default' => 'CR', - ], 'Transaction Debit Or Credit') - ->addColumn('gross_transaction_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '20,6', [ - 'nullable' => false, - 'default' => '0.000000', - ], 'Gross Transaction Amount') - ->addColumn('gross_transaction_currency', Varien_Db_Ddl_Table::TYPE_TEXT, 3, [ - 'default' => '', - ], 'Gross Transaction Currency') - ->addColumn('fee_debit_or_credit', Varien_Db_Ddl_Table::TYPE_TEXT, 2, [ - ], 'Fee Debit Or Credit') - ->addColumn('fee_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '20,6', [ - 'nullable' => false, - 'default' => '0.000000', - ], 'Fee Amount') - ->addColumn('fee_currency', Varien_Db_Ddl_Table::TYPE_TEXT, 3, [ - ], 'Fee Currency') - ->addColumn('custom_field', Varien_Db_Ddl_Table::TYPE_TEXT, 255, [ - ], 'Custom Field') - ->addColumn('consumer_id', Varien_Db_Ddl_Table::TYPE_TEXT, 127, [ - ], 'Consumer Id') - ->addIndex( - $installer->getIdxName('paypal/settlement_report_row', ['report_id']), - ['report_id'], - ) - ->addForeignKey( - $installer->getFkName('paypal/settlement_report_row', 'report_id', 'paypal/settlement_report', 'report_id'), - 'report_id', - $installer->getTable('paypal/settlement_report'), - 'report_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, - Varien_Db_Ddl_Table::ACTION_CASCADE, - ) - ->setComment('Paypal Settlement Report Row Table'); -$installer->getConnection()->createTable($table); - -/** - * Create table 'paypal/cert' - */ -$table = $installer->getConnection() - ->newTable($installer->getTable('paypal/cert')) - ->addColumn('cert_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - ], 'Cert Id') - ->addColumn('website_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [ - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - ], 'Website Id') - ->addColumn('content', Varien_Db_Ddl_Table::TYPE_TEXT, '64K', [ - ], 'Content') - ->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ - ], 'Updated At') - ->addIndex( - $installer->getIdxName('paypal/cert', ['website_id']), - ['website_id'], - ) - ->addForeignKey( - $installer->getFkName('paypal/cert', 'website_id', 'core/website', 'website_id'), - 'website_id', - $installer->getTable('core/website'), - 'website_id', - Varien_Db_Ddl_Table::ACTION_CASCADE, - Varien_Db_Ddl_Table::ACTION_CASCADE, - ) - ->setComment('Paypal Certificate Table'); -$installer->getConnection()->createTable($table); - -/** - * Add paypal attributes to the: - * - sales/flat_quote_payment_item table - * - sales/flat_order table - */ -$installer->addAttribute('quote_payment', 'paypal_payer_id', []); -$installer->addAttribute('quote_payment', 'paypal_payer_status', []); -$installer->addAttribute('quote_payment', 'paypal_correlation_id', []); -$installer->addAttribute('order', 'paypal_ipn_customer_notified', ['type' => 'int', 'visible' => false, 'default' => 0]); - -/** - * Prepare database after install - */ -$installer->endSetup(); diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php b/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php new file mode 100644 index 00000000000..c3cd67c880a --- /dev/null +++ b/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php @@ -0,0 +1,182 @@ +<?php + +/** + * PayPal installation script + * + * @category Mage + * @package Mage_Paypal + */ +$installer = $this; +/* @var $installer Mage_Paypal_Model_Resource_Setup */ + +$installer->startSetup(); + +$installer->getConnection()->dropTable($installer->getTable('paypal/debug')); + +$debugTable = $installer->getConnection() + ->newTable($installer->getTable('paypal/debug')) + ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ + 'identity' => true, + 'unsigned' => true, + 'nullable' => false, + 'primary' => true, + ], 'Entity ID') + ->addColumn('quote_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ + 'unsigned' => true, + 'nullable' => true, + ], 'Quote ID') + ->addColumn('increment_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50, [ + 'nullable' => true, + ], 'Quote Increment ID') + ->addColumn('action', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50, [ + 'nullable' => false, + ], 'Action') + ->addColumn('transaction_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 255, [ + 'nullable' => true, + ], 'Transaction ID') + ->addColumn('request_body', Varien_Db_Ddl_Table::TYPE_TEXT, null, [ + 'nullable' => true, + ], 'Request Body') + ->addColumn('response_body', Varien_Db_Ddl_Table::TYPE_TEXT, null, [ + 'nullable' => true, + ], 'Response Body') + ->addColumn('exception_message', Varien_Db_Ddl_Table::TYPE_TEXT, null, [ + 'nullable' => true, + ], 'Exception Message') + ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ + 'nullable' => false, + 'default' => Varien_Db_Ddl_Table::TIMESTAMP_INIT, + ], 'Created At') + ->addIndex( + $installer->getIdxName('paypal/debug', ['quote_id']), + ['quote_id'] + ) + ->addIndex( + $installer->getIdxName('paypal/debug', ['increment_id']), + ['increment_id'] + ) + ->addForeignKey( + $installer->getFkName('paypal/debug', 'quote_id', 'sales/quote', 'entity_id'), + 'quote_id', + $installer->getTable('sales/quote'), + 'entity_id', + Varien_Db_Ddl_Table::ACTION_CASCADE, + Varien_Db_Ddl_Table::ACTION_CASCADE + ) + ->addForeignKey( + $installer->getFkName('paypal/debug', 'increment_id', 'sales/order', 'increment_id'), + 'increment_id', + $installer->getTable('sales/order'), + 'increment_id', + Varien_Db_Ddl_Table::ACTION_SET_NULL, + Varien_Db_Ddl_Table::ACTION_NO_ACTION + ) + ->setComment('PayPal Debug Table'); +$installer->getConnection()->createTable($debugTable); + +$installer->getConnection()->delete( + $installer->getTable('core_resource'), + $installer->getConnection()->quoteInto('code = ?', 'paypaluk_setup') +); + +$installer->getConnection()->delete( + $installer->getTable('core/config_data'), + $installer->getConnection()->quoteInto('path IN (?)', [ + 'payment/paypal_billing_agreement/active', + 'payment/paypal_billing_agreement/title', + 'payment/paypal_billing_agreement/sort_order', + 'payment/paypal_billing_agreement/payment_action', + 'payment/paypal_billing_agreement/allowspecific', + 'payment/paypal_billing_agreement/debug', + 'payment/paypal_billing_agreement/verify_peer', + 'payment/paypal_billing_agreement/line_items_enabled', + 'payment/paypal_billing_agreement/allow_billing_agreement_wizard', + 'payment/paypal_express/title', + 'payment/paypal_express/sort_order', + 'payment/paypal_express/payment_action', + 'payment/paypal_express/visible_on_cart', + 'payment/paypal_express/visible_on_product', + 'payment/paypal_express/allowspecific', + 'payment/paypal_express/debug', + 'payment/paypal_express/verify_peer', + 'payment/paypal_express/line_items_enabled', + 'payment/paypal_express/transfer_shipping_options', + 'payment/paypal_express/solution_type', + 'payment/paypal_express/require_billing_address', + 'payment/paypal_express/allow_ba_signup', + 'payment/paypal_direct/using_pbridge', + 'payment/paypal_direct/active', + 'payment/paypal_direct/title', + 'payment/paypal_direct/sort_order', + 'payment/paypal_direct/payment_action', + 'payment/paypal_direct/cctypes', + 'payment/paypal_direct/allowspecific', + 'payment/paypal_direct/debug', + 'payment/paypal_direct/verify_peer', + 'payment/paypal_direct/line_items_enabled', + 'payment/paypal_direct/useccv', + 'payment/paypal_direct/centinel', + 'payment/paypal_standard/active', + 'payment/paypal_standard/title', + 'payment/paypal_standard/sort_order', + 'payment/paypal_standard/payment_action', + 'payment/paypal_standard/allowspecific', + 'payment/paypal_standard/sandbox_flag', + 'payment/paypal_standard/line_items_enabled', + 'payment/paypal_standard/debug', + 'payment/paypal_standard/verify_peer', + 'payment/paypaluk_express/active', + 'payment/paypaluk_express/title', + 'payment/paypaluk_express/sort_order', + 'payment/paypaluk_express/payment_action', + 'payment/paypaluk_express/visible_on_cart', + 'payment/paypaluk_express/visible_on_product', + 'payment/paypaluk_express/allowspecific', + 'payment/paypaluk_express/debug', + 'payment/paypaluk_express/verify_peer', + 'payment/paypaluk_express/line_items_enabled', + 'payment/paypal_express/active', + 'payment/paypal_express/skip_order_review_step', + 'payment/paypal_express_bml/active', + 'payment/paypal_express_bml/publisher_id', + 'payment/paypal_express_bml/homepage_display', + 'payment/paypal_express_bml/homepage_position', + 'payment/paypal_express_bml/homepage_size', + 'payment/paypal_express_bml/categorypage_display', + 'payment/paypal_express_bml/categorypage_position', + 'payment/paypal_express_bml/categorypage_size', + 'payment/paypal_express_bml/productpage_display', + 'payment/paypal_express_bml/productpage_position', + 'payment/paypal_express_bml/productpage_size', + 'payment/paypal_express_bml/checkout_display', + 'payment/paypal_express_bml/checkout_position', + 'payment/paypal_express_bml/checkout_size', + 'payment/paypaluk_express_bml/active', + 'payment/paypal_standard/was_active', + 'payment/paypal_wps_express/active', + 'paypal/wpp/api_authentication', + 'paypal/wpp/api_username', + 'paypal/wpp/api_password', + 'paypal/wpp/api_signature', + 'paypal/wpp/sandbox_flag', + 'paypal/wpp/use_proxy', + 'paypal/fetch_reports/ftp_login', + 'paypal/fetch_reports/ftp_password', + 'paypal/fetch_reports/ftp_sandbox', + 'paypal/fetch_reports/ftp_ip', + 'paypal/fetch_reports/ftp_path', + 'paypal/fetch_reports/active', + 'paypal/fetch_reports/schedule', + 'paypal/fetch_reports/time', + 'paypal/style/logo', + 'paypal/style/page_style', + 'paypal/style/paypal_hdrimg', + 'paypal/style/paypal_hdrbackcolor', + 'paypal/style/paypal_hdrbordercolor', + 'paypal/style/paypal_payflowcolor', + 'paypal/wpp/button_flavor', + 'paypal/general/business_account' + ]) +); + +$installer->endSetup(); diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-install-0.7.0.php b/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-install-0.7.0.php deleted file mode 100644 index 1b887941bfa..00000000000 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-install-0.7.0.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Open Software License (OSL 3.0) - * @package Mage_Paypal - */ - -/** @var Mage_Paypal_Model_Resource_Setup $installer */ -$installer = $this; -$installer->startSetup(); - -$installer->run(" - --- DROP TABLE IF EXISTS `{$this->getTable('paypal_api_debug')}`; -CREATE TABLE `{$this->getTable('paypal_api_debug')}` ( - `debug_id` int(10) unsigned NOT NULL auto_increment, - `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `request_body` text, - `response_body` text, - PRIMARY KEY (`debug_id`), - KEY `debug_at` (`debug_at`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - - "); - -$installer->endSetup(); - -$installer->addAttribute('quote_payment', 'paypal_payer_id', []); -$installer->addAttribute('quote_payment', 'paypal_payer_status', []); -$installer->addAttribute('quote_payment', 'paypal_correlation_id', []); diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-install-1.4.0.0.php b/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-install-1.4.0.0.php deleted file mode 100644 index bccc98cffc0..00000000000 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-install-1.4.0.0.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Open Software License (OSL 3.0) - * @package Mage_Paypal - */ - -/** @var Mage_Paypal_Model_Resource_Setup $installer */ -$installer = $this; -$installer->startSetup(); - -$installer->run(" -CREATE TABLE `{$this->getTable('paypal_api_debug')}` ( - `debug_id` int(10) unsigned NOT NULL auto_increment, - `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, - `request_body` text, - `response_body` text, - PRIMARY KEY (`debug_id`), - KEY `debug_at` (`debug_at`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); - -$installer->addAttribute('quote_payment', 'paypal_payer_id', []); -$installer->addAttribute('quote_payment', 'paypal_payer_status', []); -$installer->addAttribute('quote_payment', 'paypal_correlation_id', []); -$installer->addAttribute('order', 'paypal_ipn_customer_notified', ['type' => 'int', 'visible' => false, 'default' => 0]); - -$installer->endSetup(); diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-0.7.1-0.7.2.php b/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-0.7.1-0.7.2.php deleted file mode 100644 index c49ea70c033..00000000000 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-0.7.1-0.7.2.php +++ /dev/null @@ -1,14 +0,0 @@ -<?php - -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Open Software License (OSL 3.0) - * @package Mage_Paypal - */ - -/** @var Mage_Paypal_Model_Resource_Setup $installer */ -$installer = $this; -$installer->startSetup(); -$installer->addAttribute('order', 'paypal_ipn_customer_notified', ['type' => 'int', 'visible' => false, 'default' => 0]); -$installer->endSetup(); diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-0.7.2-0.7.3.php b/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-0.7.2-0.7.3.php deleted file mode 100644 index fc931089afa..00000000000 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-0.7.2-0.7.3.php +++ /dev/null @@ -1,27 +0,0 @@ -<?php - -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Open Software License (OSL 3.0) - * @package Mage_Paypal - */ - -/** @var Mage_Paypal_Model_Resource_Setup $installer */ -$installer = $this; -$installer->startSetup(); - -$installer->addAttribute('order_payment', 'cc_secure_verify', []); - -// move paypal style settings to new paths -foreach ([ - 'paypal/wpp/page_style' => 'paypal/style/page_style', - 'paypal/wps/logo_url' => 'paypal/style/logo_url', -] as $from => $to -) { - $installer->run(" - UPDATE {$installer->getTable('core/config_data')} SET `path` = '{$to}' - WHERE `path` = '{$from}' - "); -} -$installer->endSetup(); diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-1.4.0.0-1.4.0.1.php b/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-1.4.0.0-1.4.0.1.php deleted file mode 100644 index ba0c9c66c40..00000000000 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-1.4.0.0-1.4.0.1.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Open Software License (OSL 3.0) - * @package Mage_Paypal - */ - -/** @var Mage_Paypal_Model_Resource_Setup $installer */ -$installer = $this; -$installer->startSetup(); - -$installer->run(" - -CREATE TABLE `{$installer->getTable('paypal_settlement_report')}` ( - `report_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `report_date` date NOT NULL, - `account_id` varchar(64) NOT NULL, - `filename` varchar(24) NOT NULL, - `last_modified` datetime NOT NULL, - PRIMARY KEY (`report_id`), - UNIQUE KEY `UNQ_REPORT_DATE_ACCOUNT` (`report_date`,`account_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -CREATE TABLE `{$installer->getTable('paypal_settlement_report_row')}` ( - `row_id` int(10) unsigned NOT NULL AUTO_INCREMENT, - `report_id` int(10) unsigned NOT NULL, - `transaction_id` varchar(19) NOT NULL, - `invoice_id` varchar(127) DEFAULT NULL, - `paypal_reference_id` varchar(19) NOT NULL, - `paypal_reference_id_type` enum('ODR','TXN','SUB','PAP','') NOT NULL, - `transaction_event_code` char(5) NOT NULL DEFAULT '', - `transaction_initiation_date` datetime DEFAULT NULL, - `transaction_completion_date` datetime DEFAULT NULL, - `transaction_debit_or_credit` enum('CR','DR') NOT NULL DEFAULT 'CR', - `gross_transaction_amount` decimal(20,6) NOT NULL DEFAULT '0.000000', - `gross_transaction_currency` char(3) NOT NULL DEFAULT '', - `fee_debit_or_credit` enum('CR','DR') NOT NULL, - `fee_amount` decimal(20,6) NOT NULL DEFAULT '0.000000', - `fee_currency` char(3) NOT NULL, - `custom_field` varchar(255) DEFAULT NULL, - `consumer_id` varchar(127) NOT NULL DEFAULT '', - PRIMARY KEY (`row_id`), - KEY `IDX_REPORT_ID` (`report_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; - -ALTER TABLE `{$installer->getTable('paypal_settlement_report_row')}` - ADD CONSTRAINT `FK_PAYPAL_SETTLEMENT_ROW_REPORT` FOREIGN KEY (`report_id`) REFERENCES `{$installer->getTable('paypal_settlement_report')}` (`report_id`) ON DELETE CASCADE ON UPDATE CASCADE; - -"); - -$installer->endSetup(); diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-1.4.0.1-1.4.0.2.php b/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-1.4.0.1-1.4.0.2.php deleted file mode 100644 index 5aa96a3e0d6..00000000000 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-1.4.0.1-1.4.0.2.php +++ /dev/null @@ -1,30 +0,0 @@ -<?php - -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Open Software License (OSL 3.0) - * @package Mage_Paypal - */ - -/** @var Mage_Paypal_Model_Resource_Setup $installer */ -$installer = $this; - -$installer->run(" -CREATE TABLE `{$installer->getTable('paypal/cert')}` ( - `cert_id` SMALLINT(5) UNSIGNED NOT NULL AUTO_INCREMENT, - `website_id` SMALLINT(5) UNSIGNED NOT NULL DEFAULT '0', - `content` MEDIUMBLOB NOT NULL, - `updated_at` datetime default NULL, - PRIMARY KEY (`cert_id`), - KEY `IDX_PAYPAL_CERT_WEBSITE` (`website_id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; -"); - -$installer->getConnection()->addConstraint( - 'FK_PAYPAL_CERT_WEBSITE', - $this->getTable('paypal/cert'), - 'website_id', - $this->getTable('core/website'), - 'website_id', -); diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php b/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php deleted file mode 100644 index 2ff63751823..00000000000 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/mysql4-upgrade-1.5.9.9-1.6.0.0.php +++ /dev/null @@ -1,286 +0,0 @@ -<?php - -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Open Software License (OSL 3.0) - * @package Mage_Paypal - */ - -/** @var Mage_Core_Model_Resource_Setup $installer */ -$installer = $this; -$installer->startSetup(); - -/** - * Drop foreign keys - */ -$installer->getConnection()->dropForeignKey( - $installer->getTable('paypal/cert'), - 'FK_PAYPAL_CERT_WEBSITE', -); - -$installer->getConnection()->dropForeignKey( - $installer->getTable('paypal/settlement_report_row'), - 'FK_PAYPAL_SETTLEMENT_ROW_REPORT', -); - -/** - * Drop indexes - */ -$installer->getConnection()->dropIndex( - $installer->getTable('paypal/cert'), - 'IDX_PAYPAL_CERT_WEBSITE', -); - -$installer->getConnection()->dropIndex( - $installer->getTable('paypal/settlement_report'), - 'UNQ_REPORT_DATE_ACCOUNT', -); - -$installer->getConnection()->dropIndex( - $installer->getTable('paypal/settlement_report_row'), - 'IDX_REPORT_ID', -); - -/** - * Change columns - */ -$tables = [ - $installer->getTable('paypal/settlement_report') => [ - 'columns' => [ - 'report_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - 'comment' => 'Report Id', - ], - 'report_date' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP, - 'comment' => 'Report Date', - ], - 'account_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 64, - 'comment' => 'Account Id', - ], - 'filename' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 24, - 'comment' => 'Filename', - ], - 'last_modified' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP, - 'comment' => 'Last Modified', - ], - ], - 'comment' => 'Paypal Settlement Report Table', - ], - $installer->getTable('paypal/settlement_report_row') => [ - 'columns' => [ - 'row_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - 'comment' => 'Row Id', - ], - 'report_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'unsigned' => true, - 'nullable' => false, - 'comment' => 'Report Id', - ], - 'transaction_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 19, - 'comment' => 'Transaction Id', - ], - 'invoice_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 127, - 'comment' => 'Invoice Id', - ], - 'paypal_reference_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 19, - 'comment' => 'Paypal Reference Id', - ], - 'paypal_reference_id_type' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 3, - 'comment' => 'Paypal Reference Id Type', - ], - 'transaction_event_code' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 5, - 'comment' => 'Transaction Event Code', - ], - 'transaction_initiation_date' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP, - 'comment' => 'Transaction Initiation Date', - ], - 'transaction_completion_date' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP, - 'comment' => 'Transaction Completion Date', - ], - 'transaction_debit_or_credit' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 2, - 'nullable' => false, - 'default' => 'CR', - 'comment' => 'Transaction Debit Or Credit', - ], - 'gross_transaction_amount' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_DECIMAL, - 'scale' => 6, - 'precision' => 20, - 'nullable' => false, - 'default' => '0.000000', - 'comment' => 'Gross Transaction Amount', - ], - 'gross_transaction_currency' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 3, - 'default' => '', - 'comment' => 'Gross Transaction Currency', - ], - 'fee_debit_or_credit' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 2, - 'comment' => 'Fee Debit Or Credit', - ], - 'fee_amount' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_DECIMAL, - 'scale' => 6, - 'precision' => 20, - 'nullable' => false, - 'default' => '0.000000', - 'comment' => 'Fee Amount', - ], - 'fee_currency' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 3, - 'comment' => 'Fee Currency', - ], - 'custom_field' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 255, - 'comment' => 'Custom Field', - ], - 'consumer_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 127, - 'comment' => 'Consumer Id', - ], - ], - 'comment' => 'Paypal Settlement Report Row Table', - ], - $installer->getTable('paypal/cert') => [ - 'columns' => [ - 'cert_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT, - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - 'comment' => 'Cert Id', - ], - 'website_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_SMALLINT, - 'unsigned' => true, - 'nullable' => false, - 'default' => '0', - 'comment' => 'Website Id', - ], - 'content' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => '64K', - 'comment' => 'Content', - ], - 'updated_at' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP, - 'comment' => 'Updated At', - ], - ], - 'comment' => 'Paypal Certificate Table', - ], - $installer->getTable('sales/quote_payment') => [ - 'columns' => [ - 'paypal_payer_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 255, - 'comment' => 'Paypal Payer Id', - ], - 'paypal_payer_status' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 255, - 'comment' => 'Paypal Payer Status', - ], - 'paypal_correlation_id' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'length' => 255, - 'comment' => 'Paypal Correlation Id', - ], - ], - ], - $installer->getTable('sales/order') => [ - 'columns' => [ - 'paypal_ipn_customer_notified' => [ - 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER, - 'comment' => 'Paypal Ipn Customer Notified', - ], - ], - ], -]; - -$installer->getConnection()->modifyTables($tables); - -/** - * Add indexes - */ -$installer->getConnection()->addIndex( - $installer->getTable('paypal/cert'), - $installer->getIdxName('paypal/cert', ['website_id']), - ['website_id'], -); - -$installer->getConnection()->addIndex( - $installer->getTable('paypal/settlement_report'), - $installer->getIdxName( - 'paypal/settlement_report', - ['report_date', 'account_id'], - Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE, - ), - ['report_date', 'account_id'], - Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE, -); - -$installer->getConnection()->addIndex( - $installer->getTable('paypal/settlement_report_row'), - $installer->getIdxName('paypal/settlement_report_row', ['report_id']), - ['report_id'], -); - -/** - * Add foreign keys - */ -$installer->getConnection()->addForeignKey( - $installer->getFkName('paypal/settlement_report_row', 'report_id', 'paypal/settlement_report', 'report_id'), - $installer->getTable('paypal/settlement_report_row'), - 'report_id', - $installer->getTable('paypal/settlement_report'), - 'report_id', -); - -$installer->getConnection()->addForeignKey( - $installer->getFkName('paypal/cert', 'website_id', 'core/website', 'website_id'), - $installer->getTable('paypal/cert'), - 'website_id', - $installer->getTable('core/website'), - 'website_id', -); - -$installer->endSetup(); diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.0-1.6.0.1.php b/app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.0-1.6.0.1.php deleted file mode 100644 index 1a9e6361cdf..00000000000 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.0-1.6.0.1.php +++ /dev/null @@ -1,40 +0,0 @@ -<?php - -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Open Software License (OSL 3.0) - * @package Mage_Paypal - */ - -/** @var Mage_Paypal_Model_Resource_Setup $installer */ -$installer = $this; - -/** - * Create table 'paypal/payment_transaction' - */ -$table = $installer->getConnection() - ->newTable($installer->getTable('paypal/payment_transaction')) - ->addColumn('transaction_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ - 'identity' => true, - 'unsigned' => true, - 'nullable' => false, - 'primary' => true, - ], 'Entity Id') - ->addColumn('txn_id', Varien_Db_Ddl_Table::TYPE_TEXT, 100, [ - ], 'Txn Id') - ->addColumn('additional_information', Varien_Db_Ddl_Table::TYPE_BLOB, '64K', [ - ], 'Additional Information') - ->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [ - ], 'Created At') - ->addIndex( - $installer->getIdxName( - 'paypal/payment_transaction', - ['txn_id'], - Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE, - ), - ['txn_id'], - ['type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE], - ) - ->setComment('PayPal Payflow Link Payment Transaction'); -$installer->getConnection()->createTable($table); diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.1-1.6.0.2.php b/app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.1-1.6.0.2.php deleted file mode 100644 index 845c4da219f..00000000000 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.1-1.6.0.2.php +++ /dev/null @@ -1,18 +0,0 @@ -<?php - -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Open Software License (OSL 3.0) - * @package Mage_Paypal - */ - -/** @var Mage_Paypal_Model_Resource_Setup $installer */ -$installer = $this; - -$installer->getConnection() - ->addColumn($installer->getTable('paypal/settlement_report_row'), 'payment_tracking_id', [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'comment' => 'Payment Tracking ID', - 'length' => '255', - ]); diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.3-1.6.0.4.php b/app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.3-1.6.0.4.php deleted file mode 100644 index cde23eb8b74..00000000000 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/upgrade-1.6.0.3-1.6.0.4.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Open Software License (OSL 3.0) - * @package Mage_Paypal - */ - -/** @var Mage_Paypal_Model_Resource_Setup $installer */ -$installer = $this; - -$installer->getConnection() - ->addColumn($installer->getTable('paypal/settlement_report_row'), 'store_id', [ - 'type' => Varien_Db_Ddl_Table::TYPE_TEXT, - 'comment' => 'Store ID', - 'length' => '50']); diff --git a/app/code/core/Mage/Persistent/etc/config.xml b/app/code/core/Mage/Persistent/etc/config.xml index 040f5da6c3a..88325ad5395 100644 --- a/app/code/core/Mage/Persistent/etc/config.xml +++ b/app/code/core/Mage/Persistent/etc/config.xml @@ -213,14 +213,6 @@ </persistent> </observers> </controller_action_predispatch_paypal_express_start> - <controller_action_predispatch_paypaluk_express_start> - <observers> - <persistent> - <class>persistent/observer</class> - <method>preventExpressCheckout</method> - </persistent> - </observers> - </controller_action_predispatch_paypaluk_express_start> <controller_action_predispatch_checkout_multishipping_index> <observers> <persistent> diff --git a/app/code/core/Mage/Sales/Model/Order.php b/app/code/core/Mage/Sales/Model/Order.php index 3c3f413d523..ff68b5617b2 100644 --- a/app/code/core/Mage/Sales/Model/Order.php +++ b/app/code/core/Mage/Sales/Model/Order.php @@ -231,8 +231,6 @@ * @method $this setPaymentAuthorizationAmount(float $value) * @method int getPaymentAuthorizationExpiration() * @method $this setPaymentAuthorizationExpiration(int $value) - * @method int getPaypalIpnCustomerNotified() - * @method $this setPaypalIpnCustomerNotified(int $value) * @method string getProtectCode() * @method $this setProtectCode(string $value) * diff --git a/app/code/core/Mage/Sales/etc/wsdl.xml b/app/code/core/Mage/Sales/etc/wsdl.xml index 0124534ab0e..4408ade9712 100644 --- a/app/code/core/Mage/Sales/etc/wsdl.xml +++ b/app/code/core/Mage/Sales/etc/wsdl.xml @@ -183,7 +183,6 @@ <element name="edit_increment" type="xsd:string" minOccurs="0" /> <element name="forced_do_shipment_with_invoice" type="xsd:string" minOccurs="0" /> <element name="payment_authorization_expiration" type="xsd:string" minOccurs="0" /> - <element name="paypal_ipn_customer_notified" type="xsd:string" minOccurs="0" /> <element name="quote_address_id" type="xsd:string" minOccurs="0" /> <element name="adjustment_negative" type="xsd:string" minOccurs="0" /> <element name="adjustment_positive" type="xsd:string" minOccurs="0" /> diff --git a/app/code/core/Mage/Sales/etc/wsi.xml b/app/code/core/Mage/Sales/etc/wsi.xml index 95a063341a8..c8c54bd520c 100644 --- a/app/code/core/Mage/Sales/etc/wsi.xml +++ b/app/code/core/Mage/Sales/etc/wsi.xml @@ -186,7 +186,6 @@ <xsd:element name="edit_increment" type="xsd:string" minOccurs="0" /> <xsd:element name="forced_do_shipment_with_invoice" type="xsd:string" minOccurs="0" /> <xsd:element name="payment_authorization_expiration" type="xsd:string" minOccurs="0" /> - <xsd:element name="paypal_ipn_customer_notified" type="xsd:string" minOccurs="0" /> <xsd:element name="quote_address_id" type="xsd:string" minOccurs="0" /> <xsd:element name="adjustment_negative" type="xsd:string" minOccurs="0" /> <xsd:element name="adjustment_positive" type="xsd:string" minOccurs="0" /> diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-install-1.4.0.0.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-install-1.4.0.0.php index 835a25ca4fa..9ec36797e89 100644 --- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-install-1.4.0.0.php +++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-install-1.4.0.0.php @@ -91,7 +91,6 @@ `forced_do_shipment_with_invoice` tinyint(1) unsigned default NULL, `gift_message_id` int(10) default NULL, `payment_authorization_expiration` int(10) default NULL, - `paypal_ipn_customer_notified` int(10) default NULL, `quote_address_id` int(10) default NULL, `quote_id` int(10) default NULL, `shipping_address_id` int(10) default NULL, diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.50-0.9.51.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.50-0.9.51.php index 50a6a0d5fc6..7b5d670cf9c 100644 --- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.50-0.9.51.php +++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-0.9.50-0.9.51.php @@ -19,11 +19,7 @@ $connection = $installer->getConnection(); $paymentMethods = [ - 'paypal_standard', - 'paypal_express', - 'paypal_direct', - 'paypaluk_direct', - 'paypaluk_express', + 'paypal', ]; $entityTypeCode = 'order_payment'; $attributesIds = [ diff --git a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-1.3.99-1.4.0.0.php b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-1.3.99-1.4.0.0.php index 347a34fc5a6..35c2494c513 100644 --- a/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-1.3.99-1.4.0.0.php +++ b/app/code/core/Mage/Sales/sql/sales_setup/mysql4-upgrade-1.3.99-1.4.0.0.php @@ -125,7 +125,6 @@ `forced_do_shipment_with_invoice` tinyint(1) unsigned default NULL, `gift_message_id` int(10) default NULL, `payment_authorization_expiration` int(10) default NULL, - `paypal_ipn_customer_notified` int(10) default NULL, `quote_address_id` int(10) default NULL, `quote_id` int(10) default NULL, `shipping_address_id` int(10) default NULL, diff --git a/app/design/adminhtml/default/default/layout/paypal.xml b/app/design/adminhtml/default/default/layout/paypal.xml new file mode 100644 index 00000000000..074a4a5750a --- /dev/null +++ b/app/design/adminhtml/default/default/layout/paypal.xml @@ -0,0 +1,20 @@ +<?xml version="1.0"?> +<layout version="0.1.0"> + <adminhtml_paypal_webhook_index> + <reference name="content"> + <block type="paypal/adminhtml_webhook" name="paypal_webhook"/> + </reference> + </adminhtml_paypal_webhook_index> + + <adminhtml_paypal_debug_index> + <reference name="content"> + <block type="paypal/adminhtml_debug" name="paypal_debug"/> + </reference> + </adminhtml_paypal_debug_index> + + <adminhtml_paypal_transaction_index> + <reference name="content"> + <block type="paypal/adminhtml_transaction" name="paypal_transaction"/> + </reference> + </adminhtml_paypal_transaction_index> +</layout> diff --git a/app/design/adminhtml/default/default/template/paypal/info.phtml b/app/design/adminhtml/default/default/template/paypal/info.phtml new file mode 100644 index 00000000000..bcb960f7b9f --- /dev/null +++ b/app/design/adminhtml/default/default/template/paypal/info.phtml @@ -0,0 +1,73 @@ +<?php + +/** + * @see Mage_Paypal_Block_Adminhtml_Info + * @var $this Mage_Paypal_Block_Adminhtml_Info + */ +?> +<div class="paypal-info"> + <?php if ($this->getTransactionId()): ?> + <div class="paypal-transaction"> + <strong><?php echo $this->__('Transaction ID') ?>:</strong> + <?php if ($this->getTransactionUrl()): ?> + <a href="<?php echo $this->escapeHtml($this->getTransactionUrl()) ?>" target="_blank"> + <?php echo $this->escapeHtml($this->getTransactionId()) ?> + </a> + <?php else: ?> + <?php echo $this->escapeHtml($this->getTransactionId()) ?> + <?php endif; ?> + </div> + <?php endif; ?> + + <?php if ($this->getPaymentInfo()): ?> + <div class="paypal-payment-info"> + <table> + <?php foreach ($this->getPaymentInfo() as $label => $value): ?> + <tr> + <td><?php echo $this->escapeHtml($label) ?>:</td> + <td><?php echo $this->escapeHtml($value) ?></td> + </tr> + <?php endforeach; ?> + </table> + </div> + <?php endif; ?> + + <?php if ($this->canReauthorize()): ?> + <div class="paypal-reauthorize"> + <button type="button" class="scalable" onclick="setLocation('<?php echo $this->getReauthorizeUrl() ?>')"> + <span><?php echo $this->__('Reauthorize Payment') ?></span> + </button> + <p class="note"><?php echo $this->__('PayPal authorizations expire after 3 days. Reauthorize to extend the authorization period.') ?></p> + </div> + <?php endif; ?> +</div> +<style> + .paypal-info { + margin-top: 10px; + } + + .paypal-transaction { + margin-bottom: 10px; + } + + .paypal-payment-info table { + width: 100%; + } + + .paypal-payment-info td:first-child { + width: 40%; + font-weight: bold; + } + + .paypal-reauthorize { + margin-top: 15px; + padding-top: 10px; + border-top: 1px solid #d6d6d6; + } + + .paypal-reauthorize .note { + margin-top: 5px; + font-style: italic; + color: #666; + } +</style> \ No newline at end of file diff --git a/app/design/adminhtml/default/default/template/paypal/system/config/api_wizard.phtml b/app/design/adminhtml/default/default/template/paypal/system/config/api_wizard.phtml deleted file mode 100644 index c12299a6090..00000000000 --- a/app/design/adminhtml/default/default/template/paypal/system/config/api_wizard.phtml +++ /dev/null @@ -1,22 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package default_default - */ -?> -<?php -/** - * @see Mage_Paypal_Block_Adminhtml_System_Config_ApiWizard - * @var Mage_Paypal_Block_Adminhtml_System_Config_ApiWizard $this - */ -?> -<div class="pp-buttons-container"> - <button onclick="javascript:window.open('<?php echo $this->getButtonUrl()?>', 'apiwizard','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=100, top=100, width=380, height=470'); return false;" class="scalable" type="button" id="<?php echo $this->getHtmlId() ?>"> - <span><span><span><?php echo $this->escapeHtml($this->getButtonLabel()); ?></span></span></span> - </button> - <button onclick="javascript:window.open('<?php echo $this->getSandboxButtonUrl()?>', 'apiwizard','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=100, top=100, width=380, height=470'); return false;" class="scalable" type="button" id="<?php echo $this->getSandboxHtmlId() ?>"> - <span><span><span><?php echo $this->escapeHtml($this->getSandboxButtonLabel()); ?></span></span></span> - </button> -</div> diff --git a/app/design/adminhtml/default/default/template/paypal/system/config/bml_api_wizard.phtml b/app/design/adminhtml/default/default/template/paypal/system/config/bml_api_wizard.phtml deleted file mode 100644 index f1aeeacc060..00000000000 --- a/app/design/adminhtml/default/default/template/paypal/system/config/bml_api_wizard.phtml +++ /dev/null @@ -1,19 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package default_default - */ -?> -<?php -/** - * @see Mage_Paypal_Block_Adminhtml_System_Config_BmlApiWizard - * @var Mage_Paypal_Block_Adminhtml_System_Config_BmlApiWizard $this - */ -?> -<div class="pp-buttons-container"> - <button onclick="javascript:window.open('<?php echo $this->getButtonUrl()?>', 'bmlapiwizard','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=100, top=100, width=550, height=550'); return false;" class="scalable" type="button" id="<?php echo $this->getHtmlId() ?>"> - <span><span><span><?php echo $this->escapeHtml($this->getButtonLabel()); ?></span></span></span> - </button> -</div> diff --git a/app/design/adminhtml/default/default/template/paypal/system/config/fieldset/global.phtml b/app/design/adminhtml/default/default/template/paypal/system/config/fieldset/global.phtml deleted file mode 100644 index 5d43feb2301..00000000000 --- a/app/design/adminhtml/default/default/template/paypal/system/config/fieldset/global.phtml +++ /dev/null @@ -1,583 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package default_default - */ -?> -<?php -/** - * @see Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Global - * @var Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Global $this - * @deprecated since 1.7.0.1 - */ -?> -<table class="paypal-selection" id="paypal_checkout" cellspacing="0"> - <col width="75%" /> - <col width="25%" /> - <thead> - <tr> - <th><?php echo $this->escapeHtml($this->getFieldsetLabel()) ?></th> - <th class="paypal-selection-info"><a href="<?php echo $this->escapeHtml($this->getFieldsetHelpUrl()) ?>"><?php echo Mage::helper('paypal')->__('Help')?></a></th> - </tr> - </thead> - <tbody> -<?php foreach($this->getElements() as $htmlId => $element): ?> - <tr> - <?php if ($this->getIsElementSimplified($element)):?> - <td colspan="2" class="paypal-selection-simplified"> - <?php if ($this->hasInheritElement($element)): ?> - <div><?php echo $this->getInheritElementHtml($element) ?><?php echo $this->getInheritElementLabelHtml($element) ?></div> - <?php endif ?> - <label for="<?php echo $htmlId?>"><?php echo $this->getElementHtml($element) ?><strong><?php echo $this->getElementLabelTextHtml($element)?></strong> – <?php echo $this->escapeHtml($this->getElementComment($element))?></label> - </td> - <?php else: ?> - <td> - <?php if ($this->hasInheritElement($element)): ?> - <div><?php echo $this->getInheritElementHtml($element) ?><?php echo $this->getInheritElementLabelHtml($element) ?></div> - <?php endif ?> - <label for="<?php echo $htmlId?>"><?php echo $this->getElementHtml($element) ?><strong><?php echo $this->getElementLabelTextHtml($element)?></strong> – <?php echo $this->getElementComment($element)?></label> - </td> - <td class="paypal-selection-info"> - <?php if ($url = $this->getElementOriginalData($element, 'demo_url')):?> - <a id="<?php echo $element->getHtmlId()?>_demo_url" href="<?php echo $this->escapeHtml($url) ?>"><?php echo Mage::helper('paypal')->__('View Demo')?></a> | - <?php endif ?> - <?php if ($url = $this->getElementOriginalData($element, 'more_url')):?> - <a id="<?php echo $element->getHtmlId()?>_more_url" href="<?php echo $this->escapeHtml($url) ?>"><?php echo Mage::helper('paypal')->__('Learn More')?></a> - <?php endif ?> - </td> - <?php endif ?> - </tr> -<?php endforeach ?> - </tbody> -</table> - -<script type="text/javascript"> - -Event.observe(window, 'load', function() { - var pConfig = new PaypalConfig; - Element.observe('paypal_account_business_account', 'change', pConfig.trackBusinessAccount.bind(pConfig)); - Element.observe('paypal_account_merchant_country', 'change', pConfig.trackMerchantCountry.bind(pConfig)); - Element.observe('paypal_global_wpp', 'click', pConfig.trackWpp.bind(pConfig)); - Element.observe('paypal_global_wpp_pe', 'click', pConfig.trackWppPe.bind(pConfig)); - Element.observe('paypal_global_payflow_link', 'click', pConfig.trackWppPl.bind(pConfig)); - Element.observe('paypal_global_payflow_advanced', 'click', pConfig.trackWppPa.bind(pConfig)); - Element.observe('paypal_global_hosted_pro', 'click', pConfig.trackHss.bind(pConfig)); - Element.observe('paypal_global_verisign', 'click', pConfig.trackPayflowpro.bind(pConfig)); - ['ec','wps','ecpe'].each(function(m) { - Element.observe(pConfig.getMethodSwitcher(m).id, 'click', pConfig.trackMethod.bind(pConfig, m)); - }); - pConfig.fastMode = true; - pConfig.trackMerchantCountry(); - pConfig.trackBusinessAccount(); - pConfig.trackWpp(); - pConfig.trackWppPl(); - pConfig.trackWppPa(); - pConfig.trackWppPe(); - pConfig.trackWps(); - pConfig.trackHss(); - ['ec','wps','ecpe'].each(function(m) { - pConfig.trackMethod(m); - }); - pConfig.trackPayflowpro(); - pConfig.fastMode = false; - pConfig.destruct(); -}); - -PaypalConfig = Class.create(); -PaypalConfig.prototype = { - initialize: function(){ - this.methods = $H({ - ec: $H({ - switcher: 'express', - fieldset: 'express', - backendConfig : $H(<?php echo $this->getElementBackendConfig( - $this->getElement('paypal_global_express')); - ?>) - }), - wps: $H({ - switcher: 'wps', - fieldset: 'wps', - backendConfig : $H(<?php echo $this->getElementBackendConfig( - $this->getElement('paypal_global_wps')); - ?>) - }), - wpp: $H({ - switcher: 'wpp', - fieldset: 'wpp', - backendConfig : $H(<?php echo $this->getElementBackendConfig( - $this->getElement('paypal_global_wpp')); - ?>) - }), - wpppe: $H({ - switcher: 'wpp_pe', - fieldset: 'wpp_pe', - backendConfig : $H(<?php echo $this->getElementBackendConfig( - $this->getElement('paypal_global_wpp_pe')); - ?>) - }), - wpppl: $H({ - switcher: 'payflow_link', - fieldset: 'payflow_link', - backendConfig : $H(<?php echo $this->getElementBackendConfig( - $this->getElement('paypal_global_payflow_link')); - ?>) - }), - wpppa: $H({ - switcher: 'payflow_advanced', - fieldset: 'payflow_advanced', - backendConfig : $H(<?php echo $this->getElementBackendConfig( - $this->getElement('paypal_global_payflow_advanced')); - ?>) - }), - ecpe: $H({ - switcher: 'express_pe', - fieldset: 'express_pe', - backendConfig : $H(<?php echo $this->getElementBackendConfig( - $this->getElement('paypal_global_express_pe')); - ?>) - }), - payflowpro: $H({ - switcher: 'verisign', - fieldset: 'verisign', - backendConfig : $H(<?php echo $this->getElementBackendConfig( - $this->getElement('paypal_global_verisign')); - ?>) - }), - hosted_pro: $H({ - switcher: 'hosted_pro', - fieldset: 'hosted_pro', - backendConfig : $H(<?php echo $this->getElementBackendConfig( - $this->getElement('paypal_global_hosted_pro')); - ?>) - }) - }); - this.disabledMethods = []; - }, - - getMethods: function() - { - return this.methods; - }, - - getMethod: function(method) - { - return this.methods.get(method); - }, - - isDisabled: function(method) - { - return this.disabledMethods.indexOf(method) != -1; - }, - - isHidden: function(method) - { - if (this.getMethod(method).get('hidden')) { - return true; - } - return false; - }, - - getMethodFieldset: function(method) - { - var fieldsetId = 'paypal_' + this.getMethod(method).get('fieldset'); - return $(fieldsetId); - }, - - getMethodFieldsetHeadingLink: function(fieldset) - { - var heading = fieldset.previous('div'); - return heading.down('a'); - }, - - getMethodSwitcher: function(method) - { - var switcherId = 'paypal_global_' + this.getMethod(method).get('switcher'); - return $(switcherId); - }, - - getMethodSwitcherValue: function(method) - { - var switcherValueId = 'paypal_global_' + this.getMethod(method).get('switcher') + '_value'; - return $(switcherValueId); - }, - - getMethodSwitcherLabelText: function(method) - { - var switcherValueId = 'paypal_global_' + this.getMethod(method).get('switcher') + '_label_text'; - return $(switcherValueId); - }, - - getMethodLinkDemoUrl: function(method) - { - return $('paypal_global_' + this.getMethod(method).get('switcher') + '_demo_url'); - }, - - getMethodLinkMoreUrl: function(method) - { - return $('paypal_global_' + this.getMethod(method).get('switcher') + '_more_url'); - }, - - getMethodSwitcherInherit: function(method) - { - var inheritId = 'paypal_global_' + this.getMethod(method).get('switcher') + '_inherit'; - return $(inheritId); - }, - - markMethodAsReadonly: function(method, readonly) - { - if (readonly == undefined) { - readonly = true; - } - if (this.isDisabled(method) && !readonly || this.isHidden(method)) { - return; - } - if (this.fastMode) { - this.getMethod(method).set('readonly', readonly); - return; - } - var inherit = this.getMethodSwitcherInherit(method); - if (inherit != undefined) { - inherit.disabled = readonly; - if (!inherit.disabled && inherit.checked) { - readonly = true; - } - } - this.getMethodSwitcherValue(method).value = this.getMethodSwitcher(method).checked ? '1' : '0'; - this.getMethodSwitcher(method).disabled = readonly; - }, - - enableMethod: function(method, readonly) - { - if (this.isDisabled(method) || this.isHidden(method)) { - return; - } - readonly = (readonly == undefined ? false : readonly); - if (this.fastMode) { - this.getMethod(method).set('disabled', false); - this.getMethod(method).set('readonly', readonly); - return; - } - this.getMethodSwitcher(method).checked = true; - this.markMethodAsReadonly(method, readonly); - this.toggleFieldset(this.getMethodFieldset(method), this.getMethodSwitcher(method)); - }, - - disableMethod: function(method, readonly) - { - if (this.isHidden(method)) { - return; - } - readonly = (readonly == undefined ? true : readonly); - if (this.fastMode) { - this.getMethod(method).set('disabled', true); - this.getMethod(method).set('readonly', readonly); - return; - } - this.getMethodSwitcher(method).checked = false; - this.markMethodAsReadonly(method, readonly); - this.toggleFieldset(this.getMethodFieldset(method), this.getMethodSwitcher(method)); - }, - - toggleMethodVisibility: function(method, isHidden) - { - var selection = this.getMethodSwitcher(method).up('tr'); - var fieldset = this.getMethodFieldset(method); - var fieldsetHead = fieldset.previous('div'); - [selection, fieldset, fieldsetHead].each(function(e) { - isHidden ? e.hide() : e.show(); - }); - // do not show fieldset for turned off methods - if (!isHidden && !this.getMethodSwitcher(method).checked) { - fieldset.hide(); - } - this.getMethod(method).set('hidden', isHidden); - }, - - hideMethod: function(method) - { - this.toggleMethodVisibility(method, true); - }, - - showMethod: function(method) - { - this.toggleMethodVisibility(method, false); - }, - - trackMethod: function(method) - { - var switcher = this.getMethodSwitcher(method); - if (!switcher.checked && this.fastMode || !this.fastMode) { - this.toggleFieldset(this.getMethodFieldset(method), switcher); - } - this.getMethodSwitcherValue(method).value = switcher.checked ? '1' : '0'; - }, - - trackMerchantCountry: function() - { - this.disabledMethods = []; - this.getMethods().keys().each(function(methodKey) { - this.applyMethodConfig(methodKey); - }.bind(this)); - - this.trackBusinessAccount(); - this.trackWpp(); - this.trackWppPe(); - this.trackWps(); - }, - - applyMethodConfig: function(methodKey) - { - var country = $('paypal_account_merchant_country').value; - var config = this.getMethod(methodKey).get('backendConfig'); - if (!config) { - return false; - } - - var isMethodEnable = false; - var enableForCountries = config.get('enable_for_countries'); - var disableForCountries = config.get('disable_for_countries'); - var labels = config.get('labels'); - - if (enableForCountries - && (enableForCountries.indexOf(country) > -1 || enableForCountries.indexOf('all') > -1)) { - isMethodEnable = true; - } - if (disableForCountries - && (disableForCountries.indexOf(country) > -1 || disableForCountries.indexOf('all') > -1)) { - isMethodEnable = false; - } - - if (isMethodEnable) { - this.showMethod(methodKey); - this.markMethodAsReadonly(methodKey, false); - } else { - this.disableMethod(methodKey); - this.disabledMethods.push(methodKey); - this.hideMethod(methodKey); - } - - if (labels) { - var switcherLabelElement = this.getMethodSwitcherLabelText(methodKey); - var fieldsetLabelElement = this.getMethodFieldsetHeadingLink(this.getMethodFieldset(methodKey)); - if (!labels['default']) { - labels['default'] = { - switcher: switcherLabelElement.innerHTML, - fieldset: fieldsetLabelElement.innerHTML - }; - } - var labelConfig = labels[country]; - if (!labelConfig) { - labelConfig = labels['default']; - } - switcherLabelElement.update(labelConfig['switcher']); - fieldsetLabelElement.update(labelConfig['fieldset']); - } - - var urls = config.get('urls'); - if (urls) { - var linkMoreUrl = this.getMethodLinkMoreUrl(methodKey); - if (linkMoreUrl) { - if (!urls['more_url']) { - urls['more_url'] = linkMoreUrl.readAttribute('href'); - } - - var moreUrl = urls[country]; - if (!moreUrl && urls['more_url']) { - var moreUrl = { - more_url: urls['more_url'] - }; - } - - linkMoreUrl.writeAttribute('href', moreUrl['more_url']); - } - - var linkDemoUrl = this.getMethodLinkDemoUrl(methodKey); - if (linkDemoUrl) { - if (!urls['demo_url']) { - urls['demo_url'] = linkDemoUrl.readAttribute('href'); - } - - var demoUrl = urls[country]; - if (!demoUrl && urls['demo_url']) { - var demoUrl = { - demo_url: urls['demo_url'] - }; - } - - linkDemoUrl.writeAttribute('href', demoUrl['demo_url']); - } - } - }, - - trackBusinessAccount: function() - { - var elem = $('paypal_account_business_account'); - if (!Validation.validate(elem) || !elem.value) { - this.disableMethod('wps', true); - this.disableMethod('ec', true); - this.disabledMethods.push('wps','ec'); - } else { - this.disabledMethods = this.disabledMethods.without('wps','ec'); - this.markMethodAsReadonly('wps',false); - this.markMethodAsReadonly('ec',false); - } - }, - - trackWpp: function() - { - var enabled = this.getMethodSwitcher('wpp').checked; - var wpppeEnabled = this.getMethodSwitcher('wpppe').checked; - - if (enabled) { - this.enableMethod('wpp',false); - if (!wpppeEnabled) { - this.enableMethod('ec',true); - } - } else { - this.disableMethod('wpp',false); - if (!wpppeEnabled) { - this.markMethodAsReadonly('ec',false); - } - } - this.trackWps(); - }, - - trackWppPe: function() - { - this.trackMethod('wpppe'); - this.trackEcpe(); - this.trackWps(); - }, - - trackWppPl: function() - { - this.trackMethod('wpppl'); - }, - - trackWppPa: function() - { - this.trackMethod('wpppa'); - }, - - trackHss: function() - { - this.trackMethod('hosted_pro'); - }, - - trackPayflowpro: function() - { - this.trackMethod('payflowpro'); - this.trackEcpe(); - }, - - trackEcpe: function() - { - var wpppeEnabled = this.getMethodSwitcher('wpppe').checked; - if (wpppeEnabled) { - // Do not enable ecpe based on wpppe state on page load - if (!this.fastMode) { - this.enableMethod('ecpe',true); - } else { - this.markMethodAsReadonly('ecpe', true); - } - this.disableMethod('ec',true); - return; - } else { - if (!this.getMethodSwitcher('wpp').checked) { - this.markMethodAsReadonly('ec', false); - } else { - this.enableMethod('ec',true); - } - } - var disabled = !wpppeEnabled && !this.getMethodSwitcher('payflowpro').checked; - if (disabled) { - this.disableMethod('ecpe', true); - } else { - this.markMethodAsReadonly('ecpe', false); - } - }, - - trackWps: function() - { - var disabled = this.getMethodSwitcher('wpp').checked || this.getMethodSwitcher('wpppe').checked; - if (disabled) { - this.disableMethod('wps', true); - } else { - this.markMethodAsReadonly('wps',false); - } - }, - - enableRow: function(rowId) - { - $(rowId).select('input','select').each(function(e) { - e.disabled = false; - }); - $(rowId).show(); - }, - - disableRow: function(rowId) - { - $(rowId).select('input','select').each(function(e) { - e.disabled = true; - }); - $(rowId).hide(); - }, - - toggleFieldset: function(fieldset, checkbox) - { - var isHidden = !checkbox.checked; - this.toggleValueElements(checkbox, fieldset, isHidden); - isHidden ? fieldset.hide() : fieldset.show(); - var heading = fieldset.previous('div'); - var headingLink = this.getMethodFieldsetHeadingLink(fieldset); - isHidden ? heading.addClassName('disabled') : heading.removeClassName('disabled'); - if (isHidden) { - headingLink.oldHref = headingLink.href; - headingLink.oldOnclick = headingLink.onclick; - headingLink.onclick = "return false;"; - headingLink.href = "javascript:void(0)"; - } else { - if (headingLink.oldOnclick && headingLink.oldHref) { - headingLink.onclick = headingLink.oldOnclick; - headingLink.href = headingLink.oldHref; - } - } - }, - - toggleValueElements: function(checkbox, container, checked) - { - var isDisabled = (checked != undefined ? checked : $(checkbox).checked); - var elemInherit, currIsDisabled; - $(container).select('select', 'input', 'textarea', 'button').each (function(elem) { - // avoid inherit checkbox functionality rewrite - currIsDisabled = isDisabled; - if (!currIsDisabled) { - elemInherit = $(elem.id + '_inherit'); - if (elemInherit != undefined && elemInherit.checked) { - currIsDisabled = true; - } - } - elem.disabled=currIsDisabled; - if (currIsDisabled) { - elem.addClassName('disabled'); - } else { - elem.removeClassName('disabled'); - } - }); - }, - - destruct: function() - { - this.getMethods().each(function(method) { - if (method.value.get('disabled') != undefined) { - method.value.get('disabled') ? this.disableMethod(method.key) : this.enableMethod(method.key); - } - if (method.value.get('readonly') != undefined) { - this.markMethodAsReadonly(method.key, method.value.get('readonly')); - } - }.bind(this)); - } -} -</script> diff --git a/app/design/adminhtml/default/default/template/paypal/system/config/fieldset/hint.phtml b/app/design/adminhtml/default/default/template/paypal/system/config/fieldset/hint.phtml deleted file mode 100644 index 3aa76f8196e..00000000000 --- a/app/design/adminhtml/default/default/template/paypal/system/config/fieldset/hint.phtml +++ /dev/null @@ -1,19 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package default_default - */ -?> -<?php -/** - * @see Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Hint - * @var Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Hint $this - */ -?> -<?php if ($this->getHelpLink()): ?> - <div class="paypal-payment-notice"> - <?php echo Mage::helper('paypal')->__('Not sure what PayPal payment method to use? Click <a href="%s" target="_blank">here</a> to learn more.', $this->getHelpLink()); ?> - </div> -<?php endif ?> diff --git a/app/design/adminhtml/default/default/template/paypal/system/config/fieldset/store.phtml b/app/design/adminhtml/default/default/template/paypal/system/config/fieldset/store.phtml deleted file mode 100644 index ad78d36243f..00000000000 --- a/app/design/adminhtml/default/default/template/paypal/system/config/fieldset/store.phtml +++ /dev/null @@ -1,84 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package default_default - */ -?> -<?php -/** - * @see Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Store - * @var Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Store $this - */ -?> -<script type="text/javascript"> - -Event.observe(window, 'load', function () { - var pConfigDisabler = new PaypalConfigDisabler; - var disabledMethods = <?php echo Mage::helper('core')->jsonEncode($this->getPaypalDisabledMethods()); ?>; - pConfigDisabler.disableMethods(disabledMethods); -}); - -PaypalConfigDisabler = Class.create(); -PaypalConfigDisabler.prototype = { - initialize: function () { - this.methods = $H({ - express: $H({fieldset: 'express'}), - wps: $H({fieldset: 'wps'}), - wpp: $H({fieldset: 'wpp'}), - wpppe: $H({fieldset: 'wpp_pe'}), - expresspe: $H({fieldset: 'express_pe'}), - verisign: $H({fieldset: 'verisign'}), - wpppl: $H({fieldset: 'payflow_link'}), - hosted_pro: $H({fieldset: 'hosted_pro'}) - }); - }, - - getMethods: function () - { - return this.methods; - }, - - getMethod: function (method) - { - return this.methods.get(method); - }, - - getMethodFieldset: function (method) - { - var fieldsetId = 'paypal_' + this.getMethod(method).get('fieldset'); - return $(fieldsetId); - }, - - disableMethod: function (method) - { - this.hideFieldset(this.getMethodFieldset(method)); - }, - - disableMethods: function (methods) - { - for(var methodId in methods) { - this.disableMethod(methodId); - } - }, - - hideFieldset: function (fieldset) - { - this.disableValueElements(fieldset); - fieldset.hide(); - var heading = fieldset.previous('div'); - var headingLink = heading.down('a'); - heading.addClassName('disabled'); - headingLink.onclick = "return false;"; - headingLink.href = "javascript:void(0)"; - }, - - disableValueElements: function (container) - { - $(container).select('select', 'input', 'textarea', 'button').each(function (elem) { - elem.addClassName('disabled'); - }); - } -} -</script> diff --git a/app/design/adminhtml/default/default/template/paypal/system/config/payflowlink/advanced.phtml b/app/design/adminhtml/default/default/template/paypal/system/config/payflowlink/advanced.phtml deleted file mode 100644 index 847793d2a7d..00000000000 --- a/app/design/adminhtml/default/default/template/paypal/system/config/payflowlink/advanced.phtml +++ /dev/null @@ -1,22 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package default_default - */ - -/** - * @var Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Advanced $this - */ -?> -<div class="payflow-settings-notice"> - <strong class="important-label"><?php echo $this->__('Important: ') ?></strong> - <?php echo $this->__('To use PayPal Payments Advanced, you must configure your PayPal Payments Advanced account on the PayPal website.'); ?> - <?php echo $this->__('Once you log into your PayPal Advanced account, navigate to the Service Settings - Hosted Checkout Pages - Set Up menu and set the options described below') ?> - <ul class="options-list"> - <li><strong>AVS:</strong> No</li> - <li><strong>CSC:</strong> No</li> - <li><strong>Enable Secure Token:</strong> Yes</li> - </ul> -</div> diff --git a/app/design/adminhtml/default/default/template/paypal/system/config/payflowlink/info.phtml b/app/design/adminhtml/default/default/template/paypal/system/config/payflowlink/info.phtml deleted file mode 100644 index 500ae88156a..00000000000 --- a/app/design/adminhtml/default/default/template/paypal/system/config/payflowlink/info.phtml +++ /dev/null @@ -1,24 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package default_default - */ -?> -<?php -/** - * @see Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Info - * @var Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Info $this - */ -?> -<div class="payflow-settings-notice"> - <strong class="important-label"><?php echo $this->__('Important: ') ?></strong> - <?php echo $this->__('To use PayPal Payflow Link, you must configure your PayPal Payflow Link account on the PayPal website.'); ?> - <?php echo $this->__('Once you log into your PayPal Payflow Link account, navigate to the Service Settings - Hosted Checkout Pages - Set Up menu and set the options described below') ?> - <ul class="options-list"> - <li><strong>AVS:</strong> No</li> - <li><strong>CSC:</strong> No</li> - <li><strong>Enable Secure Token:</strong> Yes</li> - </ul> -</div> diff --git a/app/design/frontend/base/default/layout/bml.xml b/app/design/frontend/base/default/layout/bml.xml deleted file mode 100644 index ccc24313a67..00000000000 --- a/app/design/frontend/base/default/layout/bml.xml +++ /dev/null @@ -1,111 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ - ---> -<layout version="0.1.0"> - <cms_index_index> - <reference name="top.container"> - <block type="paypal/bml_banners" name="bml.center.logo" template="paypal/bml.phtml"> - <action method="setSection"><section>homepage</section></action> - <action method="setPosition"><position>0</position></action> - </block> - </reference> - <reference name="right"> - <block type="paypal/bml_banners" name="bml.right.logo" template="paypal/bml.phtml"> - <action method="setSection"><section>homepage</section></action> - <action method="setPosition"><position>1</position></action> - </block> - </reference> - </cms_index_index> - - <cms_index_defaultindex> - <reference name="top.container"> - <block type="paypal/bml_banners" name="bml.center.logo" template="paypal/bml.phtml"> - <action method="setSection"><section>homepage</section></action> - <action method="setPosition"><position>0</position></action> - </block> - </reference> - <reference name="right"> - <block type="paypal/bml_banners" name="bml.right.logo" template="paypal/bml.phtml"> - <action method="setSection"><section>homepage</section></action> - <action method="setPosition"><position>1</position></action> - </block> - </reference> - </cms_index_defaultindex> - - <catalog_category_default> - <reference name="top.container"> - <block type="paypal/bml_banners" name="bml.center.logo" template="paypal/bml.phtml"> - <action method="setSection"><section>categorypage</section></action> - <action method="setPosition"><position>0</position></action> - </block> - </reference> - <reference name="right"> - <block type="paypal/bml_banners" name="bml.right.logo" template="paypal/bml.phtml"> - <action method="setSection"><section>categorypage</section></action> - <action method="setPosition"><position>1</position></action> - </block> - </reference> - </catalog_category_default> - - <catalog_category_layered> - <reference name="top.container"> - <block type="paypal/bml_banners" name="bml.center.logo" template="paypal/bml.phtml"> - <action method="setSection"><section>categorypage</section></action> - <action method="setPosition"><position>0</position></action> - </block> - </reference> - <reference name="right"> - <block type="paypal/bml_banners" name="bml.right.logo" template="paypal/bml.phtml"> - <action method="setSection"><section>categorypage</section></action> - <action method="setPosition"><position>1</position></action> - </block> - - </reference> - </catalog_category_layered> - - <catalog_product_view> - <reference name="top.container"> - <block type="paypal/bml_banners" name="bml.center.logo" template="paypal/bml.phtml"> - <action method="setSection"><section>productpage</section></action> - <action method="setPosition"><position>0</position></action> - </block> - </reference> - <reference name="product.info.addtocart"> - <block type="paypal/bml_banners" name="bml.right.logo" after="product.info.addtocart.paypal" template="paypal/bml.phtml"> - <action method="setSection"><section>productpage</section></action> - <action method="setPosition"><position>1</position></action> - </block> - </reference> - </catalog_product_view> - - <checkout_cart_index> - <reference name="top.container"> - <block type="paypal/bml_banners" name="bml.center.logo" template="paypal/bml.phtml"> - <action method="setSection"><section>checkout</section></action> - <action method="setPosition"><position>0</position></action> - </block> - </reference> - <reference name="checkout.cart.methods"> - <block type="paypal/bml_banners" name="bml.right.logo" after="checkout.cart.methods.onepage.bottom" template="paypal/bml.phtml"> - <action method="setSection"><section>checkout</section></action> - <action method="setPosition"><position>1</position></action> - </block> - </reference> - </checkout_cart_index> - - <checkout_onepage_index> - <reference name="top.container"> - <block type="paypal/bml_banners" name="bml.center.logo" template="paypal/bml.phtml"> - <action method="setSection"><section>checkout</section></action> - <action method="setPosition"><position>0</position></action> - </block> - </reference> - </checkout_onepage_index> -</layout> diff --git a/app/design/frontend/base/default/layout/bundle.xml b/app/design/frontend/base/default/layout/bundle.xml index 9b8b08b8f55..14d78540dca 100644 --- a/app/design/frontend/base/default/layout/bundle.xml +++ b/app/design/frontend/base/default/layout/bundle.xml @@ -152,28 +152,6 @@ Onepage Checkout Review Page </reference> </checkout_multishipping_overview> - <paypal_express_review> - <reference name="paypal.express.review.details"> - <action method="addItemRender"><type>bundle</type><block>bundle/checkout_cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action> - </reference> - </paypal_express_review> - <paypal_express_review_details> - <reference name="root"> - <action method="addItemRender"><type>bundle</type><block>bundle/checkout_cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action> - </reference> - </paypal_express_review_details> - - <paypaluk_express_review> - <reference name="paypal.express.review.details"> - <action method="addItemRender"><type>bundle</type><block>bundle/checkout_cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action> - </reference> - </paypaluk_express_review> - <paypaluk_express_review_details> - <reference name="root"> - <action method="addItemRender"><type>bundle</type><block>bundle/checkout_cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action> - </reference> - </paypaluk_express_review_details> - <!-- Additional block for bundle product type --> diff --git a/app/design/frontend/base/default/layout/downloadable.xml b/app/design/frontend/base/default/layout/downloadable.xml index 4b73664f2dd..326d09802f2 100644 --- a/app/design/frontend/base/default/layout/downloadable.xml +++ b/app/design/frontend/base/default/layout/downloadable.xml @@ -69,28 +69,6 @@ </reference> </checkout_multishipping_success> - <paypal_express_review> - <reference name="paypal.express.review.details"> - <action method="addItemRender"><type>downloadable</type><block>downloadable/checkout_cart_item_renderer</block><template>downloadable/checkout/onepage/review/item.phtml</template></action> - </reference> - </paypal_express_review> - <paypal_express_review_details> - <reference name="root"> - <action method="addItemRender"><type>downloadable</type><block>downloadable/checkout_cart_item_renderer</block><template>downloadable/checkout/onepage/review/item.phtml</template></action> - </reference> - </paypal_express_review_details> - - <paypaluk_express_review> - <reference name="paypal.express.review.details"> - <action method="addItemRender"><type>downloadable</type><block>downloadable/checkout_cart_item_renderer</block><template>downloadable/checkout/onepage/review/item.phtml</template></action> - </reference> - </paypaluk_express_review> - <paypaluk_express_review_details> - <reference name="root"> - <action method="addItemRender"><type>downloadable</type><block>downloadable/checkout_cart_item_renderer</block><template>downloadable/checkout/onepage/review/item.phtml</template></action> - </reference> - </paypaluk_express_review_details> - <sales_order_view> <reference name="order_items"> <action method="addItemRender"><type>downloadable</type><block>downloadable/sales_order_item_renderer_downloadable</block><template>downloadable/sales/order/items/renderer/downloadable.phtml</template></action> diff --git a/app/design/frontend/base/default/layout/paypal.xml b/app/design/frontend/base/default/layout/paypal.xml index 7eb68522478..3b020dd9f06 100644 --- a/app/design/frontend/base/default/layout/paypal.xml +++ b/app/design/frontend/base/default/layout/paypal.xml @@ -1,167 +1,15 @@ <?xml version="1.0"?> -<!-- -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ - ---> <layout version="0.1.0"> - <checkout_cart_index> - <reference name="checkout.cart.top_methods"> - <block type="paypal/express_shortcut" name="checkout.cart.methods.paypal_express.top" before="-" template="paypal/express/shortcut.phtml"> - <action method="setIsQuoteAllowed"><value>1</value></action> - </block> - </reference> - - <reference name="checkout.cart.methods"> - <block type="paypal/express_shortcut" name="checkout.cart.methods.paypal_express.bottom" before="-" template="paypal/express/shortcut.phtml"> - <action method="setIsQuoteAllowed"><value>1</value></action> - </block> - </reference> - - <update handle="SHORTCUT_popup" /> - </checkout_cart_index> - - <paypal_express_review translate="label"> - <label>PayPal Express Order Review Form</label> - <remove name="right"/> - <remove name="left"/> - - <reference name="root"> - <action method="setTemplate"><template>page/1column.phtml</template></action> - </reference> - <reference name="content"> - <block type="paypal/express_review" name="paypal.express.review" template="paypal/express/review.phtml"> - <block type="paypal/express_review" name="express.review.shipping.method" as="shipping_method" template="paypal/express/review/shipping/method.phtml"/> - <block type="paypal/express_review_details" name="paypal.express.review.details" as="details" template="paypal/express/review/details.phtml"> - <action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action> - <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action> - <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action> - <block type="checkout/cart_totals" name="paypal.express.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/> - </block> - <block type="checkout/agreements" name="paypal.express.review.details.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/> - </block> - </reference> + <checkout_onepage_index> <reference name="head"> - <action method="addItem"><type>skin_js</type><name>js/checkout/review.js</name></action> - </reference> - <block type="core/text_list" name="additional.product.info" /> - </paypal_express_review> - - <paypal_express_review_details> - <block type="paypal/express_review_details" name="root" output="toHtml" template="paypal/express/review/details.phtml"> - <action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action> - <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action> - <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action> - <block type="checkout/cart_totals" name="paypal.express.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/> - </block> - </paypal_express_review_details> - -<!-- -Available logo types can be assigned with action="setLogoType": - - wePrefer_150x60 - - wePrefer_150x40 - - nowAccepting_150x60 - - nowAccepting_150x40 - - paymentsBy_150x60 - - paymentsBy_150x40 - - shopNowUsing_150x60 - - shopNowUsing_150x40 ---> - <catalog_product_view> - <reference name="product.info.addtocart"> - <block type="page/html_wrapper" name="product.info.addtocart.paypal.wrapper" translate="label"> - <label>PayPal Express Checkout Shortcut Wrapper</label> - <block type="paypal/express_shortcut" name="product.info.addtocart.paypal" template="paypal/express/shortcut.phtml"> - <action method="setIsInCatalogProduct"><value>1</value></action> - </block> - </block> + <action method="addJs"><script>paypal/payment.js</script></action> + <action method="addCss"><stylesheet>css/paypal.css</stylesheet></action> </reference> - <update handle="SHORTCUT_popup" /> - </catalog_product_view> - - <catalog_category_default> - <update handle="SHORTCUT_popup" /> - </catalog_category_default> - - <catalog_category_layered> - <update handle="SHORTCUT_popup" /> - </catalog_category_layered> - - <catalog_product_compare_index> - <update handle="SHORTCUT_popup" /> - </catalog_product_compare_index> - - <catalogsearch_result_index> - <update handle="SHORTCUT_popup" /> - </catalogsearch_result_index> - - <catalogsearch_advanced_result> - <update handle="SHORTCUT_popup" /> - </catalogsearch_advanced_result> - - <tag_product_list> - <update handle="SHORTCUT_popup" /> - </tag_product_list> - <tag_customer_view> - <update handle="SHORTCUT_popup" /> - </tag_customer_view> - - <wishlist_index_index> - <update handle="SHORTCUT_popup" /> - </wishlist_index_index> - <review_product_list> - <update handle="SHORTCUT_popup" /> - </review_product_list> - - <checkout_onepage_success> - <update handle="SHORTCUT_popup" /> - </checkout_onepage_success> - <checkout_onepage_failure> - <update handle="SHORTCUT_popup" /> - </checkout_onepage_failure> - - <default> - <reference name="topCart.extra_actions"> - <block type="paypal/express_shortcut" name="paypal.partner.top_cart.shortcut" template="paypal/express/shortcut.phtml"/> - </reference> - <reference name="cart_sidebar.extra_actions"> - <block type="paypal/express_shortcut" name="paypal.partner.cart_sidebar.shortcut" template="paypal/express/shortcut.phtml"/> - </reference> - </default> - - <checkout_onepage_review> - <reference name="checkout.onepage.review.info.items.after"> - <block type="paypal/iframe" name="paypal.iframe" /> - </reference> - <reference name="checkout.onepage.review.button"> - <action method="setTemplate"><template helper="paypal/hss/getReviewButtonTemplate"><name>paypal/hss/review/button.phtml</name><block>checkout.onepage.review.button</block></template></action> - </reference> - </checkout_onepage_review> - - <paypal_payflow_link_iframe> - <block type="paypal/payflow_link_iframe" name="payflow.link.iframe" template="paypal/payflowlink/form.phtml" /> - </paypal_payflow_link_iframe> - - <paypal_payflow_advanced_iframe> - <block type="paypal/payflow_advanced_iframe" name="payflow.advanced.iframe" template="paypal/payflowadvanced/form.phtml" /> - </paypal_payflow_advanced_iframe> - - <paypal_hosted_pro_iframe> - <block type="paypal/hosted_pro_iframe" name="hosted.pro.iframe" template="paypal/hss/form.phtml"/> - </paypal_hosted_pro_iframe> + </checkout_onepage_index> - <SHORTCUT_popup> - <reference name="product.tooltip"> - <block type="page/html_wrapper" name="product.info.addtocart.paypal.wrapper" translate="label"> - <block type="paypal/express_shortcut" name="product.info.addtocart.paypal" template="paypal/express/shortcut.phtml"> - <action method="setIsInCatalogProduct"><value>1</value></action> - <action method="setShowOrPosition"><value>after</value></action> - </block> - </block> + <checkout_onepage_paymentmethod> + <reference name="checkout.payment.methods"> + <block type="paypal/form" name="payment.method.paypal" template="paypal/payment.phtml"/> </reference> - </SHORTCUT_popup> + </checkout_onepage_paymentmethod> </layout> diff --git a/app/design/frontend/base/default/layout/review.xml b/app/design/frontend/base/default/layout/review.xml index b38380a816c..c81bbb12d94 100644 --- a/app/design/frontend/base/default/layout/review.xml +++ b/app/design/frontend/base/default/layout/review.xml @@ -63,15 +63,7 @@ Product reviews page <action method="disableGallery"/> </block> <block type="catalog/product_view" name="product.info.addto" as="addto" template="catalog/product/view/addto.phtml"/> - <block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml"> - <!-- workaround: a better place for this code is in paypal.xml --> - <block type="page/html_wrapper" name="review.product.info.addtocart.paypal.wrapper" translate="label" module="paypal"> - <label>PayPal Express Checkout Shortcut Wrapper</label> - <block type="paypal/express_shortcut" name="review.product.info.addtocart.paypal" template="paypal/express/shortcut.phtml"> - <action method="setIsInCatalogProduct"><value>1</value></action> - </block> - </block> - </block> + <block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml"/> <block type="catalog/product_view" name="product.tierprices" as="tierprices" template="catalog/product/view/tierprices.phtml"/> <block type="core/template" name="product.info.other" as="other" template="review/product/view/other.phtml"/> <block type="page/html_pager" name="product_review_list.toolbar" /> diff --git a/app/design/frontend/base/default/template/paypal/bml.phtml b/app/design/frontend/base/default/template/paypal/bml.phtml deleted file mode 100644 index 942408826f5..00000000000 --- a/app/design/frontend/base/default/template/paypal/bml.phtml +++ /dev/null @@ -1,23 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ -?> -<?php -/** - * @see Mage_Paypal_Block_Bml_Banners - * @var Mage_Paypal_Block_Bml_Banners $this - */ -?> -<div class="paypal-logo bill-me-latter"> -<script type="text/javascript" data-pp-pubid="<?php echo $this->escapeHtml($this->getPublisherId()) ?>" data-pp-placementtype="<?php echo $this->escapeHtml($this->getSize()) ?>"> (function (d, t) { - "use strict"; - var s = d.getElementsByTagName(t)[0], n = d.createElement(t); - n.src = "//paypal.adtag.where.com/merchant.js"; - s.parentNode.insertBefore(n, s); -}(document, "script")); -</script> -</div> diff --git a/app/design/frontend/base/default/template/paypal/express/review.phtml b/app/design/frontend/base/default/template/paypal/express/review.phtml deleted file mode 100644 index 22b08774647..00000000000 --- a/app/design/frontend/base/default/template/paypal/express/review.phtml +++ /dev/null @@ -1,155 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ -/** @var Mage_Paypal_Block_Express_Review $this */ -?> -<div class="page-title"> - <h1><?php echo $this->__('Review Order') ?></h1> -</div> -<?php echo $this->getMessagesBlock()->toHtml() ?> -<?php if ($this->getShippingAddress()): ?> - <div class="info-set col2-set"> - <h2 class="legend"><?php echo $this->__('Shipping Information') ?></h2> - <div class="col-1"> - <div class="box"> - <div class="box-title"> - <h3><?php echo $this->__('Shipping Address') ?><span class="separator"><?php if ($this->getCanEditShippingAddress()):?> | </span><a href="<?php echo $this->getEditUrl() ?>"><?php echo $this->__('Edit') ?></a><?php endif ?></h3> - </div> - <div class="box-content"> - <address><?php echo $this->renderAddress($this->getShippingAddress())?></address> - </div> - </div> - </div> - <div class="col-2"> - <div class="box"> - <div class="box-title"> - <h3><?php echo $this->__('Shipping Method') ?></h3> - </div> - <div class="box-content"> - <form method="post" id="shipping_method_form" action="<?php echo $this->escapeHtml($this->getShippingMethodSubmitUrl()) ?>"> - <?php if ($this->getCanEditShippingMethod() || !$this->getCurrentShippingRate()):?> - <?php if ($groups = $this->getShippingRateGroups()):?> - <?php $currentRate = $this->getCurrentShippingRate(); ?> - <fieldset> - <select name="shipping_method" id="shipping_method" style="width:250px;" class="required-entry"> - <?php if (!$currentRate):?> - <option value=""><?php echo $this->__('Please select a shipping method...') ?></option> - <?php endif ?> - <?php foreach ($groups as $code => $rates):?> - <optgroup label="<?php echo $this->escapeHtml($this->getCarrierName($code)) ?>" style="font-style:normal;"> - <?php foreach ($rates as $rate):?> - <option value="<?php echo $this->renderShippingRateValue($rate)?>"<?php echo ($currentRate === $rate) ? ' selected="selected"' : '' ;?>> - <?php echo $this->renderShippingRateOption($rate)?> - </option> - <?php endforeach ?> - </optgroup> - <?php endforeach ?> - </select> - </fieldset> - <p class="actions"> - <button id="update_shipping_method_submit" type="submit" class="button"><span><span><?php echo $this->__('Update Shipping Method') ?></span></span></button> - </p> - <?php else: ?> - <p><strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong></p> - <?php endif ?> - <?php else: ?> - <p><strong><?php echo $this->renderShippingRateOption($this->getCurrentShippingRate())?></strong></p> - <?php endif ?> - </form> - </div> - </div> - </div> - </div> -<?php endif ?> - -<div class="info-set col2-set"> - <h2 class="legend"><?php echo $this->__('Billing Information') ?></h2> - <div class="col-1"> - <div class="box"> - <div class="box-title"> - <h3><?php echo $this->__('Payment Method') ?> <span class="separator">|</span> - <?php if($this->getEditUrl()):?><a href="<?php echo $this->getEditUrl() ?>"><?php echo $this->__('Edit Payment Information') ?></a> <?php endif ?> - </h3> - </div> - <div class="box-content"> - <?php echo $this->escapeHtml($this->getPaymentMethodTitle()) ?> - </div> - </div> - </div> -</div> - -<div class="info-set"> - <h2 class="legend"><?php echo $this->__('Items in Your Shopping Cart') ?><span class="separator"> | </span><a href="<?php echo $this->getUrl('checkout/cart') ?>"><?php echo $this->__('Edit Shopping Cart') ?></a></h2> - <div id="details-reload"> - <?php echo $this->getChildHtml('details') ?> - </div> -</div> -<form method="post" id="order_review_form" action="<?php echo $this->getPlaceOrderUrl() ?>"> - <?php echo $this->getChildHtml('agreements'); ?> - <div class="buttons-set buttons-set-order" id="review-buttons-container"> - <button type="button" id="review_button" value="<?php echo Mage::helper('core')->quoteEscape($this->__('Place Order')) ?>" class="button btn-checkout"><span><span><?php echo $this->__('Place Order') ?></span></span></button> - <button type="button" id="review_submit" value="<?php echo Mage::helper('core')->quoteEscape($this->__('Place Order')) ?>" class="button btn-checkout"><span><span><?php echo $this->__('Place Order') ?></span></span></button> - <span class="please-wait" id="review-please-wait" style="display:none;"> - <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo Mage::helper('core')->quoteEscape($this->__('Submitting order information...')) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Submitting order information...')) ?>" class="v-middle" /> <?php echo $this->__('Submitting order information...') ?> - </span> - </div> -</form> -<script type="text/javascript"> - //<![CDATA[ - // submit buttons are not needed when submitting with ajax - $('review_submit').hide(); - if ($('update_shipping_method_submit')) { - $('update_shipping_method_submit').hide(); - } - - <?php if ($this->getUseAjax()):?> - OrderReviewController.prototype._submitOrder = function() { - if (this._canSubmitOrder) { - if (this._pleaseWait) { - this._pleaseWait.show(); - } - new Ajax.Request(this.form.action, { - parameters: {isAjax: 1, method: 'POST'}, - onSuccess: function(transport) { - var response = transport.responseJSON || transport.responseText.evalJSON(true) || {}; - if (response.redirect) { - setLocation(response.redirect); - return; - } - if (response.success) { - setLocation('<?php echo $this->getSuccessUrl()?>'); - return; - } else { - var msg = response.error_messages; - if (Object.isArray(msg)) { - msg = msg.join("\n").stripTags().toString(); - } - if (msg) { - $('review-please-wait').hide(); - alert(msg.stripTags().toString()); - return; - } - } - $('review-please-wait').hide(); - alert('<?php echo $this->jsQuoteEscape($this->__('Unknown Error. Please try again later.')); ?>'); - return; - }, - onFailure: function(){ - alert('<?php echo $this->jsQuoteEscape($this->__('Server Error. Please try again.')) ?>'); - $('review-please-wait').hide(); - } - }); - } - } - <?php endif ?> - - PayPalExpressAjax = new OrderReviewController($('order_review_form'), $('review_button'), - $('shipping_method'), $('shipping_method_form'), 'details-reload' - ); - PayPalExpressAjax.addPleaseWait($('review-please-wait')); - //]]> -</script> diff --git a/app/design/frontend/base/default/template/paypal/express/review/details.phtml b/app/design/frontend/base/default/template/paypal/express/review/details.phtml deleted file mode 100644 index 5a167f9e729..00000000000 --- a/app/design/frontend/base/default/template/paypal/express/review/details.phtml +++ /dev/null @@ -1,47 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ - -/** - * @see Mage_Paypal_Block_Express_Review_Details - * @var Mage_Paypal_Block_Express_Review_Details $this - */ -?> -<table id="details-table" class="data-table"> - <?php if ($this->helper('tax')->displayCartBothPrices()): $colspan = $rowspan = 2; else: $colspan = $rowspan = 1; endif; ?> - <col /> - <col width="1" /> - <col width="1" /> - <col width="1" /> - <?php if ($this->helper('tax')->displayCartBothPrices()): ?> - <col width="1" /> - <col width="1" /> - <?php endif ?> - <thead> - <tr> - <th rowspan="<?php echo $rowspan ?>"><?php echo $this->__('Product Name') ?></th> - <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Price') ?></th> - <th rowspan="<?php echo $rowspan ?>" class="a-center"><?php echo $this->__('Qty') ?></th> - <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Subtotal') ?></th> - </tr> - <?php if ($this->helper('tax')->displayCartBothPrices()): ?> - <tr> - <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th> - <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th> - <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th> - <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th> - </tr> - <?php endif ?> - </thead> -<?php echo $this->getChildHtml('totals'); ?> - <tbody> - <?php foreach($this->getItems() as $_item): ?> - <?php echo $this->getItemHtml($_item) ?> - <?php endforeach ?> - </tbody> -</table> -<script type="text/javascript">decorateTable('details-table');</script> diff --git a/app/design/frontend/base/default/template/paypal/express/review/shipping/method.phtml b/app/design/frontend/base/default/template/paypal/express/review/shipping/method.phtml deleted file mode 100644 index 20494f7036c..00000000000 --- a/app/design/frontend/base/default/template/paypal/express/review/shipping/method.phtml +++ /dev/null @@ -1,35 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ -/** @var Mage_Paypal_Block_Express_Review $this */ -?> -<fieldset id="shipping-method-container"> -<?php if ($this->getCanEditShippingMethod() || !$this->getCurrentShippingRate()):?> - <?php if ($groups = $this->getShippingRateGroups()):?> - <?php $currentRate = $this->getCurrentShippingRate(); ?> - <select name="shipping_method" id="shipping_method" style="width:250px;" class="required-entry"> - <?php if (!$currentRate):?> - <option value=""><?php echo $this->__('Please select a shipping method...') ?></option> - <?php endif ?> - <?php foreach ($groups as $code => $rates):?> - <optgroup label="<?php echo $this->escapeHtml($this->getCarrierName($code)) ?>" style="font-style:normal;"> - <?php foreach ($rates as $rate):?> - <option value="<?php echo $this->renderShippingRateValue($rate)?>"<?php echo ($currentRate === $rate) ? ' selected="selected"' : '' ;?>> - <?php echo $this->renderShippingRateOption($rate)?> - </option> - <?php endforeach ?> - </optgroup> - <?php endforeach ?> - </select> - <?php else: ?> - <p><strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong></p> - <?php endif ?> -<?php else: ?> - <p><strong><?php echo $this->renderShippingRateOption($this->getCurrentShippingRate())?></strong></p> -<?php endif ?> -</fieldset> -<div style="display:none" id="shipping_method_update"><p><?php echo $this->__('Please update order data to get shipping methods and rates') ?></p></div> diff --git a/app/design/frontend/base/default/template/paypal/express/shortcut.phtml b/app/design/frontend/base/default/template/paypal/express/shortcut.phtml deleted file mode 100644 index aa9058282e4..00000000000 --- a/app/design/frontend/base/default/template/paypal/express/shortcut.phtml +++ /dev/null @@ -1,62 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ -?> -<?php -/** - * @var Mage_Paypal_Block_Express_Shortcut $this - */ -?> -<p class="paypal-logo"> -<?php $shortcutHtmlId = $this->getShortcutHtmlId() ?> -<?php $bmlShortcutHtmlId = $this->getBmlShortcutHtmlId() ?> -<?php if ($this->isOrPositionBefore()): ?> - <span class="paypal-or"><?php echo $this->__('-OR-'); ?></span> -<?php endif ?> -<a data-action="checkout-form-submit" id="<?php echo $shortcutHtmlId ?>" href="<?php echo $this->getCheckoutUrl() ?>"><img src="<?php echo $this->getImageUrl() ?>" alt="<?php echo Mage::helper('paypal')->__('Checkout with PayPal'); ?>" title="<?php echo Mage::helper('paypal')->__('Checkout with PayPal'); ?>" /></a> -<?php if ($this->getIsBmlEnabled()): ?> - <span class="paypal-or"><?php echo $this->__('-OR-'); ?></span> - </p> -<li class="bml-checkout-type"> - <p class="paypal-logo"> - <span class="bml_button"> - <a id="<?php echo $bmlShortcutHtmlId ?>" href="<?php echo $this->getBmlCheckoutUrl() ?>"><img src="<?php echo $this->getBmlImageUrl() ?>" alt="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('paypal')->__('Checkout with PayPal Paypal Credit')); ?>" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('paypal')->__('Checkout with PayPal Paypal Credit')); ?>" /></a> - <a href="<?php echo $this->getMarketMessageUrl() ?>"><img src="<?php echo $this->getMarketMessage() ?>" /></a> - </span> - </p> -</li> -<?php else: ?> - </p> -<?php endif ?> -<?php if ($this->isOrPositionAfter()): ?> -<li> - <p class="paypal-logo"> - <span class="paypal-or"><?php echo $this->__('-OR-'); ?></span> - </p> -</li> - <?php endif ?> -<?php if ($this->getConfirmationUrl() || $this->getIsInCatalogProduct()): ?> -<?php if ($this->getIsInCatalogProduct()): ?> - <input type="hidden" id="pp_checkout_url" name="return_url" value="" /> -<?php endif ?> -<script type="text/javascript"> -//<![CDATA[ - $$('#<?php echo $shortcutHtmlId ?>','#<?php echo $bmlShortcutHtmlId ?>').invoke('observe', 'click', function(event) { - <?php if ($this->getConfirmationUrl()): ?> - if (confirm('<?php echo Mage::helper('core')->jsQuoteEscape($this->getConfirmationMessage()) ?>')) { - this.href = '<?php echo $this->getConfirmationUrl() ?>'; - } - <?php endif ?> - <?php if ($this->getIsInCatalogProduct()): ?> - $('pp_checkout_url').value = this.href; - productAddToCartForm.submit(this); - event.stop(); - <?php endif ?> - }); -//]]> -</script> -<?php endif ?> diff --git a/app/design/frontend/base/default/template/paypal/hss/form.phtml b/app/design/frontend/base/default/template/paypal/hss/form.phtml deleted file mode 100644 index 9f9d8f12691..00000000000 --- a/app/design/frontend/base/default/template/paypal/hss/form.phtml +++ /dev/null @@ -1,28 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ - -/** - * @see Mage_Paypal_Block_Payflow_Link_Iframe - * @var Mage_Paypal_Block_Payflow_Link_Iframe $this - */ -?> -<html> -<head></head> -<body> - <form id="token_form" method="POST" action="<?php echo $this->getTransactionUrl() ?>"> - <input type="hidden" name="SECURETOKEN" value="<?php echo $this->getSecureToken(); ?>" /> - <input type="hidden" name="SECURETOKENID" value="<?php echo $this->getSecureTokenId(); ?>" /> - <input type="hidden" name="MODE" value="<?php echo $this->isTestMode() ? 'TEST' : 'LIVE'; ?>" /> - </form> - <script type="text/javascript"> - //<![CDATA[ - document.getElementById('token_form').submit(); - //]]> - </script> -</body> -</html> diff --git a/app/design/frontend/base/default/template/paypal/hss/iframe.phtml b/app/design/frontend/base/default/template/paypal/hss/iframe.phtml deleted file mode 100644 index fa9cc62ca6f..00000000000 --- a/app/design/frontend/base/default/template/paypal/hss/iframe.phtml +++ /dev/null @@ -1,34 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ - -/** - * @see Mage_Paypal_Block_Iframe - * @var Mage_Paypal_Block_Iframe $this - */ -?> -<div id="iframe-warning" class="warning-message"> - <?php echo $this->__('Please do not refresh the page until you complete payment.') ?> -</div> -<iframe id="hss-iframe" style="display:none;" scrolling="no" frameborder="0" border="0" src="<?php echo $this->getFrameActionUrl() ?>" height="610" width="100%"></iframe> -<script type="text/javascript"> -//<![CDATA[ -var headers = $$('#' + checkout.accordion.container.readAttribute('id') + ' .section'); -headers.each(function(header) { - header.removeClassName('allow'); -}); -$('hss-iframe').observe('load', function(){ - $('hss-iframe').show(); - $('iframe-warning').show(); - checkout.loadWaiting = 'review'; - checkout.setLoadWaiting(false); - if (checkout.accordion.currentSection == 'opc-review') { - $('checkout-review-submit').hide(); - } -}); -//]]> -</script> diff --git a/app/design/frontend/base/default/template/paypal/hss/info.phtml b/app/design/frontend/base/default/template/paypal/hss/info.phtml deleted file mode 100644 index ee76931be61..00000000000 --- a/app/design/frontend/base/default/template/paypal/hss/info.phtml +++ /dev/null @@ -1,18 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ - -/** - * @see Mage_Paypal_Block_Payflow_Link_Info - * @var Mage_Paypal_Block_Payflow_Link_Info $this - */ -?> -<ul id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none" class="form-list"> - <li> - <?php echo $this->__('You will be required to enter your payment details after you place an order.') ?> - </li> -</ul> diff --git a/app/design/frontend/base/default/template/paypal/hss/js.phtml b/app/design/frontend/base/default/template/paypal/hss/js.phtml deleted file mode 100644 index 7705f9ed82e..00000000000 --- a/app/design/frontend/base/default/template/paypal/hss/js.phtml +++ /dev/null @@ -1,44 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ - -/** - * @see Mage_Paypal_Block_Iframe - * @var Mage_Paypal_Block_Iframe $this - */ -?> -<div id="checkout-paypaliframe-load" class="authentication"></div> -<script type="text/javascript"> -//<![CDATA[ -Review.prototype.save = function() { - if (checkout.loadWaiting!=false) return; - checkout.setLoadWaiting('review'); - var params = Form.serialize(payment.form); - if (this.agreementsForm) { - params += '&'+Form.serialize(this.agreementsForm); - } - params.save = true; - var request = new Ajax.Request( - this.saveUrl, - { - method:'post', - parameters:params, - onComplete: function(transport) { - if (transport) { - var response = transport.responseJSON || transport.responseText.evalJSON(true) || {}; - if (response.error_messages) { - checkout.setLoadWaiting(false); - } - } - }, - onSuccess: this.onSave, - onFailure: checkout.ajaxFailure.bind(checkout) - } - ); -} -//]]> -</script> diff --git a/app/design/frontend/base/default/template/paypal/hss/redirect.phtml b/app/design/frontend/base/default/template/paypal/hss/redirect.phtml deleted file mode 100644 index 92596a21fc0..00000000000 --- a/app/design/frontend/base/default/template/paypal/hss/redirect.phtml +++ /dev/null @@ -1,45 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ - -/** - * @see Mage_Paypal_Block_Iframe - * @var Mage_Paypal_Block_Iframe $this - */ -?> -<html> -<head> -<script type="text/javascript"> -//<![CDATA[ -if (window.top == window.self) { - window.location = "<?php echo $this->getUrl('checkout/cart') ?>"; -} -<?php if ($this->getGotoSection()): ?> - for (var s = 0; s < window.top.checkout.steps.length; s++) { - if (window.top.checkout.steps[s] == '<?php echo $this->getGotoSection() ?>') { - break; - } - if (window.top.document.getElementById('opc-' + window.top.checkout.steps[s])) { - window.top.document.getElementById('opc-' + window.top.checkout.steps[s]).addClassName('allow'); - } - } - window.top.checkout.gotoSection("<?php echo $this->getGotoSection() ?>"); - window.top.document.getElementById('checkout-review-submit').show(); - window.top.document.getElementById('iframe-warning').hide(); - <?php if ($this->getErrorMsg()): ?> - alert('<?php echo Mage::helper('core')->jsQuoteEscape($this->getErrorMsg()) ?>'); - <?php endif ?> -<?php elseif ($this->getGotoSuccessPage()) : ?> - window.top.location="<?php echo $this->getUrl('checkout/onepage/success') ?>"; -<?php else: ?> - window.top.location="<?php echo $this->getUrl('checkout/cart') ?>"; -<?php endif ?> -//]]> -</script> -</head> -<body></body> -</html> diff --git a/app/design/frontend/base/default/template/paypal/hss/review/button.phtml b/app/design/frontend/base/default/template/paypal/hss/review/button.phtml deleted file mode 100644 index 0dbd301d113..00000000000 --- a/app/design/frontend/base/default/template/paypal/hss/review/button.phtml +++ /dev/null @@ -1,9 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ -?> -<button type="submit" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Continue')) ?>" class="button btn-checkout" onclick="review.save();"><span><span><?php echo $this->__('Continue') ?></span></span></button> diff --git a/app/design/frontend/base/default/template/paypal/info.phtml b/app/design/frontend/base/default/template/paypal/info.phtml new file mode 100644 index 00000000000..4c11f62fe52 --- /dev/null +++ b/app/design/frontend/base/default/template/paypal/info.phtml @@ -0,0 +1,11 @@ +<?php + +/** + * @see Mage_Paypal_Block_Info + * @var $this Mage_Paypal_Block_Info + */ +?> +<p><?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?></p> +<?php if ($this->getTransactionId()): ?> + <p><?php echo $this->__('Transaction ID: %s', $this->escapeHtml($this->getTransactionId())) ?></p> +<?php endif; ?> \ No newline at end of file diff --git a/app/design/frontend/base/default/template/paypal/partner/logo.phtml b/app/design/frontend/base/default/template/paypal/partner/logo.phtml deleted file mode 100644 index a4879e87172..00000000000 --- a/app/design/frontend/base/default/template/paypal/partner/logo.phtml +++ /dev/null @@ -1,18 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ -?> -<?php -/** - * @see Mage_Paypal_Block_Logo - * @var Mage_Paypal_Block_Logo $this - * @deprecated - */ -?> -<div class="paypal-logo"> - <a href="#" title="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('paypal')->__('Additional Options')) ?>" onclick="javascript:window.open('<?php echo $this->getAboutPaypalPageUrl() ?>','paypal','width=600,height=350,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;"><img src="<?php echo $this->escapeHtml($this->getLogoImageUrl()) ?>" alt="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('paypal')->__('Additional Options')) ?>" title="<?php echo Mage::helper('paypal')->__('Additional Options') ?>" /></a> -</div> diff --git a/app/design/frontend/base/default/template/paypal/partner/us_logo.phtml b/app/design/frontend/base/default/template/paypal/partner/us_logo.phtml deleted file mode 100644 index 4e34252be5a..00000000000 --- a/app/design/frontend/base/default/template/paypal/partner/us_logo.phtml +++ /dev/null @@ -1,18 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ -?> -<?php -/** - * @see Mage_Paypal_Block_Logo - * @var Mage_Paypal_Block_Logo $this - * @deprecated - */ -?> -<div class="paypal-logo"> - <!-- PayPal Logo --><table border="0" cellpadding="10" cellspacing="0" align="center"><tr><td align="center"></td></tr><tr><td align="center"><a href="https://www.paypal.com/webapps/mpp/paypal-popup" title="How PayPal Works" onclick="javascript:window.open('https://www.paypal.com/webapps/mpp/paypal-popup','WIPaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1060, height=700'); return false;"><img src="https://www.paypalobjects.com/webstatic/mktg/logo/bdg_now_accepting_pp_2line_w.png" border="0" alt="Now accepting PayPal"></a><div style="text-align:center"><a href="https://www.paypal.com/webapps/mpp/how-paypal-works"><font size="2" face="Arial" color="#0079CD">How PayPal Works</font></a></div></td></tr></table><!-- PayPal Logo --> -</div> diff --git a/app/design/frontend/base/default/template/paypal/payflowadvanced/iframe.phtml b/app/design/frontend/base/default/template/paypal/payflowadvanced/iframe.phtml deleted file mode 100644 index 83cb2d34ca8..00000000000 --- a/app/design/frontend/base/default/template/paypal/payflowadvanced/iframe.phtml +++ /dev/null @@ -1,31 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ -/** @var Mage_Paypal_Block_Payflow_Advanced_Iframe $this */ -?> -<div id="iframe-warning" class="warning-message"> - <?php echo $this->__('Please do not refresh the page until you complete payment.') ?> -</div> -<iframe id="payflow-advanced-iframe" style="display:none;" scrolling="no" frameborder="0" - src="<?php echo $this->getFrameActionUrl() ?>" height="610" width="100%"></iframe> -<script type="text/javascript"> -//<![CDATA[ -var headers = $$('#' + checkout.accordion.container.readAttribute('id') + ' .section'); -headers.each(function(header) { - header.removeClassName('allow'); -}); -$('payflow-advanced-iframe').observe('load', function(){ - $('payflow-advanced-iframe').show(); - $('iframe-warning').show(); - checkout.loadWaiting = 'review'; - checkout.setLoadWaiting(false); - if (checkout.accordion.currentSection == 'opc-review') { - $('checkout-review-submit').hide(); - } -}); -//]]> -</script> diff --git a/app/design/frontend/base/default/template/paypal/payflowadvanced/info.phtml b/app/design/frontend/base/default/template/paypal/payflowadvanced/info.phtml deleted file mode 100644 index 57ffac85ec6..00000000000 --- a/app/design/frontend/base/default/template/paypal/payflowadvanced/info.phtml +++ /dev/null @@ -1,17 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ - -/** - * @var Mage_Paypal_Block_Payflow_Advanced_Form $this - */ -?> -<ul id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none" class="form-list"> - <li> - <?php echo $this->__('You will be required to enter your payment details after you place an order.') ?> - </li> -</ul> diff --git a/app/design/frontend/base/default/template/paypal/payflowadvanced/redirect.phtml b/app/design/frontend/base/default/template/paypal/payflowadvanced/redirect.phtml deleted file mode 100644 index 2d1239f66ad..00000000000 --- a/app/design/frontend/base/default/template/paypal/payflowadvanced/redirect.phtml +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ - -/** - * @var Mage_Paypal_Block_Payflow_Advanced_Iframe $this - */ -?> -<html> -<head> -<script type="text/javascript"> -//<![CDATA[ - if (window.top == window.self) { - window.location = "<?php echo $this->getUrl('checkout/cart') ?>"; - } - var window_top = window.top; -<?php if ($this->getGotoSection()): ?> - var checkout_steps; - - try{ - checkout_steps = window.top.checkout.steps - }catch(e){ - window_top.location="<?php echo $this->getUrl('checkout/cart') ?>"; - } - - for (var s = 0; s < checkout_steps.length; s++) { - if (checkout_steps[s] == '<?php echo $this->getGotoSection() ?>') { - break; - } - if (window_top.document.getElementById('opc-' + checkout_steps[s])) { - window_top.document.getElementById('opc-' + checkout_steps[s]).addClassName('allow'); - } - } - window_top.checkout.gotoSection("<?php echo $this->getGotoSection() ?>"); - window_top.document.getElementById('checkout-review-submit').show(); - window_top.document.getElementById('iframe-warning').hide(); - <?php if ($this->getErrorMsg()): ?> - alert('<?php echo $this->jsQuoteEscape($this->getErrorMsg()) ?>'); - <?php endif ?> -<?php elseif ($this->getGotoSuccessPage()) : ?> - window_top.location="<?php echo $this->getUrl('checkout/onepage/success') ?>"; -<?php else: ?> - window_top.location="<?php echo $this->getUrl('checkout/cart') ?>"; -<?php endif ?> -//]]> -</script> -</head> -<body></body> -</html> diff --git a/app/design/frontend/base/default/template/paypal/payflowlink/iframe.phtml b/app/design/frontend/base/default/template/paypal/payflowlink/iframe.phtml deleted file mode 100644 index 108b1131c7f..00000000000 --- a/app/design/frontend/base/default/template/paypal/payflowlink/iframe.phtml +++ /dev/null @@ -1,31 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ -/** @var Mage_Paypal_Block_Payflow_Link_Iframe $this */ -?> -<div id="iframe-warning" class="warning-message"> - <?php echo $this->__('Please do not refresh the page until you complete payment.') ?> -</div> -<iframe id="payflow-link-iframe" style="display:none;" scrolling="no" frameborder="0" border="0" - src="<?php echo $this->getFrameActionUrl() ?>" height="610" width="100%"></iframe> -<script type="text/javascript"> -//<![CDATA[ -var headers = $$('#' + checkout.accordion.container.readAttribute('id') + ' .section'); -headers.each(function(header) { - header.removeClassName('allow'); -}); -$('payflow-link-iframe').observe('load', function(){ - $('payflow-link-iframe').show(); - $('iframe-warning').show(); - checkout.loadWaiting = 'review'; - checkout.setLoadWaiting(false); - if (checkout.accordion.currentSection == 'opc-review') { - $('checkout-review-submit').hide(); - } -}); -//]]> -</script> diff --git a/app/design/frontend/base/default/template/paypal/payflowlink/info.phtml b/app/design/frontend/base/default/template/paypal/payflowlink/info.phtml deleted file mode 100644 index 29053817150..00000000000 --- a/app/design/frontend/base/default/template/paypal/payflowlink/info.phtml +++ /dev/null @@ -1,17 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ - -/** - * @var Mage_Paypal_Block_Payflow_Link_Form $this - */ -?> -<ul id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none" class="form-list"> - <li> - <?php echo $this->__('You will be required to enter your payment details after you place an order.') ?> - </li> -</ul> diff --git a/app/design/frontend/base/default/template/paypal/payflowlink/redirect.phtml b/app/design/frontend/base/default/template/paypal/payflowlink/redirect.phtml deleted file mode 100644 index bae879c3552..00000000000 --- a/app/design/frontend/base/default/template/paypal/payflowlink/redirect.phtml +++ /dev/null @@ -1,53 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ - -/** - * @var Mage_Paypal_Block_Payflow_Link_Iframe $this - */ -?> -<html> -<head> -<script type="text/javascript"> -//<![CDATA[ - if (window.top == window.self) { - window.location = "<?php echo $this->getUrl('checkout/cart') ?>"; - } - var window_top = window.top; -<?php if ($this->getGotoSection()): ?> - var checkout_steps; - - try{ - checkout_steps = window.top.checkout.steps - }catch(e){ - window_top.location="<?php echo $this->getUrl('checkout/cart') ?>"; - } - - for (var s = 0; s < checkout_steps.length; s++) { - if (checkout_steps[s] == '<?php echo $this->getGotoSection() ?>') { - break; - } - if (window_top.document.getElementById('opc-' + checkout_steps[s])) { - window_top.document.getElementById('opc-' + checkout_steps[s]).addClassName('allow'); - } - } - window_top.checkout.gotoSection("<?php echo $this->getGotoSection() ?>"); - window_top.document.getElementById('checkout-review-submit').show(); - window_top.document.getElementById('iframe-warning').hide(); - <?php if ($this->getErrorMsg()): ?> - alert('<?php echo $this->jsQuoteEscape($this->getErrorMsg()) ?>'); - <?php endif ?> -<?php elseif ($this->getGotoSuccessPage()) : ?> - window_top.location="<?php echo $this->getUrl('checkout/onepage/success') ?>"; -<?php else: ?> - window_top.location="<?php echo $this->getUrl('checkout/cart') ?>"; -<?php endif ?> -//]]> -</script> -</head> -<body></body> -</html> diff --git a/app/design/frontend/base/default/template/paypal/payment.phtml b/app/design/frontend/base/default/template/paypal/payment.phtml new file mode 100644 index 00000000000..b2eb8115ba5 --- /dev/null +++ b/app/design/frontend/base/default/template/paypal/payment.phtml @@ -0,0 +1,29 @@ +<?php + +/** + * @var $this Mage_Paypal_Block_Form + */ +?> + +<script type="text/javascript"> + var initPayPalPayment = function() { + new PayPalPayment({ + formKey: '<?php echo $this->getFormKey(); ?>', + methodCode: '<?php echo $this->getMethodCode(); ?>', + sdkUrl: '<?php echo $this->getSdkUrl(); ?>', + buttonLayout: '<?php echo $this->getButtonConfig()['layout']; ?>', + buttonColor: '<?php echo $this->getButtonConfig()['color']; ?>', + buttonShape: '<?php echo $this->getButtonConfig()['shape']; ?>', + buttonLabel: '<?php echo $this->getButtonConfig()['label']; ?>', + buttonMessage: '<?php echo $this->getButtonConfig()['message']; ?>', + createOrderUrl: '<?php echo $this->getUrl('paypal/payment/create'); ?>', + captureUrl: '<?php echo $this->getUrl('paypal/payment/process'); ?>', + placeOrderUrl: '<?php echo $this->getUrl('paypal/payment/placeOrder'); ?>', + errorMessage: '<?php echo $this->__('An error occurred while processing your payment. Please try again.'); ?>', + containerId: 'paypal-button-container', + reviewButtonContainerId: 'review-buttons-container' + }); + }; + + initPayPalPayment(); +</script> \ No newline at end of file diff --git a/app/design/frontend/base/default/template/paypal/payment/mark.phtml b/app/design/frontend/base/default/template/paypal/payment/mark.phtml deleted file mode 100644 index 72b71d6b3ef..00000000000 --- a/app/design/frontend/base/default/template/paypal/payment/mark.phtml +++ /dev/null @@ -1,21 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ -?> -<?php -/** - * Note: This mark is a requirement of PayPal - * @see Mage_Paypal_Block_Standard_Form - * @var Mage_Paypal_Block_Standard_Form $this - */ -?> -<!-- PayPal Logo --> -<img src="<?php echo $this->escapeHtml($this->getPaymentAcceptanceMarkSrc())?>" alt="<?php echo Mage::helper('core')->quoteEscape(Mage::helper('paypal')->__('Acceptance Mark')) ?>" class="v-middle" />  -<a href="<?php echo $this->getPaymentAcceptanceMarkHref()?>" onclick="javascript:window.open('<?php echo $this->getPaymentAcceptanceMarkHref()?>','olcwhatispaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, ,left=0, top=0, width=400, height=350'); return false;"> - <?php if($this->getPaymentWhatIs()) {echo Mage::helper('paypal')->__($this->getPaymentWhatIs());} else {echo Mage::helper('paypal')->__('What is PayPal?');} ?> -</a> -<!-- PayPal Logo --> diff --git a/app/design/frontend/base/default/template/paypal/payment/redirect.phtml b/app/design/frontend/base/default/template/paypal/payment/redirect.phtml deleted file mode 100644 index 6177e2dc22a..00000000000 --- a/app/design/frontend/base/default/template/paypal/payment/redirect.phtml +++ /dev/null @@ -1,24 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package base_default - */ -?> -<?php -/** - * @see Mage_PayPal_Block_Express_Form - * @see Mage_PayPal_Block_Standard_Form - * @var Mage_PayPal_Block_Express_Form $this - */ -?> -<ul class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;"> - <li class="form-alt"><?php echo $this->getRedirectMessage() ?></li> - <?php if ($code = $this->getCreateBACode()): ?> - <li class="form-alt"> - <label for="<?php echo $code ?>"><input type="checkbox" id="<?php echo $code ?>" value="1" name="payment[<?php echo $code ?>]" class="checkbox" /> - <?php echo $this->__('Sign a billing agreement to streamline further purchases with PayPal.') ?></label> - </li> - <?php endif ?> -</ul> diff --git a/app/design/frontend/rwd/default/layout/bundle.xml b/app/design/frontend/rwd/default/layout/bundle.xml index 1ecc7cdd3bf..bf9302e05c3 100644 --- a/app/design/frontend/rwd/default/layout/bundle.xml +++ b/app/design/frontend/rwd/default/layout/bundle.xml @@ -155,27 +155,6 @@ Onepage Checkout Review Page </reference> </checkout_multishipping_overview> - <paypal_express_review> - <reference name="paypal.express.review.details"> - <action method="addItemRender"><type>bundle</type><block>bundle/checkout_cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action> - </reference> - </paypal_express_review> - <paypal_express_review_details> - <reference name="root"> - <action method="addItemRender"><type>bundle</type><block>bundle/checkout_cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action> - </reference> - </paypal_express_review_details> - - <paypaluk_express_review> - <reference name="paypal.express.review.details"> - <action method="addItemRender"><type>bundle</type><block>bundle/checkout_cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action> - </reference> - </paypaluk_express_review> - <paypaluk_express_review_details> - <reference name="root"> - <action method="addItemRender"><type>bundle</type><block>bundle/checkout_cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action> - </reference> - </paypaluk_express_review_details> <!-- Additional block for bundle product type diff --git a/app/design/frontend/rwd/default/layout/downloadable.xml b/app/design/frontend/rwd/default/layout/downloadable.xml index 4b21f62e5b0..5c1365e3faf 100644 --- a/app/design/frontend/rwd/default/layout/downloadable.xml +++ b/app/design/frontend/rwd/default/layout/downloadable.xml @@ -69,27 +69,6 @@ </reference> </checkout_multishipping_success> - <paypal_express_review> - <reference name="paypal.express.review.details"> - <action method="addItemRender"><type>downloadable</type><block>downloadable/checkout_cart_item_renderer</block><template>downloadable/checkout/onepage/review/item.phtml</template></action> - </reference> - </paypal_express_review> - <paypal_express_review_details> - <reference name="root"> - <action method="addItemRender"><type>downloadable</type><block>downloadable/checkout_cart_item_renderer</block><template>downloadable/checkout/onepage/review/item.phtml</template></action> - </reference> - </paypal_express_review_details> - - <paypaluk_express_review> - <reference name="paypal.express.review.details"> - <action method="addItemRender"><type>downloadable</type><block>downloadable/checkout_cart_item_renderer</block><template>downloadable/checkout/onepage/review/item.phtml</template></action> - </reference> - </paypaluk_express_review> - <paypaluk_express_review_details> - <reference name="root"> - <action method="addItemRender"><type>downloadable</type><block>downloadable/checkout_cart_item_renderer</block><template>downloadable/checkout/onepage/review/item.phtml</template></action> - </reference> - </paypaluk_express_review_details> <sales_order_view> <reference name="order_items"> diff --git a/app/design/frontend/rwd/default/layout/paypal.xml b/app/design/frontend/rwd/default/layout/paypal.xml deleted file mode 100644 index b937ca4357f..00000000000 --- a/app/design/frontend/rwd/default/layout/paypal.xml +++ /dev/null @@ -1,170 +0,0 @@ -<?xml version="1.0"?> -<!-- -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package rwd_default - */ - ---> -<layout version="0.1.0"> - <checkout_cart_index> - <reference name="checkout.cart.top_methods"> - <block type="paypal/express_shortcut" name="checkout.cart.methods.paypal_express.top" before="checkout.cart.methods.onepage.top" template="paypal/express/shortcut.phtml"> - <action method="setIsQuoteAllowed"><value>1</value></action> - <action method="setShowOrPosition"><value>after</value></action> - </block> - </reference> - - <reference name="checkout.cart.methods"> - <block type="paypal/express_shortcut" name="checkout.cart.methods.paypal_express.bottom" before="checkout.cart.methods.onepage.bottom" template="paypal/express/shortcut.phtml"> - <action method="setIsQuoteAllowed"><value>1</value></action> - <action method="setShowOrPosition"><value>after</value></action> - </block> - </reference> - - <update handle="SHORTCUT_popup" /> - </checkout_cart_index> - - <paypal_express_review translate="label"> - <label>PayPal Express Order Review Form</label> - <remove name="right"/> - <remove name="left"/> - - <reference name="root"> - <action method="setTemplate"><template>page/1column.phtml</template></action> - </reference> - <reference name="content"> - <block type="paypal/express_review" name="paypal.express.review" template="paypal/express/review.phtml"> - <block type="paypal/express_review" name="express.review.shipping.method" as="shipping_method" template="paypal/express/review/shipping/method.phtml"/> - <block type="paypal/express_review_details" name="paypal.express.review.details" as="details" template="paypal/express/review/details.phtml"> - <action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action> - <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action> - <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action> - <block type="checkout/cart_totals" name="paypal.express.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/> - </block> - <block type="checkout/agreements" name="paypal.express.review.details.agreements" as="agreements" template="checkout/onepage/agreements.phtml"/> - </block> - </reference> - <reference name="head"> - <action method="addItem"><type>skin_js</type><name>js/checkout/review.js</name></action> - </reference> - <block type="core/text_list" name="additional.product.info" /> - </paypal_express_review> - - <paypal_express_review_details> - <block type="paypal/express_review_details" name="root" output="toHtml" template="paypal/express/review/details.phtml"> - <action method="addItemRender"><type>default</type><block>checkout/cart_item_renderer</block><template>checkout/onepage/review/item.phtml</template></action> - <action method="addItemRender"><type>grouped</type><block>checkout/cart_item_renderer_grouped</block><template>checkout/onepage/review/item.phtml</template></action> - <action method="addItemRender"><type>configurable</type><block>checkout/cart_item_renderer_configurable</block><template>checkout/onepage/review/item.phtml</template></action> - <block type="checkout/cart_totals" name="paypal.express.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/> - </block> - </paypal_express_review_details> - -<!-- -Available logo types can be assigned with action="setLogoType": - - wePrefer_150x60 - - wePrefer_150x40 - - nowAccepting_150x60 - - nowAccepting_150x40 - - paymentsBy_150x60 - - paymentsBy_150x40 - - shopNowUsing_150x60 - - shopNowUsing_150x40 ---> - <catalog_product_view> - <reference name="product.info.addtocart"> - <block type="page/html_wrapper" name="product.info.addtocart.paypal.wrapper" translate="label"> - <action method="setMayBeInvisible"><value>true</value></action> - <label>PayPal Express Checkout Shortcut Wrapper</label> - <block type="paypal/express_shortcut" name="product.info.addtocart.paypal" template="paypal/express/product/shortcut.phtml"> - <action method="setIsInCatalogProduct"><value>1</value></action> - </block> - </block> - </reference> - <update handle="SHORTCUT_popup" /> - </catalog_product_view> - - <catalog_category_default> - <update handle="SHORTCUT_popup" /> - </catalog_category_default> - - <catalog_category_layered> - <update handle="SHORTCUT_popup" /> - </catalog_category_layered> - - <catalog_product_compare_index> - <update handle="SHORTCUT_popup" /> - </catalog_product_compare_index> - - <catalogsearch_result_index> - <update handle="SHORTCUT_popup" /> - </catalogsearch_result_index> - - <catalogsearch_advanced_result> - <update handle="SHORTCUT_popup" /> - </catalogsearch_advanced_result> - - <tag_product_list> - <update handle="SHORTCUT_popup" /> - </tag_product_list> - <tag_customer_view> - <update handle="SHORTCUT_popup" /> - </tag_customer_view> - - <wishlist_index_index> - <update handle="SHORTCUT_popup" /> - </wishlist_index_index> - <review_product_list> - <update handle="SHORTCUT_popup" /> - </review_product_list> - - <checkout_onepage_success> - <update handle="SHORTCUT_popup" /> - </checkout_onepage_success> - <checkout_onepage_failure> - <update handle="SHORTCUT_popup" /> - </checkout_onepage_failure> - - <default> - <reference name="topCart.extra_actions"> - <block type="paypal/express_shortcut" name="paypal.partner.top_cart.shortcut" template="paypal/express/shortcut.phtml"/> - </reference> - <reference name="cart_sidebar.extra_actions"> - <block type="paypal/express_shortcut" name="paypal.partner.cart_sidebar.shortcut" template="paypal/express/minicart/shortcut.phtml"/> - </reference> - </default> - - <checkout_onepage_review> - <reference name="checkout.onepage.review.info.items.after"> - <block type="paypal/iframe" name="paypal.iframe" /> - </reference> - <reference name="checkout.onepage.review.button"> - <action method="setTemplate"><template helper="paypal/hss/getReviewButtonTemplate"><name>paypal/hss/review/button.phtml</name><block>checkout.onepage.review.button</block></template></action> - </reference> - </checkout_onepage_review> - - <paypal_payflow_link_iframe> - <block type="paypal/payflow_link_iframe" name="payflow.link.iframe" template="paypal/payflowlink/form.phtml" /> - </paypal_payflow_link_iframe> - - <paypal_payflow_advanced_iframe> - <block type="paypal/payflow_advanced_iframe" name="payflow.advanced.iframe" template="paypal/payflowadvanced/form.phtml" /> - </paypal_payflow_advanced_iframe> - - <paypal_hosted_pro_iframe> - <block type="paypal/hosted_pro_iframe" name="hosted.pro.iframe" template="paypal/hss/form.phtml"/> - </paypal_hosted_pro_iframe> - - <SHORTCUT_popup> - <reference name="product.tooltip"> - <block type="page/html_wrapper" name="product.info.addtocart.paypal.wrapper" translate="label"> - <block type="paypal/express_shortcut" name="product.info.addtocart.paypal" template="paypal/express/shortcut.phtml"> - <action method="setIsInCatalogProduct"><value>1</value></action> - <action method="setShowOrPosition"><value>after</value></action> - </block> - </block> - </reference> - </SHORTCUT_popup> -</layout> diff --git a/app/design/frontend/rwd/default/layout/review.xml b/app/design/frontend/rwd/default/layout/review.xml index 7823f4e9cae..41302a67676 100644 --- a/app/design/frontend/rwd/default/layout/review.xml +++ b/app/design/frontend/rwd/default/layout/review.xml @@ -75,15 +75,7 @@ Product reviews page <action method="disableGallery"/> </block> <block type="catalog/product_view" name="product.info.addto" as="addto" template="catalog/product/view/addto.phtml"/> - <block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml"> - <!-- workaround: a better place for this code is in paypal.xml --> - <block type="page/html_wrapper" name="review.product.info.addtocart.paypal.wrapper" translate="label" module="paypal"> - <label>PayPal Express Checkout Shortcut Wrapper</label> - <block type="paypal/express_shortcut" name="review.product.info.addtocart.paypal" template="paypal/express/product/shortcut.phtml"> - <action method="setIsInCatalogProduct"><value>1</value></action> - </block> - </block> - </block> + <block type="catalog/product_view" name="product.info.addtocart" as="addtocart" template="catalog/product/view/addtocart.phtml"/> <block type="catalog/product_view" name="product.tierprices" as="tierprices" template="catalog/product/view/tierprices.phtml"/> <block type="core/template" name="product.info.other" as="other" template="review/product/view/other.phtml"/> <block type="page/html_pager" name="product_review_list.toolbar" /> diff --git a/app/design/frontend/rwd/default/template/paypal/bml.phtml b/app/design/frontend/rwd/default/template/paypal/bml.phtml deleted file mode 100644 index da93af4cfe1..00000000000 --- a/app/design/frontend/rwd/default/template/paypal/bml.phtml +++ /dev/null @@ -1,32 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package rwd_default - */ -?> -<?php -/** - * @see Mage_Paypal_Block_Bml_Banners - * @var Mage_Paypal_Block_Bml_Banners $this - */ -?> -<div class="bml-ad large"> -<script type="text/javascript" data-pp-pubid="<?php echo $this->escapeHtml($this->getPublisherId()) ?>" data-pp-placementtype="<?php echo $this->escapeHtml($this->getSize()) ?>"> (function (d, t) { - "use strict"; - var s = d.getElementsByTagName(t)[0], n = d.createElement(t); - n.src = "//paypal.adtag.where.com/merchant.js"; - s.parentNode.insertBefore(n, s); -}(document, "script")); -</script> -</div> -<div class="bml-ad small"> - <script type="text/javascript" data-pp-pubid="<?php echo $this->escapeHtml($this->getPublisherId()) ?>" data-pp-placementtype="300x50"> (function (d, t) { - "use strict"; - var s = d.getElementsByTagName(t)[0], n = d.createElement(t); - n.src = "//paypal.adtag.where.com/merchant.js"; - s.parentNode.insertBefore(n, s); - }(document, "script")); - </script> -</div> diff --git a/app/design/frontend/rwd/default/template/paypal/express/minicart/shortcut.phtml b/app/design/frontend/rwd/default/template/paypal/express/minicart/shortcut.phtml deleted file mode 100644 index 27c1e2ed9d4..00000000000 --- a/app/design/frontend/rwd/default/template/paypal/express/minicart/shortcut.phtml +++ /dev/null @@ -1,55 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package rwd_default - */ -?> -<?php -/** - * @var Mage_Paypal_Block_Express_Shortcut $this - */ -?> -<li> - <p class="paypal-logo"> - <?php $shortcutHtmlId = $this->getShortcutHtmlId() ?> - <?php $bmlShortcutHtmlId = $this->getBmlShortcutHtmlId() ?> - <a class="paypal-button" data-action="checkout-form-submit" id="<?php echo $shortcutHtmlId ?>" href="<?php echo $this->getCheckoutUrl()?>"><img src="<?php echo $this->getImageUrl()?>" alt="<?php echo $this->quoteEscape(Mage::helper('paypal')->__('Checkout with PayPal')); ?>" title="<?php echo $this->quoteEscape(Mage::helper('paypal')->__('Checkout with PayPal')); ?>" /></a> - - <span class="paypal-or"><?php echo $this->__('-OR-');?></span> - </p> -</li> -<?php if ($this->getIsBmlEnabled()): ?> -<li class="bml-checkout-type"> - <p class="paypal-logo"> - <span class="bml_button"> - <a id="<?php echo $bmlShortcutHtmlId ?>" href="<?php echo $this->getBmlCheckoutUrl()?>"><img src="<?php echo $this->getBmlImageUrl()?>" alt="<?php echo $this->quoteEscape(Mage::helper('paypal')->__('Checkout with PayPal Paypal Credit')); ?>" title="<?php echo $this->quoteEscape(Mage::helper('paypal')->__('Checkout with PayPal Paypal Credit')); ?>" /></a> - <a href="<?php echo $this->getMarketMessageUrl()?>"><img src="<?php echo $this->getMarketMessage()?>" /></a> - </span> - <span class="paypal-or"><?php echo $this->__('-OR-');?></span> - </p> -</li> -<?php endif ?> - -<?php if ($this->getConfirmationUrl() || $this->getIsInCatalogProduct()): ?> - <?php if ($this->getIsInCatalogProduct()): ?> - <input type="hidden" id="pp_checkout_url" name="return_url" value="" /> - <?php endif ?> - <script type="text/javascript"> - //<![CDATA[ - $$('#<?php echo $shortcutHtmlId ?>','#<?php echo $bmlShortcutHtmlId ?>').invoke('observe', 'click', function(event) { - <?php if ($this->getConfirmationUrl()): ?> - if (confirm('<?php echo Mage::helper('core')->jsQuoteEscape($this->getConfirmationMessage())?>')) { - this.href = '<?php echo $this->getConfirmationUrl() ?>'; - } - <?php endif ?> - <?php if ($this->getIsInCatalogProduct()): ?> - $('pp_checkout_url').value = this.href; - productAddToCartForm.submit(this); - event.stop(); - <?php endif ?> - }); - //]]> - </script> -<?php endif ?> diff --git a/app/design/frontend/rwd/default/template/paypal/express/product/shortcut.phtml b/app/design/frontend/rwd/default/template/paypal/express/product/shortcut.phtml deleted file mode 100644 index f063c914d46..00000000000 --- a/app/design/frontend/rwd/default/template/paypal/express/product/shortcut.phtml +++ /dev/null @@ -1,51 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package rwd_default - */ -?> -<?php -/** - * @var Mage_Paypal_Block_Express_Shortcut $this - */ -?> -<p class="paypal-logo<?php if (!$this->getIsBmlEnabled()): ?> no-bml<?php endif ?>"> - <span class="paypal-or"><?php echo $this->__('-OR-');?></span> - - <?php $shortcutHtmlId = $this->getShortcutHtmlId() ?> - <?php $bmlShortcutHtmlId = $this->getBmlShortcutHtmlId() ?> - <a class="paypal-button" data-action="checkout-form-submit" id="<?php echo $shortcutHtmlId ?>" href="<?php echo $this->getCheckoutUrl()?>"><img src="<?php echo $this->getImageUrl()?>" alt="<?php echo $this->quoteEscape(Mage::helper('paypal')->__('Checkout with PayPal')); ?>" title="<?php echo $this->quoteEscape(Mage::helper('paypal')->__('Checkout with PayPal')); ?>" /></a> -</p> -<?php if ($this->getIsBmlEnabled()): ?> -<p class="paypal-logo"> - <span class="paypal-or"><?php echo $this->__('-OR-');?></span> - <span class="bml_button"> - <a id="<?php echo $bmlShortcutHtmlId ?>" href="<?php echo $this->getBmlCheckoutUrl()?>"><img src="<?php echo $this->getBmlImageUrl()?>" alt="<?php echo $this->quoteEscape(Mage::helper('paypal')->__('Checkout with PayPal Paypal Credit')); ?>" title="<?php echo $this->quoteEscape(Mage::helper('paypal')->__('Checkout with PayPal Paypal Credit')); ?>" /></a> - <a href="<?php echo $this->getMarketMessageUrl()?>"><img src="<?php echo $this->getMarketMessage()?>" /></a> - </span> -</p> -<?php endif ?> - -<?php if ($this->getConfirmationUrl() || $this->getIsInCatalogProduct()): ?> - <?php if ($this->getIsInCatalogProduct()): ?> - <input type="hidden" id="pp_checkout_url" name="return_url" value="" /> - <?php endif ?> - <script type="text/javascript"> - //<![CDATA[ - $$('#<?php echo $shortcutHtmlId ?>','#<?php echo $bmlShortcutHtmlId ?>').invoke('observe', 'click', function(event) { - <?php if ($this->getConfirmationUrl()): ?> - if (confirm('<?php echo Mage::helper('core')->jsQuoteEscape($this->getConfirmationMessage())?>')) { - this.href = '<?php echo $this->getConfirmationUrl() ?>'; - } - <?php endif ?> - <?php if ($this->getIsInCatalogProduct()): ?> - $('pp_checkout_url').value = this.href; - productAddToCartForm.submit(this); - event.stop(); - <?php endif ?> - }); - //]]> - </script> -<?php endif ?> diff --git a/app/design/frontend/rwd/default/template/paypal/express/review.phtml b/app/design/frontend/rwd/default/template/paypal/express/review.phtml deleted file mode 100644 index 1295803b394..00000000000 --- a/app/design/frontend/rwd/default/template/paypal/express/review.phtml +++ /dev/null @@ -1,159 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package rwd_default - */ -/** @var Mage_Paypal_Block_Express_Review $this */ -?> -<div class="page-title"> - <h1><?php echo $this->__('Review Order') ?></h1> -</div> -<?php echo $this->getMessagesBlock()->toHtml() ?> -<?php if ($this->getShippingAddress()): ?> - <div class="info-set col2-set"> - <h2 class="legend"><?php echo $this->__('Shipping Information') ?></h2> - <div class="col-1"> - <div class="box"> - <div class="box-title"> - <h3><?php echo $this->__('Shipping Address') ?><span class="separator"><?php if ($this->getCanEditShippingAddress()):?> | </span><a href="<?php echo $this->getEditUrl() ?>"><?php echo $this->__('Edit') ?></a><?php endif ?></h3> - </div> - <div class="box-content"> - <address><?php echo $this->renderAddress($this->getShippingAddress())?></address> - </div> - </div> - </div> - <div class="col-2"> - <div class="box"> - <div class="box-title"> - <h3><?php echo $this->__('Shipping Method') ?></h3> - </div> - <div class="box-content"> - <form method="post" id="shipping_method_form" action="<?php echo $this->escapeHtml($this->getShippingMethodSubmitUrl()) ?>"> - <?php if ($this->getCanEditShippingMethod() || !$this->getCurrentShippingRate()):?> - <?php if ($groups = $this->getShippingRateGroups()):?> - <?php $currentRate = $this->getCurrentShippingRate(); ?> - <fieldset> - <select name="shipping_method" id="shipping_method" style="width:250px;" class="required-entry"> - <?php if (!$currentRate):?> - <option value=""><?php echo $this->__('Please select a shipping method...') ?></option> - <?php endif ?> - <?php foreach ($groups as $code => $rates):?> - <optgroup label="<?php echo $this->escapeHtml($this->getCarrierName($code)) ?>" style="font-style:normal;"> - <?php foreach ($rates as $rate):?> - <option value="<?php echo $this->renderShippingRateValue($rate)?>"<?php echo ($currentRate === $rate) ? ' selected="selected"' : '' ;?>> - <?php echo $this->renderShippingRateOption($rate)?> - </option> - <?php endforeach ?> - </optgroup> - <?php endforeach ?> - </select> - </fieldset> - <p class="actions"> - <button id="update_shipping_method_submit" type="submit" class="button"><span><span><?php echo $this->__('Update Shipping Method') ?></span></span></button> - </p> - <?php else: ?> - <p><strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong></p> - <?php endif ?> - <?php else: ?> - <p><strong><?php echo $this->renderShippingRateOption($this->getCurrentShippingRate())?></strong></p> - <?php endif ?> - </form> - </div> - </div> - </div> - </div> -<?php endif ?> - -<div class="info-set col2-set"> - <h2 class="legend"><?php echo $this->__('Billing Information') ?></h2> - <div class="col-1"> - <div class="box"> - <div class="box-title"> - <h3><?php echo $this->__('Payment Method') ?> <span class="separator">|</span> - <?php if($this->getEditUrl()):?><a href="<?php echo $this->getEditUrl() ?>"><?php echo $this->__('Edit Payment Information') ?></a> <?php endif ?> - </h3> - </div> - <div class="box-content"> - <?php echo $this->escapeHtml($this->getPaymentMethodTitle()) ?> - </div> - </div> - </div> -</div> - -<div class="info-set"> - <h2 class="legend"><?php echo $this->__('Items in Your Shopping Cart') ?><span class="separator"> | </span><a href="<?php echo $this->getUrl('checkout/cart') ?>"><?php echo $this->__('Edit Shopping Cart') ?></a></h2> - <div id="details-reload"> - <?php echo $this->getChildHtml('details') ?> - </div> -</div> -<form method="post" id="order_review_form" action="<?php echo $this->getPlaceOrderUrl() ?>"> - <?php echo $this->getChildHtml('agreements'); ?> - <div class="buttons-set buttons-set-order" id="review-buttons-container"> - <button type="button" id="review_button" value="<?php echo $this->__('Place Order') ?>" class="button btn-checkout"><span><span><?php echo $this->__('Place Order') ?></span></span></button> - <button type="button" id="review_submit" value="<?php echo $this->__('Place Order') ?>" class="button btn-checkout"><span><span><?php echo $this->__('Place Order') ?></span></span></button> - <span class="please-wait" id="review-please-wait" style="display:none;"> - <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->quoteEscape($this->__('Submitting order information...')) ?>" title="<?php echo $this->quoteEscape($this->__('Submitting order information...')) ?>" class="v-middle" /> <?php echo $this->__('Submitting order information...') ?> - </span> - </div> -</form> -<script type="text/javascript"> - //<![CDATA[ - // submit buttons are not needed when submitting with ajax - $('review_submit').hide(); - if ($('update_shipping_method_submit')) { - $('update_shipping_method_submit').hide(); - } - - <?php if ($this->getUseAjax()):?> - OrderReviewController.prototype._submitOrder = function() { - if (this._canSubmitOrder) { - if (this._pleaseWait) { - this._pleaseWait.show(); - } - new Ajax.Request(this.form.action, { - parameters: {isAjax: 1, method: 'POST'}, - onSuccess: function(transport) { - try{ - response = eval('(' + transport.responseText + ')'); - } catch (e) { - response = {}; - } - if (response.redirect) { - setLocation(response.redirect); - return; - } - if (response.success) { - setLocation('<?php echo $this->getSuccessUrl()?>'); - return; - } else { - var msg = response.error_messages; - if (typeof(msg)=='object') { - msg = msg.join("\n"); - } - if (msg) { - $('review-please-wait').hide(); - alert(msg); - return; - } - } - $('review-please-wait').hide(); - alert('<?php echo $this->jsQuoteEscape($this->__('Unknown Error. Please try again later.')); ?>'); - return; - }, - onFailure: function(){ - alert('<?php echo $this->jsQuoteEscape($this->__('Server Error. Please try again.')) ?>'); - $('review-please-wait').hide(); - } - }); - } - } - <?php endif ?> - - PayPalExpressAjax = new OrderReviewController($('order_review_form'), $('review_button'), - $('shipping_method'), $('shipping_method_form'), 'details-reload' - ); - PayPalExpressAjax.addPleaseWait($('review-please-wait')); - //]]> -</script> diff --git a/app/design/frontend/rwd/default/template/paypal/express/review/address.phtml b/app/design/frontend/rwd/default/template/paypal/express/review/address.phtml deleted file mode 100644 index 4cb25e82ad2..00000000000 --- a/app/design/frontend/rwd/default/template/paypal/express/review/address.phtml +++ /dev/null @@ -1,173 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package rwd_default - */ -?> -<?php $prefix = $this->getFieldNamePrefix();?> -<div class="fieldset"> - <ul class="form-list form-list-narrow"> - <li id="<?php echo $prefix ?>-address-form" class="address-form"> - <div class="fieldset"> - <input type="hidden" name="<?php echo $prefix ?>[address_id]" value="<?php echo $this->getAddress()->getId() ?>" id="<?php echo $prefix ?>:address_id" /> - <ul> - <li class="fields"><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat($prefix . ':%s')->setFieldNameFormat($prefix . '[%s]')->toHtml() ?></li> - <li class="fields"> - <div class="field"> - <label for="<?php echo $prefix ?>:company"><?php echo $this->__('Company') ?></label> - <div class="input-box"> - <input type="text" id="<?php echo $prefix ?>:company" name="<?php echo $prefix ?>[company]" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Company')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" /> - </div> - </div> - <?php if(!$this->isCustomerLoggedIn() && !$this->getHideEmailAddress()): ?> - <div class="field"> - <label for="<?php echo $prefix ?>:email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label> - <div class="input-box"> - <input type="email" autocapitalize="off" autocorrect="off" spellcheck="false" name="<?php echo $prefix ?>[email]" id="<?php echo $prefix ?>:email" value="<?php echo $this->escapeHtml($this->getAddress()->getEmail()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Email Address')) ?>" class="input-text validate-email required-entry" /> - </div> - </div> - <?php endif ?> - </li> - <?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?> - <li class="fields"> - <div class="field"> - <label for="<?php echo $prefix ?>:street1" class="required"><em>*</em><?php echo $this->__('Address') ?></label> - <div class="input-box"> - <input type="text" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address')) ?>" name="<?php echo $prefix ?>[street][]" id="<?php echo $prefix ?>:street1" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>" class="input-text <?php echo $_streetValidationClass ?>" /> - </div> - </div> - </li> - <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?> - <?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?> - <li class="fields"> - <div class="field"> - <label for="billing:street<?php echo $_i ?>"><?php echo $this->__('Street Address %s', $_i) ?></label> - <div class="input-box"> - <input type="text" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Street Address %s', $_i)) ?>" name="<?php echo $prefix ?>[street][]" id="<?php echo $prefix ?>:street<?php echo $_i?>" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>" class="input-text <?php echo $_streetValidationClass ?>" /> - </div> - </div> - </li> - <?php endfor ?> - <?php if ($this->helper('customer/address')->isVatAttributeVisible()) : ?> - <li class="fields"> - <div class="field"> - <label for="<?php echo $prefix ?>:vat_id"><?php echo $this->__('VAT Number') ?></label> - <div class="input-box"> - <input type="text" id="<?php echo $prefix ?>:vat_id" name="<?php echo $prefix ?>[vat_id]" value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('VAT Number')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('vat_id') ?>" /> - </div> - </div> - </li> - <?php endif ?> - <li class="fields"> - <div class="field"> - <label for="<?php echo $prefix ?>:city" class="required"><em>*</em><?php echo $this->__('City') ?></label> - <div class="input-box"> - <input type="text" title="<?php echo Mage::helper('core')->quoteEscape($this->__('City')) ?>" name="<?php echo $prefix ?>[city]" value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="<?php echo $prefix ?>:city" /> - </div> - </div> - <div class="field"> - <label for="<?php echo $prefix ?>:region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label> - <div class="input-box"> - <select id="<?php echo $prefix ?>:region_id" name="<?php echo $prefix ?>[region_id]" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" class="validate-select" style="display:none;"> - <option value=""><?php echo $this->__('Please select region, state or province') ?></option> - </select> - <script type="text/javascript"> - //<![CDATA[ - $('<?php echo $prefix ?>:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>"); - //]]> - </script> - <input type="text" id="<?php echo $prefix ?>:region" name="<?php echo $prefix ?>[region]" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('State/Province')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" /> - </div> - </div> - </li> - <li class="fields"> - <div class="field"> - <label for="<?php echo $prefix ?>:postcode" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label> - <div class="input-box"> - <input type="text" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Zip/Postal Code')) ?>" name="<?php echo $prefix ?>[postcode]" id="<?php echo $prefix ?>:postcode" value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" /> - </div> - </div> - <div class="field"> - <label for="<?php echo $prefix ?>:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label> - <div class="input-box"> - <?php echo $this->getCountryHtmlSelect($prefix) ?> - </div> - </div> - </li> - <li class="fields"> - <div class="field"> - <label for="<?php echo $prefix ?>:telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label> - <div class="input-box"> - <input type="tel" name="<?php echo $prefix ?>[telephone]" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Telephone')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="<?php echo $prefix ?>:telephone" /> - </div> - </div> - <div class="field"> - <label for="<?php echo $prefix ?>:fax"><?php echo $this->__('Fax') ?></label> - <div class="input-box"> - <input type="tel" name="<?php echo $prefix ?>[fax]" value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Fax')) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('fax') ?>" id="<?php echo $prefix ?>:fax" /> - </div> - </div> - </li> - <?php echo $this->getChildHtml('form.additional.info'); ?> - <?php if ($this->getShowAsShippingCheckbox()): ?> - <li class="control"> - <div class="field"> - <div class="input-box"> - <input type="checkbox" name="<?php echo $prefix ?>[as_shipping]" class="checkbox" value="1" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Same as shipping')) ?>" id="<?php echo $prefix ?>:as_shipping" <?php if ($this->getAddress()->getSameAsBilling()):?>checked="checked"<?php endif ?>/> - </div> - <label for="<?php echo $prefix ?>:as_shipping"><?php echo $this->__('Same as shipping') ?></label> - </div> - </li> - <?php endif ?> - </ul> - </div> - </li> - </ul> -</div> -<script type="text/javascript"> -//<![CDATA[ - var <?php echo $prefix ?>RegionUpdater = new RegionUpdater('<?php echo $prefix ?>:country_id', '<?php echo $prefix ?>:region', '<?php echo $prefix ?>:region_id', <?php echo Mage::helper('directory')->getRegionJsonByStore() ?>, undefined, '<?php echo $prefix ?>:postcode'); - <?php echo $prefix ?>RegionUpdater.update(); -//]]> -</script> -<?php if ($this->getShowAsShippingCheckbox()): ?> -<script type="text/javascript"> - //<![CDATA[ - OrderReviewController.prototype._copyShippingToBilling_parent = OrderReviewController.prototype._copyShippingToBilling; - OrderReviewController.prototype._copyShippingToBilling = function (event) { - this._copyShippingToBilling_parent(event); - - if (!this._copyElement) { - return; - } - - if (this._copyElement.checked) { - if (this.copyShippingToBilling_allowScrollTo && Modernizr.mq && Modernizr.mq("only screen and (max-width: 767px)")) { - $('shipping-address').scrollTo(); - } - } else { - $$('[id^="billing:"]').each(function (el) { - if ($(el).up('.field')) { - $(el).up('.field').removeClassName('inactive'); - } - }) - } - } - - OrderReviewController.prototype._copyElementValue_parent = OrderReviewController.prototype._copyElementValue; - OrderReviewController.prototype._copyElementValue = function (el) { - <?php // Note: We cannot call this._copyElementValue_parent because review.js is using each() to iterate without giving it context ?> - OrderReviewController.prototype._copyElementValue_parent(el); - - var newId = el.id.replace('shipping:','billing:'); - if (newId && $(newId) && $(newId).type != 'hidden') { - if ($(newId).up('.field')) { - $(newId).up('.field').addClassName('inactive'); - } - } - } - //]]> -</script> -<?php endif ?> diff --git a/app/design/frontend/rwd/default/template/paypal/express/review/details.phtml b/app/design/frontend/rwd/default/template/paypal/express/review/details.phtml deleted file mode 100644 index f832b3316e3..00000000000 --- a/app/design/frontend/rwd/default/template/paypal/express/review/details.phtml +++ /dev/null @@ -1,47 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package rwd_default - */ - -/** - * @see Mage_Paypal_Block_Express_Review_Details - * @var Mage_Paypal_Block_Express_Review_Details $this - */ -?> -<table id="details-table" class="data-table linearize-table"> - <?php if ($this->helper('tax')->displayCartBothPrices()): $colspan = $rowspan = 2; else: $colspan = $rowspan = 1; endif; ?> - <col /> - <col width="1" /> - <col width="1" /> - <col width="1" /> - <?php if ($this->helper('tax')->displayCartBothPrices()): ?> - <col width="1" /> - <col width="1" /> - <?php endif ?> - <thead> - <tr> - <th rowspan="<?php echo $rowspan ?>"><?php echo $this->__('Product') ?></th> - <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Price') ?></th> - <th rowspan="<?php echo $rowspan ?>" class="a-center"><?php echo $this->__('Qty') ?></th> - <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Subtotal') ?></th> - </tr> - <?php if ($this->helper('tax')->displayCartBothPrices()): ?> - <tr> - <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th> - <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th> - <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th> - <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th> - </tr> - <?php endif ?> - </thead> -<?php echo $this->getChildHtml('totals'); ?> - <tbody> - <?php foreach($this->getItems() as $_item): ?> - <?php echo $this->getItemHtml($_item) ?> - <?php endforeach ?> - </tbody> -</table> -<script type="text/javascript">decorateTable('details-table');</script> diff --git a/app/design/frontend/rwd/default/template/paypal/express/review/shipping/method.phtml b/app/design/frontend/rwd/default/template/paypal/express/review/shipping/method.phtml deleted file mode 100644 index c90e1ea45ae..00000000000 --- a/app/design/frontend/rwd/default/template/paypal/express/review/shipping/method.phtml +++ /dev/null @@ -1,35 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package rwd_default - */ -/** @var Mage_Paypal_Block_Express_Review $this */ -?> -<div class="fieldset" id="shipping-method-container"> -<?php if ($this->getCanEditShippingMethod() || !$this->getCurrentShippingRate()):?> - <?php if ($groups = $this->getShippingRateGroups()):?> - <?php $currentRate = $this->getCurrentShippingRate(); ?> - <select name="shipping_method" id="shipping_method" style="width:250px;" class="required-entry"> - <?php if (!$currentRate):?> - <option value=""><?php echo $this->__('Please select a shipping method...') ?></option> - <?php endif ?> - <?php foreach ($groups as $code => $rates):?> - <optgroup label="<?php echo $this->escapeHtml($this->getCarrierName($code)) ?>" style="font-style:normal;"> - <?php foreach ($rates as $rate):?> - <option value="<?php echo $this->renderShippingRateValue($rate)?>"<?php echo ($currentRate === $rate) ? ' selected="selected"' : '' ;?>> - <?php echo $this->renderShippingRateOption($rate)?> - </option> - <?php endforeach ?> - </optgroup> - <?php endforeach ?> - </select> - <?php else: ?> - <p><strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong></p> - <?php endif ?> -<?php else: ?> - <p><strong><?php echo $this->renderShippingRateOption($this->getCurrentShippingRate())?></strong></p> -<?php endif ?> -</div> -<div style="display:none" id="shipping_method_update"><p><?php echo $this->__('Please update order data to get shipping methods and rates') ?></p></div> diff --git a/app/design/frontend/rwd/default/template/paypal/partner/us_logo.phtml b/app/design/frontend/rwd/default/template/paypal/partner/us_logo.phtml deleted file mode 100644 index c1055c83f4f..00000000000 --- a/app/design/frontend/rwd/default/template/paypal/partner/us_logo.phtml +++ /dev/null @@ -1,25 +0,0 @@ -<?php -/** - * @copyright For copyright and license information, read the COPYING.txt file. - * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) - * @package rwd_default - */ -?> -<?php -/** - * @see Mage_Paypal_Block_Logo - * @var Mage_Paypal_Block_Logo $this - * @deprecated - */ -?> -<div class="paypal-logo"> - <!-- PayPal Logo --> - <a href="https://www.paypal.com/webapps/mpp/paypal-popup" title="How PayPal Works" onclick="javascript:window.open('https://www.paypal.com/webapps/mpp/paypal-popup','WIPaypal','toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=1060, height=700'); return false;"> - <img src="https://www.paypalobjects.com/webstatic/mktg/logo/bdg_now_accepting_pp_2line_w.png" border="0" alt="Now accepting PayPal"> - </a> - <div class="label"> - <a href="https://www.paypal.com/webapps/mpp/how-paypal-works">How PayPal Works</a> - </div> - <!-- PayPal Logo --> -</div> diff --git a/js/paypal/payment.js b/js/paypal/payment.js new file mode 100644 index 00000000000..7ead7be14c9 --- /dev/null +++ b/js/paypal/payment.js @@ -0,0 +1,408 @@ +/** + * Optimized PayPal payment integration + */ +var PayPalPayment = Class.create(); +PayPalPayment.prototype = { + initialize: function (config) { + this.config = config || {}; + this.buttonInitialized = false; + this.sdkLoaded = false; + this.renderPromise = null; + this.reviewContainerInterval = null; + + // Initialize on DOM ready + document.readyState === 'loading' + ? document.observe('dom:loaded', this.onDOMReady.bind(this)) + : this.onDOMReady(); + }, + + onDOMReady: function () { + this.setupPaymentMethodHandling(); + this.setupPaymentButtonHandling(); + this.checkAndInitialize(); + }, + + setupPaymentButtonHandling: function () { + const paymentButton = $$('button[onclick="payment.save()"]')[0]; + if (paymentButton) { + paymentButton.observe('click', () => { + if (this.getCurrentPaymentMethod() === this.config.methodCode) { + this.waitForReviewContainer().then(() => this.init()); + } + }); + } + }, + + waitForReviewContainer: function () { + return new Promise(resolve => { + // Clear existing interval + if (this.reviewContainerInterval) { + clearInterval(this.reviewContainerInterval); + this.reviewContainerInterval = null; + } + + const maxAttempts = 20; // 10 seconds max + let attempts = 0; + + const checkForContainer = () => { + attempts++; + const reviewContainer = $(this.config.reviewButtonContainerId); + + if (reviewContainer || attempts >= maxAttempts) { + if (this.reviewContainerInterval) { + clearInterval(this.reviewContainerInterval); + this.reviewContainerInterval = null; + } + resolve(reviewContainer); + } + }; + + // Initial check + checkForContainer(); + + // Set interval if not found + if (!$(this.config.reviewButtonContainerId)) { + this.reviewContainerInterval = setInterval(checkForContainer, 500); + } + }); + }, + + checkAndInitialize: function () { + this.getCurrentPaymentMethod() === this.config.methodCode && this.init(); + }, + + getCurrentPaymentMethod: function () { + const checkedInput = $$('input[name="payment[method]"]:checked')[0]; + return checkedInput ? checkedInput.value : null; + }, + + init: function () { + if (this.buttonInitialized) return Promise.resolve(); + + return this.loadPayPalSDK() + .then(() => this.renderButton()) + .catch(() => { }); + }, + + debugCheckEnvironment: function () { + // Removed debug info + }, + + loadPayPalSDK: function () { + return new Promise((resolve, reject) => { + // Check if SDK is already loaded + if (typeof paypal !== 'undefined') { + this.sdkLoaded = true; + return resolve(); + } + + const script = document.createElement('script'); + script.src = this.config.sdkUrl; + script.async = true; + script.onload = () => { + this.sdkLoaded = true; + resolve(); + }; + script.onerror = reject; + document.body.appendChild(script); + }); + }, + + renderButton: function () { + // Reset previous render operation + this.renderPromise = null; + + if (!this.sdkLoaded) { + return Promise.reject(new Error('SDK not loaded')); + } + + const reviewContainer = $(this.config.reviewButtonContainerId); + if (!reviewContainer) { + return Promise.reject(new Error('Review container not found')); + } + + // Remove existing PayPal button + this.removePayPalButton(); + + // Find the existing checkout button + const checkoutButton = reviewContainer.down('button.btn-checkout'); + + // Create PayPal button container + const paypalContainer = new Element('div', { + 'id': this.config.containerId, + 'class': 'paypal-button-container', + 'style': 'margin: 0; min-height: 35px;' + }); + + if (!checkoutButton) { + // Insert at the beginning of the container + reviewContainer.insert({ top: paypalContainer }); + } else { + // Remove the original checkout button + checkoutButton.remove(); + + // Insert PayPal container in the same position + const pleaseWaitSpan = reviewContainer.down('span.please-wait'); + pleaseWaitSpan + ? pleaseWaitSpan.insert({ before: paypalContainer }) + : reviewContainer.insert({ top: paypalContainer }); + } + + return this.createPayPalButton(paypalContainer, reviewContainer); + }, + + createPayPalButton: function (paypalContainer, reviewContainer) { + this.renderPromise = new Promise((resolve, reject) => { + try { + // Create button wrapper + const buttonWrapper = new Element('div', { 'class': 'paypal-button-wrapper' }); + paypalContainer.insert(buttonWrapper); + + // Render PayPal button + paypal.Buttons({ + style: { + layout: this.config.buttonLayout || 'vertical', + color: this.config.buttonColor || 'gold', + shape: this.config.buttonShape || 'rect', + label: this.config.buttonLabel || 'paypal', + height: this.config.buttonHeight || 40 + }, + createOrder: () => this.createOrder(), + onApprove: data => this.onApprove(data), + onError: error => this.onButtonError(error), + onCancel: data => this.onCancel(data) + }).render(buttonWrapper) + .then(() => { + this.buttonInitialized = true; + resolve(); + }) + .catch(error => { + this.handleRenderError(error, reviewContainer, paypalContainer); + reject(error); + }); + } catch (error) { + this.handleRenderError(error, reviewContainer, paypalContainer); + reject(error); + } + }); + + return this.renderPromise; + }, + + handleRenderError: function (error, reviewContainer, paypalContainer) { + // Clean up PayPal container + paypalContainer?.parentNode && paypalContainer.remove(); + + // Recreate the original checkout button + this.recreateCheckoutButton(reviewContainer); + this.buttonInitialized = false; + }, + + recreateCheckoutButton: function (reviewContainer) { + // Skip if button already exists + if (reviewContainer.down('button.btn-checkout')) return; + + // Create checkout button + const checkoutButton = new Element('button', { + 'type': 'submit', + 'title': 'Place Order', + 'class': 'button btn-checkout', + 'onclick': 'review.save();' + }).insert( + new Element('span').insert( + new Element('span').update('Place Order') + ) + ); + + // Insert button + const pleaseWaitSpan = reviewContainer.down('span.please-wait'); + pleaseWaitSpan + ? pleaseWaitSpan.insert({ before: checkoutButton }) + : reviewContainer.insert({ top: checkoutButton }); + }, + + createOrder: function () { + this.showLoadingMask(); + + return new Promise((resolve, reject) => { + if (!this.validateForm()) { + this.hideLoadingMask(); + return reject(new Error('Form validation failed')); + } + new Ajax.Request(this.config.createOrderUrl, { + method: 'post', + parameters: { form_key: this.config.formKey }, + onSuccess: response => { + const result = response.responseJSON; + result?.success && result.id + ? resolve(result.id) + : reject(new Error(result?.message || 'Failed to create PayPal order')); + }, + onFailure: () => reject(new Error('Failed to create PayPal order')), + onComplete: () => this.hideLoadingMask() + }); + }); + }, + + onApprove: function (data) { + this.showLoadingMask(); + return new Promise((resolve, reject) => { + new Ajax.Request(this.config.captureUrl, { + method: 'post', + parameters: { order_id: data.orderID, form_key: this.config.formKey }, + onSuccess: response => { + const result = response.responseJSON; + if (result?.success) { + this.submitPlaceOrderForm(data.orderID); + resolve(result); + } else { + this.showError(result?.message); + this.hideLoadingMask(); + reject(new Error('Payment capture failed')); + } + }, + onFailure: () => { + this.showError(); + this.hideLoadingMask(); + reject(new Error('Payment capture failed')); + } + }); + }); + }, + + submitPlaceOrderForm: function (orderId) { + const form = new Element('form', { + method: 'post', + action: this.config.placeOrderUrl, + style: 'display: none' + }); + + form.insert(new Element('input', { + type: 'hidden', + name: 'id', + value: orderId + })); + + form.insert(new Element('input', { + type: 'hidden', + name: 'form_key', + value: this.config.formKey + })); + + document.body.appendChild(form); + form.submit(); + }, + + onButtonError: function () { + this.showError(); + }, + + onCancel: function () { + this.hideLoadingMask(); + }, + + validateForm: function () { + const form = $('firecheckout-form') || $('co-payment-form'); + if (!form) return false; + + const validator = new Validation(form); + return validator.validate(); + }, + + setupPaymentMethodHandling: function () { + // Handle payment method selection + $$('input[name="payment[method]"]').each(input => { + input.observe('click', () => this.handlePaymentMethodChange(input.value)); + }); + + // Handle review section updates + document.observe('payment-method:switched', event => { + const methodCode = event.memo?.method_code; + methodCode && this.handlePaymentMethodChange(methodCode); + }); + + // Check initial payment method + const currentMethod = this.getCurrentPaymentMethod(); + currentMethod && this.handlePaymentMethodChange(currentMethod); + }, + + handlePaymentMethodChange: function (selectedMethod) { + const reviewContainer = $(this.config.reviewButtonContainerId); + if (!reviewContainer) return; + + this.buttonInitialized = false; + reviewContainer.remove(); + }, + + removePayPalButton: function () { + const container = $(this.config.containerId); + if (container) { + container.remove(); + this.buttonInitialized = false; + } + }, + + showLoadingMask: function () { + let mask = $('loading-mask'); + if (!mask) { + mask = new Element('div', { + 'id': 'loading-mask', + 'class': 'loading-mask', + 'style': 'position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 9999; display: flex; align-items: center; justify-content: center;' + }).insert( + new Element('div', { + 'class': 'loading-mask-loader', + 'style': 'color: white; font-size: 18px;' + }).update('Processing...') + ); + document.body.appendChild(mask); + } + mask.show(); + }, + + hideLoadingMask: function () { + $('loading-mask')?.hide(); + }, + + showError: function (message) { + // Remove existing error + const errorId = this.config.containerId + '-error'; + $(errorId)?.remove(); + + // Create new error element + const container = $(this.config.containerId); + if (container) { + const errorDiv = new Element('div', { + 'id': errorId, + 'class': 'paypal-error', + 'style': 'color: red; margin: 10px 0; padding: 10px; border: 1px solid red; background: #ffe6e6;' + }); + container.insert({ after: errorDiv }); + errorDiv.update(message || this.config.errorMessage || 'An error occurred. Please try again later.'); + } + }, + + log: function () { + // Removed logging + }, + + destroy: function () { + // Remove event listeners + $$('input[name="payment[method]"]').each(input => { + input.stopObserving('click'); + }); + + // Remove payment button observer + const paymentButton = $$('button[onclick="payment.save()"]')[0]; + paymentButton?.stopObserving('click'); + + // Clear interval + if (this.reviewContainerInterval) { + clearInterval(this.reviewContainerInterval); + this.reviewContainerInterval = null; + } + + // Clean up containers + this.removePayPalButton(); + } +}; \ No newline at end of file diff --git a/js/varien/payment.js b/js/varien/payment.js index bc1f4ebef48..fdcd88e84dd 100644 --- a/js/varien/payment.js +++ b/js/varien/payment.js @@ -54,4 +54,4 @@ paymentForm.prototype = { this.currentMethod = method; } } -}; +}; \ No newline at end of file diff --git a/skin/adminhtml/default/default/boxes.css b/skin/adminhtml/default/default/boxes.css index 82a53b450fb..994500bb9f7 100644 --- a/skin/adminhtml/default/default/boxes.css +++ b/skin/adminhtml/default/default/boxes.css @@ -1009,21 +1009,6 @@ ul.item-options li { padding-left:.7em; } .giftmessage-whole-order-container .entry-edit textarea { width:99% !important; padding:2px 3px; } .giftmessage-whole-order-container .entry-edit label { width:121px; } -/* PayPal */ - -.pp-general-uk > .config-heading .heading strong, -.pp-method-payflow > .config-heading .heading strong, -.pp-method-express > .config-heading .heading strong, -.pp-method-general > .config-heading .heading strong { padding-left:56px; background:url(images/paypal/logo-paypal.png) no-repeat 0 2px; } -.pp-method-general > .config-heading .button-container { padding:8px 0 0 180px; background:url(images/paypal/pp-allinone.png) no-repeat 0 0; height:26px; } -.pp-method-express > .config-heading .button-container { padding:0 0 0 174px; background:url(images/paypal/pp-alt.png) no-repeat 0 0; height:29px; } -.pp-method-payflow > .config-heading .button-container { padding:0px 0 0 99px; background:url(images/paypal/pp-gateways.png) no-repeat 1px 0; height:36px; } -.pp-general-uk > .config-heading .button-container { padding:9px 0 0 201px; background:url(images/paypal/pp-uk.png) no-repeat 0 0; height:27px; } -.payflow-settings-notice {padding-bottom: 1em;max-width: 660px;} -.payflow-settings-notice .important-label {color:red;} -.payflow-settings-notice ul.options-list {list-style:disc;padding:0 2em;} - - /* Packaging for Shipping Popup */ #popup-window-mask, .popup-window-mask { background:url(images/bg_window_mask.png) repeat 0 0; background:rgba(239, 239, 239, 0.5); position:absolute; top:0; right:0; bottom:0; left:0; width:100%; height:100%; z-index:399; } @@ -1319,8 +1304,6 @@ ul.config-tabs a.last span { background-image:none; } .comment { padding:5px; } .comment a { color:#888; margin-left:3px; } -.paypal-payment-notice { font-weight: bold; margin: -10px 0 10px 0; } - .payment-group-title { border:0; padding:10px 5px 10px; } .payment-group-title strong { display:inline; font-size:14px; border:0; } diff --git a/skin/frontend/base/default/css/paypal.css b/skin/frontend/base/default/css/paypal.css new file mode 100644 index 00000000000..6e7f21ad1be --- /dev/null +++ b/skin/frontend/base/default/css/paypal.css @@ -0,0 +1,25 @@ +.paypal-payment-method { + margin: 10px 0; +} + +.paypal-button-container { + min-height: 35px; + margin: 10px 0; +} + +.paypal-button-container[data-loading="true"] { + opacity: 0.5; + pointer-events: none; +} + +.paypal-error { + color: #df280a; + margin: 5px 0; + font-size: 13px; +} + +.paypal-message { + margin: 10px 0; + font-size: 13px; + color: #666; +} \ No newline at end of file diff --git a/skin/frontend/base/default/js/msrp.js b/skin/frontend/base/default/js/msrp.js index eece5853461..5d8d49fc9af 100644 --- a/skin/frontend/base/default/js/msrp.js +++ b/skin/frontend/base/default/js/msrp.js @@ -108,9 +108,6 @@ Catalog.Map = { if (helpBox.parentNode != bodyNode) { helpBox.remove(); bodyNode.insert(helpBox); - // Fix for FF4-FF5 bug with missing alt text after DOM manipulations - var paypalImg = helpBox.select('.paypal-logo > a > img')[0]; - if (paypalImg) paypalImg.src = paypalImg.src; } if (this != Catalog.Map && Catalog.Map.active != this.link) { diff --git a/skin/frontend/rwd/default/css/styles.css b/skin/frontend/rwd/default/css/styles.css index 4070de61841..a63c2154718 100644 --- a/skin/frontend/rwd/default/css/styles.css +++ b/skin/frontend/rwd/default/css/styles.css @@ -1015,50 +1015,6 @@ a.button:hover { display: none; } } -/* -------------------------------------------- * - * Paypal Button - */ -.paypal-logo.paypal-after { - float: left; -} - -.paypal-after .paypal-or { - float: left; -} - -.paypal-or { - line-height: 34px; - margin: 0px 10px 5px; -} - -.paypal-after .paypal-button { - float: left; -} - -.paypal-button { - line-height: 0px; -} - -.paypal-button img { - display: inline; -} - -@media only screen and (max-width: 740px) { - .paypal-or { - line-height: 20px; - } - - .paypal-logo, - .paypal-or, - .paypal-button { - text-align: center; - width: 100%; - display: block; - margin-right: 0; - margin-left: 0; - float: none; - } -} /* -------------------------------------------- * * Button Sets */ @@ -5170,9 +5126,6 @@ p.product-name a:hover { .product-view .product-options-bottom .price-box, .product-view .add-to-cart .qty-wrapper, .product-view .add-to-cart-buttons .button, -.product-view .add-to-cart-buttons .paypal-logo { - margin-bottom: 10px; -} .product-view .add-to-cart .qty-wrapper, .product-view .add-to-cart .qty-wrapper label { margin-right: 7px; @@ -5190,31 +5143,6 @@ p.product-name a:hover { margin-right: 10px; max-width: 100%; } -.product-view .add-to-cart-buttons .paypal-logo { - clear: left; - text-align: center; -} -.product-view .add-to-cart-buttons .paypal-logo .paypal-button { - margin: 0 auto; - display: block; - width: 170px; -} -.product-view .add-to-cart-buttons .paypal-logo .bml_button { - display: block; - width: 174px; - margin: 0 auto; -} -.product-view .add-to-cart-buttons .paypal-logo .bml_button a { - text-align: center; -} -.product-view .add-to-cart-buttons .paypal-logo .paypal-or { - display: block; - margin-bottom: 10px; - margin-left: 0; - margin-right: 0; - line-height: 1; - text-align: center; -} .product-view .add-to-cart-buttons .button { min-height: 40px; line-height: 40px; @@ -5229,23 +5157,6 @@ p.product-name a:hover { .product-view .alert-stock { clear: both; } - -@media only screen and (max-width: 479px) { - .product-view .add-to-cart-buttons .paypal-or { - line-height: 20px; - } - .product-view .add-to-cart-buttons .paypal-logo, - .product-view .add-to-cart-buttons .paypal-or, - .product-view .add-to-cart-buttons .paypal-button, - .product-view .add-to-cart-buttons .button { - text-align: center; - width: 100%; - display: block; - margin-right: 0; - margin-left: 0; - float: none; - } -} /* This is the "or" that separates the "Add to Cart" and "Add to X" links */ .add-to-box .or { display: none; @@ -5967,46 +5878,6 @@ p.product-name a:hover { .map-popup .map-popup-checkout .additional-addtocart-box li { list-style-type: none; } -.map-popup .map-popup-checkout .paypal-logo { - width: auto; -} -.map-popup .map-popup-checkout .paypal-logo a { - display: inline-block; - float: left; - clear: left; -} -.map-popup .map-popup-checkout .paypal-logo .paypal-or { - float: left; - text-align: center; - padding: 5px 15px; - clear: left; -} -.map-popup .map-popup-checkout .paypal-logo:after { - content: ''; - display: table; - clear: both; -} -.map-popup .map-popup-checkout .paypal-logo .bml_button a { - clear: left; -} -@media only screen and (max-width: 479px) { - .map-popup .map-popup-checkout { - text-align: center; - } - .map-popup .map-popup-checkout .button, - .map-popup .map-popup-checkout .additional-addtocart-box, - .map-popup .map-popup-checkout .paypal-logo a, - .map-popup .map-popup-checkout .paypal-logo .paypal-or { - float: none; - } - .map-popup .map-popup-checkout .additional-addtocart-box { - min-width: 0px; - } - .map-popup .map-popup-checkout .paypal-logo .paypal-or { - margin: 0px; - margin-bottom: 10px; - } -} .map-popup .map-popup-checkout:after { content: ''; display: table; @@ -6235,24 +6106,6 @@ p.product-name a:hover { .checkout-types.top .bml_button img { display: block; } -.checkout-types.top .paypal-logo .paypal-or { - margin-top: 5px; -} -.checkout-types.bottom .paypal-logo a, .checkout-types.minicart .paypal-logo a { - display: block; -} -.checkout-types.bottom .paypal-or, .checkout-types.minicart .paypal-or { - margin: 0px; - display: block; - text-align: center; -} - -@media only screen and (min-width: 741px) { - .checkout-types.bottom .paypal-or { - text-align: right; - padding-right: 70px; - } -} .cart-totals .checkout-types .btn-checkout { margin-bottom: 7px; } @@ -6262,10 +6115,6 @@ p.product-name a:hover { float: none; text-align: center; } - .checkout-types.bottom .paypal-or, .checkout-types.minicart .paypal-or { - width: auto; - float: none; - } .checkout-types li { float: none; @@ -7006,12 +6855,6 @@ p.product-name a:hover { padding: 5px 5px 5px 0; } -@media only screen and (max-width: 479px) { - .opc .buttons-set .button + .buttons-set .button, - .paypal-express-review .buttons-set .button + .buttons-set .button { - margin-left: 0; - } -} .opc #opc-login .step { padding: 0px; } @@ -8340,135 +8183,6 @@ body.newsletter-manage-index .my-account .form-list { } } -/* ============================================ * - * PayPal - * ============================================ */ -@media only screen and (max-width: 870px) and (min-width: 771px) { - .paypal-review-order .col2-set .col-1, - .paypal-review-order .col2-set .col-2 { - padding: 0px; - } -} -.paypal-review-order .info-set { - margin-bottom: 10px; - padding-bottom: 10px; - border-bottom: 1px solid #ededed; -} -.paypal-review-order .buttons-set { - margin-top: 0px; - padding-top: 0px; - border: 0; -} -.paypal-review-order .buttons-set button { - margin-bottom: 10px; -} -@media only screen and (max-width: 770px) { - .paypal-review-order .col-1 { - padding-bottom: 0; - } - .paypal-review-order .field.inactive { - display: none; - } -} - -.top-container .bml-ad { - margin-top: 7px; - margin-bottom: 7px; - text-align: center; -} -.top-container .bml-ad span { - display: inline-block; -} -.top-container .bml-ad span a { - display: block; -} - -.bml-ad { - display: none; - text-align: center; - margin-bottom: 5px; -} -.bml-ad span { - display: block; - line-height: 0; -} -.bml-ad a { - display: inline-block; - max-width: 100%; -} -.bml-ad a:hover { - opacity: 0.7; -} -.bml-ad img { - height: auto !important; - max-width: 100%; -} - -.cart-totals-wrapper .bml-ad.large img { - display: block; - margin: 0; -} - -@media only screen and (max-width: 770px) { - .bml-ad.small { - display: block; - } -} -@media only screen and (min-width: 771px) { - .bml-ad.large { - display: block; - } -} -div.paypal-logo { - text-align: center; - margin: 15px 0; - max-width: 100%; -} -div.paypal-logo span { - display: block; - width: 100%; -} -div.paypal-logo span a { - display: inline-block; - max-width: 100%; -} -div.paypal-logo span a img { - max-width: 100%; -} -div.paypal-logo span > img { - display: none; -} - -.checkout-types div.paypal-logo { - text-align: right; -} - -.bml-checkout-type { - list-style-type: none; -} - -.sidebar .paypal-logo { - text-align: center; - line-height: 0; -} -.sidebar .paypal-logo > a { - display: inline-block; - max-width: 100%; -} -.sidebar .paypal-logo > a:hover { - opacity: 0.8; -} -.sidebar .paypal-logo > a img { - display: block; -} -.sidebar .paypal-logo .label { - margin-top: 4px; -} -.sidebar .paypal-logo .label a { - font-size: 12px; - line-height: 1.5; -} - /* ============================================ * * Review - Customer * ============================================ */ @@ -9391,9 +9105,6 @@ div.paypal-logo span > img { text-transform: uppercase; font-size: 13px; } -.header-minicart .minicart-actions .paypal-logo .paypal-or { - line-height: 1.6; -} .header-minicart #minicart-error-message { text-align: center; color: red; @@ -9452,21 +9163,6 @@ div.paypal-logo span > img { .header-minicart .minicart-actions .checkout-types.minicart li { display: inline-block; } - .header-minicart .minicart-actions .checkout-types.minicart li .paypal-logo > a { - display: inline; - } - .header-minicart .minicart-actions .checkout-types.minicart li .paypal-logo .bml_button { - display: inline-block; - vertical-align: top; - } - .header-minicart .minicart-actions .checkout-types.minicart li .paypal-logo .paypal-or { - width: auto; - float: none; - display: inline; - margin: 0 10px 5px 10px; - line-height: 40px; - } -} @media only screen and (max-width: 740px) { .header-minicart .minicart-actions .cart-link { right: auto; @@ -9474,15 +9170,6 @@ div.paypal-logo span > img { text-align: center; width: 100%; } - .header-minicart .minicart-actions .checkout-types.minicart li .paypal-logo .paypal-or, - .header-minicart .minicart-actions .checkout-types.minicart li .paypal-logo .paypal-button { - width: 100%; - display: block; - margin-left: 0; - } - .header-minicart .minicart-actions .checkout-types.minicart li .paypal-logo .paypal-or { - line-height: 1.6; - } } @media only screen and (max-width: 599px) { .header-minicart .minicart-actions .checkout-button { diff --git a/skin/frontend/rwd/default/scss/_core.scss b/skin/frontend/rwd/default/scss/_core.scss index d964f42c94c..cd86a4a5372 100644 --- a/skin/frontend/rwd/default/scss/_core.scss +++ b/skin/frontend/rwd/default/scss/_core.scss @@ -63,7 +63,6 @@ @import "module/configurableswatches"; @import "module/customer"; @import "module/contacts"; -@import "module/paypal"; @import "module/review"; @import "module/slideshow"; @import "module/wishlist"; diff --git a/skin/frontend/rwd/default/scss/core/_common.scss b/skin/frontend/rwd/default/scss/core/_common.scss index 3dc1b5f1b3a..a5104a04eaa 100644 --- a/skin/frontend/rwd/default/scss/core/_common.scss +++ b/skin/frontend/rwd/default/scss/core/_common.scss @@ -455,52 +455,6 @@ a.button:hover { } } -/* -------------------------------------------- * - * Paypal Button - */ - -.paypal-logo.paypal-after { - float: left; -} - -.paypal-after .paypal-or { - float: left; -} - -.paypal-or { - line-height: 34px; - margin: 0px 10px 5px; -} - -.paypal-after .paypal-button { - float: left; -} - -.paypal-button { - line-height: 0px; -} - -.paypal-button img { - display: inline; -} - -@include bp(max-width, 740px) { - .paypal-or { - line-height: 20px; - } - - .paypal-logo, - .paypal-or, - .paypal-button { - text-align: center; - width: 100%; - display: block; - margin-right: 0; - margin-left: 0; - float: none; - } -} - /* -------------------------------------------- * * Button Sets */ diff --git a/skin/frontend/rwd/default/scss/module/_catalog-msrp.scss b/skin/frontend/rwd/default/scss/module/_catalog-msrp.scss index 9113f2ed80d..09f727c0645 100644 --- a/skin/frontend/rwd/default/scss/module/_catalog-msrp.scss +++ b/skin/frontend/rwd/default/scss/module/_catalog-msrp.scss @@ -130,51 +130,12 @@ } } - .paypal-logo { - width: auto; - - a { - display: inline-block; - float: left; - clear: left; - } - - .paypal-or { - float: left; - text-align: center; - padding: 5px 15px; - clear: left; - } - - &:after { - @include clearfix; - } - - .bml_button { - a { - clear: left; - } - } - } - @include bp(max-width, $bp-xsmall) { text-align: center; - .button, - .additional-addtocart-box, - .paypal-logo a, - .paypal-logo .paypal-or { - float: none; - } - .additional-addtocart-box { min-width: 0px; } - - .paypal-logo .paypal-or { - margin: 0px; - margin-bottom: 10px; - } } &:after { diff --git a/skin/frontend/rwd/default/scss/module/_catalog-product.scss b/skin/frontend/rwd/default/scss/module/_catalog-product.scss index 0bcde976579..c1387fa3d19 100644 --- a/skin/frontend/rwd/default/scss/module/_catalog-product.scss +++ b/skin/frontend/rwd/default/scss/module/_catalog-product.scss @@ -334,13 +334,6 @@ min-height: 40px; } - .product-options-bottom .price-box, - .add-to-cart .qty-wrapper, - .add-to-cart-buttons .button, - .add-to-cart-buttons .paypal-logo { - margin-bottom: 10px; - } - .add-to-cart .qty-wrapper, .add-to-cart .qty-wrapper label { margin-right: 7px; @@ -360,36 +353,6 @@ float: left; margin-right: 10px; max-width: 100%; // Constrain width in Firefox - - .paypal-logo { - clear: left; - text-align: center; - - .paypal-button { - margin: 0 auto; - display: block; - width: 170px; - } - - .bml_button { - display: block; - width: 174px; - margin: 0 auto; - - a { - text-align: center; - } - } - - .paypal-or { - display: block; - margin-bottom: 10px; - margin-left: 0; - margin-right: 0; - line-height: 1; - text-align: center; - } - } } .add-to-cart-buttons .button { @@ -409,25 +372,6 @@ } } -@include bp(max-width, $bp-xsmall) { - .product-view .add-to-cart-buttons { - .paypal-or { - line-height: 20px; - } - - .paypal-logo, - .paypal-or, - .paypal-button, - .button { - text-align: center; - width: 100%; - display: block; - margin-right: 0; - margin-left: 0; - float: none; - } - } -} /* This is the "or" that separates the "Add to Cart" and "Add to X" links */ .add-to-box .or { diff --git a/skin/frontend/rwd/default/scss/module/_checkout-cart-minicart.scss b/skin/frontend/rwd/default/scss/module/_checkout-cart-minicart.scss index 52723a8743d..2b513ce8a25 100644 --- a/skin/frontend/rwd/default/scss/module/_checkout-cart-minicart.scss +++ b/skin/frontend/rwd/default/scss/module/_checkout-cart-minicart.scss @@ -171,12 +171,6 @@ text-transform: uppercase; font-size: $f-size-s; } - - .paypal-logo { - .paypal-or { - line-height: 1.6; - } - } } #minicart-error-message { @@ -253,25 +247,6 @@ .checkout-types.minicart { li { display: inline-block; - - .paypal-logo { - > a { - display: inline; - } - - .bml_button { - display: inline-block; - vertical-align: top; - } - - .paypal-or { - width: auto; - float: none; - display: inline; - margin: 0 10px 5px 10px; - line-height: 40px; - } - } } } } @@ -287,23 +262,6 @@ text-align: center; width: 100%; } - - .checkout-types.minicart { - li { - .paypal-logo { - .paypal-or, - .paypal-button { - width: 100%; - display: block; - margin-left: 0; - } - - .paypal-or { - line-height: 1.6; - } - } - } - } } } } diff --git a/skin/frontend/rwd/default/scss/module/_checkout-cart.scss b/skin/frontend/rwd/default/scss/module/_checkout-cart.scss index b3f2565dcc4..beec358b589 100644 --- a/skin/frontend/rwd/default/scss/module/_checkout-cart.scss +++ b/skin/frontend/rwd/default/scss/module/_checkout-cart.scss @@ -167,42 +167,6 @@ li { display: inline-block; } - - .bml_button { - display: inline-block; - vertical-align: top; - - img { - display: block; - } - } - - .paypal-logo .paypal-or { - margin-top: 5px; - } - } - - &.bottom, - &.minicart { - .paypal-logo { - a { - display: block; - } - } - .paypal-or { - margin: 0px; - display: block; - text-align: center; - } - } -} - -@include bp(min-width, 741px) { - .checkout-types.bottom { - .paypal-or { - text-align: right; - padding-right: 70px; - } } } @@ -214,14 +178,6 @@ .checkout-types { float: none; text-align: center; - - &.bottom, - &.minicart { - .paypal-or { - width: auto; - float: none; - } - } } .checkout-types li { diff --git a/skin/frontend/rwd/default/scss/module/_checkout-onepage.scss b/skin/frontend/rwd/default/scss/module/_checkout-onepage.scss index 0fe85096b4f..7a21caeaf8b 100644 --- a/skin/frontend/rwd/default/scss/module/_checkout-onepage.scss +++ b/skin/frontend/rwd/default/scss/module/_checkout-onepage.scss @@ -180,15 +180,6 @@ } } -@include bp(max-width, $bp-xsmall) { - .opc, - .paypal-express-review { - .buttons-set .button + .buttons-set .button { - margin-left: 0; - } - } -} - .opc #opc-login { .step { padding: 0px; @@ -266,14 +257,6 @@ body:not(.opc-has-progressed-from-login) .opc.opc-firststep-login .section#opc-l dd li { margin: 5px 0; } - label img { // This applies to the Paypal Express label - float: left; - } - label a { // This applies to the Paypal Express label - margin-top: 6px; - float: right; - margin-left: 10px; - } .price { font-weight: bold; } diff --git a/skin/frontend/rwd/default/scss/module/_paypal.scss b/skin/frontend/rwd/default/scss/module/_paypal.scss deleted file mode 100644 index 8afb5922583..00000000000 --- a/skin/frontend/rwd/default/scss/module/_paypal.scss +++ /dev/null @@ -1,171 +0,0 @@ -// -// OpenMage -// -// This source file is subject to the Academic Free License (AFL 3.0) -// that is bundled with this package in the file LICENSE_AFL.txt. -// It is also available at https://opensource.org/license/afl-3-0-php -// -// @category design -// @package rwd_default -// @copyright Copyright (c) 2006-2020 Magento, Inc. (https://www.magento.com) -// @copyright Copyright (c) 2022 The OpenMage Contributors (https://www.openmage.org) -// @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) -// - -/* ============================================ * - * PayPal - * ============================================ */ - -.paypal-review-order { - @include bp(max-width, $bp-medium + 100) { - @include bp(min-width, $bp-medium + 1) { - .col2-set { - .col-1, - .col-2 { - padding: 0px; - } - } - } - } - - .info-set { - margin-bottom: $gap; - padding-bottom: $gap; - border-bottom: 1px solid $c-fieldset-border-light; - } - - .buttons-set { - margin-top: 0px; - padding-top: 0px; - border: 0; - - button { - margin-bottom: $gap; - } - } - - @include bp(max-width, $bp-medium) { - .col-1 { - padding-bottom: 0; - } - - .field.inactive { - display: none; - } - } -} - - -.top-container .bml-ad { - margin-top: $element-spacing; - margin-bottom: $element-spacing; - text-align: center; - - span { - display: inline-block; - - a { - display: block; - } - } -} - -.bml-ad { - display: none; - text-align: center; - margin-bottom: 5px; - - span { - display: block; - line-height: 0; - } - a { - display: inline-block; - max-width: 100%; - } - a:hover { - opacity: 0.7; - } - img { - height: auto !important; // Override inline style - max-width: 100%; - } -} - -// Prevent small 2px space on right side of image -.cart-totals-wrapper .bml-ad.large img { - display: block; - margin: 0; -} - -@include bp(max-width, $bp-medium) { - .bml-ad.small { - display: block; - } -} - -@include bp(min-width, $bp-medium + 1) { - .bml-ad.large { - display: block; - } -} - -div.paypal-logo { - text-align: center; - margin: $trim-small 0; - max-width: 100%; - - span { - display: block; - width: 100%; - - a { - display: inline-block; - max-width: 100%; - - img { - max-width: 100%; - } - } - } - - span > img { - display: none; - } -} - -.checkout-types { - div.paypal-logo { - text-align: right; - } -} - -.bml-checkout-type { - list-style-type: none; -} - -.sidebar { - .paypal-logo { - text-align: center; - line-height: 0; - - > a { - display: inline-block; - max-width: 100%; - - &:hover { - opacity: 0.8; - } - img { - display: block; - } - } - .label { - margin-top: 4px; - a { - font-size: $f-size-xs; - line-height: 1.5; - } - } - } -} diff --git a/tests/unit/Traits/DataProvider/Base/ModulesTrait.php b/tests/unit/Traits/DataProvider/Base/ModulesTrait.php index 8f9f5661217..89130c15d9b 100644 --- a/tests/unit/Traits/DataProvider/Base/ModulesTrait.php +++ b/tests/unit/Traits/DataProvider/Base/ModulesTrait.php @@ -60,7 +60,6 @@ final public function provideAllModules(): array 'Mage_Paygate', 'Mage_Payment', 'Mage_Paypal', - 'Mage_PaypalUk', 'Mage_Persistent', 'Mage_ProductAlert', 'Mage_Rating', diff --git a/tests/unit/Traits/PhpStormMetaData/BlocksTrait.php b/tests/unit/Traits/PhpStormMetaData/BlocksTrait.php index 9ebe3228956..42428b80f17 100644 --- a/tests/unit/Traits/PhpStormMetaData/BlocksTrait.php +++ b/tests/unit/Traits/PhpStormMetaData/BlocksTrait.php @@ -1122,53 +1122,6 @@ public function getAllBlockClasses(): array 'payment/info_checkmo' => \Mage_Payment_Block_Info_Checkmo::class, 'payment/info_container' => \Mage_Payment_Block_Info_Container::class, 'payment/info_purchaseorder' => \Mage_Payment_Block_Info_Purchaseorder::class, - 'paypaluk/bml_form' => \Mage_PaypalUk_Block_Bml_Form::class, - 'paypaluk/express_form' => \Mage_PaypalUk_Block_Express_Form::class, - 'paypaluk/express_shortcut' => \Mage_PaypalUk_Block_Express_Shortcut::class, - 'paypal/adminhtml_settlement_details' => \Mage_Paypal_Block_Adminhtml_Settlement_Details::class, - 'paypal/adminhtml_settlement_details_form' => \Mage_Paypal_Block_Adminhtml_Settlement_Details_Form::class, - 'paypal/adminhtml_settlement_report' => \Mage_Paypal_Block_Adminhtml_Settlement_Report::class, - 'paypal/adminhtml_settlement_report_grid' => \Mage_Paypal_Block_Adminhtml_Settlement_Report_Grid::class, - 'paypal/adminhtml_system_config_apiWizard' => \Mage_Paypal_Block_Adminhtml_System_Config_ApiWizard::class, - 'paypal/adminhtml_system_config_bmlApiWizard' => \Mage_Paypal_Block_Adminhtml_System_Config_BmlApiWizard::class, - 'paypal/adminhtml_system_config_field_country' => \Mage_Paypal_Block_Adminhtml_System_Config_Field_Country::class, - 'paypal/adminhtml_system_config_field_hidden' => \Mage_Paypal_Block_Adminhtml_System_Config_Field_Hidden::class, - 'paypal/adminhtml_system_config_field_solutionType' => \Mage_Paypal_Block_Adminhtml_System_Config_Field_SolutionType::class, - 'paypal/adminhtml_system_config_fieldset_deprecated' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Deprecated::class, - 'paypal/adminhtml_system_config_fieldset_expanded' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Expanded::class, - 'paypal/adminhtml_system_config_fieldset_global' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Global::class, - 'paypal/adminhtml_system_config_fieldset_group' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Group::class, - 'paypal/adminhtml_system_config_fieldset_hint' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Hint::class, - 'paypal/adminhtml_system_config_fieldset_location' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Location::class, - 'paypal/adminhtml_system_config_fieldset_pathDependent' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_PathDependent::class, - 'paypal/adminhtml_system_config_fieldset_payment' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Payment::class, - 'paypal/adminhtml_system_config_fieldset_store' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Store::class, - 'paypal/adminhtml_system_config_payflowlink_advanced' => \Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Advanced::class, - 'paypal/adminhtml_system_config_payflowlink_info' => \Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Info::class, - 'paypal/bml_banners' => \Mage_Paypal_Block_Bml_Banners::class, - 'paypal/bml_form' => \Mage_Paypal_Block_Bml_Form::class, - 'paypal/express_form' => \Mage_Paypal_Block_Express_Form::class, - 'paypal/express_review' => \Mage_Paypal_Block_Express_Review::class, - 'paypal/express_review_billing' => \Mage_Paypal_Block_Express_Review_Billing::class, - 'paypal/express_review_details' => \Mage_Paypal_Block_Express_Review_Details::class, - 'paypal/express_review_shipping' => \Mage_Paypal_Block_Express_Review_Shipping::class, - 'paypal/express_shortcut' => \Mage_Paypal_Block_Express_Shortcut::class, - 'paypal/hosted_pro_form' => \Mage_Paypal_Block_Hosted_Pro_Form::class, - 'paypal/hosted_pro_iframe' => \Mage_Paypal_Block_Hosted_Pro_Iframe::class, - 'paypal/hosted_pro_info' => \Mage_Paypal_Block_Hosted_Pro_Info::class, - 'paypal/iframe' => \Mage_Paypal_Block_Iframe::class, - 'paypal/logo' => \Mage_Paypal_Block_Logo::class, - 'paypal/payflow_advanced_form' => \Mage_Paypal_Block_Payflow_Advanced_Form::class, - 'paypal/payflow_advanced_iframe' => \Mage_Paypal_Block_Payflow_Advanced_Iframe::class, - 'paypal/payflow_advanced_info' => \Mage_Paypal_Block_Payflow_Advanced_Info::class, - 'paypal/payflow_advanced_review' => \Mage_Paypal_Block_Payflow_Advanced_Review::class, - 'paypal/payflow_link_form' => \Mage_Paypal_Block_Payflow_Link_Form::class, - 'paypal/payflow_link_iframe' => \Mage_Paypal_Block_Payflow_Link_Iframe::class, - 'paypal/payflow_link_info' => \Mage_Paypal_Block_Payflow_Link_Info::class, - 'paypal/payflow_link_review' => \Mage_Paypal_Block_Payflow_Link_Review::class, - 'paypal/payment_info' => \Mage_Paypal_Block_Payment_Info::class, - 'paypal/standard_form' => \Mage_Paypal_Block_Standard_Form::class, - 'paypal/standard_redirect' => \Mage_Paypal_Block_Standard_Redirect::class, 'persistent/form_remember' => \Mage_Persistent_Block_Form_Remember::class, 'persistent/header_additional' => \Mage_Persistent_Block_Header_Additional::class, 'productalert/email_abstract' => \Mage_ProductAlert_Block_Email_Abstract::class, @@ -1680,14 +1633,6 @@ public function getBlockClassesWithSessions(): array \Mage_Oauth_Block_Adminhtml_Oauth_Consumer_Edit::class, \Mage_Oauth_Block_Adminhtml_Oauth_Consumer_Grid::class, \Mage_Oauth_Block_Customer_Token_List::class, - \Mage_Paypal_Block_Adminhtml_Settlement_Details::class, - \Mage_Paypal_Block_Adminhtml_Settlement_Report::class, - \Mage_Paypal_Block_Express_Review_Billing::class, - \Mage_Paypal_Block_Express_Review_Shipping::class, - \Mage_Paypal_Block_Hosted_Pro_Iframe::class, - \Mage_Paypal_Block_Iframe::class, - \Mage_Paypal_Block_Payflow_Advanced_Iframe::class, - \Mage_Paypal_Block_Payflow_Link_Iframe::class, \Mage_Review_Block_Customer_List::class, \Mage_Review_Block_Customer_Recent::class, \Mage_Review_Block_Form::class, From b57d1e1e8989e7276b496081f2e32386ca1fc898 Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Sun, 22 Jun 2025 00:16:03 +0200 Subject: [PATCH 04/40] fix: fix paypal module configurations --- app/code/core/Mage/Paypal/etc/config.xml | 8 +--- app/code/core/Mage/Paypal/etc/system.xml | 37 +++++++++++++------ .../sql/paypal_setup/install-2.0.0.0.php | 5 --- 3 files changed, 28 insertions(+), 22 deletions(-) diff --git a/app/code/core/Mage/Paypal/etc/config.xml b/app/code/core/Mage/Paypal/etc/config.xml index c584ab50be8..b243e77cb18 100644 --- a/app/code/core/Mage/Paypal/etc/config.xml +++ b/app/code/core/Mage/Paypal/etc/config.xml @@ -50,11 +50,6 @@ </states> </order> </sales> - <payment> - <groups> - <paypal>PayPal</paypal> - </groups> - </payment> <resources> <paypal_setup> <setup> @@ -130,7 +125,8 @@ <payment> <paypal> <model>paypal/paypal</model> - <title>PayPal + PayPal Express Checkout + US 0 1 capture diff --git a/app/code/core/Mage/Paypal/etc/system.xml b/app/code/core/Mage/Paypal/etc/system.xml index a6726bf42f2..2d6aa37ef2e 100644 --- a/app/code/core/Mage/Paypal/etc/system.xml +++ b/app/code/core/Mage/Paypal/etc/system.xml @@ -20,6 +20,17 @@ 1 Accept payments with PayPal Express Checkout. + + + + select + adminhtml/system_config_source_yesno + 5 + 1 + 1 + If you want to use PayPal Express Checkout, you must complete + the settings below. + If not specified, Default Country from General Config will be @@ -30,20 +41,24 @@ paypal/system_config_backend_merchantCountry 1 1 - 5 - - - - select - adminhtml/system_config_source_yesno 10 + + 1 + + 1 + + + <label>Title</label> + <frontend_type>text</frontend_type> + <sort_order>15</sort_order> <show_in_default>1</show_in_default> <show_in_website>1</show_in_website> - <comment>If you want to use PayPal Express Checkout, you must complete - the settings below.</comment> - <requires>express_checkout_settings</requires> - </active> - + <comment>Enter the title for the PayPal Express Checkout button.</comment> + <depends> + <active>1</active> + </depends> + <required>1</required> + text diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php b/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php index c3cd67c880a..b56c549e24c 100644 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php +++ b/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php @@ -83,7 +83,6 @@ $installer->getTable('core/config_data'), $installer->getConnection()->quoteInto('path IN (?)', [ 'payment/paypal_billing_agreement/active', - 'payment/paypal_billing_agreement/title', 'payment/paypal_billing_agreement/sort_order', 'payment/paypal_billing_agreement/payment_action', 'payment/paypal_billing_agreement/allowspecific', @@ -91,7 +90,6 @@ 'payment/paypal_billing_agreement/verify_peer', 'payment/paypal_billing_agreement/line_items_enabled', 'payment/paypal_billing_agreement/allow_billing_agreement_wizard', - 'payment/paypal_express/title', 'payment/paypal_express/sort_order', 'payment/paypal_express/payment_action', 'payment/paypal_express/visible_on_cart', @@ -106,7 +104,6 @@ 'payment/paypal_express/allow_ba_signup', 'payment/paypal_direct/using_pbridge', 'payment/paypal_direct/active', - 'payment/paypal_direct/title', 'payment/paypal_direct/sort_order', 'payment/paypal_direct/payment_action', 'payment/paypal_direct/cctypes', @@ -117,7 +114,6 @@ 'payment/paypal_direct/useccv', 'payment/paypal_direct/centinel', 'payment/paypal_standard/active', - 'payment/paypal_standard/title', 'payment/paypal_standard/sort_order', 'payment/paypal_standard/payment_action', 'payment/paypal_standard/allowspecific', @@ -126,7 +122,6 @@ 'payment/paypal_standard/debug', 'payment/paypal_standard/verify_peer', 'payment/paypaluk_express/active', - 'payment/paypaluk_express/title', 'payment/paypaluk_express/sort_order', 'payment/paypaluk_express/payment_action', 'payment/paypaluk_express/visible_on_cart', From f6554f00dcfadfb904818083af0c870707449630 Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Sun, 22 Jun 2025 00:55:28 +0200 Subject: [PATCH 05/40] fix: php-cs-fixer and update copyright --- .../Mage/Paypal/Block/Adminhtml/Debug.php | 16 +- .../Paypal/Block/Adminhtml/Debug/Grid.php | 10 +- .../Debug/Grid/Renderer/Exception.php | 14 +- .../Adminhtml/Debug/Grid/Renderer/Request.php | 12 +- .../Debug/Grid/Renderer/Response.php | 12 +- .../Block/Adminhtml/Grid/Renderer/Json.php | 14 +- .../Block/Adminhtml/Grid/Renderer/Order.php | 16 +- .../core/Mage/Paypal/Block/Adminhtml/Info.php | 19 ++- .../Adminhtml/System/Config/Field/Country.php | 14 +- app/code/core/Mage/Paypal/Block/Button.php | 19 ++- app/code/core/Mage/Paypal/Block/Form.php | 15 +- app/code/core/Mage/Paypal/Block/Info.php | 7 + app/code/core/Mage/Paypal/Helper/Data.php | 7 + app/code/core/Mage/Paypal/Model/Api.php | 31 ++-- .../core/Mage/Paypal/Model/Api/Exception.php | 10 +- .../core/Mage/Paypal/Model/Api/Helper.php | 10 +- app/code/core/Mage/Paypal/Model/Cart.php | 29 ++-- app/code/core/Mage/Paypal/Model/Config.php | 49 +++--- app/code/core/Mage/Paypal/Model/Debug.php | 8 + app/code/core/Mage/Paypal/Model/Exception.php | 8 + app/code/core/Mage/Paypal/Model/Paypal.php | 144 +++++++++--------- .../core/Mage/Paypal/Model/Resource/Debug.php | 10 +- .../Model/Resource/Debug/Collection.php | 8 + .../core/Mage/Paypal/Model/Resource/Setup.php | 2 +- .../System/Config/Backend/MerchantCountry.php | 10 +- .../System/Config/Source/ButtonColors.php | 20 ++- .../System/Config/Source/ButtonLabels.php | 20 ++- .../System/Config/Source/ButtonLayouts.php | 14 +- .../System/Config/Source/ButtonShapes.php | 16 +- .../System/Config/Source/MerchantCountry.php | 16 +- .../System/Config/Source/PaymentActions.php | 14 +- .../core/Mage/Paypal/Model/Validator/Api.php | 16 +- .../Mage/Paypal/Model/Validator/Payment.php | 17 ++- .../core/Mage/Paypal/Model/Webhook/Log.php | 10 +- .../Adminhtml/Paypal/DebugController.php | 14 +- .../Paypal/TransactionController.php | 26 +--- .../Paypal/controllers/PaymentController.php | 29 ++-- app/code/core/Mage/Paypal/etc/adminhtml.xml | 8 + app/code/core/Mage/Paypal/etc/system.xml | 2 +- .../sql/paypal_setup/install-2.0.0.0.php | 21 ++- .../default/template/paypal/info.phtml | 6 + .../base/default/template/paypal/info.phtml | 7 + .../default/template/paypal/payment.phtml | 7 + app/locale/en_US/Mage_Paypal.csv | 59 +++++++ js/paypal/payment.js | 14 ++ 45 files changed, 592 insertions(+), 238 deletions(-) diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug.php index 826d51de47c..6f1603794d0 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug.php @@ -1,4 +1,12 @@ _headerText = Mage::helper('paypal')->__('PayPal Debug Log'); parent::__construct(); $this->_removeButton('add'); - + $this->_addButton('delete_all', [ 'label' => Mage::helper('paypal')->__('Delete All Logs'), - 'onclick' => 'deleteConfirm(\'' . - Mage::helper('paypal')->__('Are you sure you want to delete all debug logs?') . + 'onclick' => 'deleteConfirm(\'' . + Mage::helper('paypal')->__('Are you sure you want to delete all debug logs?') . '\', \'' . $this->getUrl('*/*/deleteAll') . '\')', - 'class' => 'delete' + 'class' => 'delete', ]); } } diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php index a4a00802bf6..2b8ebdf5766 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php @@ -1,4 +1,12 @@ getMassactionBlock()->addItem('delete', [ 'label' => Mage::helper('paypal')->__('Delete'), 'url' => $this->getUrl('*/*/massDelete'), - 'confirm' => Mage::helper('paypal')->__('Are you sure?') + 'confirm' => Mage::helper('paypal')->__('Are you sure?'), ]); return $this; diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php index 0360706d69a..1bc7f65aac1 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php @@ -1,4 +1,12 @@ escapeHtml($value); - + return '' . $escapedValue . ''; } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php index 5c494f901df..e29f7da9ce7 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php @@ -1,4 +1,12 @@ _formatJson($value); $rawValue = $this->escapeHtml($value); - + return '
' . $formattedValue . '
'; } } diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php index b380584bfee..53aa6e4f696 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php @@ -1,4 +1,12 @@ _formatJson($value); $rawValue = $this->escapeHtml($value); - + return '
' . $formattedValue . '
'; } } diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php index 4927d7aee8a..9bcdbffb282 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php @@ -1,4 +1,12 @@ jsonDecode($json); - + // Format with proper indentation and spacing $formattedJson = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); - + // Escape HTML entities $formattedJson = $this->escapeHtml($formattedJson); - + return sprintf('
%s
', $formattedJson); } catch (Exception $e) { return $this->escapeHtml($json); diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php index e9f24f2718f..5b74e82ed38 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php @@ -1,4 +1,12 @@ loadByIncrementId($incrementId); if (!$order->getId()) { return $this->escapeHtml($incrementId); } - + return sprintf( '%s', $this->getUrl('*/sales_order/view', ['order_id' => $order->getId()]), - $this->escapeHtml($incrementId) + $this->escapeHtml($incrementId), ); } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php index 51b189accf6..61be7065815 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php @@ -1,5 +1,12 @@ getInfo(); - if ($payment->getMethod() !== 'paypal' || + if ($payment->getMethod() !== 'paypal' || !$payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID)) { return false; } - + $expirationTime = $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME); if ($expirationTime) { $now = new DateTime(); @@ -95,15 +102,15 @@ public function canReauthorize() $daysDiff = $now->diff($expDate)->days; return $daysDiff <= 26; } - + $authTime = $payment->getCreatedAt(); $now = new DateTime(); $authDate = new DateTime($authTime); $daysDiff = $now->diff($authDate)->days; - + return $daysDiff >= 3; } - + /** * Get reauthorize URL * @@ -113,7 +120,7 @@ public function getReauthorizeUrl() { return Mage::getUrl('*/paypal_transaction/reauthorize', [ 'order_id' => $this->getInfo()->getOrder()->getId(), - '_secure' => true + '_secure' => true, ]); } } diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Country.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Country.php index be261d74506..0e8e50da334 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Country.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Country.php @@ -1,14 +1,22 @@ toOptionArray(false); - + $element->setValues($countries) ->setClass('paypal-merchant-country'); - + return parent::_getElementHtml($element); } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Paypal/Block/Button.php b/app/code/core/Mage/Paypal/Block/Button.php index 25af3f3b983..1be25a8522b 100644 --- a/app/code/core/Mage/Paypal/Block/Button.php +++ b/app/code/core/Mage/Paypal/Block/Button.php @@ -1,5 +1,12 @@ getButtonConfig(); $intent = Mage::getSingleton('paypal/config')->getPaymentAction(); - + $params = [ 'client-id' => $this->getClientId(), 'components' => 'buttons,messages', 'intent' => $intent, - 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode() + 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode(), ]; if ($config['message']) { @@ -58,7 +65,7 @@ public function getFormKey() { return Mage::getSingleton('core/session')->getFormKey(); } - + /** * Check if button should be rendered * @@ -89,7 +96,7 @@ public function getContainerAttributes() { return sprintf( 'id="%s" class="paypal-button-container" data-loading="false" style="min-height: 35px;"', - $this->getContainerId() + $this->getContainerId(), ); } @@ -102,7 +109,7 @@ public function getButtonScript() { $config = $this->getButtonConfig(); $containerId = $this->getContainerId(); - + return sprintf( 'window.paypalLoadPromise = window.paypalLoadPromise || new Promise(function(resolve) { var script = document.createElement("script"); @@ -184,7 +191,7 @@ public function getButtonScript() $this->getUrl('paypal/payment/createOrder'), $this->getUrl('paypal/payment/capture'), $this->getUrl('checkout/onepage/success'), - $containerId + $containerId, ); } } diff --git a/app/code/core/Mage/Paypal/Block/Form.php b/app/code/core/Mage/Paypal/Block/Form.php index 3937315218d..a670eb20625 100644 --- a/app/code/core/Mage/Paypal/Block/Form.php +++ b/app/code/core/Mage/Paypal/Block/Form.php @@ -1,5 +1,12 @@ getPaymentAction(); - $params = array( + $params = [ 'client-id' => $this->getClientId(), 'components' => 'buttons', 'intent' => $intent, - 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode() - ); + 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode(), + ]; $baseUrl = $this->getEndpointUrl(); if (substr($baseUrl, -1) !== '/') { diff --git a/app/code/core/Mage/Paypal/Block/Info.php b/app/code/core/Mage/Paypal/Block/Info.php index 0de3d521281..499812b9049 100644 --- a/app/code/core/Mage/Paypal/Block/Info.php +++ b/app/code/core/Mage/Paypal/Block/Info.php @@ -1,5 +1,12 @@ self::PREFER_RETURN_REPRESENTATION, - 'body' => $orderRequest + 'body' => $orderRequest, ]; $response = $this->getClient()->getOrdersController()->createOrder($request); @@ -85,7 +92,7 @@ public function authorizeOrder( try { $request = [ 'id' => $id, - 'prefer' => self::PREFER_RETURN_REPRESENTATION + 'prefer' => self::PREFER_RETURN_REPRESENTATION, ]; $response = $this->getClient()->getOrdersController()->authorizeOrder($request); @@ -113,7 +120,7 @@ public function reAuthorizeOrder( try { $request = [ 'authorizationId' => $id, - 'prefer' => self::PREFER_RETURN_REPRESENTATION + 'prefer' => self::PREFER_RETURN_REPRESENTATION, ]; $response = $this->getClient()->getPaymentsController()->reauthorizePayment($request); @@ -127,7 +134,7 @@ public function reAuthorizeOrder( /** * Capture authorized payment for a PayPal order - * + * * @param string $id PayPal order ID * @param Mage_Sales_Model_Order $order * @return ApiResponse|null @@ -140,7 +147,7 @@ public function captureAuthorizedPayment(string $id, Mage_Sales_Model_Order $ord try { $request = [ 'authorizationId' => $id, - 'prefer' => self::PREFER_RETURN_REPRESENTATION + 'prefer' => self::PREFER_RETURN_REPRESENTATION, ]; $response = $this->getClient()->getPaymentsController()->captureAuthorizedPayment($request); $this->helper->logDebug('Capture Authorized Payment', $order, $request, $response); @@ -167,7 +174,7 @@ public function captureOrder( try { $request = [ 'id' => $id, - 'prefer' => self::PREFER_RETURN_REPRESENTATION + 'prefer' => self::PREFER_RETURN_REPRESENTATION, ]; $response = $this->getClient()->getOrdersController()->captureOrder($request); @@ -203,7 +210,7 @@ public function refundCapturedPayment( $request = [ 'captureId' => $captureId, 'prefer' => self::PREFER_RETURN_REPRESENTATION, - 'body' => $this->_buildRefundBody($amount, $currencyCode) + 'body' => $this->_buildRefundBody($amount, $currencyCode), ]; $response = $this->getClient()->getPaymentsController()->refundCapturedPayment($request); @@ -229,7 +236,7 @@ public function voidPayment(string $authorizationId, Mage_Sales_Model_Order $ord try { $request = [ 'authorizationId' => $authorizationId, - 'prefer' => self::PREFER_RETURN_REPRESENTATION + 'prefer' => self::PREFER_RETURN_REPRESENTATION, ]; $response = $this->getClient()->getPaymentsController()->voidPayment($request); @@ -280,8 +287,8 @@ private function _initializeClient(): void ->clientCredentialsAuthCredentials( ClientCredentialsAuthCredentialsBuilder::init( $credentials['client_id'], - $credentials['client_secret'] - ) + $credentials['client_secret'], + ), ) ->environment($environment) ->build(); @@ -367,8 +374,8 @@ private function _buildRefundBody(float $amount, string $currencyCode): array return [ 'amount' => [ 'value' => number_format($amount, 2, '.', ''), - 'currency_code' => $currencyCode - ] + 'currency_code' => $currencyCode, + ], ]; } diff --git a/app/code/core/Mage/Paypal/Model/Api/Exception.php b/app/code/core/Mage/Paypal/Model/Api/Exception.php index d7b13f473d1..281882d8dc5 100644 --- a/app/code/core/Mage/Paypal/Model/Api/Exception.php +++ b/app/code/core/Mage/Paypal/Model/Api/Exception.php @@ -1,4 +1,12 @@ _debugData; } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Paypal/Model/Api/Helper.php b/app/code/core/Mage/Paypal/Model/Api/Helper.php index 0753fb049c8..544f3973530 100644 --- a/app/code/core/Mage/Paypal/Model/Api/Helper.php +++ b/app/code/core/Mage/Paypal/Model/Api/Helper.php @@ -1,4 +1,12 @@ $message, - 'error' => $exception->getMessage() + 'error' => $exception->getMessage(), ]; if ($exception instanceof Mage_Paypal_Model_Exception) { diff --git a/app/code/core/Mage/Paypal/Model/Cart.php b/app/code/core/Mage/Paypal/Model/Cart.php index 3e95500e993..2db2e4d4676 100644 --- a/app/code/core/Mage/Paypal/Model/Cart.php +++ b/app/code/core/Mage/Paypal/Model/Cart.php @@ -1,15 +1,22 @@ __('Selected currency code (%s) is not supported by PayPal', $currentCurrency) + Mage::helper('paypal')->__('Selected currency code (%s) is not supported by PayPal', $currentCurrency), ); } $this->_currency = $currentCurrency; @@ -69,7 +76,7 @@ protected function _prepareItems() $qty = $item->getQty(); $moneyBuilder = MoneyBuilder::init( $this->_currency, - number_format($item->getCalculationPrice(), 2, '.', '') + number_format($item->getCalculationPrice(), 2, '.', ''), ); $taxMoneyBuilder = ($taxAmount > 0) @@ -100,20 +107,20 @@ protected function _prepareTotals() $this->_totals = [ self::TOTAL_SUBTOTAL => MoneyBuilder::init( $this->_currency, - number_format($this->_quote->getSubtotal(), 2, '.', '') + number_format($this->_quote->getSubtotal(), 2, '.', ''), )->build(), self::TOTAL_TAX => MoneyBuilder::init( $this->_currency, - number_format($shippingAddress->getTaxAmount() ?? 0, 2, '.', '') + number_format($shippingAddress->getTaxAmount() ?? 0, 2, '.', ''), )->build(), self::TOTAL_SHIPPING => MoneyBuilder::init( $this->_currency, - number_format($shippingAddress->getShippingAmount() ?? 0, 2, '.', '') + number_format($shippingAddress->getShippingAmount() ?? 0, 2, '.', ''), )->build(), self::TOTAL_DISCOUNT => MoneyBuilder::init( $this->_currency, - number_format($totalDiscount, 2, '.', '') - )->build() + number_format($totalDiscount, 2, '.', ''), + )->build(), ]; return $this; diff --git a/app/code/core/Mage/Paypal/Model/Config.php b/app/code/core/Mage/Paypal/Model/Config.php index 7e416554630..bd06b1cee4d 100644 --- a/app/code/core/Mage/Paypal/Model/Config.php +++ b/app/code/core/Mage/Paypal/Model/Config.php @@ -1,25 +1,32 @@ $this->getConfigData('client_id'), 'client_secret' => Mage::helper('core')->decrypt( - $this->getConfigData('client_secret') + $this->getConfigData('client_secret'), ), ]; } public function isDebugEnabled() { - return (bool)$this->getConfigData('debug'); + return (bool) $this->getConfigData('debug'); } public function isSandbox() { - return (bool)$this->getConfigData('sandbox_mode'); + return (bool) $this->getConfigData('sandbox_mode'); } public function getPaymentAction() @@ -91,7 +98,7 @@ public function getButtonConfiguration() 'color' => $this->getConfigData('button_color'), 'layout' => $this->getConfigData('button_layout'), 'label' => $this->getConfigData('button_label'), - 'message' => (bool)$this->getConfigData('button_message') + 'message' => (bool) $this->getConfigData('button_message'), ]; } @@ -103,7 +110,7 @@ public function getMerchantCountry() public function isActive($store = null) { - return (bool)$this->getConfigData('active', $store); + return (bool) $this->getConfigData('active', $store); } public function getAllowedCurrencyCodes() diff --git a/app/code/core/Mage/Paypal/Model/Debug.php b/app/code/core/Mage/Paypal/Model/Debug.php index a9213e4e34c..df15b6b3357 100644 --- a/app/code/core/Mage/Paypal/Model/Debug.php +++ b/app/code/core/Mage/Paypal/Model/Debug.php @@ -1,4 +1,12 @@ false, - 'error' => $e->getMessage() + 'error' => $e->getMessage(), ]; } } /** * Capture PayPal payment via API - * + * * @param string $orderId PayPal order ID * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote * @throws Mage_Core_Exception @@ -110,13 +112,13 @@ public function captureOrder(string $orderId, Mage_Sales_Model_Quote|Mage_Sales_ $this->_handleApiError($response, 'Capture failed'); } $captureId = $this->_extractCaptureId($result); - $this->_updatePaymentAfterCapture($quote->getPayment(), $response, $captureId); + $this->_updatePaymentAfterCapture($quote->getPayment(), $response, $captureId); $quote->collectTotals()->save(); } /** * Authorize PayPal payment via API - * + * * @param string $orderId PayPal order ID * @param Mage_Sales_Model_Quote $quote * @throws Mage_Core_Exception @@ -140,7 +142,7 @@ public function authorizePayment(string $orderId, Mage_Sales_Model_Quote $quote) /** * Reauthorize a payment after the initial authorization has expired - * + * * @param string $orderId PayPal order ID * @param Mage_Sales_Model_Order $order Magento order * @return array{success: bool, authorization_id?: string, error?: string} @@ -165,7 +167,7 @@ public function reauthorizePayment(string $orderId, Mage_Sales_Model_Order $orde self::PAYPAL_PAYMENT_STATUS => $authorization->getStatus(), self::PAYPAL_PAYMENT_AUTHORIZATION_ID => $authorizationId, self::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME => $expirationTime, - Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->_prepareRawDetails($response->getBody()) + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->_prepareRawDetails($response->getBody()), ])->getShouldCloseParentTransaction(); $payment->save(); @@ -176,7 +178,7 @@ public function reauthorizePayment(string $orderId, Mage_Sales_Model_Order $orde ->setIsClosed(0) ->setAdditionalInformation( Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->_prepareRawDetails($response->getBody()) + $this->_prepareRawDetails($response->getBody()), ); $transaction->save(); @@ -188,20 +190,20 @@ public function reauthorizePayment(string $orderId, Mage_Sales_Model_Order $orde Mage::helper('paypal')->__( 'PayPal payment has been reauthorized. New authorization ID: %s. Expires on: %s', $authorizationId, - $date->format('Y-m-d H:i:s') + $date->format('Y-m-d H:i:s'), ), - false + false, )->save(); return [ 'success' => true, - 'authorization_id' => $authorizationId + 'authorization_id' => $authorizationId, ]; } catch (Exception $e) { Mage::logException($e); return [ 'success' => false, - 'error' => $e->getMessage() + 'error' => $e->getMessage(), ]; } } @@ -217,7 +219,7 @@ public function validate(): static /** * Refund payment method - * + * * @param Varien_Object $payment Payment object * @param float $amount Refund amount * @return static @@ -227,13 +229,13 @@ public function refund(Varien_Object $payment, $amount): static { try { if (is_string($amount)) { - $amount = (float)$amount; + $amount = (float) $amount; } $response = $this->_getApi()->refundCapturedPayment( $payment->getParentTransactionId(), $amount, $payment->getOrder()->getOrderCurrencyCode(), - $payment->getOrder() + $payment->getOrder(), ); if ($response->isError()) { @@ -246,7 +248,7 @@ public function refund(Varien_Object $payment, $amount): static } catch (Exception $e) { Mage::logException($e); throw new Mage_Core_Exception( - Mage::helper('paypal')->__('Refund error: %s', $e->getMessage()) + Mage::helper('paypal')->__('Refund error: %s', $e->getMessage()), ); } @@ -255,7 +257,7 @@ public function refund(Varien_Object $payment, $amount): static /** * Capture payment method - * + * * @param Varien_Object $payment Payment object * @param float $amount Capture amount * @return static @@ -274,7 +276,7 @@ public function capture(Varien_Object $payment, $amount): static if (!$authorizationId) { throw new Mage_Core_Exception( - Mage::helper('paypal')->__(self::ERROR_NO_AUTHORIZATION_ID) + Mage::helper('paypal')->__(self::ERROR_NO_AUTHORIZATION_ID), ); } @@ -293,7 +295,7 @@ public function capture(Varien_Object $payment, $amount): static /** * Void payment method - * + * * @param Varien_Object $payment Payment object * @return static * @throws Mage_Core_Exception @@ -316,12 +318,12 @@ public function void(Varien_Object $payment): static $this->_createVoidTransaction($payment, $response); $payment->getOrder()->addStatusHistoryComment( Mage::helper('paypal')->__('PayPal payment voided successfully. Transaction ID: %s', $transactionId), - false + false, )->save(); } catch (Exception $e) { Mage::logException($e); throw new Mage_Core_Exception( - Mage::helper('paypal')->__('Void error: %s', $e->getMessage()) + Mage::helper('paypal')->__('Void error: %s', $e->getMessage()), ); } @@ -330,7 +332,7 @@ public function void(Varien_Object $payment): static /** * Cancel payment method - * + * * @param Varien_Object $payment Payment object * @return static * @throws Mage_Core_Exception @@ -346,7 +348,7 @@ public function cancel(Varien_Object $payment): static /** * Check if payment method is available - * + * * @param Mage_Sales_Model_Quote|null $quote * @return bool */ @@ -371,7 +373,7 @@ private function _getApi(): Mage_Paypal_Model_Api /** * Handle API error response - * + * * @param ApiResponse $response API response * @param string $defaultMessage Default error message * @throws Mage_Core_Exception @@ -392,7 +394,7 @@ private function _getQuote(): Mage_Sales_Model_Quote /** * Validate quote for PayPal payment processing - * + * * @param Mage_Sales_Model_Quote $quote * @throws Mage_Core_Exception */ @@ -402,14 +404,14 @@ private function _validateQuoteForPayment(Mage_Sales_Model_Quote $quote): void if (!$quote->getGrandTotal() && !$quote->hasNominalItems()) { throw new Mage_Core_Exception( - Mage::helper('paypal')->__(self::ERROR_ZERO_AMOUNT) + Mage::helper('paypal')->__(self::ERROR_ZERO_AMOUNT), ); } } /** * Update payment object with PayPal order information - * + * * @param Mage_Sales_Model_Quote_Payment $payment * @param ApiResponse $response */ @@ -419,14 +421,14 @@ private function _updatePaymentWithOrderInfo(Mage_Sales_Model_Quote_Payment $pay $payment->setPaypalCorrelationId($result->getId()) ->setAdditionalInformation( Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->_prepareRawDetails($response->getBody()) + $this->_prepareRawDetails($response->getBody()), ) ->save(); } /** * Build a purchase unit using PayPal SDK builders - * + * * @param Mage_Sales_Model_Quote $quote * @param string|null $referenceId Optional reference ID * @return object The built purchase unit object @@ -461,24 +463,24 @@ private function _buildPurchaseUnit(Mage_Sales_Model_Quote $quote, ?string $refe if ($taxDifference < 0) { if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_TAX])) { $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->setValue( - number_format($taxCalculated, 2, '.', '') + number_format($taxCalculated, 2, '.', ''), ); } if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT])) { $totalDiscount = (float) $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]->getValue(); $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]->setValue( - number_format(abs($taxDifference) + $totalDiscount, 2, '.', '') + number_format(abs($taxDifference) + $totalDiscount, 2, '.', ''), ); } else { $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT] = MoneyBuilder::init( $currency, - number_format(abs($taxDifference), 2, '.', '') + number_format(abs($taxDifference), 2, '.', ''), )->build(); } } else { $moneyBuilder = MoneyBuilder::init( $currency, - number_format(abs($taxDifference), 2, '.', '') + number_format(abs($taxDifference), 2, '.', ''), ); $itemBuilder = ItemBuilder::init(Mage::helper('paypal')->__('Rounding'), $moneyBuilder->build(), '1') ->sku(Mage::helper('paypal')->__('Rounding')) @@ -486,7 +488,7 @@ private function _buildPurchaseUnit(Mage_Sales_Model_Quote $quote, ?string $refe $items[] = $itemBuilder->build(); if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_TAX])) { $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->setValue( - number_format($taxCalculated, 2, '.', '') + number_format($taxCalculated, 2, '.', ''), ); } } @@ -496,14 +498,14 @@ private function _buildPurchaseUnit(Mage_Sales_Model_Quote $quote, ?string $refe if (!empty($items)) { $purchaseUnitBuilder->items($items); } - $purchaseUnitBuilder->referenceId($referenceId ?: (string)$quote->getId()); - $purchaseUnitBuilder->invoiceId($referenceId ?: (string)$quote->getId()); + $purchaseUnitBuilder->referenceId($referenceId ?: (string) $quote->getId()); + $purchaseUnitBuilder->invoiceId($referenceId ?: (string) $quote->getId()); return $purchaseUnitBuilder->build(); } /** * Build amount breakdown from cart totals - * + * * @param array $totals Cart totals * @return object Built breakdown object */ @@ -535,7 +537,7 @@ private function _buildAmountBreakdown(array $totals): object /** * Build amount with breakdown - * + * * @param string $currency * @param float $totalAmount * @param object $breakdown Built breakdown object @@ -552,7 +554,7 @@ private function _buildAmountWithBreakdown(string $currency, float $totalAmount, /** * Build a complete PayPal order request using SDK builders - * + * * @param Mage_Sales_Model_Quote $quote * @param string|null $referenceId Optional reference ID * @return object The built order request object @@ -562,7 +564,7 @@ private function _buildOrderRequest(Mage_Sales_Model_Quote $quote, ?string $refe $purchaseUnit = $this->_buildPurchaseUnit($quote, $referenceId); $orderRequestBuilder = OrderRequestBuilder::init( $this->_getPaymentIntent(), - [$purchaseUnit] + [$purchaseUnit], ); $payer = $this->_buildPayerFromBillingAddress($quote); @@ -575,7 +577,7 @@ private function _buildOrderRequest(Mage_Sales_Model_Quote $quote, ?string $refe /** * Build payer object from billing address - * + * * @param Mage_Sales_Model_Quote $quote * @return object|null */ @@ -626,7 +628,7 @@ private function _getPaymentIntent(): string /** * Extract capture ID from API result - * + * * @param mixed $result API result * @return string|null */ @@ -656,7 +658,7 @@ private function _extractCaptureId(mixed $result): ?string /** * Update payment object after successful capture - * + * * @param Mage_Sales_Model_Quote_Payment|Mage_Sales_Model_Order_Payment $payment * @param ApiResponse $response API result * @param string $orderId PayPal order ID @@ -674,7 +676,7 @@ private function _updatePaymentAfterCapture( ->setIsTransactionClosed(true) ->setAdditionalInformation( Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->_prepareRawDetails($response->getBody()) + $this->_prepareRawDetails($response->getBody()), ); $paymentSource = $result->getPaymentSource(); if ($paymentSource->getPaypal() instanceof PaypalWalletResponse) { @@ -688,7 +690,7 @@ private function _updatePaymentAfterCapture( /** * Update payment object after successful authorization - * + * * @param Mage_Sales_Model_Quote_Payment $payment * @param ApiResponse $response API result */ @@ -708,14 +710,14 @@ private function _updatePaymentAfterAuthorization(Mage_Sales_Model_Quote_Payment self::PAYPAL_PAYMENT_STATUS => $authorization->getStatus(), self::PAYPAL_PAYMENT_AUTHORIZATION_ID => $authorization->getId(), self::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME => $authorization->getExpirationTime(), - Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->_prepareRawDetails($response->getBody()) + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->_prepareRawDetails($response->getBody()), ]); $payment->save(); } /** * Add order status comment - * + * * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote * @param string $action Action performed (captured, authorized, etc.) * @param string|null $transactionId Transaction ID @@ -734,14 +736,14 @@ private function _addOrderComment( $quote->addStatusHistoryComment( Mage::helper('paypal')->__($message, $transactionId), - false + false, ); } } /** * Update payment after refund - * + * * @param Varien_Object $payment Payment object * @param Refund $result API result */ @@ -755,7 +757,7 @@ private function _updatePaymentAfterRefund(Varien_Object $payment, Refund $resul /** * Create refund transaction record - * + * * @param Varien_Object $payment Payment object * @param ApiResponse $response API result * @param float $amount Refund amount @@ -771,7 +773,7 @@ private function _createRefundTransaction(Varien_Object $payment, ApiResponse $r ->setIsClosed(1) ->setAdditionalInformation( Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->_prepareRawDetails($response->getBody()) + $this->_prepareRawDetails($response->getBody()), ); $transaction->save(); @@ -779,7 +781,7 @@ private function _createRefundTransaction(Varien_Object $payment, ApiResponse $r /** * Update payment after authorized capture - * + * * @param Varien_Object $payment Payment object * @param ApiResponse $response * @param string $authorizationId Authorization ID @@ -794,13 +796,13 @@ private function _updatePaymentAfterAuthorizedCapture(Varien_Object $payment, Ap ->setShouldCloseParentTransaction(true) ->setAdditionalInformation( Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->_prepareRawDetails($response->getBody()) + $this->_prepareRawDetails($response->getBody()), ); } /** * Create capture transaction record - * + * * @param Varien_Object $payment Payment object * @param ApiResponse $response * @param string $authorizationId Authorization ID @@ -816,7 +818,7 @@ private function _createCaptureTransaction(Varien_Object $payment, ApiResponse $ ->setIsClosed(1) ->setAdditionalInformation( Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->_prepareRawDetails($response->getBody()) + $this->_prepareRawDetails($response->getBody()), ); $transaction->save(); @@ -824,7 +826,7 @@ private function _createCaptureTransaction(Varien_Object $payment, ApiResponse $ /** * Update payment after void - * + * * @param Varien_Object $payment Payment object */ private function _updatePaymentAfterVoid(Varien_Object $payment): void @@ -836,7 +838,7 @@ private function _updatePaymentAfterVoid(Varien_Object $payment): void /** * Create void transaction record - * + * * @param Varien_Object $payment Payment object * @param ApiResponse $response API response */ @@ -851,7 +853,7 @@ private function _createVoidTransaction(Varien_Object $payment, ApiResponse $res ->setIsClosed(1) ->setAdditionalInformation( Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->_prepareRawDetails($response->getBody()) + $this->_prepareRawDetails($response->getBody()), ); $transaction->save(); @@ -864,7 +866,7 @@ private function _createVoidTransaction(Varien_Object $payment, ApiResponse $res /** * Handle multishipping notification - * + * * @param Mage_Sales_Model_Quote|null $quote */ private function _handleMultishippingNotification(?Mage_Sales_Model_Quote $quote): void @@ -875,15 +877,15 @@ private function _handleMultishippingNotification(?Mage_Sales_Model_Quote $quote ) { Mage::getSingleton('core/session')->addNotice( Mage::helper('paypal')->__( - 'PayPal will process multishipping orders as immediate capture regardless of your authorization setting.' - ) + 'PayPal will process multishipping orders as immediate capture regardless of your authorization setting.', + ), ); } } /** * Extract error message from API response - * + * * @param ApiResponse $response API response * @param string $defaultMessage Default error message * @return string @@ -902,7 +904,7 @@ private function _extractErrorMessage(ApiResponse $response, string $defaultMess /** * Prepare raw details for storage - * + * * @param string $details JSON details object * @return array */ @@ -914,7 +916,7 @@ private function _prepareRawDetails(string $details): array } return array_map( fn($v) => is_array($v) ? json_encode($v) : $v, - $decoded ?? [] + $decoded ?? [], ); } } diff --git a/app/code/core/Mage/Paypal/Model/Resource/Debug.php b/app/code/core/Mage/Paypal/Model/Resource/Debug.php index fed1894fba0..82cacc2270b 100644 --- a/app/code/core/Mage/Paypal/Model/Resource/Debug.php +++ b/app/code/core/Mage/Paypal/Model/Resource/Debug.php @@ -1,9 +1,17 @@ _init('paypal/debug', 'entity_id'); } - + } diff --git a/app/code/core/Mage/Paypal/Model/Resource/Debug/Collection.php b/app/code/core/Mage/Paypal/Model/Resource/Debug/Collection.php index 02d2998e71e..0cf43a12a32 100644 --- a/app/code/core/Mage/Paypal/Model/Resource/Debug/Collection.php +++ b/app/code/core/Mage/Paypal/Model/Resource/Debug/Collection.php @@ -1,4 +1,12 @@ Mage_Paypal_Model_Config::BUTTON_COLOR_GOLD, - 'label' => Mage::helper('paypal')->__('Gold') + 'label' => Mage::helper('paypal')->__('Gold'), ], [ 'value' => Mage_Paypal_Model_Config::BUTTON_COLOR_BLUE, - 'label' => Mage::helper('paypal')->__('Blue') + 'label' => Mage::helper('paypal')->__('Blue'), ], [ 'value' => Mage_Paypal_Model_Config::BUTTON_COLOR_SILVER, - 'label' => Mage::helper('paypal')->__('Silver') + 'label' => Mage::helper('paypal')->__('Silver'), ], [ 'value' => Mage_Paypal_Model_Config::BUTTON_COLOR_WHITE, - 'label' => Mage::helper('paypal')->__('White') + 'label' => Mage::helper('paypal')->__('White'), ], [ 'value' => Mage_Paypal_Model_Config::BUTTON_COLOR_BLACK, - 'label' => Mage::helper('paypal')->__('Black') - ] + 'label' => Mage::helper('paypal')->__('Black'), + ], ]; } } diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLabels.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLabels.php index 137e3d32774..edc1f8f0f62 100644 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLabels.php +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLabels.php @@ -1,4 +1,12 @@ Mage_Paypal_Model_Config::BUTTON_LABEL_PAYPAL, - 'label' => Mage::helper('paypal')->__('PayPal (Recommended)') + 'label' => Mage::helper('paypal')->__('PayPal (Recommended)'), ], [ 'value' => Mage_Paypal_Model_Config::BUTTON_LABEL_CHECKOUT, - 'label' => Mage::helper('paypal')->__('Checkout') + 'label' => Mage::helper('paypal')->__('Checkout'), ], [ 'value' => Mage_Paypal_Model_Config::BUTTON_LABEL_BUYNOW, - 'label' => Mage::helper('paypal')->__('Buy Now') + 'label' => Mage::helper('paypal')->__('Buy Now'), ], [ 'value' => Mage_Paypal_Model_Config::BUTTON_LABEL_PAY, - 'label' => Mage::helper('paypal')->__('Pay with PayPal') + 'label' => Mage::helper('paypal')->__('Pay with PayPal'), ], [ 'value' => Mage_Paypal_Model_Config::BUTTON_LABEL_INSTALLMENT, - 'label' => Mage::helper('paypal')->__('PayPal Installment') - ] + 'label' => Mage::helper('paypal')->__('PayPal Installment'), + ], ]; } } diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLayouts.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLayouts.php index 25279a39498..a2728921f4b 100644 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLayouts.php +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonLayouts.php @@ -1,4 +1,12 @@ Mage_Paypal_Model_Config::BUTTON_LAYOUT_VERTICAL, - 'label' => Mage::helper('paypal')->__('Vertical') + 'label' => Mage::helper('paypal')->__('Vertical'), ], [ 'value' => Mage_Paypal_Model_Config::BUTTON_LAYOUT_HORIZONTAL, - 'label' => Mage::helper('paypal')->__('Horizontal') - ] + 'label' => Mage::helper('paypal')->__('Horizontal'), + ], ]; } } diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonShapes.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonShapes.php index f23fb08f50a..a96cf9ca820 100644 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonShapes.php +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonShapes.php @@ -1,4 +1,12 @@ Mage_Paypal_Model_Config::BUTTON_SHAPE_RECT, - 'label' => Mage::helper('paypal')->__('Rectangle') + 'label' => Mage::helper('paypal')->__('Rectangle'), ], [ 'value' => Mage_Paypal_Model_Config::BUTTON_SHAPE_PILL, - 'label' => Mage::helper('paypal')->__('Pill') + 'label' => Mage::helper('paypal')->__('Pill'), ], [ 'value' => Mage_Paypal_Model_Config::BUTTON_SHAPE_SHARP, - 'label' => Mage::helper('paypal')->__('Sharp') - ] + 'label' => Mage::helper('paypal')->__('Sharp'), + ], ]; } } diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php index e4a7385b3ab..206ea9b445b 100644 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php @@ -1,4 +1,12 @@ toOptionArray(false); - + // Filter to only PayPal supported countries $supportedCountries = [ 'AU', // Australia @@ -58,9 +66,9 @@ public function toOptionArray() 'US', // United States 'VN', // Vietnam ]; - - return array_filter($countries, function($country) use ($supportedCountries) { + + return array_filter($countries, function ($country) use ($supportedCountries) { return in_array($country['value'], $supportedCountries); }); } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions.php index e1513abf105..221e91e7538 100644 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions.php +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions.php @@ -1,21 +1,27 @@ strtolower(CheckoutPaymentIntent::AUTHORIZE), - 'label' => Mage::helper('paypal')->__('Authorize') + 'label' => Mage::helper('paypal')->__('Authorize'), ], [ 'value' => strtolower(CheckoutPaymentIntent::CAPTURE), - 'label' => Mage::helper('paypal')->__('Capture') - ] + 'label' => Mage::helper('paypal')->__('Capture'), + ], ]; } } diff --git a/app/code/core/Mage/Paypal/Model/Validator/Api.php b/app/code/core/Mage/Paypal/Model/Validator/Api.php index 5ca6ffab140..1e4b778e14d 100644 --- a/app/code/core/Mage/Paypal/Model/Validator/Api.php +++ b/app/code/core/Mage/Paypal/Model/Validator/Api.php @@ -1,4 +1,12 @@ isSuccess()) { $message = 'PayPal API Error: ' . $response->getError(); Mage::log($message, Zend_Log::ERR, 'paypal.log', true); - + if (Mage::getStoreConfigFlag('payment/paypal/debug')) { $quote = $order->getQuote(); $quoteId = $quote ? $quote->getId() : $order->getQuoteId(); - + Mage::getModel('paypal/debug')->log( $quoteId, 'validation_error', 'Validation Error', $response->getError(), null, - null + null, ); } - + throw new Mage_Paypal_Model_Exception($message); } return true; diff --git a/app/code/core/Mage/Paypal/Model/Validator/Payment.php b/app/code/core/Mage/Paypal/Model/Validator/Payment.php index 236448c5a43..3e271d820e0 100644 --- a/app/code/core/Mage/Paypal/Model/Validator/Payment.php +++ b/app/code/core/Mage/Paypal/Model/Validator/Payment.php @@ -1,4 +1,12 @@ $epsilon) { $message = 'Total amount mismatch'; - Mage::log($message . sprintf(' (calculated: %s, order: %s)', - $calculatedTotal, - $orderTotal + Mage::log($message . sprintf( + ' (calculated: %s, order: %s)', + $calculatedTotal, + $orderTotal, ), Zend_Log::ERR, 'paypal.log', true); throw new Mage_Paypal_Model_Exception($message); } diff --git a/app/code/core/Mage/Paypal/Model/Webhook/Log.php b/app/code/core/Mage/Paypal/Model/Webhook/Log.php index 07084251417..2bdf2c5386d 100644 --- a/app/code/core/Mage/Paypal/Model/Webhook/Log.php +++ b/app/code/core/Mage/Paypal/Model/Webhook/Log.php @@ -1,4 +1,12 @@ getResource()->clean($days); return $this; } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/DebugController.php b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/DebugController.php index 1bc5b5c23f4..f4e6fba56e3 100644 --- a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/DebugController.php +++ b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/DebugController.php @@ -1,4 +1,12 @@ _setActiveMenu('report/paypal/debug') ->_addBreadcrumb( Mage::helper('paypal')->__('Reports'), - Mage::helper('paypal')->__('PayPal Debug Log') + Mage::helper('paypal')->__('PayPal Debug Log'), ); return $this; } @@ -23,7 +31,7 @@ public function gridAction() { $this->loadLayout(); $this->getResponse()->setBody( - $this->getLayout()->createBlock('paypal/adminhtml_debug_grid')->toHtml() + $this->getLayout()->createBlock('paypal/adminhtml_debug_grid')->toHtml(), ); } @@ -38,7 +46,7 @@ public function massDeleteAction() Mage::getModel('paypal/debug')->load($debugId)->delete(); } $this->_getSession()->addSuccess( - $this->__('Total of %d record(s) have been deleted.', count($debugIds)) + $this->__('Total of %d record(s) have been deleted.', count($debugIds)), ); } catch (Exception $e) { $this->_getSession()->addError($e->getMessage()); diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php index 7ba82da0dad..cf672e20883 100644 --- a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php +++ b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php @@ -1,28 +1,10 @@ isAllowedGuestCheckout( $this->_getQuote(), - $this->_getQuote()->getStoreId() + $this->_getQuote()->getStoreId(), ) ) { Mage::getSingleton('core/session')->addNotice( - Mage::helper('paypal')->__('To proceed to Checkout, please log in using your email address.') + Mage::helper('paypal')->__('To proceed to Checkout, please log in using your email address.'), ); $this->_redirectLogin(); Mage::getSingleton('customer/session') @@ -83,7 +90,7 @@ public function createAction() ->setHeader('Content-Type', 'application/json') ->setBody(Mage::helper('core')->jsonEncode([ 'success' => false, - 'error' => $e->getMessage() + 'error' => $e->getMessage(), ])); } } @@ -112,7 +119,7 @@ public function processAction() $this->getResponse() ->setHeader('Content-Type', 'application/json')->setBody(Mage::helper('core')->jsonEncode([ - 'success' => true + 'success' => true, ])); } catch (Exception $e) { Mage::logException($e); @@ -120,7 +127,7 @@ public function processAction() $this->getResponse() ->setHeader('Content-Type', 'application/json')->setBody(Mage::helper('core')->jsonEncode([ 'success' => false, - 'message' => $e->getMessage() + 'message' => $e->getMessage(), ])); } } @@ -190,17 +197,17 @@ public function placeOrderAction() $order->addStatusHistoryComment( Mage::helper('paypal')->__('Paypal payment has been authorized, capture is required before date ' . $date->format('Y-m-d H:i:s')), - false + false, ); $order->setState( Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, true, - Mage::helper('paypal')->__('Payment has been authorized. Capture is required.') + Mage::helper('paypal')->__('Payment has been authorized. Capture is required.'), )->save(); } else { $order->addStatusHistoryComment( Mage::helper('paypal')->__('PayPal payment captured successfully. Capture ID: %s', $transaction->getTxnId()), - false + false, ); $transaction->setOrderPaymentObject($orderPayment) ->setTxnId($quotePayment->getPaypalCorrelationId()) @@ -459,8 +466,8 @@ protected function _redirectLogin() $this->getResponse()->setRedirect( Mage::helper('core/url')->addRequestParam( Mage::helper('customer')->getLoginUrl(), - ['context' => 'checkout'] - ) + ['context' => 'checkout'], + ), ); } @@ -476,7 +483,7 @@ protected function _involveNewCustomer() $customer->sendNewAccountEmail('confirmation', '', $this->_quote->getStoreId()); $url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail()); $this->getCustomerSession()->addSuccess( - Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please click here.', $url) + Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please click here.', $url), ); } else { $customer->sendNewAccountEmail('registered', '', $this->_quote->getStoreId()); diff --git a/app/code/core/Mage/Paypal/etc/adminhtml.xml b/app/code/core/Mage/Paypal/etc/adminhtml.xml index c8d30fe5e87..fa0fa3ce0f7 100644 --- a/app/code/core/Mage/Paypal/etc/adminhtml.xml +++ b/app/code/core/Mage/Paypal/etc/adminhtml.xml @@ -1,4 +1,12 @@ + diff --git a/app/code/core/Mage/Paypal/etc/system.xml b/app/code/core/Mage/Paypal/etc/system.xml index 2d6aa37ef2e..76b85ea5719 100644 --- a/app/code/core/Mage/Paypal/etc/system.xml +++ b/app/code/core/Mage/Paypal/etc/system.xml @@ -3,7 +3,7 @@ /** * @copyright For copyright and license information, read the COPYING.txt file. * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) + * @license Open Software License (OSL 3.0) * @package Mage_Paypal */ --> diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php b/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php index b56c549e24c..c013099e30a 100644 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php +++ b/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php @@ -1,5 +1,12 @@ addIndex( $installer->getIdxName('paypal/debug', ['quote_id']), - ['quote_id'] + ['quote_id'], ) ->addIndex( $installer->getIdxName('paypal/debug', ['increment_id']), - ['increment_id'] + ['increment_id'], ) ->addForeignKey( $installer->getFkName('paypal/debug', 'quote_id', 'sales/quote', 'entity_id'), @@ -61,7 +68,7 @@ $installer->getTable('sales/quote'), 'entity_id', Varien_Db_Ddl_Table::ACTION_CASCADE, - Varien_Db_Ddl_Table::ACTION_CASCADE + Varien_Db_Ddl_Table::ACTION_CASCADE, ) ->addForeignKey( $installer->getFkName('paypal/debug', 'increment_id', 'sales/order', 'increment_id'), @@ -69,14 +76,14 @@ $installer->getTable('sales/order'), 'increment_id', Varien_Db_Ddl_Table::ACTION_SET_NULL, - Varien_Db_Ddl_Table::ACTION_NO_ACTION + Varien_Db_Ddl_Table::ACTION_NO_ACTION, ) ->setComment('PayPal Debug Table'); $installer->getConnection()->createTable($debugTable); $installer->getConnection()->delete( $installer->getTable('core_resource'), - $installer->getConnection()->quoteInto('code = ?', 'paypaluk_setup') + $installer->getConnection()->quoteInto('code = ?', 'paypaluk_setup'), ); $installer->getConnection()->delete( @@ -170,8 +177,8 @@ 'paypal/style/paypal_hdrbordercolor', 'paypal/style/paypal_payflowcolor', 'paypal/wpp/button_flavor', - 'paypal/general/business_account' - ]) + 'paypal/general/business_account', + ]), ); $installer->endSetup(); diff --git a/app/design/adminhtml/default/default/template/paypal/info.phtml b/app/design/adminhtml/default/default/template/paypal/info.phtml index bcb960f7b9f..aab6ae4e2df 100644 --- a/app/design/adminhtml/default/default/template/paypal/info.phtml +++ b/app/design/adminhtml/default/default/template/paypal/info.phtml @@ -1,4 +1,10 @@ Learn more about PayPal API credentials","Enter your PayPal REST API Client ID.Learn more about PayPal API credentials" +"Enter your PayPal REST API Client Secret.Learn more about PayPal API credentials","Enter your PayPal REST API Client Secret.Learn more about PayPal API credentials" +"Exception","Exception" +"Failed to reauthorize payment","Failed to reauthorize payment" +"Gold","Gold" +"Horizontal","Horizontal" +"If not specified, Default Country from General Config will be used","If not specified, Default Country from General Config will be used" +"If you want to use PayPal Express Checkout, you must complete the settings below.","If you want to use PayPal Express Checkout, you must complete the settings below." +"Invalid form key","Invalid form key" +"Order ID is required","Order ID is required" +"Order not found","Order not found" +"Pay with PayPal","Pay with PayPal" +"PayPal","PayPal" +"PayPal (Recommended)","PayPal (Recommended)" +"PayPal Debug Log","PayPal Debug Log" +"PayPal Installment","PayPal Installment" +"PayPal Settings","PayPal Settings" +"PayPal authorizations expire after 3 days. Reauthorize to extend the authorization period.","PayPal authorizations expire after 3 days. Reauthorize to extend the authorization period." +"PayPal payment captured successfully. Capture ID: %s","PayPal payment captured successfully. Capture ID: %s" +"PayPal payment has been reauthorized. New authorization ID: %s. Expires on: %s","PayPal payment has been reauthorized. New authorization ID: %s. Expires on: %s" +"PayPal payment voided successfully. Transaction ID: %s","PayPal payment voided successfully. Transaction ID: %s" +"PayPal will process multishipping orders as immediate capture regardless of your authorization setting.","PayPal will process multishipping orders as immediate capture regardless of your authorization setting." +"Payment has been authorized. Capture is required.","Payment has been authorized. Capture is required." +"Payment has been successfully reauthorized. New authorization ID: %s","Payment has been successfully reauthorized. New authorization ID: %s" +"Paypal payment has been authorized, capture is required before date","Paypal payment has been authorized, capture is required before date" +"Pill","Pill" +"Please select log(s) to delete.","Please select log(s) to delete." +"Quote #","Quote #" +"Reauthorize Payment","Reauthorize Payment" +"Rectangle","Rectangle" +"Refund error: %s","Refund error: %s" +"Request","Request" +"Response","Response" +"Rounding","Rounding" +"Select whether to authorize or capture the payment immediately. Note: Authorization is not supported for multishipping orders and will automatically use capture instead.When using Authorize, funds are reserved for up to 29 days, but it's best to capture within 3 days.","Select whether to authorize or capture the payment immediately. Note: Authorization is not supported for multishipping orders and will automatically use capture instead.When using Authorize, funds are reserved for up to 29 days, but it's best to capture within 3 days." +"Selected currency code (%s) is not supported by PayPal","Selected currency code (%s) is not supported by PayPal" +"Sharp","Sharp" +"Silver","Silver" +"This order does not have a PayPal authorization","This order does not have a PayPal authorization" +"This order was not placed using PayPal","This order was not placed using PayPal" +"Transaction ID: %s","Transaction ID: %s" +"Vertical","Vertical" +"Void error: %s","Void error: %s" +"White","White" diff --git a/js/paypal/payment.js b/js/paypal/payment.js index 7ead7be14c9..4c8eb5035a8 100644 --- a/js/paypal/payment.js +++ b/js/paypal/payment.js @@ -1,3 +1,17 @@ + +/** + * OpenMage + * + * This source file is subject to the Academic Free License (AFL 3.0) + * that is bundled with this package in the file LICENSE_AFL.txt. + * It is also available at https://opensource.org/license/afl-3-0-php + * + * @category Varien + * @package js + * @copyright Copyright (c) 2022-2025 The OpenMage Contributors (https://www.openmage.org) + * @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) + */ + /** * Optimized PayPal payment integration */ From 5fa5e58f6f7a551a90bee2de40facaee862c51a0 Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Sun, 22 Jun 2025 00:56:26 +0200 Subject: [PATCH 06/40] fix: update meta files --- .phpstorm.meta.php/magento_blocks.meta.php | 60 +- .../magento_blocks_methods.meta.php | 60 +- .phpstorm.meta.php/magento_helpers.meta.php | 7 +- .../magento_helpers_methods.meta.php | 112 ++- .phpstorm.meta.php/magento_models.meta.php | 170 +--- .../magento_models_methods.meta.php | 765 +++++------------- .../magento_resource_models.meta.php | 16 +- .../magento_resource_models_methods.meta.php | 8 +- 8 files changed, 327 insertions(+), 871 deletions(-) diff --git a/.phpstorm.meta.php/magento_blocks.meta.php b/.phpstorm.meta.php/magento_blocks.meta.php index c1af1bf09b2..72af9f9d38a 100644 --- a/.phpstorm.meta.php/magento_blocks.meta.php +++ b/.phpstorm.meta.php/magento_blocks.meta.php @@ -588,6 +588,7 @@ 'adminhtml/system_config_form' => \Mage_Adminhtml_Block_System_Config_Form::class, 'adminhtml/system_config_form_field' => \Mage_Adminhtml_Block_System_Config_Form_Field::class, 'adminhtml/system_config_form_field_array_abstract' => \Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract::class, + 'adminhtml/system_config_form_field_csp_hosts' => \Mage_Adminhtml_Block_System_Config_Form_Field_Csp_Hosts::class, 'adminhtml/system_config_form_field_datetime' => \Mage_Adminhtml_Block_System_Config_Form_Field_Datetime::class, 'adminhtml/system_config_form_field_export' => \Mage_Adminhtml_Block_System_Config_Form_Field_Export::class, 'adminhtml/system_config_form_field_file' => \Mage_Adminhtml_Block_System_Config_Form_Field_File::class, @@ -968,6 +969,8 @@ 'core/text_tag_debug' => \Mage_Core_Block_Text_Tag_Debug::class, 'core/text_tag_js' => \Mage_Core_Block_Text_Tag_Js::class, 'core/text_tag_meta' => \Mage_Core_Block_Text_Tag_Meta::class, + 'csp/adminhtml_meta' => \Mage_Csp_Block_Adminhtml_Meta::class, + 'csp/meta' => \Mage_Csp_Block_Meta::class, 'currencysymbol/adminhtml_system_currencysymbol' => \Mage_CurrencySymbol_Block_Adminhtml_System_Currencysymbol::class, 'customer/account' => \Mage_Customer_Block_Account::class, 'customer/account_changeforgotten' => \Mage_Customer_Block_Account_Changeforgotten::class, @@ -1105,53 +1108,18 @@ 'payment/info_checkmo' => \Mage_Payment_Block_Info_Checkmo::class, 'payment/info_container' => \Mage_Payment_Block_Info_Container::class, 'payment/info_purchaseorder' => \Mage_Payment_Block_Info_Purchaseorder::class, - 'paypaluk/bml_form' => \Mage_PaypalUk_Block_Bml_Form::class, - 'paypaluk/express_form' => \Mage_PaypalUk_Block_Express_Form::class, - 'paypaluk/express_shortcut' => \Mage_PaypalUk_Block_Express_Shortcut::class, - 'paypal/adminhtml_settlement_details' => \Mage_Paypal_Block_Adminhtml_Settlement_Details::class, - 'paypal/adminhtml_settlement_details_form' => \Mage_Paypal_Block_Adminhtml_Settlement_Details_Form::class, - 'paypal/adminhtml_settlement_report' => \Mage_Paypal_Block_Adminhtml_Settlement_Report::class, - 'paypal/adminhtml_settlement_report_grid' => \Mage_Paypal_Block_Adminhtml_Settlement_Report_Grid::class, - 'paypal/adminhtml_system_config_apiWizard' => \Mage_Paypal_Block_Adminhtml_System_Config_ApiWizard::class, - 'paypal/adminhtml_system_config_bmlApiWizard' => \Mage_Paypal_Block_Adminhtml_System_Config_BmlApiWizard::class, + 'paypal/adminhtml_debug' => \Mage_Paypal_Block_Adminhtml_Debug::class, + 'paypal/adminhtml_debug_grid' => \Mage_Paypal_Block_Adminhtml_Debug_Grid::class, + 'paypal/adminhtml_debug_grid_renderer_exception' => \Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Exception::class, + 'paypal/adminhtml_debug_grid_renderer_request' => \Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Request::class, + 'paypal/adminhtml_debug_grid_renderer_response' => \Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Response::class, + 'paypal/adminhtml_grid_renderer_json' => \Mage_Paypal_Block_Adminhtml_Grid_Renderer_Json::class, + 'paypal/adminhtml_grid_renderer_order' => \Mage_Paypal_Block_Adminhtml_Grid_Renderer_Order::class, + 'paypal/adminhtml_info' => \Mage_Paypal_Block_Adminhtml_Info::class, 'paypal/adminhtml_system_config_field_country' => \Mage_Paypal_Block_Adminhtml_System_Config_Field_Country::class, - 'paypal/adminhtml_system_config_field_hidden' => \Mage_Paypal_Block_Adminhtml_System_Config_Field_Hidden::class, - 'paypal/adminhtml_system_config_field_solutionType' => \Mage_Paypal_Block_Adminhtml_System_Config_Field_SolutionType::class, - 'paypal/adminhtml_system_config_fieldset_deprecated' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Deprecated::class, - 'paypal/adminhtml_system_config_fieldset_expanded' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Expanded::class, - 'paypal/adminhtml_system_config_fieldset_global' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Global::class, - 'paypal/adminhtml_system_config_fieldset_group' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Group::class, - 'paypal/adminhtml_system_config_fieldset_hint' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Hint::class, - 'paypal/adminhtml_system_config_fieldset_location' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Location::class, - 'paypal/adminhtml_system_config_fieldset_pathDependent' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_PathDependent::class, - 'paypal/adminhtml_system_config_fieldset_payment' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Payment::class, - 'paypal/adminhtml_system_config_fieldset_store' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Store::class, - 'paypal/adminhtml_system_config_payflowlink_advanced' => \Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Advanced::class, - 'paypal/adminhtml_system_config_payflowlink_info' => \Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Info::class, - 'paypal/bml_banners' => \Mage_Paypal_Block_Bml_Banners::class, - 'paypal/bml_form' => \Mage_Paypal_Block_Bml_Form::class, - 'paypal/express_form' => \Mage_Paypal_Block_Express_Form::class, - 'paypal/express_review' => \Mage_Paypal_Block_Express_Review::class, - 'paypal/express_review_billing' => \Mage_Paypal_Block_Express_Review_Billing::class, - 'paypal/express_review_details' => \Mage_Paypal_Block_Express_Review_Details::class, - 'paypal/express_review_shipping' => \Mage_Paypal_Block_Express_Review_Shipping::class, - 'paypal/express_shortcut' => \Mage_Paypal_Block_Express_Shortcut::class, - 'paypal/hosted_pro_form' => \Mage_Paypal_Block_Hosted_Pro_Form::class, - 'paypal/hosted_pro_iframe' => \Mage_Paypal_Block_Hosted_Pro_Iframe::class, - 'paypal/hosted_pro_info' => \Mage_Paypal_Block_Hosted_Pro_Info::class, - 'paypal/iframe' => \Mage_Paypal_Block_Iframe::class, - 'paypal/logo' => \Mage_Paypal_Block_Logo::class, - 'paypal/payflow_advanced_form' => \Mage_Paypal_Block_Payflow_Advanced_Form::class, - 'paypal/payflow_advanced_iframe' => \Mage_Paypal_Block_Payflow_Advanced_Iframe::class, - 'paypal/payflow_advanced_info' => \Mage_Paypal_Block_Payflow_Advanced_Info::class, - 'paypal/payflow_advanced_review' => \Mage_Paypal_Block_Payflow_Advanced_Review::class, - 'paypal/payflow_link_form' => \Mage_Paypal_Block_Payflow_Link_Form::class, - 'paypal/payflow_link_iframe' => \Mage_Paypal_Block_Payflow_Link_Iframe::class, - 'paypal/payflow_link_info' => \Mage_Paypal_Block_Payflow_Link_Info::class, - 'paypal/payflow_link_review' => \Mage_Paypal_Block_Payflow_Link_Review::class, - 'paypal/payment_info' => \Mage_Paypal_Block_Payment_Info::class, - 'paypal/standard_form' => \Mage_Paypal_Block_Standard_Form::class, - 'paypal/standard_redirect' => \Mage_Paypal_Block_Standard_Redirect::class, + 'paypal/button' => \Mage_Paypal_Block_Button::class, + 'paypal/form' => \Mage_Paypal_Block_Form::class, + 'paypal/info' => \Mage_Paypal_Block_Info::class, 'persistent/form_remember' => \Mage_Persistent_Block_Form_Remember::class, 'persistent/header_additional' => \Mage_Persistent_Block_Header_Additional::class, 'productalert/email_abstract' => \Mage_ProductAlert_Block_Email_Abstract::class, diff --git a/.phpstorm.meta.php/magento_blocks_methods.meta.php b/.phpstorm.meta.php/magento_blocks_methods.meta.php index bcded4467bb..9811549474b 100644 --- a/.phpstorm.meta.php/magento_blocks_methods.meta.php +++ b/.phpstorm.meta.php/magento_blocks_methods.meta.php @@ -588,6 +588,7 @@ 'adminhtml/system_config_form' => \Mage_Adminhtml_Block_System_Config_Form::class, 'adminhtml/system_config_form_field' => \Mage_Adminhtml_Block_System_Config_Form_Field::class, 'adminhtml/system_config_form_field_array_abstract' => \Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract::class, + 'adminhtml/system_config_form_field_csp_hosts' => \Mage_Adminhtml_Block_System_Config_Form_Field_Csp_Hosts::class, 'adminhtml/system_config_form_field_datetime' => \Mage_Adminhtml_Block_System_Config_Form_Field_Datetime::class, 'adminhtml/system_config_form_field_export' => \Mage_Adminhtml_Block_System_Config_Form_Field_Export::class, 'adminhtml/system_config_form_field_file' => \Mage_Adminhtml_Block_System_Config_Form_Field_File::class, @@ -968,6 +969,8 @@ 'core/text_tag_debug' => \Mage_Core_Block_Text_Tag_Debug::class, 'core/text_tag_js' => \Mage_Core_Block_Text_Tag_Js::class, 'core/text_tag_meta' => \Mage_Core_Block_Text_Tag_Meta::class, + 'csp/adminhtml_meta' => \Mage_Csp_Block_Adminhtml_Meta::class, + 'csp/meta' => \Mage_Csp_Block_Meta::class, 'currencysymbol/adminhtml_system_currencysymbol' => \Mage_CurrencySymbol_Block_Adminhtml_System_Currencysymbol::class, 'customer/account' => \Mage_Customer_Block_Account::class, 'customer/account_changeforgotten' => \Mage_Customer_Block_Account_Changeforgotten::class, @@ -1105,53 +1108,18 @@ 'payment/info_checkmo' => \Mage_Payment_Block_Info_Checkmo::class, 'payment/info_container' => \Mage_Payment_Block_Info_Container::class, 'payment/info_purchaseorder' => \Mage_Payment_Block_Info_Purchaseorder::class, - 'paypaluk/bml_form' => \Mage_PaypalUk_Block_Bml_Form::class, - 'paypaluk/express_form' => \Mage_PaypalUk_Block_Express_Form::class, - 'paypaluk/express_shortcut' => \Mage_PaypalUk_Block_Express_Shortcut::class, - 'paypal/adminhtml_settlement_details' => \Mage_Paypal_Block_Adminhtml_Settlement_Details::class, - 'paypal/adminhtml_settlement_details_form' => \Mage_Paypal_Block_Adminhtml_Settlement_Details_Form::class, - 'paypal/adminhtml_settlement_report' => \Mage_Paypal_Block_Adminhtml_Settlement_Report::class, - 'paypal/adminhtml_settlement_report_grid' => \Mage_Paypal_Block_Adminhtml_Settlement_Report_Grid::class, - 'paypal/adminhtml_system_config_apiWizard' => \Mage_Paypal_Block_Adminhtml_System_Config_ApiWizard::class, - 'paypal/adminhtml_system_config_bmlApiWizard' => \Mage_Paypal_Block_Adminhtml_System_Config_BmlApiWizard::class, + 'paypal/adminhtml_debug' => \Mage_Paypal_Block_Adminhtml_Debug::class, + 'paypal/adminhtml_debug_grid' => \Mage_Paypal_Block_Adminhtml_Debug_Grid::class, + 'paypal/adminhtml_debug_grid_renderer_exception' => \Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Exception::class, + 'paypal/adminhtml_debug_grid_renderer_request' => \Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Request::class, + 'paypal/adminhtml_debug_grid_renderer_response' => \Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Response::class, + 'paypal/adminhtml_grid_renderer_json' => \Mage_Paypal_Block_Adminhtml_Grid_Renderer_Json::class, + 'paypal/adminhtml_grid_renderer_order' => \Mage_Paypal_Block_Adminhtml_Grid_Renderer_Order::class, + 'paypal/adminhtml_info' => \Mage_Paypal_Block_Adminhtml_Info::class, 'paypal/adminhtml_system_config_field_country' => \Mage_Paypal_Block_Adminhtml_System_Config_Field_Country::class, - 'paypal/adminhtml_system_config_field_hidden' => \Mage_Paypal_Block_Adminhtml_System_Config_Field_Hidden::class, - 'paypal/adminhtml_system_config_field_solutionType' => \Mage_Paypal_Block_Adminhtml_System_Config_Field_SolutionType::class, - 'paypal/adminhtml_system_config_fieldset_deprecated' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Deprecated::class, - 'paypal/adminhtml_system_config_fieldset_expanded' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Expanded::class, - 'paypal/adminhtml_system_config_fieldset_global' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Global::class, - 'paypal/adminhtml_system_config_fieldset_group' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Group::class, - 'paypal/adminhtml_system_config_fieldset_hint' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Hint::class, - 'paypal/adminhtml_system_config_fieldset_location' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Location::class, - 'paypal/adminhtml_system_config_fieldset_pathDependent' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_PathDependent::class, - 'paypal/adminhtml_system_config_fieldset_payment' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Payment::class, - 'paypal/adminhtml_system_config_fieldset_store' => \Mage_Paypal_Block_Adminhtml_System_Config_Fieldset_Store::class, - 'paypal/adminhtml_system_config_payflowlink_advanced' => \Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Advanced::class, - 'paypal/adminhtml_system_config_payflowlink_info' => \Mage_Paypal_Block_Adminhtml_System_Config_Payflowlink_Info::class, - 'paypal/bml_banners' => \Mage_Paypal_Block_Bml_Banners::class, - 'paypal/bml_form' => \Mage_Paypal_Block_Bml_Form::class, - 'paypal/express_form' => \Mage_Paypal_Block_Express_Form::class, - 'paypal/express_review' => \Mage_Paypal_Block_Express_Review::class, - 'paypal/express_review_billing' => \Mage_Paypal_Block_Express_Review_Billing::class, - 'paypal/express_review_details' => \Mage_Paypal_Block_Express_Review_Details::class, - 'paypal/express_review_shipping' => \Mage_Paypal_Block_Express_Review_Shipping::class, - 'paypal/express_shortcut' => \Mage_Paypal_Block_Express_Shortcut::class, - 'paypal/hosted_pro_form' => \Mage_Paypal_Block_Hosted_Pro_Form::class, - 'paypal/hosted_pro_iframe' => \Mage_Paypal_Block_Hosted_Pro_Iframe::class, - 'paypal/hosted_pro_info' => \Mage_Paypal_Block_Hosted_Pro_Info::class, - 'paypal/iframe' => \Mage_Paypal_Block_Iframe::class, - 'paypal/logo' => \Mage_Paypal_Block_Logo::class, - 'paypal/payflow_advanced_form' => \Mage_Paypal_Block_Payflow_Advanced_Form::class, - 'paypal/payflow_advanced_iframe' => \Mage_Paypal_Block_Payflow_Advanced_Iframe::class, - 'paypal/payflow_advanced_info' => \Mage_Paypal_Block_Payflow_Advanced_Info::class, - 'paypal/payflow_advanced_review' => \Mage_Paypal_Block_Payflow_Advanced_Review::class, - 'paypal/payflow_link_form' => \Mage_Paypal_Block_Payflow_Link_Form::class, - 'paypal/payflow_link_iframe' => \Mage_Paypal_Block_Payflow_Link_Iframe::class, - 'paypal/payflow_link_info' => \Mage_Paypal_Block_Payflow_Link_Info::class, - 'paypal/payflow_link_review' => \Mage_Paypal_Block_Payflow_Link_Review::class, - 'paypal/payment_info' => \Mage_Paypal_Block_Payment_Info::class, - 'paypal/standard_form' => \Mage_Paypal_Block_Standard_Form::class, - 'paypal/standard_redirect' => \Mage_Paypal_Block_Standard_Redirect::class, + 'paypal/button' => \Mage_Paypal_Block_Button::class, + 'paypal/form' => \Mage_Paypal_Block_Form::class, + 'paypal/info' => \Mage_Paypal_Block_Info::class, 'persistent/form_remember' => \Mage_Persistent_Block_Form_Remember::class, 'persistent/header_additional' => \Mage_Persistent_Block_Header_Additional::class, 'productalert/email_abstract' => \Mage_ProductAlert_Block_Email_Abstract::class, diff --git a/.phpstorm.meta.php/magento_helpers.meta.php b/.phpstorm.meta.php/magento_helpers.meta.php index 8d25c1bd54e..a0414bab12c 100644 --- a/.phpstorm.meta.php/magento_helpers.meta.php +++ b/.phpstorm.meta.php/magento_helpers.meta.php @@ -61,6 +61,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -96,6 +97,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -139,12 +142,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, diff --git a/.phpstorm.meta.php/magento_helpers_methods.meta.php b/.phpstorm.meta.php/magento_helpers_methods.meta.php index 78008eeee27..8f918a14b59 100644 --- a/.phpstorm.meta.php/magento_helpers_methods.meta.php +++ b/.phpstorm.meta.php/magento_helpers_methods.meta.php @@ -61,6 +61,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -96,6 +97,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -139,12 +142,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -251,6 +250,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -286,6 +286,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -329,12 +331,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -441,6 +439,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -476,6 +475,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -519,12 +520,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -631,6 +628,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -666,6 +664,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -709,12 +709,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -821,6 +817,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -856,6 +853,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -899,12 +898,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -1011,6 +1006,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -1046,6 +1042,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -1089,12 +1087,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -1201,6 +1195,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -1236,6 +1231,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -1279,12 +1276,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -1391,6 +1384,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -1426,6 +1420,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -1469,12 +1465,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -1581,6 +1573,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -1616,6 +1609,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -1659,12 +1654,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -1771,6 +1762,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -1806,6 +1798,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -1849,12 +1843,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -1961,6 +1951,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -1996,6 +1987,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -2039,12 +2032,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -2151,6 +2140,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -2186,6 +2176,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -2229,12 +2221,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -2341,6 +2329,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -2376,6 +2365,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -2419,12 +2410,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -2531,6 +2518,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -2566,6 +2554,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -2609,12 +2599,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -2721,6 +2707,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -2756,6 +2743,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -2799,12 +2788,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, @@ -2911,6 +2896,7 @@ 'catalog/product_url' => \Mage_Catalog_Helper_Product_Url::class, 'catalog/product_url_rewrite' => \Mage_Catalog_Helper_Product_Url_Rewrite::class, 'catalog/product_view' => \Mage_Catalog_Helper_Product_View::class, + 'catalog/search' => \Mage_Catalog_Helper_Search::class, 'centinel' => \Mage_Centinel_Helper_Data::class, 'centinel/data' => \Mage_Centinel_Helper_Data::class, 'checkout/cart' => \Mage_Checkout_Helper_Cart::class, @@ -2946,6 +2932,8 @@ 'core/unserializeArray' => \Mage_Core_Helper_UnserializeArray::class, 'core/url' => \Mage_Core_Helper_Url::class, 'core/url_rewrite' => \Mage_Core_Helper_Url_Rewrite::class, + 'csp' => \Mage_Csp_Helper_Data::class, + 'csp/data' => \Mage_Csp_Helper_Data::class, 'currencysymbol' => \Mage_CurrencySymbol_Helper_Data::class, 'currencysymbol/data' => \Mage_CurrencySymbol_Helper_Data::class, 'customer/address' => \Mage_Customer_Helper_Address::class, @@ -2989,12 +2977,8 @@ 'page/layout' => \Mage_Page_Helper_Layout::class, 'payment' => \Mage_Payment_Helper_Data::class, 'payment/data' => \Mage_Payment_Helper_Data::class, - 'paypaluk' => \Mage_PaypalUk_Helper_Data::class, - 'paypaluk/data' => \Mage_PaypalUk_Helper_Data::class, - 'paypal/checkout' => \Mage_Paypal_Helper_Checkout::class, 'paypal' => \Mage_Paypal_Helper_Data::class, 'paypal/data' => \Mage_Paypal_Helper_Data::class, - 'paypal/hss' => \Mage_Paypal_Helper_Hss::class, 'persistent' => \Mage_Persistent_Helper_Data::class, 'persistent/data' => \Mage_Persistent_Helper_Data::class, 'persistent/session' => \Mage_Persistent_Helper_Session::class, diff --git a/.phpstorm.meta.php/magento_models.meta.php b/.phpstorm.meta.php/magento_models.meta.php index 18ac65f08c0..65fcd688ccf 100644 --- a/.phpstorm.meta.php/magento_models.meta.php +++ b/.phpstorm.meta.php/magento_models.meta.php @@ -181,6 +181,7 @@ 'adminhtml/system_config_source_customer_forgotpassword' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Forgotpassword::class, 'adminhtml/system_config_source_customer_group' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group::class, 'adminhtml/system_config_source_customer_group_multiselect' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group_Multiselect::class, + 'adminhtml/system_config_source_dashboard_chart_type' => \Mage_Adminhtml_Model_System_Config_Source_Dashboard_Chart_Type::class, 'adminhtml/system_config_source_date_short' => \Mage_Adminhtml_Model_System_Config_Source_Date_Short::class, 'adminhtml/system_config_source_design_robots' => \Mage_Adminhtml_Model_System_Config_Source_Design_Robots::class, 'adminhtml/system_config_source_dev_dbautoup' => \Mage_Adminhtml_Model_System_Config_Source_Dev_Dbautoup::class, @@ -643,6 +644,7 @@ 'catalog/layer_filter_price_algorithm' => \Mage_Catalog_Model_Layer_Filter_Price_Algorithm::class, 'catalog/layer_state' => \Mage_Catalog_Model_Layer_State::class, 'catalog/observer' => \Mage_Catalog_Model_Observer::class, + 'catalog/observer_disableAdvancedSearch' => \Mage_Catalog_Model_Observer_DisableAdvancedSearch::class, 'catalog/product' => \Mage_Catalog_Model_Product::class, 'catalog/product_action' => \Mage_Catalog_Model_Product_Action::class, 'catalog/product_api' => \Mage_Catalog_Model_Product_Api::class, @@ -1322,6 +1324,9 @@ 'cron/resource_schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron_resource/schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron/schedule' => \Mage_Cron_Model_Schedule::class, + 'csp/observer_abstract' => \Mage_Csp_Model_Observer_Abstract::class, + 'csp/observer_addAdminCspHeaders' => \Mage_Csp_Model_Observer_AddAdminCspHeaders::class, + 'csp/observer_addFrontendCspHeaders' => \Mage_Csp_Model_Observer_AddFrontendCspHeaders::class, 'currencysymbol/observer' => \Mage_CurrencySymbol_Model_Observer::class, 'currencysymbol/system_currencysymbol' => \Mage_CurrencySymbol_Model_System_Currencysymbol::class, 'customer/address' => \Mage_Customer_Model_Address::class, @@ -1930,76 +1935,30 @@ 'payment/recurring_profile' => \Mage_Payment_Model_Recurring_Profile::class, 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, - 'paypaluk/api_express_nvp' => \Mage_PaypalUk_Model_Api_Express_Nvp::class, - 'paypaluk/api_nvp' => \Mage_PaypalUk_Model_Api_Nvp::class, - 'paypaluk/bml' => \Mage_PaypalUk_Model_Bml::class, - 'paypaluk/direct' => \Mage_PaypalUk_Model_Direct::class, - 'paypaluk/express' => \Mage_PaypalUk_Model_Express::class, - 'paypaluk/express_checkout' => \Mage_PaypalUk_Model_Express_Checkout::class, - 'paypaluk/express_pro' => \Mage_PaypalUk_Model_Express_Pro::class, - 'paypaluk/pro' => \Mage_PaypalUk_Model_Pro::class, - 'paypaluk/session' => \Mage_PaypalUk_Model_Session::class, - 'paypal/api_abstract' => \Mage_Paypal_Model_Api_Abstract::class, - 'paypal/api_nvp' => \Mage_Paypal_Model_Api_Nvp::class, - 'paypal/api_processableException' => \Mage_Paypal_Model_Api_ProcessableException::class, - 'paypal/api_standard' => \Mage_Paypal_Model_Api_Standard::class, - 'paypal/bml' => \Mage_Paypal_Model_Bml::class, + 'paypal/api' => \Mage_Paypal_Model_Api::class, + 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, + 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, - 'paypal/cert' => \Mage_Paypal_Model_Cert::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, - 'paypal/direct' => \Mage_Paypal_Model_Direct::class, - 'paypal/express' => \Mage_Paypal_Model_Express::class, - 'paypal/express_checkout' => \Mage_Paypal_Model_Express_Checkout::class, - 'paypal/hostedpro' => \Mage_Paypal_Model_Hostedpro::class, - 'paypal/hostedpro_request' => \Mage_Paypal_Model_Hostedpro_Request::class, - 'paypal/info' => \Mage_Paypal_Model_Info::class, - 'paypal/ipn' => \Mage_Paypal_Model_Ipn::class, - 'paypal/method_agreement' => \Mage_Paypal_Model_Method_Agreement::class, - 'paypal/mysql4_cert' => \Mage_Paypal_Model_Mysql4_Cert::class, - 'paypal/mysql4_report_settlement' => \Mage_Paypal_Model_Mysql4_Report_Settlement::class, - 'paypal/mysql4_report_settlement_row' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row::class, - 'paypal/mysql4_report_settlement_row_collection' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row_Collection::class, - 'paypal/mysql4_setup' => \Mage_Paypal_Model_Mysql4_Setup::class, - 'paypal/observer' => \Mage_Paypal_Model_Observer::class, - 'paypal/payflow_request' => \Mage_Paypal_Model_Payflow_Request::class, - 'paypal/payflowadvanced' => \Mage_Paypal_Model_Payflowadvanced::class, - 'paypal/payflowlink' => \Mage_Paypal_Model_Payflowlink::class, - 'paypal/payflowpro' => \Mage_Paypal_Model_Payflowpro::class, - 'paypal/payment_transaction' => \Mage_Paypal_Model_Payment_Transaction::class, - 'paypal/pro' => \Mage_Paypal_Model_Pro::class, - 'paypal/report_settlement' => \Mage_Paypal_Model_Report_Settlement::class, - 'paypal/report_settlement_row' => \Mage_Paypal_Model_Report_Settlement_Row::class, - 'paypal/resource_cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal_resource/cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal/resource_payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal_resource/payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal/resource_payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal_resource/payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal/resource_report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal_resource/report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal/resource_report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal_resource/report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal/resource_report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, - 'paypal_resource/report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, + 'paypal/debug' => \Mage_Paypal_Model_Debug::class, + 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, + 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal/resource_debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, + 'paypal_resource/debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, 'paypal/resource_setup' => \Mage_Paypal_Model_Resource_Setup::class, 'paypal_resource/setup' => \Mage_Paypal_Model_Resource_Setup::class, - 'paypal/session' => \Mage_Paypal_Model_Session::class, - 'paypal/standard' => \Mage_Paypal_Model_Standard::class, - 'paypal/system_config_backend_cert' => \Mage_Paypal_Model_System_Config_Backend_Cert::class, - 'paypal/system_config_backend_cron' => \Mage_Paypal_Model_System_Config_Backend_Cron::class, 'paypal/system_config_backend_merchantCountry' => \Mage_Paypal_Model_System_Config_Backend_MerchantCountry::class, - 'paypal/system_config_source_authorizationAmounts' => \Mage_Paypal_Model_System_Config_Source_AuthorizationAmounts::class, - 'paypal/system_config_source_bmlPosition' => \Mage_Paypal_Model_System_Config_Source_BmlPosition::class, - 'paypal/system_config_source_bmlSize' => \Mage_Paypal_Model_System_Config_Source_BmlSize::class, - 'paypal/system_config_source_buyerCountry' => \Mage_Paypal_Model_System_Config_Source_BuyerCountry::class, - 'paypal/system_config_source_fetchingSchedule' => \Mage_Paypal_Model_System_Config_Source_FetchingSchedule::class, - 'paypal/system_config_source_logo' => \Mage_Paypal_Model_System_Config_Source_Logo::class, + 'paypal/system_config_source_buttonColors' => \Mage_Paypal_Model_System_Config_Source_ButtonColors::class, + 'paypal/system_config_source_buttonLabels' => \Mage_Paypal_Model_System_Config_Source_ButtonLabels::class, + 'paypal/system_config_source_buttonLayouts' => \Mage_Paypal_Model_System_Config_Source_ButtonLayouts::class, + 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/system_config_source_paymentActions_express' => \Mage_Paypal_Model_System_Config_Source_PaymentActions_Express::class, - 'paypal/system_config_source_requireBillingAddress' => \Mage_Paypal_Model_System_Config_Source_RequireBillingAddress::class, - 'paypal/system_config_source_urlMethod' => \Mage_Paypal_Model_System_Config_Source_UrlMethod::class, - 'paypal/system_config_source_yesnoShortcut' => \Mage_Paypal_Model_System_Config_Source_YesnoShortcut::class, + 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, + 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, + 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -3337,6 +3296,7 @@ 'adminhtml/system_config_source_customer_forgotpassword' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Forgotpassword::class, 'adminhtml/system_config_source_customer_group' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group::class, 'adminhtml/system_config_source_customer_group_multiselect' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group_Multiselect::class, + 'adminhtml/system_config_source_dashboard_chart_type' => \Mage_Adminhtml_Model_System_Config_Source_Dashboard_Chart_Type::class, 'adminhtml/system_config_source_date_short' => \Mage_Adminhtml_Model_System_Config_Source_Date_Short::class, 'adminhtml/system_config_source_design_robots' => \Mage_Adminhtml_Model_System_Config_Source_Design_Robots::class, 'adminhtml/system_config_source_dev_dbautoup' => \Mage_Adminhtml_Model_System_Config_Source_Dev_Dbautoup::class, @@ -3799,6 +3759,7 @@ 'catalog/layer_filter_price_algorithm' => \Mage_Catalog_Model_Layer_Filter_Price_Algorithm::class, 'catalog/layer_state' => \Mage_Catalog_Model_Layer_State::class, 'catalog/observer' => \Mage_Catalog_Model_Observer::class, + 'catalog/observer_disableAdvancedSearch' => \Mage_Catalog_Model_Observer_DisableAdvancedSearch::class, 'catalog/product' => \Mage_Catalog_Model_Product::class, 'catalog/product_action' => \Mage_Catalog_Model_Product_Action::class, 'catalog/product_api' => \Mage_Catalog_Model_Product_Api::class, @@ -4478,6 +4439,9 @@ 'cron/resource_schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron_resource/schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron/schedule' => \Mage_Cron_Model_Schedule::class, + 'csp/observer_abstract' => \Mage_Csp_Model_Observer_Abstract::class, + 'csp/observer_addAdminCspHeaders' => \Mage_Csp_Model_Observer_AddAdminCspHeaders::class, + 'csp/observer_addFrontendCspHeaders' => \Mage_Csp_Model_Observer_AddFrontendCspHeaders::class, 'currencysymbol/observer' => \Mage_CurrencySymbol_Model_Observer::class, 'currencysymbol/system_currencysymbol' => \Mage_CurrencySymbol_Model_System_Currencysymbol::class, 'customer/address' => \Mage_Customer_Model_Address::class, @@ -5086,76 +5050,30 @@ 'payment/recurring_profile' => \Mage_Payment_Model_Recurring_Profile::class, 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, - 'paypaluk/api_express_nvp' => \Mage_PaypalUk_Model_Api_Express_Nvp::class, - 'paypaluk/api_nvp' => \Mage_PaypalUk_Model_Api_Nvp::class, - 'paypaluk/bml' => \Mage_PaypalUk_Model_Bml::class, - 'paypaluk/direct' => \Mage_PaypalUk_Model_Direct::class, - 'paypaluk/express' => \Mage_PaypalUk_Model_Express::class, - 'paypaluk/express_checkout' => \Mage_PaypalUk_Model_Express_Checkout::class, - 'paypaluk/express_pro' => \Mage_PaypalUk_Model_Express_Pro::class, - 'paypaluk/pro' => \Mage_PaypalUk_Model_Pro::class, - 'paypaluk/session' => \Mage_PaypalUk_Model_Session::class, - 'paypal/api_abstract' => \Mage_Paypal_Model_Api_Abstract::class, - 'paypal/api_nvp' => \Mage_Paypal_Model_Api_Nvp::class, - 'paypal/api_processableException' => \Mage_Paypal_Model_Api_ProcessableException::class, - 'paypal/api_standard' => \Mage_Paypal_Model_Api_Standard::class, - 'paypal/bml' => \Mage_Paypal_Model_Bml::class, + 'paypal/api' => \Mage_Paypal_Model_Api::class, + 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, + 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, - 'paypal/cert' => \Mage_Paypal_Model_Cert::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, - 'paypal/direct' => \Mage_Paypal_Model_Direct::class, - 'paypal/express' => \Mage_Paypal_Model_Express::class, - 'paypal/express_checkout' => \Mage_Paypal_Model_Express_Checkout::class, - 'paypal/hostedpro' => \Mage_Paypal_Model_Hostedpro::class, - 'paypal/hostedpro_request' => \Mage_Paypal_Model_Hostedpro_Request::class, - 'paypal/info' => \Mage_Paypal_Model_Info::class, - 'paypal/ipn' => \Mage_Paypal_Model_Ipn::class, - 'paypal/method_agreement' => \Mage_Paypal_Model_Method_Agreement::class, - 'paypal/mysql4_cert' => \Mage_Paypal_Model_Mysql4_Cert::class, - 'paypal/mysql4_report_settlement' => \Mage_Paypal_Model_Mysql4_Report_Settlement::class, - 'paypal/mysql4_report_settlement_row' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row::class, - 'paypal/mysql4_report_settlement_row_collection' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row_Collection::class, - 'paypal/mysql4_setup' => \Mage_Paypal_Model_Mysql4_Setup::class, - 'paypal/observer' => \Mage_Paypal_Model_Observer::class, - 'paypal/payflow_request' => \Mage_Paypal_Model_Payflow_Request::class, - 'paypal/payflowadvanced' => \Mage_Paypal_Model_Payflowadvanced::class, - 'paypal/payflowlink' => \Mage_Paypal_Model_Payflowlink::class, - 'paypal/payflowpro' => \Mage_Paypal_Model_Payflowpro::class, - 'paypal/payment_transaction' => \Mage_Paypal_Model_Payment_Transaction::class, - 'paypal/pro' => \Mage_Paypal_Model_Pro::class, - 'paypal/report_settlement' => \Mage_Paypal_Model_Report_Settlement::class, - 'paypal/report_settlement_row' => \Mage_Paypal_Model_Report_Settlement_Row::class, - 'paypal/resource_cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal_resource/cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal/resource_payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal_resource/payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal/resource_payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal_resource/payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal/resource_report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal_resource/report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal/resource_report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal_resource/report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal/resource_report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, - 'paypal_resource/report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, + 'paypal/debug' => \Mage_Paypal_Model_Debug::class, + 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, + 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal/resource_debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, + 'paypal_resource/debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, 'paypal/resource_setup' => \Mage_Paypal_Model_Resource_Setup::class, 'paypal_resource/setup' => \Mage_Paypal_Model_Resource_Setup::class, - 'paypal/session' => \Mage_Paypal_Model_Session::class, - 'paypal/standard' => \Mage_Paypal_Model_Standard::class, - 'paypal/system_config_backend_cert' => \Mage_Paypal_Model_System_Config_Backend_Cert::class, - 'paypal/system_config_backend_cron' => \Mage_Paypal_Model_System_Config_Backend_Cron::class, 'paypal/system_config_backend_merchantCountry' => \Mage_Paypal_Model_System_Config_Backend_MerchantCountry::class, - 'paypal/system_config_source_authorizationAmounts' => \Mage_Paypal_Model_System_Config_Source_AuthorizationAmounts::class, - 'paypal/system_config_source_bmlPosition' => \Mage_Paypal_Model_System_Config_Source_BmlPosition::class, - 'paypal/system_config_source_bmlSize' => \Mage_Paypal_Model_System_Config_Source_BmlSize::class, - 'paypal/system_config_source_buyerCountry' => \Mage_Paypal_Model_System_Config_Source_BuyerCountry::class, - 'paypal/system_config_source_fetchingSchedule' => \Mage_Paypal_Model_System_Config_Source_FetchingSchedule::class, - 'paypal/system_config_source_logo' => \Mage_Paypal_Model_System_Config_Source_Logo::class, + 'paypal/system_config_source_buttonColors' => \Mage_Paypal_Model_System_Config_Source_ButtonColors::class, + 'paypal/system_config_source_buttonLabels' => \Mage_Paypal_Model_System_Config_Source_ButtonLabels::class, + 'paypal/system_config_source_buttonLayouts' => \Mage_Paypal_Model_System_Config_Source_ButtonLayouts::class, + 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/system_config_source_paymentActions_express' => \Mage_Paypal_Model_System_Config_Source_PaymentActions_Express::class, - 'paypal/system_config_source_requireBillingAddress' => \Mage_Paypal_Model_System_Config_Source_RequireBillingAddress::class, - 'paypal/system_config_source_urlMethod' => \Mage_Paypal_Model_System_Config_Source_UrlMethod::class, - 'paypal/system_config_source_yesnoShortcut' => \Mage_Paypal_Model_System_Config_Source_YesnoShortcut::class, + 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, + 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, + 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, diff --git a/.phpstorm.meta.php/magento_models_methods.meta.php b/.phpstorm.meta.php/magento_models_methods.meta.php index a43119c4fee..2e843c5d4a3 100644 --- a/.phpstorm.meta.php/magento_models_methods.meta.php +++ b/.phpstorm.meta.php/magento_models_methods.meta.php @@ -181,6 +181,7 @@ 'adminhtml/system_config_source_customer_forgotpassword' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Forgotpassword::class, 'adminhtml/system_config_source_customer_group' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group::class, 'adminhtml/system_config_source_customer_group_multiselect' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group_Multiselect::class, + 'adminhtml/system_config_source_dashboard_chart_type' => \Mage_Adminhtml_Model_System_Config_Source_Dashboard_Chart_Type::class, 'adminhtml/system_config_source_date_short' => \Mage_Adminhtml_Model_System_Config_Source_Date_Short::class, 'adminhtml/system_config_source_design_robots' => \Mage_Adminhtml_Model_System_Config_Source_Design_Robots::class, 'adminhtml/system_config_source_dev_dbautoup' => \Mage_Adminhtml_Model_System_Config_Source_Dev_Dbautoup::class, @@ -643,6 +644,7 @@ 'catalog/layer_filter_price_algorithm' => \Mage_Catalog_Model_Layer_Filter_Price_Algorithm::class, 'catalog/layer_state' => \Mage_Catalog_Model_Layer_State::class, 'catalog/observer' => \Mage_Catalog_Model_Observer::class, + 'catalog/observer_disableAdvancedSearch' => \Mage_Catalog_Model_Observer_DisableAdvancedSearch::class, 'catalog/product' => \Mage_Catalog_Model_Product::class, 'catalog/product_action' => \Mage_Catalog_Model_Product_Action::class, 'catalog/product_api' => \Mage_Catalog_Model_Product_Api::class, @@ -1322,6 +1324,9 @@ 'cron/resource_schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron_resource/schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron/schedule' => \Mage_Cron_Model_Schedule::class, + 'csp/observer_abstract' => \Mage_Csp_Model_Observer_Abstract::class, + 'csp/observer_addAdminCspHeaders' => \Mage_Csp_Model_Observer_AddAdminCspHeaders::class, + 'csp/observer_addFrontendCspHeaders' => \Mage_Csp_Model_Observer_AddFrontendCspHeaders::class, 'currencysymbol/observer' => \Mage_CurrencySymbol_Model_Observer::class, 'currencysymbol/system_currencysymbol' => \Mage_CurrencySymbol_Model_System_Currencysymbol::class, 'customer/address' => \Mage_Customer_Model_Address::class, @@ -1930,76 +1935,30 @@ 'payment/recurring_profile' => \Mage_Payment_Model_Recurring_Profile::class, 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, - 'paypaluk/api_express_nvp' => \Mage_PaypalUk_Model_Api_Express_Nvp::class, - 'paypaluk/api_nvp' => \Mage_PaypalUk_Model_Api_Nvp::class, - 'paypaluk/bml' => \Mage_PaypalUk_Model_Bml::class, - 'paypaluk/direct' => \Mage_PaypalUk_Model_Direct::class, - 'paypaluk/express' => \Mage_PaypalUk_Model_Express::class, - 'paypaluk/express_checkout' => \Mage_PaypalUk_Model_Express_Checkout::class, - 'paypaluk/express_pro' => \Mage_PaypalUk_Model_Express_Pro::class, - 'paypaluk/pro' => \Mage_PaypalUk_Model_Pro::class, - 'paypaluk/session' => \Mage_PaypalUk_Model_Session::class, - 'paypal/api_abstract' => \Mage_Paypal_Model_Api_Abstract::class, - 'paypal/api_nvp' => \Mage_Paypal_Model_Api_Nvp::class, - 'paypal/api_processableException' => \Mage_Paypal_Model_Api_ProcessableException::class, - 'paypal/api_standard' => \Mage_Paypal_Model_Api_Standard::class, - 'paypal/bml' => \Mage_Paypal_Model_Bml::class, + 'paypal/api' => \Mage_Paypal_Model_Api::class, + 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, + 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, - 'paypal/cert' => \Mage_Paypal_Model_Cert::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, - 'paypal/direct' => \Mage_Paypal_Model_Direct::class, - 'paypal/express' => \Mage_Paypal_Model_Express::class, - 'paypal/express_checkout' => \Mage_Paypal_Model_Express_Checkout::class, - 'paypal/hostedpro' => \Mage_Paypal_Model_Hostedpro::class, - 'paypal/hostedpro_request' => \Mage_Paypal_Model_Hostedpro_Request::class, - 'paypal/info' => \Mage_Paypal_Model_Info::class, - 'paypal/ipn' => \Mage_Paypal_Model_Ipn::class, - 'paypal/method_agreement' => \Mage_Paypal_Model_Method_Agreement::class, - 'paypal/mysql4_cert' => \Mage_Paypal_Model_Mysql4_Cert::class, - 'paypal/mysql4_report_settlement' => \Mage_Paypal_Model_Mysql4_Report_Settlement::class, - 'paypal/mysql4_report_settlement_row' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row::class, - 'paypal/mysql4_report_settlement_row_collection' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row_Collection::class, - 'paypal/mysql4_setup' => \Mage_Paypal_Model_Mysql4_Setup::class, - 'paypal/observer' => \Mage_Paypal_Model_Observer::class, - 'paypal/payflow_request' => \Mage_Paypal_Model_Payflow_Request::class, - 'paypal/payflowadvanced' => \Mage_Paypal_Model_Payflowadvanced::class, - 'paypal/payflowlink' => \Mage_Paypal_Model_Payflowlink::class, - 'paypal/payflowpro' => \Mage_Paypal_Model_Payflowpro::class, - 'paypal/payment_transaction' => \Mage_Paypal_Model_Payment_Transaction::class, - 'paypal/pro' => \Mage_Paypal_Model_Pro::class, - 'paypal/report_settlement' => \Mage_Paypal_Model_Report_Settlement::class, - 'paypal/report_settlement_row' => \Mage_Paypal_Model_Report_Settlement_Row::class, - 'paypal/resource_cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal_resource/cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal/resource_payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal_resource/payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal/resource_payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal_resource/payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal/resource_report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal_resource/report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal/resource_report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal_resource/report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal/resource_report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, - 'paypal_resource/report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, + 'paypal/debug' => \Mage_Paypal_Model_Debug::class, + 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, + 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal/resource_debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, + 'paypal_resource/debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, 'paypal/resource_setup' => \Mage_Paypal_Model_Resource_Setup::class, 'paypal_resource/setup' => \Mage_Paypal_Model_Resource_Setup::class, - 'paypal/session' => \Mage_Paypal_Model_Session::class, - 'paypal/standard' => \Mage_Paypal_Model_Standard::class, - 'paypal/system_config_backend_cert' => \Mage_Paypal_Model_System_Config_Backend_Cert::class, - 'paypal/system_config_backend_cron' => \Mage_Paypal_Model_System_Config_Backend_Cron::class, 'paypal/system_config_backend_merchantCountry' => \Mage_Paypal_Model_System_Config_Backend_MerchantCountry::class, - 'paypal/system_config_source_authorizationAmounts' => \Mage_Paypal_Model_System_Config_Source_AuthorizationAmounts::class, - 'paypal/system_config_source_bmlPosition' => \Mage_Paypal_Model_System_Config_Source_BmlPosition::class, - 'paypal/system_config_source_bmlSize' => \Mage_Paypal_Model_System_Config_Source_BmlSize::class, - 'paypal/system_config_source_buyerCountry' => \Mage_Paypal_Model_System_Config_Source_BuyerCountry::class, - 'paypal/system_config_source_fetchingSchedule' => \Mage_Paypal_Model_System_Config_Source_FetchingSchedule::class, - 'paypal/system_config_source_logo' => \Mage_Paypal_Model_System_Config_Source_Logo::class, + 'paypal/system_config_source_buttonColors' => \Mage_Paypal_Model_System_Config_Source_ButtonColors::class, + 'paypal/system_config_source_buttonLabels' => \Mage_Paypal_Model_System_Config_Source_ButtonLabels::class, + 'paypal/system_config_source_buttonLayouts' => \Mage_Paypal_Model_System_Config_Source_ButtonLayouts::class, + 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/system_config_source_paymentActions_express' => \Mage_Paypal_Model_System_Config_Source_PaymentActions_Express::class, - 'paypal/system_config_source_requireBillingAddress' => \Mage_Paypal_Model_System_Config_Source_RequireBillingAddress::class, - 'paypal/system_config_source_urlMethod' => \Mage_Paypal_Model_System_Config_Source_UrlMethod::class, - 'paypal/system_config_source_yesnoShortcut' => \Mage_Paypal_Model_System_Config_Source_YesnoShortcut::class, + 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, + 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, + 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -3337,6 +3296,7 @@ 'adminhtml/system_config_source_customer_forgotpassword' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Forgotpassword::class, 'adminhtml/system_config_source_customer_group' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group::class, 'adminhtml/system_config_source_customer_group_multiselect' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group_Multiselect::class, + 'adminhtml/system_config_source_dashboard_chart_type' => \Mage_Adminhtml_Model_System_Config_Source_Dashboard_Chart_Type::class, 'adminhtml/system_config_source_date_short' => \Mage_Adminhtml_Model_System_Config_Source_Date_Short::class, 'adminhtml/system_config_source_design_robots' => \Mage_Adminhtml_Model_System_Config_Source_Design_Robots::class, 'adminhtml/system_config_source_dev_dbautoup' => \Mage_Adminhtml_Model_System_Config_Source_Dev_Dbautoup::class, @@ -3799,6 +3759,7 @@ 'catalog/layer_filter_price_algorithm' => \Mage_Catalog_Model_Layer_Filter_Price_Algorithm::class, 'catalog/layer_state' => \Mage_Catalog_Model_Layer_State::class, 'catalog/observer' => \Mage_Catalog_Model_Observer::class, + 'catalog/observer_disableAdvancedSearch' => \Mage_Catalog_Model_Observer_DisableAdvancedSearch::class, 'catalog/product' => \Mage_Catalog_Model_Product::class, 'catalog/product_action' => \Mage_Catalog_Model_Product_Action::class, 'catalog/product_api' => \Mage_Catalog_Model_Product_Api::class, @@ -4478,6 +4439,9 @@ 'cron/resource_schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron_resource/schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron/schedule' => \Mage_Cron_Model_Schedule::class, + 'csp/observer_abstract' => \Mage_Csp_Model_Observer_Abstract::class, + 'csp/observer_addAdminCspHeaders' => \Mage_Csp_Model_Observer_AddAdminCspHeaders::class, + 'csp/observer_addFrontendCspHeaders' => \Mage_Csp_Model_Observer_AddFrontendCspHeaders::class, 'currencysymbol/observer' => \Mage_CurrencySymbol_Model_Observer::class, 'currencysymbol/system_currencysymbol' => \Mage_CurrencySymbol_Model_System_Currencysymbol::class, 'customer/address' => \Mage_Customer_Model_Address::class, @@ -5086,76 +5050,30 @@ 'payment/recurring_profile' => \Mage_Payment_Model_Recurring_Profile::class, 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, - 'paypaluk/api_express_nvp' => \Mage_PaypalUk_Model_Api_Express_Nvp::class, - 'paypaluk/api_nvp' => \Mage_PaypalUk_Model_Api_Nvp::class, - 'paypaluk/bml' => \Mage_PaypalUk_Model_Bml::class, - 'paypaluk/direct' => \Mage_PaypalUk_Model_Direct::class, - 'paypaluk/express' => \Mage_PaypalUk_Model_Express::class, - 'paypaluk/express_checkout' => \Mage_PaypalUk_Model_Express_Checkout::class, - 'paypaluk/express_pro' => \Mage_PaypalUk_Model_Express_Pro::class, - 'paypaluk/pro' => \Mage_PaypalUk_Model_Pro::class, - 'paypaluk/session' => \Mage_PaypalUk_Model_Session::class, - 'paypal/api_abstract' => \Mage_Paypal_Model_Api_Abstract::class, - 'paypal/api_nvp' => \Mage_Paypal_Model_Api_Nvp::class, - 'paypal/api_processableException' => \Mage_Paypal_Model_Api_ProcessableException::class, - 'paypal/api_standard' => \Mage_Paypal_Model_Api_Standard::class, - 'paypal/bml' => \Mage_Paypal_Model_Bml::class, + 'paypal/api' => \Mage_Paypal_Model_Api::class, + 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, + 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, - 'paypal/cert' => \Mage_Paypal_Model_Cert::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, - 'paypal/direct' => \Mage_Paypal_Model_Direct::class, - 'paypal/express' => \Mage_Paypal_Model_Express::class, - 'paypal/express_checkout' => \Mage_Paypal_Model_Express_Checkout::class, - 'paypal/hostedpro' => \Mage_Paypal_Model_Hostedpro::class, - 'paypal/hostedpro_request' => \Mage_Paypal_Model_Hostedpro_Request::class, - 'paypal/info' => \Mage_Paypal_Model_Info::class, - 'paypal/ipn' => \Mage_Paypal_Model_Ipn::class, - 'paypal/method_agreement' => \Mage_Paypal_Model_Method_Agreement::class, - 'paypal/mysql4_cert' => \Mage_Paypal_Model_Mysql4_Cert::class, - 'paypal/mysql4_report_settlement' => \Mage_Paypal_Model_Mysql4_Report_Settlement::class, - 'paypal/mysql4_report_settlement_row' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row::class, - 'paypal/mysql4_report_settlement_row_collection' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row_Collection::class, - 'paypal/mysql4_setup' => \Mage_Paypal_Model_Mysql4_Setup::class, - 'paypal/observer' => \Mage_Paypal_Model_Observer::class, - 'paypal/payflow_request' => \Mage_Paypal_Model_Payflow_Request::class, - 'paypal/payflowadvanced' => \Mage_Paypal_Model_Payflowadvanced::class, - 'paypal/payflowlink' => \Mage_Paypal_Model_Payflowlink::class, - 'paypal/payflowpro' => \Mage_Paypal_Model_Payflowpro::class, - 'paypal/payment_transaction' => \Mage_Paypal_Model_Payment_Transaction::class, - 'paypal/pro' => \Mage_Paypal_Model_Pro::class, - 'paypal/report_settlement' => \Mage_Paypal_Model_Report_Settlement::class, - 'paypal/report_settlement_row' => \Mage_Paypal_Model_Report_Settlement_Row::class, - 'paypal/resource_cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal_resource/cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal/resource_payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal_resource/payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal/resource_payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal_resource/payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal/resource_report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal_resource/report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal/resource_report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal_resource/report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal/resource_report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, - 'paypal_resource/report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, + 'paypal/debug' => \Mage_Paypal_Model_Debug::class, + 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, + 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal/resource_debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, + 'paypal_resource/debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, 'paypal/resource_setup' => \Mage_Paypal_Model_Resource_Setup::class, 'paypal_resource/setup' => \Mage_Paypal_Model_Resource_Setup::class, - 'paypal/session' => \Mage_Paypal_Model_Session::class, - 'paypal/standard' => \Mage_Paypal_Model_Standard::class, - 'paypal/system_config_backend_cert' => \Mage_Paypal_Model_System_Config_Backend_Cert::class, - 'paypal/system_config_backend_cron' => \Mage_Paypal_Model_System_Config_Backend_Cron::class, 'paypal/system_config_backend_merchantCountry' => \Mage_Paypal_Model_System_Config_Backend_MerchantCountry::class, - 'paypal/system_config_source_authorizationAmounts' => \Mage_Paypal_Model_System_Config_Source_AuthorizationAmounts::class, - 'paypal/system_config_source_bmlPosition' => \Mage_Paypal_Model_System_Config_Source_BmlPosition::class, - 'paypal/system_config_source_bmlSize' => \Mage_Paypal_Model_System_Config_Source_BmlSize::class, - 'paypal/system_config_source_buyerCountry' => \Mage_Paypal_Model_System_Config_Source_BuyerCountry::class, - 'paypal/system_config_source_fetchingSchedule' => \Mage_Paypal_Model_System_Config_Source_FetchingSchedule::class, - 'paypal/system_config_source_logo' => \Mage_Paypal_Model_System_Config_Source_Logo::class, + 'paypal/system_config_source_buttonColors' => \Mage_Paypal_Model_System_Config_Source_ButtonColors::class, + 'paypal/system_config_source_buttonLabels' => \Mage_Paypal_Model_System_Config_Source_ButtonLabels::class, + 'paypal/system_config_source_buttonLayouts' => \Mage_Paypal_Model_System_Config_Source_ButtonLayouts::class, + 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/system_config_source_paymentActions_express' => \Mage_Paypal_Model_System_Config_Source_PaymentActions_Express::class, - 'paypal/system_config_source_requireBillingAddress' => \Mage_Paypal_Model_System_Config_Source_RequireBillingAddress::class, - 'paypal/system_config_source_urlMethod' => \Mage_Paypal_Model_System_Config_Source_UrlMethod::class, - 'paypal/system_config_source_yesnoShortcut' => \Mage_Paypal_Model_System_Config_Source_YesnoShortcut::class, + 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, + 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, + 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -6493,6 +6411,7 @@ 'adminhtml/system_config_source_customer_forgotpassword' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Forgotpassword::class, 'adminhtml/system_config_source_customer_group' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group::class, 'adminhtml/system_config_source_customer_group_multiselect' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group_Multiselect::class, + 'adminhtml/system_config_source_dashboard_chart_type' => \Mage_Adminhtml_Model_System_Config_Source_Dashboard_Chart_Type::class, 'adminhtml/system_config_source_date_short' => \Mage_Adminhtml_Model_System_Config_Source_Date_Short::class, 'adminhtml/system_config_source_design_robots' => \Mage_Adminhtml_Model_System_Config_Source_Design_Robots::class, 'adminhtml/system_config_source_dev_dbautoup' => \Mage_Adminhtml_Model_System_Config_Source_Dev_Dbautoup::class, @@ -6955,6 +6874,7 @@ 'catalog/layer_filter_price_algorithm' => \Mage_Catalog_Model_Layer_Filter_Price_Algorithm::class, 'catalog/layer_state' => \Mage_Catalog_Model_Layer_State::class, 'catalog/observer' => \Mage_Catalog_Model_Observer::class, + 'catalog/observer_disableAdvancedSearch' => \Mage_Catalog_Model_Observer_DisableAdvancedSearch::class, 'catalog/product' => \Mage_Catalog_Model_Product::class, 'catalog/product_action' => \Mage_Catalog_Model_Product_Action::class, 'catalog/product_api' => \Mage_Catalog_Model_Product_Api::class, @@ -7634,6 +7554,9 @@ 'cron/resource_schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron_resource/schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron/schedule' => \Mage_Cron_Model_Schedule::class, + 'csp/observer_abstract' => \Mage_Csp_Model_Observer_Abstract::class, + 'csp/observer_addAdminCspHeaders' => \Mage_Csp_Model_Observer_AddAdminCspHeaders::class, + 'csp/observer_addFrontendCspHeaders' => \Mage_Csp_Model_Observer_AddFrontendCspHeaders::class, 'currencysymbol/observer' => \Mage_CurrencySymbol_Model_Observer::class, 'currencysymbol/system_currencysymbol' => \Mage_CurrencySymbol_Model_System_Currencysymbol::class, 'customer/address' => \Mage_Customer_Model_Address::class, @@ -8242,76 +8165,30 @@ 'payment/recurring_profile' => \Mage_Payment_Model_Recurring_Profile::class, 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, - 'paypaluk/api_express_nvp' => \Mage_PaypalUk_Model_Api_Express_Nvp::class, - 'paypaluk/api_nvp' => \Mage_PaypalUk_Model_Api_Nvp::class, - 'paypaluk/bml' => \Mage_PaypalUk_Model_Bml::class, - 'paypaluk/direct' => \Mage_PaypalUk_Model_Direct::class, - 'paypaluk/express' => \Mage_PaypalUk_Model_Express::class, - 'paypaluk/express_checkout' => \Mage_PaypalUk_Model_Express_Checkout::class, - 'paypaluk/express_pro' => \Mage_PaypalUk_Model_Express_Pro::class, - 'paypaluk/pro' => \Mage_PaypalUk_Model_Pro::class, - 'paypaluk/session' => \Mage_PaypalUk_Model_Session::class, - 'paypal/api_abstract' => \Mage_Paypal_Model_Api_Abstract::class, - 'paypal/api_nvp' => \Mage_Paypal_Model_Api_Nvp::class, - 'paypal/api_processableException' => \Mage_Paypal_Model_Api_ProcessableException::class, - 'paypal/api_standard' => \Mage_Paypal_Model_Api_Standard::class, - 'paypal/bml' => \Mage_Paypal_Model_Bml::class, + 'paypal/api' => \Mage_Paypal_Model_Api::class, + 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, + 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, - 'paypal/cert' => \Mage_Paypal_Model_Cert::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, - 'paypal/direct' => \Mage_Paypal_Model_Direct::class, - 'paypal/express' => \Mage_Paypal_Model_Express::class, - 'paypal/express_checkout' => \Mage_Paypal_Model_Express_Checkout::class, - 'paypal/hostedpro' => \Mage_Paypal_Model_Hostedpro::class, - 'paypal/hostedpro_request' => \Mage_Paypal_Model_Hostedpro_Request::class, - 'paypal/info' => \Mage_Paypal_Model_Info::class, - 'paypal/ipn' => \Mage_Paypal_Model_Ipn::class, - 'paypal/method_agreement' => \Mage_Paypal_Model_Method_Agreement::class, - 'paypal/mysql4_cert' => \Mage_Paypal_Model_Mysql4_Cert::class, - 'paypal/mysql4_report_settlement' => \Mage_Paypal_Model_Mysql4_Report_Settlement::class, - 'paypal/mysql4_report_settlement_row' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row::class, - 'paypal/mysql4_report_settlement_row_collection' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row_Collection::class, - 'paypal/mysql4_setup' => \Mage_Paypal_Model_Mysql4_Setup::class, - 'paypal/observer' => \Mage_Paypal_Model_Observer::class, - 'paypal/payflow_request' => \Mage_Paypal_Model_Payflow_Request::class, - 'paypal/payflowadvanced' => \Mage_Paypal_Model_Payflowadvanced::class, - 'paypal/payflowlink' => \Mage_Paypal_Model_Payflowlink::class, - 'paypal/payflowpro' => \Mage_Paypal_Model_Payflowpro::class, - 'paypal/payment_transaction' => \Mage_Paypal_Model_Payment_Transaction::class, - 'paypal/pro' => \Mage_Paypal_Model_Pro::class, - 'paypal/report_settlement' => \Mage_Paypal_Model_Report_Settlement::class, - 'paypal/report_settlement_row' => \Mage_Paypal_Model_Report_Settlement_Row::class, - 'paypal/resource_cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal_resource/cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal/resource_payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal_resource/payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal/resource_payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal_resource/payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal/resource_report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal_resource/report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal/resource_report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal_resource/report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal/resource_report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, - 'paypal_resource/report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, + 'paypal/debug' => \Mage_Paypal_Model_Debug::class, + 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, + 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal/resource_debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, + 'paypal_resource/debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, 'paypal/resource_setup' => \Mage_Paypal_Model_Resource_Setup::class, 'paypal_resource/setup' => \Mage_Paypal_Model_Resource_Setup::class, - 'paypal/session' => \Mage_Paypal_Model_Session::class, - 'paypal/standard' => \Mage_Paypal_Model_Standard::class, - 'paypal/system_config_backend_cert' => \Mage_Paypal_Model_System_Config_Backend_Cert::class, - 'paypal/system_config_backend_cron' => \Mage_Paypal_Model_System_Config_Backend_Cron::class, 'paypal/system_config_backend_merchantCountry' => \Mage_Paypal_Model_System_Config_Backend_MerchantCountry::class, - 'paypal/system_config_source_authorizationAmounts' => \Mage_Paypal_Model_System_Config_Source_AuthorizationAmounts::class, - 'paypal/system_config_source_bmlPosition' => \Mage_Paypal_Model_System_Config_Source_BmlPosition::class, - 'paypal/system_config_source_bmlSize' => \Mage_Paypal_Model_System_Config_Source_BmlSize::class, - 'paypal/system_config_source_buyerCountry' => \Mage_Paypal_Model_System_Config_Source_BuyerCountry::class, - 'paypal/system_config_source_fetchingSchedule' => \Mage_Paypal_Model_System_Config_Source_FetchingSchedule::class, - 'paypal/system_config_source_logo' => \Mage_Paypal_Model_System_Config_Source_Logo::class, + 'paypal/system_config_source_buttonColors' => \Mage_Paypal_Model_System_Config_Source_ButtonColors::class, + 'paypal/system_config_source_buttonLabels' => \Mage_Paypal_Model_System_Config_Source_ButtonLabels::class, + 'paypal/system_config_source_buttonLayouts' => \Mage_Paypal_Model_System_Config_Source_ButtonLayouts::class, + 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/system_config_source_paymentActions_express' => \Mage_Paypal_Model_System_Config_Source_PaymentActions_Express::class, - 'paypal/system_config_source_requireBillingAddress' => \Mage_Paypal_Model_System_Config_Source_RequireBillingAddress::class, - 'paypal/system_config_source_urlMethod' => \Mage_Paypal_Model_System_Config_Source_UrlMethod::class, - 'paypal/system_config_source_yesnoShortcut' => \Mage_Paypal_Model_System_Config_Source_YesnoShortcut::class, + 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, + 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, + 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -9649,6 +9526,7 @@ 'adminhtml/system_config_source_customer_forgotpassword' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Forgotpassword::class, 'adminhtml/system_config_source_customer_group' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group::class, 'adminhtml/system_config_source_customer_group_multiselect' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group_Multiselect::class, + 'adminhtml/system_config_source_dashboard_chart_type' => \Mage_Adminhtml_Model_System_Config_Source_Dashboard_Chart_Type::class, 'adminhtml/system_config_source_date_short' => \Mage_Adminhtml_Model_System_Config_Source_Date_Short::class, 'adminhtml/system_config_source_design_robots' => \Mage_Adminhtml_Model_System_Config_Source_Design_Robots::class, 'adminhtml/system_config_source_dev_dbautoup' => \Mage_Adminhtml_Model_System_Config_Source_Dev_Dbautoup::class, @@ -10111,6 +9989,7 @@ 'catalog/layer_filter_price_algorithm' => \Mage_Catalog_Model_Layer_Filter_Price_Algorithm::class, 'catalog/layer_state' => \Mage_Catalog_Model_Layer_State::class, 'catalog/observer' => \Mage_Catalog_Model_Observer::class, + 'catalog/observer_disableAdvancedSearch' => \Mage_Catalog_Model_Observer_DisableAdvancedSearch::class, 'catalog/product' => \Mage_Catalog_Model_Product::class, 'catalog/product_action' => \Mage_Catalog_Model_Product_Action::class, 'catalog/product_api' => \Mage_Catalog_Model_Product_Api::class, @@ -10790,6 +10669,9 @@ 'cron/resource_schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron_resource/schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron/schedule' => \Mage_Cron_Model_Schedule::class, + 'csp/observer_abstract' => \Mage_Csp_Model_Observer_Abstract::class, + 'csp/observer_addAdminCspHeaders' => \Mage_Csp_Model_Observer_AddAdminCspHeaders::class, + 'csp/observer_addFrontendCspHeaders' => \Mage_Csp_Model_Observer_AddFrontendCspHeaders::class, 'currencysymbol/observer' => \Mage_CurrencySymbol_Model_Observer::class, 'currencysymbol/system_currencysymbol' => \Mage_CurrencySymbol_Model_System_Currencysymbol::class, 'customer/address' => \Mage_Customer_Model_Address::class, @@ -11398,76 +11280,30 @@ 'payment/recurring_profile' => \Mage_Payment_Model_Recurring_Profile::class, 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, - 'paypaluk/api_express_nvp' => \Mage_PaypalUk_Model_Api_Express_Nvp::class, - 'paypaluk/api_nvp' => \Mage_PaypalUk_Model_Api_Nvp::class, - 'paypaluk/bml' => \Mage_PaypalUk_Model_Bml::class, - 'paypaluk/direct' => \Mage_PaypalUk_Model_Direct::class, - 'paypaluk/express' => \Mage_PaypalUk_Model_Express::class, - 'paypaluk/express_checkout' => \Mage_PaypalUk_Model_Express_Checkout::class, - 'paypaluk/express_pro' => \Mage_PaypalUk_Model_Express_Pro::class, - 'paypaluk/pro' => \Mage_PaypalUk_Model_Pro::class, - 'paypaluk/session' => \Mage_PaypalUk_Model_Session::class, - 'paypal/api_abstract' => \Mage_Paypal_Model_Api_Abstract::class, - 'paypal/api_nvp' => \Mage_Paypal_Model_Api_Nvp::class, - 'paypal/api_processableException' => \Mage_Paypal_Model_Api_ProcessableException::class, - 'paypal/api_standard' => \Mage_Paypal_Model_Api_Standard::class, - 'paypal/bml' => \Mage_Paypal_Model_Bml::class, + 'paypal/api' => \Mage_Paypal_Model_Api::class, + 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, + 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, - 'paypal/cert' => \Mage_Paypal_Model_Cert::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, - 'paypal/direct' => \Mage_Paypal_Model_Direct::class, - 'paypal/express' => \Mage_Paypal_Model_Express::class, - 'paypal/express_checkout' => \Mage_Paypal_Model_Express_Checkout::class, - 'paypal/hostedpro' => \Mage_Paypal_Model_Hostedpro::class, - 'paypal/hostedpro_request' => \Mage_Paypal_Model_Hostedpro_Request::class, - 'paypal/info' => \Mage_Paypal_Model_Info::class, - 'paypal/ipn' => \Mage_Paypal_Model_Ipn::class, - 'paypal/method_agreement' => \Mage_Paypal_Model_Method_Agreement::class, - 'paypal/mysql4_cert' => \Mage_Paypal_Model_Mysql4_Cert::class, - 'paypal/mysql4_report_settlement' => \Mage_Paypal_Model_Mysql4_Report_Settlement::class, - 'paypal/mysql4_report_settlement_row' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row::class, - 'paypal/mysql4_report_settlement_row_collection' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row_Collection::class, - 'paypal/mysql4_setup' => \Mage_Paypal_Model_Mysql4_Setup::class, - 'paypal/observer' => \Mage_Paypal_Model_Observer::class, - 'paypal/payflow_request' => \Mage_Paypal_Model_Payflow_Request::class, - 'paypal/payflowadvanced' => \Mage_Paypal_Model_Payflowadvanced::class, - 'paypal/payflowlink' => \Mage_Paypal_Model_Payflowlink::class, - 'paypal/payflowpro' => \Mage_Paypal_Model_Payflowpro::class, - 'paypal/payment_transaction' => \Mage_Paypal_Model_Payment_Transaction::class, - 'paypal/pro' => \Mage_Paypal_Model_Pro::class, - 'paypal/report_settlement' => \Mage_Paypal_Model_Report_Settlement::class, - 'paypal/report_settlement_row' => \Mage_Paypal_Model_Report_Settlement_Row::class, - 'paypal/resource_cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal_resource/cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal/resource_payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal_resource/payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal/resource_payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal_resource/payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal/resource_report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal_resource/report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal/resource_report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal_resource/report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal/resource_report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, - 'paypal_resource/report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, + 'paypal/debug' => \Mage_Paypal_Model_Debug::class, + 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, + 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal/resource_debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, + 'paypal_resource/debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, 'paypal/resource_setup' => \Mage_Paypal_Model_Resource_Setup::class, 'paypal_resource/setup' => \Mage_Paypal_Model_Resource_Setup::class, - 'paypal/session' => \Mage_Paypal_Model_Session::class, - 'paypal/standard' => \Mage_Paypal_Model_Standard::class, - 'paypal/system_config_backend_cert' => \Mage_Paypal_Model_System_Config_Backend_Cert::class, - 'paypal/system_config_backend_cron' => \Mage_Paypal_Model_System_Config_Backend_Cron::class, 'paypal/system_config_backend_merchantCountry' => \Mage_Paypal_Model_System_Config_Backend_MerchantCountry::class, - 'paypal/system_config_source_authorizationAmounts' => \Mage_Paypal_Model_System_Config_Source_AuthorizationAmounts::class, - 'paypal/system_config_source_bmlPosition' => \Mage_Paypal_Model_System_Config_Source_BmlPosition::class, - 'paypal/system_config_source_bmlSize' => \Mage_Paypal_Model_System_Config_Source_BmlSize::class, - 'paypal/system_config_source_buyerCountry' => \Mage_Paypal_Model_System_Config_Source_BuyerCountry::class, - 'paypal/system_config_source_fetchingSchedule' => \Mage_Paypal_Model_System_Config_Source_FetchingSchedule::class, - 'paypal/system_config_source_logo' => \Mage_Paypal_Model_System_Config_Source_Logo::class, + 'paypal/system_config_source_buttonColors' => \Mage_Paypal_Model_System_Config_Source_ButtonColors::class, + 'paypal/system_config_source_buttonLabels' => \Mage_Paypal_Model_System_Config_Source_ButtonLabels::class, + 'paypal/system_config_source_buttonLayouts' => \Mage_Paypal_Model_System_Config_Source_ButtonLayouts::class, + 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/system_config_source_paymentActions_express' => \Mage_Paypal_Model_System_Config_Source_PaymentActions_Express::class, - 'paypal/system_config_source_requireBillingAddress' => \Mage_Paypal_Model_System_Config_Source_RequireBillingAddress::class, - 'paypal/system_config_source_urlMethod' => \Mage_Paypal_Model_System_Config_Source_UrlMethod::class, - 'paypal/system_config_source_yesnoShortcut' => \Mage_Paypal_Model_System_Config_Source_YesnoShortcut::class, + 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, + 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, + 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -12805,6 +12641,7 @@ 'adminhtml/system_config_source_customer_forgotpassword' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Forgotpassword::class, 'adminhtml/system_config_source_customer_group' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group::class, 'adminhtml/system_config_source_customer_group_multiselect' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group_Multiselect::class, + 'adminhtml/system_config_source_dashboard_chart_type' => \Mage_Adminhtml_Model_System_Config_Source_Dashboard_Chart_Type::class, 'adminhtml/system_config_source_date_short' => \Mage_Adminhtml_Model_System_Config_Source_Date_Short::class, 'adminhtml/system_config_source_design_robots' => \Mage_Adminhtml_Model_System_Config_Source_Design_Robots::class, 'adminhtml/system_config_source_dev_dbautoup' => \Mage_Adminhtml_Model_System_Config_Source_Dev_Dbautoup::class, @@ -13267,6 +13104,7 @@ 'catalog/layer_filter_price_algorithm' => \Mage_Catalog_Model_Layer_Filter_Price_Algorithm::class, 'catalog/layer_state' => \Mage_Catalog_Model_Layer_State::class, 'catalog/observer' => \Mage_Catalog_Model_Observer::class, + 'catalog/observer_disableAdvancedSearch' => \Mage_Catalog_Model_Observer_DisableAdvancedSearch::class, 'catalog/product' => \Mage_Catalog_Model_Product::class, 'catalog/product_action' => \Mage_Catalog_Model_Product_Action::class, 'catalog/product_api' => \Mage_Catalog_Model_Product_Api::class, @@ -13946,6 +13784,9 @@ 'cron/resource_schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron_resource/schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron/schedule' => \Mage_Cron_Model_Schedule::class, + 'csp/observer_abstract' => \Mage_Csp_Model_Observer_Abstract::class, + 'csp/observer_addAdminCspHeaders' => \Mage_Csp_Model_Observer_AddAdminCspHeaders::class, + 'csp/observer_addFrontendCspHeaders' => \Mage_Csp_Model_Observer_AddFrontendCspHeaders::class, 'currencysymbol/observer' => \Mage_CurrencySymbol_Model_Observer::class, 'currencysymbol/system_currencysymbol' => \Mage_CurrencySymbol_Model_System_Currencysymbol::class, 'customer/address' => \Mage_Customer_Model_Address::class, @@ -14554,76 +14395,30 @@ 'payment/recurring_profile' => \Mage_Payment_Model_Recurring_Profile::class, 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, - 'paypaluk/api_express_nvp' => \Mage_PaypalUk_Model_Api_Express_Nvp::class, - 'paypaluk/api_nvp' => \Mage_PaypalUk_Model_Api_Nvp::class, - 'paypaluk/bml' => \Mage_PaypalUk_Model_Bml::class, - 'paypaluk/direct' => \Mage_PaypalUk_Model_Direct::class, - 'paypaluk/express' => \Mage_PaypalUk_Model_Express::class, - 'paypaluk/express_checkout' => \Mage_PaypalUk_Model_Express_Checkout::class, - 'paypaluk/express_pro' => \Mage_PaypalUk_Model_Express_Pro::class, - 'paypaluk/pro' => \Mage_PaypalUk_Model_Pro::class, - 'paypaluk/session' => \Mage_PaypalUk_Model_Session::class, - 'paypal/api_abstract' => \Mage_Paypal_Model_Api_Abstract::class, - 'paypal/api_nvp' => \Mage_Paypal_Model_Api_Nvp::class, - 'paypal/api_processableException' => \Mage_Paypal_Model_Api_ProcessableException::class, - 'paypal/api_standard' => \Mage_Paypal_Model_Api_Standard::class, - 'paypal/bml' => \Mage_Paypal_Model_Bml::class, + 'paypal/api' => \Mage_Paypal_Model_Api::class, + 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, + 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, - 'paypal/cert' => \Mage_Paypal_Model_Cert::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, - 'paypal/direct' => \Mage_Paypal_Model_Direct::class, - 'paypal/express' => \Mage_Paypal_Model_Express::class, - 'paypal/express_checkout' => \Mage_Paypal_Model_Express_Checkout::class, - 'paypal/hostedpro' => \Mage_Paypal_Model_Hostedpro::class, - 'paypal/hostedpro_request' => \Mage_Paypal_Model_Hostedpro_Request::class, - 'paypal/info' => \Mage_Paypal_Model_Info::class, - 'paypal/ipn' => \Mage_Paypal_Model_Ipn::class, - 'paypal/method_agreement' => \Mage_Paypal_Model_Method_Agreement::class, - 'paypal/mysql4_cert' => \Mage_Paypal_Model_Mysql4_Cert::class, - 'paypal/mysql4_report_settlement' => \Mage_Paypal_Model_Mysql4_Report_Settlement::class, - 'paypal/mysql4_report_settlement_row' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row::class, - 'paypal/mysql4_report_settlement_row_collection' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row_Collection::class, - 'paypal/mysql4_setup' => \Mage_Paypal_Model_Mysql4_Setup::class, - 'paypal/observer' => \Mage_Paypal_Model_Observer::class, - 'paypal/payflow_request' => \Mage_Paypal_Model_Payflow_Request::class, - 'paypal/payflowadvanced' => \Mage_Paypal_Model_Payflowadvanced::class, - 'paypal/payflowlink' => \Mage_Paypal_Model_Payflowlink::class, - 'paypal/payflowpro' => \Mage_Paypal_Model_Payflowpro::class, - 'paypal/payment_transaction' => \Mage_Paypal_Model_Payment_Transaction::class, - 'paypal/pro' => \Mage_Paypal_Model_Pro::class, - 'paypal/report_settlement' => \Mage_Paypal_Model_Report_Settlement::class, - 'paypal/report_settlement_row' => \Mage_Paypal_Model_Report_Settlement_Row::class, - 'paypal/resource_cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal_resource/cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal/resource_payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal_resource/payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal/resource_payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal_resource/payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal/resource_report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal_resource/report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal/resource_report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal_resource/report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal/resource_report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, - 'paypal_resource/report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, + 'paypal/debug' => \Mage_Paypal_Model_Debug::class, + 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, + 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal/resource_debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, + 'paypal_resource/debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, 'paypal/resource_setup' => \Mage_Paypal_Model_Resource_Setup::class, 'paypal_resource/setup' => \Mage_Paypal_Model_Resource_Setup::class, - 'paypal/session' => \Mage_Paypal_Model_Session::class, - 'paypal/standard' => \Mage_Paypal_Model_Standard::class, - 'paypal/system_config_backend_cert' => \Mage_Paypal_Model_System_Config_Backend_Cert::class, - 'paypal/system_config_backend_cron' => \Mage_Paypal_Model_System_Config_Backend_Cron::class, 'paypal/system_config_backend_merchantCountry' => \Mage_Paypal_Model_System_Config_Backend_MerchantCountry::class, - 'paypal/system_config_source_authorizationAmounts' => \Mage_Paypal_Model_System_Config_Source_AuthorizationAmounts::class, - 'paypal/system_config_source_bmlPosition' => \Mage_Paypal_Model_System_Config_Source_BmlPosition::class, - 'paypal/system_config_source_bmlSize' => \Mage_Paypal_Model_System_Config_Source_BmlSize::class, - 'paypal/system_config_source_buyerCountry' => \Mage_Paypal_Model_System_Config_Source_BuyerCountry::class, - 'paypal/system_config_source_fetchingSchedule' => \Mage_Paypal_Model_System_Config_Source_FetchingSchedule::class, - 'paypal/system_config_source_logo' => \Mage_Paypal_Model_System_Config_Source_Logo::class, + 'paypal/system_config_source_buttonColors' => \Mage_Paypal_Model_System_Config_Source_ButtonColors::class, + 'paypal/system_config_source_buttonLabels' => \Mage_Paypal_Model_System_Config_Source_ButtonLabels::class, + 'paypal/system_config_source_buttonLayouts' => \Mage_Paypal_Model_System_Config_Source_ButtonLayouts::class, + 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/system_config_source_paymentActions_express' => \Mage_Paypal_Model_System_Config_Source_PaymentActions_Express::class, - 'paypal/system_config_source_requireBillingAddress' => \Mage_Paypal_Model_System_Config_Source_RequireBillingAddress::class, - 'paypal/system_config_source_urlMethod' => \Mage_Paypal_Model_System_Config_Source_UrlMethod::class, - 'paypal/system_config_source_yesnoShortcut' => \Mage_Paypal_Model_System_Config_Source_YesnoShortcut::class, + 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, + 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, + 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -15961,6 +15756,7 @@ 'adminhtml/system_config_source_customer_forgotpassword' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Forgotpassword::class, 'adminhtml/system_config_source_customer_group' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group::class, 'adminhtml/system_config_source_customer_group_multiselect' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group_Multiselect::class, + 'adminhtml/system_config_source_dashboard_chart_type' => \Mage_Adminhtml_Model_System_Config_Source_Dashboard_Chart_Type::class, 'adminhtml/system_config_source_date_short' => \Mage_Adminhtml_Model_System_Config_Source_Date_Short::class, 'adminhtml/system_config_source_design_robots' => \Mage_Adminhtml_Model_System_Config_Source_Design_Robots::class, 'adminhtml/system_config_source_dev_dbautoup' => \Mage_Adminhtml_Model_System_Config_Source_Dev_Dbautoup::class, @@ -16423,6 +16219,7 @@ 'catalog/layer_filter_price_algorithm' => \Mage_Catalog_Model_Layer_Filter_Price_Algorithm::class, 'catalog/layer_state' => \Mage_Catalog_Model_Layer_State::class, 'catalog/observer' => \Mage_Catalog_Model_Observer::class, + 'catalog/observer_disableAdvancedSearch' => \Mage_Catalog_Model_Observer_DisableAdvancedSearch::class, 'catalog/product' => \Mage_Catalog_Model_Product::class, 'catalog/product_action' => \Mage_Catalog_Model_Product_Action::class, 'catalog/product_api' => \Mage_Catalog_Model_Product_Api::class, @@ -17102,6 +16899,9 @@ 'cron/resource_schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron_resource/schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron/schedule' => \Mage_Cron_Model_Schedule::class, + 'csp/observer_abstract' => \Mage_Csp_Model_Observer_Abstract::class, + 'csp/observer_addAdminCspHeaders' => \Mage_Csp_Model_Observer_AddAdminCspHeaders::class, + 'csp/observer_addFrontendCspHeaders' => \Mage_Csp_Model_Observer_AddFrontendCspHeaders::class, 'currencysymbol/observer' => \Mage_CurrencySymbol_Model_Observer::class, 'currencysymbol/system_currencysymbol' => \Mage_CurrencySymbol_Model_System_Currencysymbol::class, 'customer/address' => \Mage_Customer_Model_Address::class, @@ -17710,76 +17510,30 @@ 'payment/recurring_profile' => \Mage_Payment_Model_Recurring_Profile::class, 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, - 'paypaluk/api_express_nvp' => \Mage_PaypalUk_Model_Api_Express_Nvp::class, - 'paypaluk/api_nvp' => \Mage_PaypalUk_Model_Api_Nvp::class, - 'paypaluk/bml' => \Mage_PaypalUk_Model_Bml::class, - 'paypaluk/direct' => \Mage_PaypalUk_Model_Direct::class, - 'paypaluk/express' => \Mage_PaypalUk_Model_Express::class, - 'paypaluk/express_checkout' => \Mage_PaypalUk_Model_Express_Checkout::class, - 'paypaluk/express_pro' => \Mage_PaypalUk_Model_Express_Pro::class, - 'paypaluk/pro' => \Mage_PaypalUk_Model_Pro::class, - 'paypaluk/session' => \Mage_PaypalUk_Model_Session::class, - 'paypal/api_abstract' => \Mage_Paypal_Model_Api_Abstract::class, - 'paypal/api_nvp' => \Mage_Paypal_Model_Api_Nvp::class, - 'paypal/api_processableException' => \Mage_Paypal_Model_Api_ProcessableException::class, - 'paypal/api_standard' => \Mage_Paypal_Model_Api_Standard::class, - 'paypal/bml' => \Mage_Paypal_Model_Bml::class, + 'paypal/api' => \Mage_Paypal_Model_Api::class, + 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, + 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, - 'paypal/cert' => \Mage_Paypal_Model_Cert::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, - 'paypal/direct' => \Mage_Paypal_Model_Direct::class, - 'paypal/express' => \Mage_Paypal_Model_Express::class, - 'paypal/express_checkout' => \Mage_Paypal_Model_Express_Checkout::class, - 'paypal/hostedpro' => \Mage_Paypal_Model_Hostedpro::class, - 'paypal/hostedpro_request' => \Mage_Paypal_Model_Hostedpro_Request::class, - 'paypal/info' => \Mage_Paypal_Model_Info::class, - 'paypal/ipn' => \Mage_Paypal_Model_Ipn::class, - 'paypal/method_agreement' => \Mage_Paypal_Model_Method_Agreement::class, - 'paypal/mysql4_cert' => \Mage_Paypal_Model_Mysql4_Cert::class, - 'paypal/mysql4_report_settlement' => \Mage_Paypal_Model_Mysql4_Report_Settlement::class, - 'paypal/mysql4_report_settlement_row' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row::class, - 'paypal/mysql4_report_settlement_row_collection' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row_Collection::class, - 'paypal/mysql4_setup' => \Mage_Paypal_Model_Mysql4_Setup::class, - 'paypal/observer' => \Mage_Paypal_Model_Observer::class, - 'paypal/payflow_request' => \Mage_Paypal_Model_Payflow_Request::class, - 'paypal/payflowadvanced' => \Mage_Paypal_Model_Payflowadvanced::class, - 'paypal/payflowlink' => \Mage_Paypal_Model_Payflowlink::class, - 'paypal/payflowpro' => \Mage_Paypal_Model_Payflowpro::class, - 'paypal/payment_transaction' => \Mage_Paypal_Model_Payment_Transaction::class, - 'paypal/pro' => \Mage_Paypal_Model_Pro::class, - 'paypal/report_settlement' => \Mage_Paypal_Model_Report_Settlement::class, - 'paypal/report_settlement_row' => \Mage_Paypal_Model_Report_Settlement_Row::class, - 'paypal/resource_cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal_resource/cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal/resource_payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal_resource/payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal/resource_payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal_resource/payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal/resource_report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal_resource/report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal/resource_report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal_resource/report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal/resource_report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, - 'paypal_resource/report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, + 'paypal/debug' => \Mage_Paypal_Model_Debug::class, + 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, + 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal/resource_debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, + 'paypal_resource/debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, 'paypal/resource_setup' => \Mage_Paypal_Model_Resource_Setup::class, 'paypal_resource/setup' => \Mage_Paypal_Model_Resource_Setup::class, - 'paypal/session' => \Mage_Paypal_Model_Session::class, - 'paypal/standard' => \Mage_Paypal_Model_Standard::class, - 'paypal/system_config_backend_cert' => \Mage_Paypal_Model_System_Config_Backend_Cert::class, - 'paypal/system_config_backend_cron' => \Mage_Paypal_Model_System_Config_Backend_Cron::class, 'paypal/system_config_backend_merchantCountry' => \Mage_Paypal_Model_System_Config_Backend_MerchantCountry::class, - 'paypal/system_config_source_authorizationAmounts' => \Mage_Paypal_Model_System_Config_Source_AuthorizationAmounts::class, - 'paypal/system_config_source_bmlPosition' => \Mage_Paypal_Model_System_Config_Source_BmlPosition::class, - 'paypal/system_config_source_bmlSize' => \Mage_Paypal_Model_System_Config_Source_BmlSize::class, - 'paypal/system_config_source_buyerCountry' => \Mage_Paypal_Model_System_Config_Source_BuyerCountry::class, - 'paypal/system_config_source_fetchingSchedule' => \Mage_Paypal_Model_System_Config_Source_FetchingSchedule::class, - 'paypal/system_config_source_logo' => \Mage_Paypal_Model_System_Config_Source_Logo::class, + 'paypal/system_config_source_buttonColors' => \Mage_Paypal_Model_System_Config_Source_ButtonColors::class, + 'paypal/system_config_source_buttonLabels' => \Mage_Paypal_Model_System_Config_Source_ButtonLabels::class, + 'paypal/system_config_source_buttonLayouts' => \Mage_Paypal_Model_System_Config_Source_ButtonLayouts::class, + 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/system_config_source_paymentActions_express' => \Mage_Paypal_Model_System_Config_Source_PaymentActions_Express::class, - 'paypal/system_config_source_requireBillingAddress' => \Mage_Paypal_Model_System_Config_Source_RequireBillingAddress::class, - 'paypal/system_config_source_urlMethod' => \Mage_Paypal_Model_System_Config_Source_UrlMethod::class, - 'paypal/system_config_source_yesnoShortcut' => \Mage_Paypal_Model_System_Config_Source_YesnoShortcut::class, + 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, + 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, + 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -19117,6 +18871,7 @@ 'adminhtml/system_config_source_customer_forgotpassword' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Forgotpassword::class, 'adminhtml/system_config_source_customer_group' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group::class, 'adminhtml/system_config_source_customer_group_multiselect' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group_Multiselect::class, + 'adminhtml/system_config_source_dashboard_chart_type' => \Mage_Adminhtml_Model_System_Config_Source_Dashboard_Chart_Type::class, 'adminhtml/system_config_source_date_short' => \Mage_Adminhtml_Model_System_Config_Source_Date_Short::class, 'adminhtml/system_config_source_design_robots' => \Mage_Adminhtml_Model_System_Config_Source_Design_Robots::class, 'adminhtml/system_config_source_dev_dbautoup' => \Mage_Adminhtml_Model_System_Config_Source_Dev_Dbautoup::class, @@ -19579,6 +19334,7 @@ 'catalog/layer_filter_price_algorithm' => \Mage_Catalog_Model_Layer_Filter_Price_Algorithm::class, 'catalog/layer_state' => \Mage_Catalog_Model_Layer_State::class, 'catalog/observer' => \Mage_Catalog_Model_Observer::class, + 'catalog/observer_disableAdvancedSearch' => \Mage_Catalog_Model_Observer_DisableAdvancedSearch::class, 'catalog/product' => \Mage_Catalog_Model_Product::class, 'catalog/product_action' => \Mage_Catalog_Model_Product_Action::class, 'catalog/product_api' => \Mage_Catalog_Model_Product_Api::class, @@ -20258,6 +20014,9 @@ 'cron/resource_schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron_resource/schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron/schedule' => \Mage_Cron_Model_Schedule::class, + 'csp/observer_abstract' => \Mage_Csp_Model_Observer_Abstract::class, + 'csp/observer_addAdminCspHeaders' => \Mage_Csp_Model_Observer_AddAdminCspHeaders::class, + 'csp/observer_addFrontendCspHeaders' => \Mage_Csp_Model_Observer_AddFrontendCspHeaders::class, 'currencysymbol/observer' => \Mage_CurrencySymbol_Model_Observer::class, 'currencysymbol/system_currencysymbol' => \Mage_CurrencySymbol_Model_System_Currencysymbol::class, 'customer/address' => \Mage_Customer_Model_Address::class, @@ -20866,76 +20625,30 @@ 'payment/recurring_profile' => \Mage_Payment_Model_Recurring_Profile::class, 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, - 'paypaluk/api_express_nvp' => \Mage_PaypalUk_Model_Api_Express_Nvp::class, - 'paypaluk/api_nvp' => \Mage_PaypalUk_Model_Api_Nvp::class, - 'paypaluk/bml' => \Mage_PaypalUk_Model_Bml::class, - 'paypaluk/direct' => \Mage_PaypalUk_Model_Direct::class, - 'paypaluk/express' => \Mage_PaypalUk_Model_Express::class, - 'paypaluk/express_checkout' => \Mage_PaypalUk_Model_Express_Checkout::class, - 'paypaluk/express_pro' => \Mage_PaypalUk_Model_Express_Pro::class, - 'paypaluk/pro' => \Mage_PaypalUk_Model_Pro::class, - 'paypaluk/session' => \Mage_PaypalUk_Model_Session::class, - 'paypal/api_abstract' => \Mage_Paypal_Model_Api_Abstract::class, - 'paypal/api_nvp' => \Mage_Paypal_Model_Api_Nvp::class, - 'paypal/api_processableException' => \Mage_Paypal_Model_Api_ProcessableException::class, - 'paypal/api_standard' => \Mage_Paypal_Model_Api_Standard::class, - 'paypal/bml' => \Mage_Paypal_Model_Bml::class, + 'paypal/api' => \Mage_Paypal_Model_Api::class, + 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, + 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, - 'paypal/cert' => \Mage_Paypal_Model_Cert::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, - 'paypal/direct' => \Mage_Paypal_Model_Direct::class, - 'paypal/express' => \Mage_Paypal_Model_Express::class, - 'paypal/express_checkout' => \Mage_Paypal_Model_Express_Checkout::class, - 'paypal/hostedpro' => \Mage_Paypal_Model_Hostedpro::class, - 'paypal/hostedpro_request' => \Mage_Paypal_Model_Hostedpro_Request::class, - 'paypal/info' => \Mage_Paypal_Model_Info::class, - 'paypal/ipn' => \Mage_Paypal_Model_Ipn::class, - 'paypal/method_agreement' => \Mage_Paypal_Model_Method_Agreement::class, - 'paypal/mysql4_cert' => \Mage_Paypal_Model_Mysql4_Cert::class, - 'paypal/mysql4_report_settlement' => \Mage_Paypal_Model_Mysql4_Report_Settlement::class, - 'paypal/mysql4_report_settlement_row' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row::class, - 'paypal/mysql4_report_settlement_row_collection' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row_Collection::class, - 'paypal/mysql4_setup' => \Mage_Paypal_Model_Mysql4_Setup::class, - 'paypal/observer' => \Mage_Paypal_Model_Observer::class, - 'paypal/payflow_request' => \Mage_Paypal_Model_Payflow_Request::class, - 'paypal/payflowadvanced' => \Mage_Paypal_Model_Payflowadvanced::class, - 'paypal/payflowlink' => \Mage_Paypal_Model_Payflowlink::class, - 'paypal/payflowpro' => \Mage_Paypal_Model_Payflowpro::class, - 'paypal/payment_transaction' => \Mage_Paypal_Model_Payment_Transaction::class, - 'paypal/pro' => \Mage_Paypal_Model_Pro::class, - 'paypal/report_settlement' => \Mage_Paypal_Model_Report_Settlement::class, - 'paypal/report_settlement_row' => \Mage_Paypal_Model_Report_Settlement_Row::class, - 'paypal/resource_cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal_resource/cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal/resource_payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal_resource/payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal/resource_payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal_resource/payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal/resource_report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal_resource/report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal/resource_report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal_resource/report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal/resource_report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, - 'paypal_resource/report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, + 'paypal/debug' => \Mage_Paypal_Model_Debug::class, + 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, + 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal/resource_debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, + 'paypal_resource/debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, 'paypal/resource_setup' => \Mage_Paypal_Model_Resource_Setup::class, 'paypal_resource/setup' => \Mage_Paypal_Model_Resource_Setup::class, - 'paypal/session' => \Mage_Paypal_Model_Session::class, - 'paypal/standard' => \Mage_Paypal_Model_Standard::class, - 'paypal/system_config_backend_cert' => \Mage_Paypal_Model_System_Config_Backend_Cert::class, - 'paypal/system_config_backend_cron' => \Mage_Paypal_Model_System_Config_Backend_Cron::class, 'paypal/system_config_backend_merchantCountry' => \Mage_Paypal_Model_System_Config_Backend_MerchantCountry::class, - 'paypal/system_config_source_authorizationAmounts' => \Mage_Paypal_Model_System_Config_Source_AuthorizationAmounts::class, - 'paypal/system_config_source_bmlPosition' => \Mage_Paypal_Model_System_Config_Source_BmlPosition::class, - 'paypal/system_config_source_bmlSize' => \Mage_Paypal_Model_System_Config_Source_BmlSize::class, - 'paypal/system_config_source_buyerCountry' => \Mage_Paypal_Model_System_Config_Source_BuyerCountry::class, - 'paypal/system_config_source_fetchingSchedule' => \Mage_Paypal_Model_System_Config_Source_FetchingSchedule::class, - 'paypal/system_config_source_logo' => \Mage_Paypal_Model_System_Config_Source_Logo::class, + 'paypal/system_config_source_buttonColors' => \Mage_Paypal_Model_System_Config_Source_ButtonColors::class, + 'paypal/system_config_source_buttonLabels' => \Mage_Paypal_Model_System_Config_Source_ButtonLabels::class, + 'paypal/system_config_source_buttonLayouts' => \Mage_Paypal_Model_System_Config_Source_ButtonLayouts::class, + 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/system_config_source_paymentActions_express' => \Mage_Paypal_Model_System_Config_Source_PaymentActions_Express::class, - 'paypal/system_config_source_requireBillingAddress' => \Mage_Paypal_Model_System_Config_Source_RequireBillingAddress::class, - 'paypal/system_config_source_urlMethod' => \Mage_Paypal_Model_System_Config_Source_UrlMethod::class, - 'paypal/system_config_source_yesnoShortcut' => \Mage_Paypal_Model_System_Config_Source_YesnoShortcut::class, + 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, + 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, + 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -22273,6 +21986,7 @@ 'adminhtml/system_config_source_customer_forgotpassword' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Forgotpassword::class, 'adminhtml/system_config_source_customer_group' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group::class, 'adminhtml/system_config_source_customer_group_multiselect' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group_Multiselect::class, + 'adminhtml/system_config_source_dashboard_chart_type' => \Mage_Adminhtml_Model_System_Config_Source_Dashboard_Chart_Type::class, 'adminhtml/system_config_source_date_short' => \Mage_Adminhtml_Model_System_Config_Source_Date_Short::class, 'adminhtml/system_config_source_design_robots' => \Mage_Adminhtml_Model_System_Config_Source_Design_Robots::class, 'adminhtml/system_config_source_dev_dbautoup' => \Mage_Adminhtml_Model_System_Config_Source_Dev_Dbautoup::class, @@ -22735,6 +22449,7 @@ 'catalog/layer_filter_price_algorithm' => \Mage_Catalog_Model_Layer_Filter_Price_Algorithm::class, 'catalog/layer_state' => \Mage_Catalog_Model_Layer_State::class, 'catalog/observer' => \Mage_Catalog_Model_Observer::class, + 'catalog/observer_disableAdvancedSearch' => \Mage_Catalog_Model_Observer_DisableAdvancedSearch::class, 'catalog/product' => \Mage_Catalog_Model_Product::class, 'catalog/product_action' => \Mage_Catalog_Model_Product_Action::class, 'catalog/product_api' => \Mage_Catalog_Model_Product_Api::class, @@ -23414,6 +23129,9 @@ 'cron/resource_schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron_resource/schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron/schedule' => \Mage_Cron_Model_Schedule::class, + 'csp/observer_abstract' => \Mage_Csp_Model_Observer_Abstract::class, + 'csp/observer_addAdminCspHeaders' => \Mage_Csp_Model_Observer_AddAdminCspHeaders::class, + 'csp/observer_addFrontendCspHeaders' => \Mage_Csp_Model_Observer_AddFrontendCspHeaders::class, 'currencysymbol/observer' => \Mage_CurrencySymbol_Model_Observer::class, 'currencysymbol/system_currencysymbol' => \Mage_CurrencySymbol_Model_System_Currencysymbol::class, 'customer/address' => \Mage_Customer_Model_Address::class, @@ -24022,76 +23740,30 @@ 'payment/recurring_profile' => \Mage_Payment_Model_Recurring_Profile::class, 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, - 'paypaluk/api_express_nvp' => \Mage_PaypalUk_Model_Api_Express_Nvp::class, - 'paypaluk/api_nvp' => \Mage_PaypalUk_Model_Api_Nvp::class, - 'paypaluk/bml' => \Mage_PaypalUk_Model_Bml::class, - 'paypaluk/direct' => \Mage_PaypalUk_Model_Direct::class, - 'paypaluk/express' => \Mage_PaypalUk_Model_Express::class, - 'paypaluk/express_checkout' => \Mage_PaypalUk_Model_Express_Checkout::class, - 'paypaluk/express_pro' => \Mage_PaypalUk_Model_Express_Pro::class, - 'paypaluk/pro' => \Mage_PaypalUk_Model_Pro::class, - 'paypaluk/session' => \Mage_PaypalUk_Model_Session::class, - 'paypal/api_abstract' => \Mage_Paypal_Model_Api_Abstract::class, - 'paypal/api_nvp' => \Mage_Paypal_Model_Api_Nvp::class, - 'paypal/api_processableException' => \Mage_Paypal_Model_Api_ProcessableException::class, - 'paypal/api_standard' => \Mage_Paypal_Model_Api_Standard::class, - 'paypal/bml' => \Mage_Paypal_Model_Bml::class, + 'paypal/api' => \Mage_Paypal_Model_Api::class, + 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, + 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, - 'paypal/cert' => \Mage_Paypal_Model_Cert::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, - 'paypal/direct' => \Mage_Paypal_Model_Direct::class, - 'paypal/express' => \Mage_Paypal_Model_Express::class, - 'paypal/express_checkout' => \Mage_Paypal_Model_Express_Checkout::class, - 'paypal/hostedpro' => \Mage_Paypal_Model_Hostedpro::class, - 'paypal/hostedpro_request' => \Mage_Paypal_Model_Hostedpro_Request::class, - 'paypal/info' => \Mage_Paypal_Model_Info::class, - 'paypal/ipn' => \Mage_Paypal_Model_Ipn::class, - 'paypal/method_agreement' => \Mage_Paypal_Model_Method_Agreement::class, - 'paypal/mysql4_cert' => \Mage_Paypal_Model_Mysql4_Cert::class, - 'paypal/mysql4_report_settlement' => \Mage_Paypal_Model_Mysql4_Report_Settlement::class, - 'paypal/mysql4_report_settlement_row' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row::class, - 'paypal/mysql4_report_settlement_row_collection' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row_Collection::class, - 'paypal/mysql4_setup' => \Mage_Paypal_Model_Mysql4_Setup::class, - 'paypal/observer' => \Mage_Paypal_Model_Observer::class, - 'paypal/payflow_request' => \Mage_Paypal_Model_Payflow_Request::class, - 'paypal/payflowadvanced' => \Mage_Paypal_Model_Payflowadvanced::class, - 'paypal/payflowlink' => \Mage_Paypal_Model_Payflowlink::class, - 'paypal/payflowpro' => \Mage_Paypal_Model_Payflowpro::class, - 'paypal/payment_transaction' => \Mage_Paypal_Model_Payment_Transaction::class, - 'paypal/pro' => \Mage_Paypal_Model_Pro::class, - 'paypal/report_settlement' => \Mage_Paypal_Model_Report_Settlement::class, - 'paypal/report_settlement_row' => \Mage_Paypal_Model_Report_Settlement_Row::class, - 'paypal/resource_cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal_resource/cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal/resource_payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal_resource/payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal/resource_payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal_resource/payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal/resource_report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal_resource/report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal/resource_report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal_resource/report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal/resource_report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, - 'paypal_resource/report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, + 'paypal/debug' => \Mage_Paypal_Model_Debug::class, + 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, + 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal/resource_debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, + 'paypal_resource/debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, 'paypal/resource_setup' => \Mage_Paypal_Model_Resource_Setup::class, 'paypal_resource/setup' => \Mage_Paypal_Model_Resource_Setup::class, - 'paypal/session' => \Mage_Paypal_Model_Session::class, - 'paypal/standard' => \Mage_Paypal_Model_Standard::class, - 'paypal/system_config_backend_cert' => \Mage_Paypal_Model_System_Config_Backend_Cert::class, - 'paypal/system_config_backend_cron' => \Mage_Paypal_Model_System_Config_Backend_Cron::class, 'paypal/system_config_backend_merchantCountry' => \Mage_Paypal_Model_System_Config_Backend_MerchantCountry::class, - 'paypal/system_config_source_authorizationAmounts' => \Mage_Paypal_Model_System_Config_Source_AuthorizationAmounts::class, - 'paypal/system_config_source_bmlPosition' => \Mage_Paypal_Model_System_Config_Source_BmlPosition::class, - 'paypal/system_config_source_bmlSize' => \Mage_Paypal_Model_System_Config_Source_BmlSize::class, - 'paypal/system_config_source_buyerCountry' => \Mage_Paypal_Model_System_Config_Source_BuyerCountry::class, - 'paypal/system_config_source_fetchingSchedule' => \Mage_Paypal_Model_System_Config_Source_FetchingSchedule::class, - 'paypal/system_config_source_logo' => \Mage_Paypal_Model_System_Config_Source_Logo::class, + 'paypal/system_config_source_buttonColors' => \Mage_Paypal_Model_System_Config_Source_ButtonColors::class, + 'paypal/system_config_source_buttonLabels' => \Mage_Paypal_Model_System_Config_Source_ButtonLabels::class, + 'paypal/system_config_source_buttonLayouts' => \Mage_Paypal_Model_System_Config_Source_ButtonLayouts::class, + 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/system_config_source_paymentActions_express' => \Mage_Paypal_Model_System_Config_Source_PaymentActions_Express::class, - 'paypal/system_config_source_requireBillingAddress' => \Mage_Paypal_Model_System_Config_Source_RequireBillingAddress::class, - 'paypal/system_config_source_urlMethod' => \Mage_Paypal_Model_System_Config_Source_UrlMethod::class, - 'paypal/system_config_source_yesnoShortcut' => \Mage_Paypal_Model_System_Config_Source_YesnoShortcut::class, + 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, + 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, + 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -25429,6 +25101,7 @@ 'adminhtml/system_config_source_customer_forgotpassword' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Forgotpassword::class, 'adminhtml/system_config_source_customer_group' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group::class, 'adminhtml/system_config_source_customer_group_multiselect' => \Mage_Adminhtml_Model_System_Config_Source_Customer_Group_Multiselect::class, + 'adminhtml/system_config_source_dashboard_chart_type' => \Mage_Adminhtml_Model_System_Config_Source_Dashboard_Chart_Type::class, 'adminhtml/system_config_source_date_short' => \Mage_Adminhtml_Model_System_Config_Source_Date_Short::class, 'adminhtml/system_config_source_design_robots' => \Mage_Adminhtml_Model_System_Config_Source_Design_Robots::class, 'adminhtml/system_config_source_dev_dbautoup' => \Mage_Adminhtml_Model_System_Config_Source_Dev_Dbautoup::class, @@ -25891,6 +25564,7 @@ 'catalog/layer_filter_price_algorithm' => \Mage_Catalog_Model_Layer_Filter_Price_Algorithm::class, 'catalog/layer_state' => \Mage_Catalog_Model_Layer_State::class, 'catalog/observer' => \Mage_Catalog_Model_Observer::class, + 'catalog/observer_disableAdvancedSearch' => \Mage_Catalog_Model_Observer_DisableAdvancedSearch::class, 'catalog/product' => \Mage_Catalog_Model_Product::class, 'catalog/product_action' => \Mage_Catalog_Model_Product_Action::class, 'catalog/product_api' => \Mage_Catalog_Model_Product_Api::class, @@ -26570,6 +26244,9 @@ 'cron/resource_schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron_resource/schedule_collection' => \Mage_Cron_Model_Resource_Schedule_Collection::class, 'cron/schedule' => \Mage_Cron_Model_Schedule::class, + 'csp/observer_abstract' => \Mage_Csp_Model_Observer_Abstract::class, + 'csp/observer_addAdminCspHeaders' => \Mage_Csp_Model_Observer_AddAdminCspHeaders::class, + 'csp/observer_addFrontendCspHeaders' => \Mage_Csp_Model_Observer_AddFrontendCspHeaders::class, 'currencysymbol/observer' => \Mage_CurrencySymbol_Model_Observer::class, 'currencysymbol/system_currencysymbol' => \Mage_CurrencySymbol_Model_System_Currencysymbol::class, 'customer/address' => \Mage_Customer_Model_Address::class, @@ -27178,76 +26855,30 @@ 'payment/recurring_profile' => \Mage_Payment_Model_Recurring_Profile::class, 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, - 'paypaluk/api_express_nvp' => \Mage_PaypalUk_Model_Api_Express_Nvp::class, - 'paypaluk/api_nvp' => \Mage_PaypalUk_Model_Api_Nvp::class, - 'paypaluk/bml' => \Mage_PaypalUk_Model_Bml::class, - 'paypaluk/direct' => \Mage_PaypalUk_Model_Direct::class, - 'paypaluk/express' => \Mage_PaypalUk_Model_Express::class, - 'paypaluk/express_checkout' => \Mage_PaypalUk_Model_Express_Checkout::class, - 'paypaluk/express_pro' => \Mage_PaypalUk_Model_Express_Pro::class, - 'paypaluk/pro' => \Mage_PaypalUk_Model_Pro::class, - 'paypaluk/session' => \Mage_PaypalUk_Model_Session::class, - 'paypal/api_abstract' => \Mage_Paypal_Model_Api_Abstract::class, - 'paypal/api_nvp' => \Mage_Paypal_Model_Api_Nvp::class, - 'paypal/api_processableException' => \Mage_Paypal_Model_Api_ProcessableException::class, - 'paypal/api_standard' => \Mage_Paypal_Model_Api_Standard::class, - 'paypal/bml' => \Mage_Paypal_Model_Bml::class, + 'paypal/api' => \Mage_Paypal_Model_Api::class, + 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, + 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, - 'paypal/cert' => \Mage_Paypal_Model_Cert::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, - 'paypal/direct' => \Mage_Paypal_Model_Direct::class, - 'paypal/express' => \Mage_Paypal_Model_Express::class, - 'paypal/express_checkout' => \Mage_Paypal_Model_Express_Checkout::class, - 'paypal/hostedpro' => \Mage_Paypal_Model_Hostedpro::class, - 'paypal/hostedpro_request' => \Mage_Paypal_Model_Hostedpro_Request::class, - 'paypal/info' => \Mage_Paypal_Model_Info::class, - 'paypal/ipn' => \Mage_Paypal_Model_Ipn::class, - 'paypal/method_agreement' => \Mage_Paypal_Model_Method_Agreement::class, - 'paypal/mysql4_cert' => \Mage_Paypal_Model_Mysql4_Cert::class, - 'paypal/mysql4_report_settlement' => \Mage_Paypal_Model_Mysql4_Report_Settlement::class, - 'paypal/mysql4_report_settlement_row' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row::class, - 'paypal/mysql4_report_settlement_row_collection' => \Mage_Paypal_Model_Mysql4_Report_Settlement_Row_Collection::class, - 'paypal/mysql4_setup' => \Mage_Paypal_Model_Mysql4_Setup::class, - 'paypal/observer' => \Mage_Paypal_Model_Observer::class, - 'paypal/payflow_request' => \Mage_Paypal_Model_Payflow_Request::class, - 'paypal/payflowadvanced' => \Mage_Paypal_Model_Payflowadvanced::class, - 'paypal/payflowlink' => \Mage_Paypal_Model_Payflowlink::class, - 'paypal/payflowpro' => \Mage_Paypal_Model_Payflowpro::class, - 'paypal/payment_transaction' => \Mage_Paypal_Model_Payment_Transaction::class, - 'paypal/pro' => \Mage_Paypal_Model_Pro::class, - 'paypal/report_settlement' => \Mage_Paypal_Model_Report_Settlement::class, - 'paypal/report_settlement_row' => \Mage_Paypal_Model_Report_Settlement_Row::class, - 'paypal/resource_cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal_resource/cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal/resource_payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal_resource/payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal/resource_payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal_resource/payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal/resource_report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal_resource/report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal/resource_report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal_resource/report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal/resource_report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, - 'paypal_resource/report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, + 'paypal/debug' => \Mage_Paypal_Model_Debug::class, + 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, + 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal/resource_debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, + 'paypal_resource/debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, 'paypal/resource_setup' => \Mage_Paypal_Model_Resource_Setup::class, 'paypal_resource/setup' => \Mage_Paypal_Model_Resource_Setup::class, - 'paypal/session' => \Mage_Paypal_Model_Session::class, - 'paypal/standard' => \Mage_Paypal_Model_Standard::class, - 'paypal/system_config_backend_cert' => \Mage_Paypal_Model_System_Config_Backend_Cert::class, - 'paypal/system_config_backend_cron' => \Mage_Paypal_Model_System_Config_Backend_Cron::class, 'paypal/system_config_backend_merchantCountry' => \Mage_Paypal_Model_System_Config_Backend_MerchantCountry::class, - 'paypal/system_config_source_authorizationAmounts' => \Mage_Paypal_Model_System_Config_Source_AuthorizationAmounts::class, - 'paypal/system_config_source_bmlPosition' => \Mage_Paypal_Model_System_Config_Source_BmlPosition::class, - 'paypal/system_config_source_bmlSize' => \Mage_Paypal_Model_System_Config_Source_BmlSize::class, - 'paypal/system_config_source_buyerCountry' => \Mage_Paypal_Model_System_Config_Source_BuyerCountry::class, - 'paypal/system_config_source_fetchingSchedule' => \Mage_Paypal_Model_System_Config_Source_FetchingSchedule::class, - 'paypal/system_config_source_logo' => \Mage_Paypal_Model_System_Config_Source_Logo::class, + 'paypal/system_config_source_buttonColors' => \Mage_Paypal_Model_System_Config_Source_ButtonColors::class, + 'paypal/system_config_source_buttonLabels' => \Mage_Paypal_Model_System_Config_Source_ButtonLabels::class, + 'paypal/system_config_source_buttonLayouts' => \Mage_Paypal_Model_System_Config_Source_ButtonLayouts::class, + 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/system_config_source_paymentActions_express' => \Mage_Paypal_Model_System_Config_Source_PaymentActions_Express::class, - 'paypal/system_config_source_requireBillingAddress' => \Mage_Paypal_Model_System_Config_Source_RequireBillingAddress::class, - 'paypal/system_config_source_urlMethod' => \Mage_Paypal_Model_System_Config_Source_UrlMethod::class, - 'paypal/system_config_source_yesnoShortcut' => \Mage_Paypal_Model_System_Config_Source_YesnoShortcut::class, + 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, + 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, + 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, diff --git a/.phpstorm.meta.php/magento_resource_models.meta.php b/.phpstorm.meta.php/magento_resource_models.meta.php index 2e8ab002dbb..3f4773b3858 100644 --- a/.phpstorm.meta.php/magento_resource_models.meta.php +++ b/.phpstorm.meta.php/magento_resource_models.meta.php @@ -382,12 +382,8 @@ 'oauth/token_collection' => \Mage_Oauth_Model_Resource_Token_Collection::class, 'paygate/authorizenet_debug' => \Mage_Paygate_Model_Resource_Authorizenet_Debug::class, 'paygate/authorizenet_debug_collection' => \Mage_Paygate_Model_Resource_Authorizenet_Debug_Collection::class, - 'paypal/cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal/payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal/payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal/report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal/report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal/report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, + 'paypal/debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal/debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, 'paypal/setup' => \Mage_Paypal_Model_Resource_Setup::class, 'persistent/session' => \Mage_Persistent_Model_Resource_Session::class, 'productalert/abstract' => \Mage_ProductAlert_Model_Resource_Abstract::class, @@ -1015,12 +1011,8 @@ 'oauth/token_collection' => \Mage_Oauth_Model_Resource_Token_Collection::class, 'paygate/authorizenet_debug' => \Mage_Paygate_Model_Resource_Authorizenet_Debug::class, 'paygate/authorizenet_debug_collection' => \Mage_Paygate_Model_Resource_Authorizenet_Debug_Collection::class, - 'paypal/cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal/payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal/payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal/report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal/report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal/report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, + 'paypal/debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal/debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, 'paypal/setup' => \Mage_Paypal_Model_Resource_Setup::class, 'persistent/session' => \Mage_Persistent_Model_Resource_Session::class, 'productalert/abstract' => \Mage_ProductAlert_Model_Resource_Abstract::class, diff --git a/.phpstorm.meta.php/magento_resource_models_methods.meta.php b/.phpstorm.meta.php/magento_resource_models_methods.meta.php index fd8ccde3495..85849aad391 100644 --- a/.phpstorm.meta.php/magento_resource_models_methods.meta.php +++ b/.phpstorm.meta.php/magento_resource_models_methods.meta.php @@ -382,12 +382,8 @@ 'oauth/token_collection' => \Mage_Oauth_Model_Resource_Token_Collection::class, 'paygate/authorizenet_debug' => \Mage_Paygate_Model_Resource_Authorizenet_Debug::class, 'paygate/authorizenet_debug_collection' => \Mage_Paygate_Model_Resource_Authorizenet_Debug_Collection::class, - 'paypal/cert' => \Mage_Paypal_Model_Resource_Cert::class, - 'paypal/payment_transaction' => \Mage_Paypal_Model_Resource_Payment_Transaction::class, - 'paypal/payment_transaction_collection' => \Mage_Paypal_Model_Resource_Payment_Transaction_Collection::class, - 'paypal/report_settlement' => \Mage_Paypal_Model_Resource_Report_Settlement::class, - 'paypal/report_settlement_row' => \Mage_Paypal_Model_Resource_Report_Settlement_Row::class, - 'paypal/report_settlement_row_collection' => \Mage_Paypal_Model_Resource_Report_Settlement_Row_Collection::class, + 'paypal/debug' => \Mage_Paypal_Model_Resource_Debug::class, + 'paypal/debug_collection' => \Mage_Paypal_Model_Resource_Debug_Collection::class, 'paypal/setup' => \Mage_Paypal_Model_Resource_Setup::class, 'persistent/session' => \Mage_Persistent_Model_Resource_Session::class, 'productalert/abstract' => \Mage_ProductAlert_Model_Resource_Abstract::class, From 84329a60a9d3e0bea706e0045fb1a49974c2298c Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Sun, 22 Jun 2025 02:38:48 +0200 Subject: [PATCH 07/40] refactor: optimize paypal module for PHP 8.4 --- .../Mage/Paypal/Block/Adminhtml/Debug.php | 13 ++ .../Paypal/Block/Adminhtml/Debug/Grid.php | 46 ++-- .../Debug/Grid/Renderer/Exception.php | 5 +- .../Adminhtml/Debug/Grid/Renderer/Request.php | 5 +- .../Debug/Grid/Renderer/Response.php | 5 +- .../Block/Adminhtml/Grid/Renderer/Json.php | 23 +- .../Block/Adminhtml/Grid/Renderer/Order.php | 8 +- .../core/Mage/Paypal/Block/Adminhtml/Info.php | 54 +++-- .../Adminhtml/System/Config/Field/Country.php | 22 -- app/code/core/Mage/Paypal/Block/Button.php | 197 ------------------ app/code/core/Mage/Paypal/Block/Form.php | 33 ++- app/code/core/Mage/Paypal/Block/Info.php | 33 +-- app/code/core/Mage/Paypal/Helper/Data.php | 34 +-- .../core/Mage/Paypal/Model/Api/Exception.php | 31 --- .../core/Mage/Paypal/Model/Api/Helper.php | 58 +++--- app/code/core/Mage/Paypal/Model/Cart.php | 71 ++++++- app/code/core/Mage/Paypal/Model/Config.php | 83 ++++++-- app/code/core/Mage/Paypal/Model/Debug.php | 5 + app/code/core/Mage/Paypal/Model/Exception.php | 12 +- .../core/Mage/Paypal/Model/Resource/Debug.php | 4 +- .../Model/Resource/Debug/Collection.php | 40 ++-- .../core/Mage/Paypal/Model/Resource/Setup.php | 1 + .../System/Config/Backend/MerchantCountry.php | 3 +- .../System/Config/Source/ButtonColors.php | 4 +- .../System/Config/Source/ButtonLabels.php | 4 +- .../System/Config/Source/ButtonLayouts.php | 3 +- .../System/Config/Source/ButtonShapes.php | 3 +- .../System/Config/Source/MerchantCountry.php | 138 +++++++----- .../System/Config/Source/PaymentActions.php | 3 +- .../core/Mage/Paypal/Model/Validator/Api.php | 36 ---- .../Mage/Paypal/Model/Validator/Payment.php | 78 ------- .../core/Mage/Paypal/Model/Webhook/Log.php | 28 --- .../Adminhtml/Paypal/DebugController.php | 44 +++- .../Paypal/TransactionController.php | 18 +- .../Paypal/controllers/PaymentController.php | 96 +++++---- app/code/core/Mage/Paypal/etc/config.xml | 2 +- app/code/core/Mage/Paypal/etc/system.xml | 5 +- app/locale/en_US/Mage_Paypal.csv | 4 +- js/paypal/payment.js | 48 +---- 39 files changed, 573 insertions(+), 727 deletions(-) delete mode 100644 app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Country.php delete mode 100644 app/code/core/Mage/Paypal/Block/Button.php delete mode 100644 app/code/core/Mage/Paypal/Model/Api/Exception.php delete mode 100644 app/code/core/Mage/Paypal/Model/Validator/Api.php delete mode 100644 app/code/core/Mage/Paypal/Model/Validator/Payment.php delete mode 100644 app/code/core/Mage/Paypal/Model/Webhook/Log.php diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug.php index 6f1603794d0..4f8fd3927db 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug.php @@ -7,8 +7,21 @@ * @package Mage_Paypal */ +declare(strict_types=1); + +/** + * PayPal Debug Grid Container Block + * + * Provides the container for the PayPal debug log grid in the admin panel + */ class Mage_Paypal_Block_Adminhtml_Debug extends Mage_Adminhtml_Block_Widget_Grid_Container { + /** + * Initialize debug grid container + * + * Sets up the grid container properties, including block group, controller, + * header text, and configures available buttons. + */ public function __construct() { $this->_blockGroup = 'paypal'; diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php index 2b8ebdf5766..a280b24dbb9 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php @@ -1,5 +1,7 @@ setSaveParametersInSession(true); } - protected function _prepareCollection() + /** + * Prepare collection + * + * @return $this + */ + protected function _prepareCollection(): self { $collection = Mage::getModel('paypal/debug')->getCollection(); $this->setCollection($collection); return parent::_prepareCollection(); } - protected function _prepareColumns() + /** + * Prepare columns + * + * @return $this + */ + protected function _prepareColumns(): self { $this->addColumn('entity_id', [ 'header' => Mage::helper('paypal')->__('ID'), @@ -34,18 +50,17 @@ protected function _prepareColumns() ]); $this->addColumn('quote_id', [ - 'header' => Mage::helper('paypal')->__('Quote #'), - 'index' => 'quote_id', - 'type' => 'number', + 'header' => Mage::helper('paypal')->__('Quote #'), + 'index' => 'quote_id', + 'type' => 'number', ]); $this->addColumn('increment_id', [ 'header' => Mage::helper('paypal')->__('Order #'), 'index' => 'increment_id', - 'renderer' => 'paypal/adminhtml_grid_renderer_order', + 'renderer' => 'paypal/adminhtml_grid_renderer_order', ]); - $this->addColumn('action', [ 'header' => Mage::helper('paypal')->__('Action'), 'index' => 'action', @@ -71,8 +86,8 @@ protected function _prepareColumns() ]); $this->addColumn('exception_message', [ - 'header' => Mage::helper('paypal')->__('Exception'), - 'index' => 'exception_message', + 'header' => Mage::helper('paypal')->__('Exception'), + 'index' => 'exception_message', 'renderer' => 'paypal/adminhtml_debug_grid_renderer_exception', ]); @@ -85,15 +100,20 @@ protected function _prepareColumns() return parent::_prepareColumns(); } - protected function _prepareMassaction() + /** + * Prepare massaction + * + * @return $this + */ + protected function _prepareMassaction(): self { $this->setMassactionIdField('entity_id'); $this->getMassactionBlock()->setFormFieldName('debug'); $this->getMassactionBlock()->addItem('delete', [ - 'label' => Mage::helper('paypal')->__('Delete'), - 'url' => $this->getUrl('*/*/massDelete'), - 'confirm' => Mage::helper('paypal')->__('Are you sure?'), + 'label' => Mage::helper('paypal')->__('Delete'), + 'url' => $this->getUrl('*/*/massDelete'), + 'confirm' => Mage::helper('paypal')->__('Are you sure?'), ]); return $this; diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php index 1bc7f65aac1..6ac73c4dcd5 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php @@ -1,5 +1,7 @@ getData($this->getColumn()->getIndex()); + if (empty($value)) { return ''; } diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php index e29f7da9ce7..a0af97ac46e 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php @@ -1,5 +1,7 @@ getData($this->getColumn()->getIndex()); + if (empty($value)) { return ''; } diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php index 53aa6e4f696..80848f716f0 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php @@ -1,5 +1,7 @@ getData($this->getColumn()->getIndex()); + if (empty($value)) { return ''; } diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php index 9bcdbffb282..653e453bc3c 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php @@ -7,6 +7,8 @@ * @package Mage_Paypal */ +declare(strict_types=1); + class Mage_Paypal_Block_Adminhtml_Grid_Renderer_Json extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract { /** @@ -15,23 +17,24 @@ class Mage_Paypal_Block_Adminhtml_Grid_Renderer_Json extends Mage_Adminhtml_Bloc * @param string $json * @return string */ - protected function _formatJson($json) + protected function _formatJson(?string $json): string { - if (!$json) { + if (empty($json)) { return ''; } try { - // Decode JSON $data = Mage::helper('core')->jsonDecode($json); - // Format with proper indentation and spacing - $formattedJson = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); - - // Escape HTML entities - $formattedJson = $this->escapeHtml($formattedJson); + $formattedJson = json_encode( + $data, + JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE, + ); - return sprintf('
%s
', $formattedJson); + return sprintf( + '
%s
', + $this->escapeHtml($formattedJson), + ); } catch (Exception $e) { return $this->escapeHtml($json); } @@ -43,7 +46,7 @@ protected function _formatJson($json) * @param Varien_Object $row * @return string */ - public function render(Varien_Object $row) + public function render(Varien_Object $row): string { return $this->_formatJson($row->getData($this->getColumn()->getIndex())); } diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php index 5b74e82ed38..38a6cf418b1 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php @@ -1,5 +1,7 @@ getData($this->getColumn()->getIndex()); - if (!$incrementId) { + + if (empty($incrementId)) { return ''; } $order = Mage::getModel('sales/order')->loadByIncrementId($incrementId); + if (!$order->getId()) { return $this->escapeHtml($incrementId); } diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php index 61be7065815..667ad84b934 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php @@ -7,33 +7,38 @@ * @package Mage_Paypal */ +declare(strict_types=1); + /** * PayPal payment information block for admin order view */ class Mage_Paypal_Block_Adminhtml_Info extends Mage_Payment_Block_Info { - protected function _construct() + /** + * Initializes the payment information block by setting the template. + */ + protected function _construct(): void { parent::_construct(); $this->setTemplate('paypal/info.phtml'); } /** - * Get transaction ID + * Retrieves the transaction ID from the payment information. * * @return string|null */ - public function getTransactionId() + public function getTransactionId(): ?string { return $this->getInfo()->getLastTransId(); } /** - * Get PayPal transaction URL + * Generates the PayPal transaction URL based on the transaction ID and sandbox status. * * @return string|null */ - public function getTransactionUrl() + public function getTransactionUrl(): ?string { $transactionId = $this->getTransactionId(); if (!$transactionId) { @@ -45,21 +50,24 @@ public function getTransactionUrl() } /** - * Get additional information from payment + * Retrieves and formats additional payment information, such as status and authorization details. * * @return array */ - public function getPaymentInfo() + public function getPaymentInfo(): array { $payment = $this->getInfo(); $info = []; if ($payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_STATUS)) { - $info[Mage::helper('paypal')->__('Status')] = $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_STATUS); + $info[Mage::helper('paypal')->__('Status')] = + $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_STATUS); } if ($payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID)) { - $info[Mage::helper('paypal')->__('Authorization ID')] = $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID); + $info[Mage::helper('paypal')->__('Authorization ID')] = + $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID); if ($payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME)) { - $expirationTime = $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME); + $expirationTime = + $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME); $info[Mage::helper('paypal')->__('Authorization Expires')] = $this->formatExpirationDate($expirationTime); } } @@ -68,12 +76,12 @@ public function getPaymentInfo() } /** - * Format expiration date to local timezone + * Formats a given UTC expiration timestamp to the store's local timezone. * - * @param string $expirationTime - * @return string + * @param string $expirationTime The expiration timestamp in UTC. + * @return string The formatted date and time string. */ - protected function formatExpirationDate($expirationTime) + protected function formatExpirationDate(string $expirationTime): string { $storeTimezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE); $date = new DateTime($expirationTime, new DateTimeZone('UTC')); @@ -82,16 +90,18 @@ protected function formatExpirationDate($expirationTime) } /** - * Check if payment can be reauthorized + * Determines if the payment can be reauthorized based on its method, authorization ID, and expiration/creation time. * - * @return bool + * @return bool True if the payment can be reauthorized, false otherwise. */ - public function canReauthorize() + public function canReauthorize(): bool { $payment = $this->getInfo(); - if ($payment->getMethod() !== 'paypal' || - !$payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID)) { + if ( + $payment->getMethod() !== 'paypal' || + !$payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID) + ) { return false; } @@ -112,11 +122,11 @@ public function canReauthorize() } /** - * Get reauthorize URL + * Generates the URL for reauthorizing the payment. * - * @return string + * @return string The reauthorization URL. */ - public function getReauthorizeUrl() + public function getReauthorizeUrl(): string { return Mage::getUrl('*/paypal_transaction/reauthorize', [ 'order_id' => $this->getInfo()->getOrder()->getId(), diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Country.php b/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Country.php deleted file mode 100644 index 0e8e50da334..00000000000 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Field/Country.php +++ /dev/null @@ -1,22 +0,0 @@ -toOptionArray(false); - - $element->setValues($countries) - ->setClass('paypal-merchant-country'); - - return parent::_getElementHtml($element); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Button.php b/app/code/core/Mage/Paypal/Block/Button.php deleted file mode 100644 index 1be25a8522b..00000000000 --- a/app/code/core/Mage/Paypal/Block/Button.php +++ /dev/null @@ -1,197 +0,0 @@ -getButtonConfig(); - } - - /** - * Get PayPal client ID - * - * @return string - */ - public function getClientId() - { - return Mage::helper('paypal')->getConfig()->getApiCredentials()['client_id']; - } - - /** - * Get PayPal SDK URL - * - * @return string - */ - public function getSdkUrl() - { - $config = $this->getButtonConfig(); - $intent = Mage::getSingleton('paypal/config')->getPaymentAction(); - - $params = [ - 'client-id' => $this->getClientId(), - 'components' => 'buttons,messages', - 'intent' => $intent, - 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode(), - ]; - - if ($config['message']) { - $params['enable-funding'] = 'paylater'; - } - - return 'https://www.paypal.com/sdk/js?' . http_build_query($params); - } - - /** - * Get form key for CSRF protection - * - * @return string - */ - public function getFormKey() - { - return Mage::getSingleton('core/session')->getFormKey(); - } - - /** - * Check if button should be rendered - * - * @return bool - */ - public function shouldRender() - { - return Mage::helper('paypal')->isAvailable() - && $this->getClientId(); - } - - /** - * Get button container ID - * - * @return string - */ - public function getContainerId() - { - return 'paypal-button-container-' . $this->getNameInLayout(); - } - - /** - * Get button container attributes - * - * @return string - */ - public function getContainerAttributes() - { - return sprintf( - 'id="%s" class="paypal-button-container" data-loading="false" style="min-height: 35px;"', - $this->getContainerId(), - ); - } - - /** - * Get button initialization script - * - * @return string - */ - public function getButtonScript() - { - $config = $this->getButtonConfig(); - $containerId = $this->getContainerId(); - - return sprintf( - 'window.paypalLoadPromise = window.paypalLoadPromise || new Promise(function(resolve) { - var script = document.createElement("script"); - script.src = "%s"; - script.onload = resolve; - document.body.appendChild(script); - }); - - window.paypalLoadPromise.then(function() { - var container = document.getElementById("%s"); - container.setAttribute("data-loading", "true"); - - try { - paypal.Buttons({ - style: { - layout: "%s", - color: "%s", - shape: "%s", - label: "%s" - }, - createOrder: function() { - container.setAttribute("data-loading", "true"); - return fetch("%s", { - method: "POST", - headers: { - "Content-Type": "application/json" - } - }) - .then(function(res) { return res.json(); }) - .then(function(data) { - if (!data.success) { - throw new Error(data.error || "Error creating PayPal order"); - } - return data.order_id; - }); - }, - onApprove: function(data) { - container.setAttribute("data-loading", "true"); - return fetch("%s", { - method: "POST", - headers: { - "Content-Type": "application/json" - }, - body: JSON.stringify({ - order_id: data.orderID - }) - }) - .then(function(res) { return res.json(); }) - .then(function(data) { - if (!data.success) { - throw new Error(data.error || "Error processing payment"); - } - window.location.href = "%s"; - }); - }, - onError: function(err) { - console.error("PayPal Error:", err); - alert("There was an error with PayPal. Please try again."); - container.setAttribute("data-loading", "false"); - } - }).render("#%s") - .catch(function(err) { - console.error("PayPal Render Error:", err); - container.innerHTML = "
Could not load PayPal button
"; - container.setAttribute("data-loading", "false"); - }); - } catch (err) { - console.error("PayPal Init Error:", err); - container.innerHTML = "
Could not initialize PayPal
"; - container.setAttribute("data-loading", "false"); - } - });', - $this->getSdkUrl(), - $containerId, - $config['layout'], - $config['color'], - $config['shape'], - $config['label'], - $this->getUrl('paypal/payment/createOrder'), - $this->getUrl('paypal/payment/capture'), - $this->getUrl('checkout/onepage/success'), - $containerId, - ); - } -} diff --git a/app/code/core/Mage/Paypal/Block/Form.php b/app/code/core/Mage/Paypal/Block/Form.php index a670eb20625..6922871c462 100644 --- a/app/code/core/Mage/Paypal/Block/Form.php +++ b/app/code/core/Mage/Paypal/Block/Form.php @@ -7,7 +7,7 @@ * @package Mage_Paypal */ -use PaypalServerSdkLib\Models\CheckoutPaymentIntent; +declare(strict_types=1); /** * PayPal payment form block @@ -15,57 +15,57 @@ class Mage_Paypal_Block_Form extends Mage_Payment_Block_Form { /** - * Set template and init PayPal config + * Initializes the block by setting the payment template. */ - protected function _construct() + protected function _construct(): void { parent::_construct(); $this->setTemplate('paypal/payment.phtml'); } /** - * Get PayPal button configuration + * Retrieves the configuration for the PayPal button. * * @return array */ - public function getButtonConfig() + public function getButtonConfig(): array { return Mage::helper('paypal')->getButtonConfig(); } /** - * Get PayPal endpoint URL + * Retrieves the PayPal API endpoint URL. * * @return string */ - public function getEndpointUrl() + public function getEndpointUrl(): string { return Mage::helper('paypal')->getConfig()->getEndpoint(); } /** - * Get PayPal client ID + * Retrieves the PayPal client ID from the API credentials. * * @return string */ - public function getClientId() + public function getClientId(): string { return Mage::helper('paypal')->getConfig()->getApiCredentials()['client_id']; } /** - * Get PayPal SDK URL + * Constructs and retrieves the full URL for the PayPal JavaScript SDK. * * @return string */ - public function getSdkUrl() + public function getSdkUrl(): string { $intent = Mage::getSingleton('paypal/config')->getPaymentAction(); $params = [ 'client-id' => $this->getClientId(), 'components' => 'buttons', - 'intent' => $intent, + 'intent' => (string) $intent, 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode(), ]; @@ -73,12 +73,11 @@ public function getSdkUrl() if (substr($baseUrl, -1) !== '/') { $baseUrl .= '/'; } - $url = $baseUrl . 'sdk/js?' . http_build_query($params); - return $url; + return $baseUrl . 'sdk/js?' . http_build_query($params); } /** - * Get order amount + * Retrieves the grand total amount from the current quote. * * @return float */ @@ -88,11 +87,11 @@ public function getAmount() } /** - * Get currency code + * Retrieves the currency code for the current store. * * @return string */ - public function getCurrencyCode() + public function getCurrencyCode(): string { return Mage::app()->getStore()->getCurrentCurrencyCode(); } diff --git a/app/code/core/Mage/Paypal/Block/Info.php b/app/code/core/Mage/Paypal/Block/Info.php index 499812b9049..2e650cfbfbe 100644 --- a/app/code/core/Mage/Paypal/Block/Info.php +++ b/app/code/core/Mage/Paypal/Block/Info.php @@ -7,46 +7,29 @@ * @package Mage_Paypal */ +declare(strict_types=1); + /** * PayPal payment information block for frontend order view */ class Mage_Paypal_Block_Info extends Mage_Payment_Block_Info { - protected function _construct() + /** + * Initializes the block by setting the payment template. + */ + protected function _construct(): void { parent::_construct(); $this->setTemplate('paypal/info.phtml'); } /** - * Get transaction ID + * Retrieves the transaction ID from the payment information. * * @return string|null */ - public function getTransactionId() + public function getTransactionId(): ?string { return $this->getInfo()->getLastTransId(); } - - /** - * Get PayPal transaction URL - * - * @return string|null - */ - public function getTransactionUrl() - { - // Frontend doesn't show transaction URL - return null; - } - - /** - * Get additional information from payment - * - * @return array - */ - public function getPaymentInfo() - { - // Frontend shows minimal information - return []; - } } diff --git a/app/code/core/Mage/Paypal/Helper/Data.php b/app/code/core/Mage/Paypal/Helper/Data.php index 54378b70766..58e34363798 100644 --- a/app/code/core/Mage/Paypal/Helper/Data.php +++ b/app/code/core/Mage/Paypal/Helper/Data.php @@ -7,63 +7,65 @@ * @package Mage_Paypal */ +declare(strict_types=1); + /** * PayPal module helper */ class Mage_Paypal_Helper_Data extends Mage_Core_Helper_Abstract { /** - * Get PayPal configuration model + * Retrieves the PayPal configuration model, optionally for a specific store. * - * @param mixed $store + * @param mixed $store The store ID or object. * @return Mage_Paypal_Model_Config */ - public function getConfig($store = null) + public function getConfig(mixed $store = null): Mage_Paypal_Model_Config { return Mage::getSingleton('paypal/config')->setStoreId($store); } /** - * Check if PayPal is available + * Checks if the PayPal payment method is active and available, optionally for a specific store. * - * @param mixed $store + * @param mixed $store The store ID or object. * @return bool */ - public function isAvailable($store = null) + public function isAvailable(mixed $store = null): bool { return $this->getConfig($store)->isActive(); } /** - * Get PayPal button configuration + * Retrieves the configuration settings for the PayPal button, optionally for a specific store. * - * @param mixed $store + * @param mixed $store The store ID or object. * @return array */ - public function getButtonConfig($store = null) + public function getButtonConfig(mixed $store = null): array { return $this->getConfig($store)->getButtonConfiguration(); } /** - * Format price for PayPal API + * Formats a numeric price into a string with two decimal places, suitable for the PayPal API. * - * @param float $amount + * @param float $amount The price amount to format. * @return string */ - public function formatPrice($amount) + public function formatPrice(float $amount): string { return number_format($amount, 2, '.', ''); } /** - * Get transaction URL in PayPal merchant dashboard + * Constructs the URL to view a specific transaction in the PayPal merchant dashboard. * - * @param string $transactionId - * @param bool $sandbox + * @param string $transactionId The transaction ID. + * @param bool $sandbox Whether to use the sandbox environment. * @return string */ - public function getTransactionUrl($transactionId, $sandbox = false) + public function getTransactionUrl(string $transactionId, bool $sandbox = false): string { if (strpos($transactionId, '-') !== false) { $parts = explode('-', $transactionId); diff --git a/app/code/core/Mage/Paypal/Model/Api/Exception.php b/app/code/core/Mage/Paypal/Model/Api/Exception.php deleted file mode 100644 index 281882d8dc5..00000000000 --- a/app/code/core/Mage/Paypal/Model/Api/Exception.php +++ /dev/null @@ -1,31 +0,0 @@ -_errorCode = $errorCode; - $this->_debugData = $debugData; - parent::__construct($message); - } - - public function getErrorCode() - { - return $this->_errorCode; - } - - public function getDebugData() - { - return $this->_debugData; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Api/Helper.php b/app/code/core/Mage/Paypal/Model/Api/Helper.php index 544f3973530..982bf64241a 100644 --- a/app/code/core/Mage/Paypal/Model/Api/Helper.php +++ b/app/code/core/Mage/Paypal/Model/Api/Helper.php @@ -7,41 +7,45 @@ * @package Mage_Paypal */ +declare(strict_types=1); + +use PaypalServerSdkLib\Http\ApiResponse; + +/** + * PayPal API Helper + * + * Provides utility methods for logging and validation related to PayPal API interactions. + */ class Mage_Paypal_Model_Api_Helper { - protected $_validator; + /** + * @var Mage_Paypal_Helper_Data + */ protected $_helper; + /** + * Initializes the helper with its dependencies. + */ public function __construct() { - $this->_validator = Mage::getSingleton('paypal/validator_payment'); $this->_helper = Mage::helper('paypal'); } - public function validatePurchaseUnit($purchaseUnit) - { - if (empty($purchaseUnit['amount']) || empty($purchaseUnit['amount']['value'])) { - throw new Mage_Paypal_Model_Exception('Invalid purchase unit: missing amount'); - } - - if (empty($purchaseUnit['reference_id'])) { - throw new Mage_Paypal_Model_Exception('Invalid purchase unit: missing reference ID'); - } - - return true; - } - /** - * Log debug information + * Logs debug information for a PayPal API request if debugging is enabled. * - * @param string $action Action being performed - * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote Quote or order object - * @param mixed $request Request object or data - * @param PaypalServerSdkLib\Http\ApiResponse|null $response API response (optional) + * @param string $action Action being performed (e.g., 'Create Order'). + * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote Quote or order object. + * @param mixed $request Request object or data sent to the API. + * @param ApiResponse|null $response API response, if available. * @return void */ - public function logDebug($action, $quote, $request, $response = null) - { + public function logDebug( + string $action, + Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote, + mixed $request, + ?ApiResponse $response = null + ): void { if (Mage::getStoreConfigFlag('payment/paypal/debug')) { $requestData = ''; @@ -64,7 +68,7 @@ public function logDebug($action, $quote, $request, $response = null) $debug->setAction($action) ->setRequestBody($requestData); Mage::log($response, null, 'paypal.log'); - if ($response instanceof PaypalServerSdkLib\Http\ApiResponse) { + if ($response instanceof ApiResponse) { $result = $response->getResult(); if ($response->isError()) { $debug->setTransactionId($result['debug_id']) @@ -79,13 +83,13 @@ public function logDebug($action, $quote, $request, $response = null) } /** - * Log error information + * Logs an error message and exception details if debugging is enabled. * - * @param string $message Error message - * @param Exception $exception Exception object + * @param string $message The error message. + * @param Exception $exception The exception object. * @return void */ - public function logError($message, $exception) + public function logError(string $message, Exception $exception): void { if (Mage::getStoreConfigFlag('payment/paypal/debug')) { $errorData = [ diff --git a/app/code/core/Mage/Paypal/Model/Cart.php b/app/code/core/Mage/Paypal/Model/Cart.php index 2db2e4d4676..f0caa45f1ea 100644 --- a/app/code/core/Mage/Paypal/Model/Cart.php +++ b/app/code/core/Mage/Paypal/Model/Cart.php @@ -7,6 +7,8 @@ * @package Mage_Paypal */ +declare(strict_types=1); + use PaypalServerSdkLib\Models\Builders\MoneyBuilder; use PaypalServerSdkLib\Models\Builders\ItemBuilder; use PaypalServerSdkLib\Models\ItemCategory; @@ -18,12 +20,33 @@ class Mage_Paypal_Model_Cart public const TOTAL_TAX = 'tax'; public const TOTAL_SHIPPING = 'shipping'; - protected $_quote = null; + /** + * @var Mage_Sales_Model_Order|Mage_Sales_Model_Quote|null + */ + protected $_quote; + + /** + * @var array + */ protected $_totals = []; + + /** + * @var array + */ protected $_items = []; - protected $_currency = null; - public function __construct($params = []) + /** + * @var string|null + */ + protected $_currency; + + /** + * Initializes the cart model with a sales entity (order or quote). + * + * @param array $params + * @throws Exception + */ + public function __construct(array $params = []) { $salesEntity = array_shift($params); if ( @@ -38,7 +61,12 @@ public function __construct($params = []) $this->_validateCurrency(); } - protected function _validateCurrency() + /** + * Validates that the quote's currency is supported by PayPal. + * + * @return self + */ + protected function _validateCurrency(): self { $allowedCurrencies = Mage::getModel('paypal/config')->getAllowedCurrencyCodes(); $currentCurrency = $this->_quote->getOrderCurrencyCode() @@ -53,7 +81,12 @@ protected function _validateCurrency() return $this; } - public function getAllItems() + /** + * Retrieves all prepared items for the PayPal request. Items are prepared if not already. + * + * @return array + */ + public function getAllItems(): array { if (empty($this->_items)) { $this->_prepareItems(); @@ -61,7 +94,12 @@ public function getAllItems() return $this->_items; } - public function getAmounts() + /** + * Retrieves all prepared totals (subtotal, tax, shipping, discount). Totals are prepared if not already. + * + * @return array + */ + public function getAmounts(): array { if (empty($this->_totals)) { $this->_prepareTotals(); @@ -69,7 +107,12 @@ public function getAmounts() return $this->_totals; } - protected function _prepareItems() + /** + * Prepares the line items from the quote for the PayPal API request. + * + * @return self + */ + protected function _prepareItems(): self { foreach ($this->_quote->getAllVisibleItems() as $item) { $taxAmount = $item->getData('tax_amount'); @@ -99,7 +142,13 @@ protected function _prepareItems() return $this; } - protected function _prepareTotals() + + /** + * Prepares the cart totals from the quote for the PayPal API request. + * + * @return self + */ + protected function _prepareTotals(): self { $this->_quote->collectTotals()->save(); $shippingAddress = $this->_quote->getShippingAddress(); @@ -127,11 +176,11 @@ protected function _prepareTotals() } /** - * Get the quote object associated with this cart. + * Get the sales entity (quote or order) object associated with this cart. * - * @return Mage_Sales_Model_Quote + * @return Mage_Sales_Model_Order|Mage_Sales_Model_Quote */ - public function getQuote() + public function getQuote(): Mage_Sales_Model_Order|Mage_Sales_Model_Quote { return $this->_quote; } diff --git a/app/code/core/Mage/Paypal/Model/Config.php b/app/code/core/Mage/Paypal/Model/Config.php index bd06b1cee4d..c61788b8dde 100644 --- a/app/code/core/Mage/Paypal/Model/Config.php +++ b/app/code/core/Mage/Paypal/Model/Config.php @@ -7,6 +7,8 @@ * @package Mage_Paypal */ +declare(strict_types=1); + class Mage_Paypal_Model_Config extends Varien_Object { public const BUTTON_SHAPE_RECT = 'rect'; @@ -61,7 +63,12 @@ class Mage_Paypal_Model_Config extends Varien_Object 'USD', ]; - public function getApiCredentials() + /** + * Retrieves the API credentials, including the client ID and decrypted client secret. + * + * @return array + */ + public function getApiCredentials(): array { return [ 'client_id' => $this->getConfigData('client_id'), @@ -71,54 +78,92 @@ public function getApiCredentials() ]; } - public function isDebugEnabled() + /** + * Checks if debug mode is enabled. + * + * @return bool + */ + public function isDebugEnabled(): bool { return (bool) $this->getConfigData('debug'); } - public function isSandbox() + /** + * Checks if sandbox mode is enabled. + * + * @return bool + */ + public function isSandbox(): bool { return (bool) $this->getConfigData('sandbox_mode'); } - public function getPaymentAction() + /** + * Retrieves the configured payment action (e.g., 'authorize', 'capture'). + * + * @return string + */ + public function getPaymentAction(): string { - return $this->getConfigData('payment_action'); + return (string) $this->getConfigData('payment_action'); } - public function getEndpoint() + /** + * Retrieves the PayPal API endpoint URL based on the sandbox mode. + * + * @return string + */ + public function getEndpoint(): string { return $this->isSandbox() ? 'https://www.sandbox.paypal.com' : 'https://www.paypal.com'; } - public function getButtonConfiguration() + /** + * Retrieves an array of configuration settings for the PayPal button. + * + * @return array + */ + public function getButtonConfiguration(): array { return [ - 'shape' => $this->getConfigData('button_shape'), - 'color' => $this->getConfigData('button_color'), - 'layout' => $this->getConfigData('button_layout'), - 'label' => $this->getConfigData('button_label'), + 'shape' => (string) $this->getConfigData('button_shape'), + 'color' => (string) $this->getConfigData('button_color'), + 'layout' => (string) $this->getConfigData('button_layout'), + 'label' => (string) $this->getConfigData('button_label'), 'message' => (bool) $this->getConfigData('button_message'), ]; } - public function getMerchantCountry() - { - return $this->getConfigData('merchant_country') - ?: Mage::getStoreConfig('general/country/default'); - } - public function isActive($store = null) + /** + * Checks if the PayPal payment method is active for the given store. + * + * @param mixed|null $store The store ID or object to check for. + * @return bool + */ + public function isActive(mixed $store = null): bool { return (bool) $this->getConfigData('active', $store); } - public function getAllowedCurrencyCodes() + /** + * Retrieves a list of supported currency codes. + * + * @return string[] + */ + public function getAllowedCurrencyCodes(): array { return $this->_supportedCurrencies; } - protected function getConfigData($field, $store = null) + /** + * Retrieves a specific configuration value from the store config. + * + * @param string $field The configuration field to retrieve. + * @param mixed|null $store The store ID or object. + * @return mixed + */ + protected function getConfigData(string $field, mixed $store = null): mixed { return Mage::getStoreConfig('payment/paypal/' . $field, $store); } diff --git a/app/code/core/Mage/Paypal/Model/Debug.php b/app/code/core/Mage/Paypal/Model/Debug.php index df15b6b3357..28c1cbb86bf 100644 --- a/app/code/core/Mage/Paypal/Model/Debug.php +++ b/app/code/core/Mage/Paypal/Model/Debug.php @@ -7,6 +7,11 @@ * @package Mage_Paypal */ +declare(strict_types=1); + +/** + * PayPal Debug Model + */ class Mage_Paypal_Model_Debug extends Mage_Core_Model_Abstract { protected function _construct() diff --git a/app/code/core/Mage/Paypal/Model/Exception.php b/app/code/core/Mage/Paypal/Model/Exception.php index 5ec8db8e3ff..b35e224f35a 100644 --- a/app/code/core/Mage/Paypal/Model/Exception.php +++ b/app/code/core/Mage/Paypal/Model/Exception.php @@ -7,6 +7,11 @@ * @package Mage_Paypal */ +declare(strict_types=1); + +/** + * PayPal Exception + */ class Mage_Paypal_Model_Exception extends Mage_Core_Exception { protected $_debugData = []; @@ -17,7 +22,12 @@ public function __construct($message = '', $debugData = []) parent::__construct($message); } - public function getDebugData() + /** + * Get debug data + * + * @return array + */ + public function getDebugData(): array { return $this->_debugData; } diff --git a/app/code/core/Mage/Paypal/Model/Resource/Debug.php b/app/code/core/Mage/Paypal/Model/Resource/Debug.php index 82cacc2270b..98465ec252b 100644 --- a/app/code/core/Mage/Paypal/Model/Resource/Debug.php +++ b/app/code/core/Mage/Paypal/Model/Resource/Debug.php @@ -1,5 +1,7 @@ _init('paypal/debug', 'entity_id'); } - } diff --git a/app/code/core/Mage/Paypal/Model/Resource/Debug/Collection.php b/app/code/core/Mage/Paypal/Model/Resource/Debug/Collection.php index 0cf43a12a32..360cc736dca 100644 --- a/app/code/core/Mage/Paypal/Model/Resource/Debug/Collection.php +++ b/app/code/core/Mage/Paypal/Model/Resource/Debug/Collection.php @@ -7,57 +7,62 @@ * @package Mage_Paypal */ +declare(strict_types=1); + class Mage_Paypal_Model_Resource_Debug_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract { - protected function _construct() + /** + * Initializes the resource collection. + */ + protected function _construct(): void { $this->_init('paypal/debug'); } /** - * Add filter by quote ID + * Adds a filter to the collection for a specific quote ID. * - * @param int $quoteId + * @param int $quoteId The quote ID to filter by. * @return $this */ - public function addQuoteIdFilter($quoteId) + public function addQuoteIdFilter(int $quoteId): self { $this->addFieldToFilter('quote_id', $quoteId); return $this; } /** - * Add filter by transaction ID + * Adds a filter to the collection for a specific transaction ID. * - * @param string $transactionId + * @param string $transactionId The transaction ID to filter by. * @return $this */ - public function addTransactionIdFilter($transactionId) + public function addTransactionIdFilter(string $transactionId): self { $this->addFieldToFilter('transaction_id', $transactionId); return $this; } /** - * Add filter by action + * Adds a filter to the collection for a specific action. * - * @param string $action + * @param string $action The action string to filter by. * @return $this */ - public function addActionFilter($action) + public function addActionFilter(string $action): self { $this->addFieldToFilter('action', $action); return $this; } /** - * Add date range filter + * Adds a date range filter to the collection based on the 'created_at' field. * - * @param string $from - * @param string $to + * @param string|null $from The start date of the range. + * @param string|null $to The end date of the range. * @return $this */ - public function addDateRangeFilter($from, $to) + public function addDateRangeFilter(?string $from, ?string $to): self { if ($from) { $this->addFieldToFilter('created_at', ['gteq' => $from]); @@ -68,7 +73,12 @@ public function addDateRangeFilter($from, $to) return $this; } - protected function _initSelect() + /** + * Initializes the select object for the collection, setting the default order. + * + * @return $this + */ + protected function _initSelect(): self { parent::_initSelect(); $this->getSelect()->order('created_at DESC'); diff --git a/app/code/core/Mage/Paypal/Model/Resource/Setup.php b/app/code/core/Mage/Paypal/Model/Resource/Setup.php index b880552d0c9..afbdddd6138 100644 --- a/app/code/core/Mage/Paypal/Model/Resource/Setup.php +++ b/app/code/core/Mage/Paypal/Model/Resource/Setup.php @@ -1,5 +1,6 @@ getValue(); if (!$value) { diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonColors.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonColors.php index 1b1815353a9..c455e3cb6f6 100644 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonColors.php +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/ButtonColors.php @@ -1,5 +1,7 @@ toOptionArray(false); + ->toOptionArray(); - // Filter to only PayPal supported countries $supportedCountries = [ - 'AU', // Australia - 'AT', // Austria - 'BE', // Belgium - 'BR', // Brazil - 'CA', // Canada - 'CN', // China - 'CZ', // Czech Republic - 'DK', // Denmark - 'FI', // Finland - 'FR', // France - 'DE', // Germany - 'GR', // Greece - 'HK', // Hong Kong - 'HU', // Hungary - 'IN', // India - 'ID', // Indonesia - 'IE', // Ireland - 'IL', // Israel - 'IT', // Italy - 'JP', // Japan - 'LU', // Luxembourg - 'MY', // Malaysia - 'MX', // Mexico - 'NL', // Netherlands - 'NZ', // New Zealand - 'NO', // Norway - 'PH', // Philippines - 'PL', // Poland - 'PT', // Portugal - 'RU', // Russia - 'SG', // Singapore - 'SK', // Slovakia - 'KR', // South Korea - 'ES', // Spain - 'SE', // Sweden - 'CH', // Switzerland - 'TW', // Taiwan - 'TH', // Thailand - 'TR', // Turkey - 'AE', // United Arab Emirates - 'GB', // United Kingdom - 'US', // United States - 'VN', // Vietnam + 'AL', + 'DZ', + 'AD', + 'AG', + 'AR', + 'AU', + 'AT', + 'BS', + 'BH', + 'BB', + 'BE', + 'BZ', + 'BA', + 'BW', + 'BR', + 'BG', + 'CA', + 'CL', + 'CN', + 'CR', + 'HR', + 'CY', + 'CZ', + 'DK', + 'DO', + 'EC', + 'EG', + 'SV', + 'EE', + 'FI', + 'FR', + 'DE', + 'GR', + 'GT', + 'HN', + 'HK', + 'HU', + 'IS', + 'IN', + 'ID', + 'IE', + 'IT', + 'JM', + 'JP', + 'JO', + 'KE', + 'KW', + 'LV', + 'LI', + 'LT', + 'LU', + 'MY', + 'MT', + 'MX', + 'MD', + 'MC', + 'NL', + 'NZ', + 'NO', + 'OM', + 'PA', + 'PE', + 'PH', + 'PL', + 'PT', + 'QA', + 'RO', + 'RU', + 'SA', + 'RS', + 'SG', + 'SK', + 'SI', + 'ZA', + 'KR', + 'ES', + 'SE', + 'CH', + 'TW', + 'TH', + 'TT', + 'AE', + 'GB', + 'US', + 'UY', + 'VN', ]; + ; return array_filter($countries, function ($country) use ($supportedCountries) { return in_array($country['value'], $supportedCountries); diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions.php index 221e91e7538..4c4a4544a78 100644 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions.php +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/PaymentActions.php @@ -1,5 +1,6 @@ isSuccess()) { - $message = 'PayPal API Error: ' . $response->getError(); - Mage::log($message, Zend_Log::ERR, 'paypal.log', true); - - if (Mage::getStoreConfigFlag('payment/paypal/debug')) { - $quote = $order->getQuote(); - $quoteId = $quote ? $quote->getId() : $order->getQuoteId(); - - Mage::getModel('paypal/debug')->log( - $quoteId, - 'validation_error', - 'Validation Error', - $response->getError(), - null, - null, - ); - } - - throw new Mage_Paypal_Model_Exception($message); - } - return true; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Validator/Payment.php b/app/code/core/Mage/Paypal/Model/Validator/Payment.php deleted file mode 100644 index 3e271d820e0..00000000000 --- a/app/code/core/Mage/Paypal/Model/Validator/Payment.php +++ /dev/null @@ -1,78 +0,0 @@ -_supportedCurrencies)) { - $message = sprintf('Currency "%s" is not supported by PayPal', $currencyCode); - Mage::log($message, Zend_Log::ERR, 'paypal.log', true); - throw new Mage_Paypal_Model_Exception($message); - } - return true; - } - - public function validateAmount($amount) - { - if ($amount <= 0) { - Mage::log('Invalid payment amount', Zend_Log::ERR, 'paypal.log', true); - throw new Mage_Paypal_Model_Exception('Invalid payment amount'); - } - return true; - } - - public function validateTotal($calculatedTotal, $orderTotal) - { - $epsilon = 0.00001; - if (abs($calculatedTotal - $orderTotal) > $epsilon) { - $message = 'Total amount mismatch'; - Mage::log($message . sprintf( - ' (calculated: %s, order: %s)', - $calculatedTotal, - $orderTotal, - ), Zend_Log::ERR, 'paypal.log', true); - throw new Mage_Paypal_Model_Exception($message); - } - return true; - } -} diff --git a/app/code/core/Mage/Paypal/Model/Webhook/Log.php b/app/code/core/Mage/Paypal/Model/Webhook/Log.php deleted file mode 100644 index 2bdf2c5386d..00000000000 --- a/app/code/core/Mage/Paypal/Model/Webhook/Log.php +++ /dev/null @@ -1,28 +0,0 @@ -_init('paypal/webhook_log'); - } - - /** - * Clean old log entries - * - * @param int $days Number of days to keep - * @return $this - */ - public function clean($days = 30) - { - $this->getResource()->clean($days); - return $this; - } -} diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/DebugController.php b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/DebugController.php index f4e6fba56e3..1584d4f8f74 100644 --- a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/DebugController.php +++ b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/DebugController.php @@ -7,9 +7,16 @@ * @package Mage_Paypal */ +declare(strict_types=1); + class Mage_Paypal_Adminhtml_Paypal_DebugController extends Mage_Adminhtml_Controller_Action { - protected function _initAction() + /** + * Initializes the layout and sets the active menu for the debug log page. + * + * @return $this + */ + protected function _initAction(): self { $this->loadLayout() ->_setActiveMenu('report/paypal/debug') @@ -20,14 +27,24 @@ protected function _initAction() return $this; } - public function indexAction() + /** + * Renders the PayPal debug log grid page. + * + * @return void + */ + public function indexAction(): void { $this->_initAction() ->_addContent($this->getLayout()->createBlock('paypal/adminhtml_debug')) ->renderLayout(); } - public function gridAction() + /** + * Renders the debug log grid for AJAX requests. + * + * @return void + */ + public function gridAction(): void { $this->loadLayout(); $this->getResponse()->setBody( @@ -35,7 +52,12 @@ public function gridAction() ); } - public function massDeleteAction() + /** + * Handles the mass deletion of selected debug log entries. + * + * @return void + */ + public function massDeleteAction(): void { $debugIds = $this->getRequest()->getParam('debug'); if (!is_array($debugIds)) { @@ -55,7 +77,12 @@ public function massDeleteAction() $this->_redirect('*/*/index'); } - public function deleteAllAction() + /** + * Handles the deletion of all debug log entries. + * + * @return void + */ + public function deleteAllAction(): void { try { $collection = Mage::getModel('paypal/debug')->getCollection(); @@ -69,7 +96,12 @@ public function deleteAllAction() $this->_redirect('*/*/index'); } - protected function _isAllowed() + /** + * Checks if the current user has permission to access this controller. + * + * @return bool + */ + protected function _isAllowed(): bool { return Mage::getSingleton('admin/session')->isAllowed('report/paypal/debug'); } diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php index cf672e20883..214b5d53579 100644 --- a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php +++ b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php @@ -7,19 +7,21 @@ * @package Mage_Paypal */ +declare(strict_types=1); + /** * PayPal Transaction Controller - * - * @category Mage - * @package Mage_Paypal - * @author Magento Core Team */ class Mage_Paypal_Adminhtml_Paypal_TransactionController extends Mage_Adminhtml_Controller_Action { /** - * Reauthorize a payment + * Handles the reauthorization of a PayPal payment for a specific order. + * It validates the order and payment details, triggers the reauthorization process, + * and redirects the user back to the order view with a success or error message. + * + * @return void */ - public function reauthorizeAction() + public function reauthorizeAction(): void { $orderId = $this->getRequest()->getParam('order_id'); if (!$orderId) { @@ -60,11 +62,11 @@ public function reauthorizeAction() } /** - * Check if the current user is allowed to access this controller + * Checks if the current user has permission to access this controller's actions. * * @return bool */ - protected function _isAllowed() + protected function _isAllowed(): bool { return true; } diff --git a/app/code/core/Mage/Paypal/controllers/PaymentController.php b/app/code/core/Mage/Paypal/controllers/PaymentController.php index c1f4edb8c87..a93d12f44d5 100644 --- a/app/code/core/Mage/Paypal/controllers/PaymentController.php +++ b/app/code/core/Mage/Paypal/controllers/PaymentController.php @@ -7,6 +7,8 @@ * @package Mage_Paypal */ +declare(strict_types=1); + use PaypalServerSdkLib\Models\CheckoutPaymentIntent; /** @@ -19,24 +21,27 @@ class Mage_Paypal_PaymentController extends Mage_Core_Controller_Front_Action */ protected $_quote = false; - /** - * @var Mage_Customer_Model_Session + * @var Mage_Customer_Model_Session|null */ protected $_customerSession = null; /** - * @var Mage_Paypal_Model_Paypal + * @var Mage_Paypal_Model_Paypal|null */ protected $_paypal = null; + /** - * Create PayPal order + * Handles the AJAX request to create a PayPal order. + * Validates the quote and creates a PayPal order via the PayPal model. + * + * @return void */ - public function createAction() + public function createAction(): void { try { if (!$this->getRequest()->isAjax()) { - throw new Mage_Core_Exception('Invalid request'); + throw new Mage_Core_Exception('Invalid request.'); } if (!$this->getRequest()->isPost() || !$this->getRequest()->getParam('form_key')) { @@ -96,9 +101,13 @@ public function createAction() } /** - * Process PayPal payment (authorize or capture based on configuration) + * Processes the PayPal payment after customer approval on the PayPal side. + * This action will either authorize or capture the payment based on the store's configuration. + * + * @return void + * @throws Exception */ - public function processAction() + public function processAction(): void { try { $orderId = $this->getRequest()->getParam('order_id'); @@ -132,7 +141,13 @@ public function processAction() } } - public function placeOrderAction() + /** + * Places the Magento order after the PayPal payment has been successfully processed. + * It handles guest, new customer, and existing customer checkouts, creates the order, + * and redirects to the success or cart page. + * @return void + */ + public function placeOrderAction(): void { try { $isNewCustomer = false; @@ -245,11 +260,11 @@ public function placeOrderAction() } /** - * Return checkout session object + * Retrieves the checkout session model. * * @return Mage_Checkout_Model_Session */ - protected function _getCheckoutSession() + protected function _getCheckoutSession(): Mage_Checkout_Model_Session { return Mage::getSingleton('checkout/session'); } @@ -259,7 +274,7 @@ protected function _getCheckoutSession() * * @return Mage_Sales_Model_Quote */ - private function _getQuote() + private function _getQuote(): Mage_Sales_Model_Quote { if (!$this->_quote) { $this->_quote = $this->_getCheckoutSession()->getQuote(); @@ -268,11 +283,11 @@ private function _getQuote() } /** - * Return PayPal model + * Retrieves the PayPal model instance. * * @return Mage_Paypal_Model_Paypal */ - private function _getPaypal() + private function _getPaypal(): Mage_Paypal_Model_Paypal { if (!$this->_paypal) { $this->_paypal = Mage::getModel('paypal/paypal'); @@ -281,11 +296,11 @@ private function _getPaypal() } /** - * Prepare quote for guest checkout order submit + * Prepares the quote for a guest checkout. * - * @return $this + * @return self */ - protected function _prepareGuestQuote() + protected function _prepareGuestQuote(): self { $quote = $this->_quote; $quote->setCustomerEmail($quote->getBillingAddress()->getEmail()) @@ -295,12 +310,11 @@ protected function _prepareGuestQuote() } /** - * Prepare quote for customer registration and customer order submit - * and restore magento customer data from quote + * Prepares the quote for a new customer registration during checkout. * - * @return $this + * @return self */ - protected function _prepareNewCustomerQuote() + protected function _prepareNewCustomerQuote(): self { $quote = $this->_quote; $billing = $quote->getBillingAddress(); @@ -359,11 +373,11 @@ protected function _prepareNewCustomerQuote() } /** - * Prepare quote for customer order submit + * Prepares the quote for an existing, logged-in customer. * - * @return $this + * @return self */ - protected function _prepareCustomerQuote() + protected function _prepareCustomerQuote(): self { $quote = $this->_getQuote(); $billing = $quote->getBillingAddress(); @@ -398,11 +412,11 @@ protected function _prepareCustomerQuote() } /** - * Get customer session object + * Retrieves the customer session model. * * @return Mage_Customer_Model_Session */ - public function getCustomerSession() + public function getCustomerSession(): Mage_Customer_Model_Session { if (is_null($this->_customerSession)) { $this->_customerSession = Mage::getSingleton('customer/session'); @@ -411,12 +425,12 @@ public function getCustomerSession() } /** - * Check if customer email exists + * Checks if a customer with the given email address already exists for the current website. * - * @param string $email + * @param string $email The customer email to check. * @return bool */ - protected function _customerEmailExists($email) + protected function _customerEmailExists(string $email): bool { $result = false; $customer = Mage::getModel('customer/customer'); @@ -433,11 +447,11 @@ protected function _customerEmailExists($email) } /** - * Checks if customer with email coming from Express checkout exists + * Looks up a customer ID by the email address stored in the quote. * - * @return int + * @return int|null The customer ID if found, otherwise null. */ - protected function _lookupCustomerId() + protected function _lookupCustomerId(): ?int { return Mage::getModel('customer/customer') ->setWebsiteId(Mage::app()->getWebsite()->getId()) @@ -446,21 +460,23 @@ protected function _lookupCustomerId() } /** - * Make sure addresses will be saved without validation errors + * Sets the quote addresses to ignore validation during the order placement process. + * + * @return void */ - private function _ignoreAddressValidation() + private function _ignoreAddressValidation(): void { $this->_quote->getBillingAddress()->setShouldIgnoreValidation(true); if (!$this->_quote->getIsVirtual()) { $this->_quote->getShippingAddress()->setShouldIgnoreValidation(true); } } - /** - * Redirect to login page + * Redirects the user to the customer login page. * + * @return void */ - protected function _redirectLogin() + protected function _redirectLogin(): void { $this->setFlag('', 'no-dispatch', true); $this->getResponse()->setRedirect( @@ -472,11 +488,11 @@ protected function _redirectLogin() } /** - * Involve new customer to system + * Handles the post-order actions for a newly registered customer, such as sending confirmation emails. * - * @return $this + * @return self */ - protected function _involveNewCustomer() + protected function _involveNewCustomer(): self { $customer = $this->_quote->getCustomer(); if ($customer->isConfirmationRequired()) { diff --git a/app/code/core/Mage/Paypal/etc/config.xml b/app/code/core/Mage/Paypal/etc/config.xml index b243e77cb18..1c4254ca932 100644 --- a/app/code/core/Mage/Paypal/etc/config.xml +++ b/app/code/core/Mage/Paypal/etc/config.xml @@ -3,7 +3,7 @@ /** * @copyright For copyright and license information, read the COPYING.txt file. * @link /COPYING.txt - * @license Academic Free License (AFL 3.0) + * @license Open Software License (OSL 3.0) * @package Mage_Paypal */ --> diff --git a/app/code/core/Mage/Paypal/etc/system.xml b/app/code/core/Mage/Paypal/etc/system.xml index 76b85ea5719..71e0b5fc3d6 100644 --- a/app/code/core/Mage/Paypal/etc/system.xml +++ b/app/code/core/Mage/Paypal/etc/system.xml @@ -33,10 +33,9 @@ - If not specified, Default Country from General Config will be - used + Learn more about PayPal Supported Countries.]]> select - paypal/adminhtml_system_config_field_country paypal/system_config_source_merchantCountry paypal/system_config_backend_merchantCountry 1 diff --git a/app/locale/en_US/Mage_Paypal.csv b/app/locale/en_US/Mage_Paypal.csv index a77acd02733..99eadf78cc9 100644 --- a/app/locale/en_US/Mage_Paypal.csv +++ b/app/locale/en_US/Mage_Paypal.csv @@ -665,7 +665,9 @@ "Failed to reauthorize payment","Failed to reauthorize payment" "Gold","Gold" "Horizontal","Horizontal" -"If not specified, Default Country from General Config will be used","If not specified, Default Country from General Config will be used" +"If not specified, Default Country from General Config will be + used. Learn more about PayPal Supported Countries.","If not specified, Default Country from General Config will be + used. Learn more about PayPal Supported Countries." "If you want to use PayPal Express Checkout, you must complete the settings below.","If you want to use PayPal Express Checkout, you must complete the settings below." "Invalid form key","Invalid form key" "Order ID is required","Order ID is required" diff --git a/js/paypal/payment.js b/js/paypal/payment.js index 4c8eb5035a8..3f70d90e117 100644 --- a/js/paypal/payment.js +++ b/js/paypal/payment.js @@ -1,4 +1,3 @@ - /** * OpenMage * @@ -24,7 +23,6 @@ PayPalPayment.prototype = { this.renderPromise = null; this.reviewContainerInterval = null; - // Initialize on DOM ready document.readyState === 'loading' ? document.observe('dom:loaded', this.onDOMReady.bind(this)) : this.onDOMReady(); @@ -49,13 +47,12 @@ PayPalPayment.prototype = { waitForReviewContainer: function () { return new Promise(resolve => { - // Clear existing interval if (this.reviewContainerInterval) { clearInterval(this.reviewContainerInterval); this.reviewContainerInterval = null; } - const maxAttempts = 20; // 10 seconds max + const maxAttempts = 20; let attempts = 0; const checkForContainer = () => { @@ -71,10 +68,8 @@ PayPalPayment.prototype = { } }; - // Initial check checkForContainer(); - // Set interval if not found if (!$(this.config.reviewButtonContainerId)) { this.reviewContainerInterval = setInterval(checkForContainer, 500); } @@ -98,13 +93,9 @@ PayPalPayment.prototype = { .catch(() => { }); }, - debugCheckEnvironment: function () { - // Removed debug info - }, loadPayPalSDK: function () { return new Promise((resolve, reject) => { - // Check if SDK is already loaded if (typeof paypal !== 'undefined') { this.sdkLoaded = true; return resolve(); @@ -123,9 +114,7 @@ PayPalPayment.prototype = { }, renderButton: function () { - // Reset previous render operation this.renderPromise = null; - if (!this.sdkLoaded) { return Promise.reject(new Error('SDK not loaded')); } @@ -135,13 +124,10 @@ PayPalPayment.prototype = { return Promise.reject(new Error('Review container not found')); } - // Remove existing PayPal button this.removePayPalButton(); - // Find the existing checkout button const checkoutButton = reviewContainer.down('button.btn-checkout'); - // Create PayPal button container const paypalContainer = new Element('div', { 'id': this.config.containerId, 'class': 'paypal-button-container', @@ -149,13 +135,9 @@ PayPalPayment.prototype = { }); if (!checkoutButton) { - // Insert at the beginning of the container reviewContainer.insert({ top: paypalContainer }); } else { - // Remove the original checkout button checkoutButton.remove(); - - // Insert PayPal container in the same position const pleaseWaitSpan = reviewContainer.down('span.please-wait'); pleaseWaitSpan ? pleaseWaitSpan.insert({ before: paypalContainer }) @@ -168,11 +150,9 @@ PayPalPayment.prototype = { createPayPalButton: function (paypalContainer, reviewContainer) { this.renderPromise = new Promise((resolve, reject) => { try { - // Create button wrapper const buttonWrapper = new Element('div', { 'class': 'paypal-button-wrapper' }); paypalContainer.insert(buttonWrapper); - // Render PayPal button paypal.Buttons({ style: { layout: this.config.buttonLayout || 'vertical', @@ -204,19 +184,17 @@ PayPalPayment.prototype = { }, handleRenderError: function (error, reviewContainer, paypalContainer) { - // Clean up PayPal container - paypalContainer?.parentNode && paypalContainer.remove(); + if (paypalContainer && paypalContainer.parentNode) { + paypalContainer.remove(); + } - // Recreate the original checkout button this.recreateCheckoutButton(reviewContainer); this.buttonInitialized = false; }, recreateCheckoutButton: function (reviewContainer) { - // Skip if button already exists if (reviewContainer.down('button.btn-checkout')) return; - // Create checkout button const checkoutButton = new Element('button', { 'type': 'submit', 'title': 'Place Order', @@ -228,7 +206,6 @@ PayPalPayment.prototype = { ) ); - // Insert button const pleaseWaitSpan = reviewContainer.down('span.please-wait'); pleaseWaitSpan ? pleaseWaitSpan.insert({ before: checkoutButton }) @@ -324,18 +301,15 @@ PayPalPayment.prototype = { }, setupPaymentMethodHandling: function () { - // Handle payment method selection $$('input[name="payment[method]"]').each(input => { input.observe('click', () => this.handlePaymentMethodChange(input.value)); }); - // Handle review section updates document.observe('payment-method:switched', event => { const methodCode = event.memo?.method_code; methodCode && this.handlePaymentMethodChange(methodCode); }); - // Check initial payment method const currentMethod = this.getCurrentPaymentMethod(); currentMethod && this.handlePaymentMethodChange(currentMethod); }, @@ -375,15 +349,14 @@ PayPalPayment.prototype = { }, hideLoadingMask: function () { - $('loading-mask')?.hide(); + const mask = $('loading-mask'); + if (mask) mask.hide(); }, showError: function (message) { - // Remove existing error const errorId = this.config.containerId + '-error'; $(errorId)?.remove(); - // Create new error element const container = $(this.config.containerId); if (container) { const errorDiv = new Element('div', { @@ -396,27 +369,20 @@ PayPalPayment.prototype = { } }, - log: function () { - // Removed logging - }, - destroy: function () { - // Remove event listeners + $$('input[name="payment[method]"]').each(input => { input.stopObserving('click'); }); - // Remove payment button observer const paymentButton = $$('button[onclick="payment.save()"]')[0]; paymentButton?.stopObserving('click'); - // Clear interval if (this.reviewContainerInterval) { clearInterval(this.reviewContainerInterval); this.reviewContainerInterval = null; } - // Clean up containers this.removePayPalButton(); } }; \ No newline at end of file From 8c09f3e0780e558d93d62423e90c4081ef9d9a0d Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Sun, 22 Jun 2025 02:43:11 +0200 Subject: [PATCH 08/40] refactor: optimize paypal module for PHP 8.4 --- .../Debug/Grid/Renderer/Exception.php | 3 -- .../Adminhtml/Debug/Grid/Renderer/Request.php | 3 -- .../Debug/Grid/Renderer/Response.php | 3 -- .../Block/Adminhtml/Grid/Renderer/Json.php | 6 +--- .../Block/Adminhtml/Grid/Renderer/Order.php | 3 -- .../core/Mage/Paypal/Block/Adminhtml/Info.php | 6 ---- app/code/core/Mage/Paypal/Block/Form.php | 12 +------- app/code/core/Mage/Paypal/Block/Info.php | 2 -- app/code/core/Mage/Paypal/Helper/Data.php | 7 +---- app/code/core/Mage/Paypal/Model/Api.php | 24 ---------------- .../core/Mage/Paypal/Model/Api/Helper.php | 2 -- app/code/core/Mage/Paypal/Model/Cart.php | 15 +--------- app/code/core/Mage/Paypal/Model/Config.php | 10 ------- app/code/core/Mage/Paypal/Model/Exception.php | 2 -- app/code/core/Mage/Paypal/Model/Paypal.php | 28 ------------------- .../System/Config/Source/MerchantCountry.php | 2 -- .../Adminhtml/Paypal/DebugController.php | 10 ------- .../Paypal/TransactionController.php | 4 --- .../Paypal/controllers/PaymentController.php | 25 ----------------- 19 files changed, 4 insertions(+), 163 deletions(-) diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php index 6ac73c4dcd5..06a648fa224 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php @@ -16,9 +16,6 @@ class Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Exception extends Mage_Adm { /** * Renders the exception_message column with copy functionality - * - * @param Varien_Object $row - * @return string */ public function render(Varien_Object $row): string { diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php index a0af97ac46e..17b418430b0 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Request.php @@ -16,9 +16,6 @@ class Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Request extends Mage_Paypa { /** * Renders the request_body column with copy functionality - * - * @param Varien_Object $row - * @return string */ public function render(Varien_Object $row): string { diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php index 80848f716f0..d35b4f5c60d 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Response.php @@ -16,9 +16,6 @@ class Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Response extends Mage_Payp { /** * Renders the response_body column with copy functionality - * - * @param Varien_Object $row - * @return string */ public function render(Varien_Object $row): string { diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php index 653e453bc3c..fd2575acae2 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Json.php @@ -15,7 +15,6 @@ class Mage_Paypal_Block_Adminhtml_Grid_Renderer_Json extends Mage_Adminhtml_Bloc * Format JSON data for display * * @param string $json - * @return string */ protected function _formatJson(?string $json): string { @@ -35,16 +34,13 @@ protected function _formatJson(?string $json): string '
%s
', $this->escapeHtml($formattedJson), ); - } catch (Exception $e) { + } catch (Exception) { return $this->escapeHtml($json); } } /** * Render cell content - * - * @param Varien_Object $row - * @return string */ public function render(Varien_Object $row): string { diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php index 38a6cf418b1..689a4f34605 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Grid/Renderer/Order.php @@ -13,9 +13,6 @@ class Mage_Paypal_Block_Adminhtml_Grid_Renderer_Order extends Mage_Adminhtml_Blo { /** * Render order link - * - * @param Varien_Object $row - * @return string */ public function render(Varien_Object $row): string { diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php index 667ad84b934..50e7d41c2e1 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php @@ -25,8 +25,6 @@ protected function _construct(): void /** * Retrieves the transaction ID from the payment information. - * - * @return string|null */ public function getTransactionId(): ?string { @@ -35,8 +33,6 @@ public function getTransactionId(): ?string /** * Generates the PayPal transaction URL based on the transaction ID and sandbox status. - * - * @return string|null */ public function getTransactionUrl(): ?string { @@ -51,8 +47,6 @@ public function getTransactionUrl(): ?string /** * Retrieves and formats additional payment information, such as status and authorization details. - * - * @return array */ public function getPaymentInfo(): array { diff --git a/app/code/core/Mage/Paypal/Block/Form.php b/app/code/core/Mage/Paypal/Block/Form.php index 6922871c462..db49eb6d7df 100644 --- a/app/code/core/Mage/Paypal/Block/Form.php +++ b/app/code/core/Mage/Paypal/Block/Form.php @@ -25,8 +25,6 @@ protected function _construct(): void /** * Retrieves the configuration for the PayPal button. - * - * @return array */ public function getButtonConfig(): array { @@ -35,8 +33,6 @@ public function getButtonConfig(): array /** * Retrieves the PayPal API endpoint URL. - * - * @return string */ public function getEndpointUrl(): string { @@ -45,8 +41,6 @@ public function getEndpointUrl(): string /** * Retrieves the PayPal client ID from the API credentials. - * - * @return string */ public function getClientId(): string { @@ -55,8 +49,6 @@ public function getClientId(): string /** * Constructs and retrieves the full URL for the PayPal JavaScript SDK. - * - * @return string */ public function getSdkUrl(): string { @@ -70,7 +62,7 @@ public function getSdkUrl(): string ]; $baseUrl = $this->getEndpointUrl(); - if (substr($baseUrl, -1) !== '/') { + if (!str_ends_with($baseUrl, '/')) { $baseUrl .= '/'; } return $baseUrl . 'sdk/js?' . http_build_query($params); @@ -88,8 +80,6 @@ public function getAmount() /** * Retrieves the currency code for the current store. - * - * @return string */ public function getCurrencyCode(): string { diff --git a/app/code/core/Mage/Paypal/Block/Info.php b/app/code/core/Mage/Paypal/Block/Info.php index 2e650cfbfbe..1bc78ebb5bf 100644 --- a/app/code/core/Mage/Paypal/Block/Info.php +++ b/app/code/core/Mage/Paypal/Block/Info.php @@ -25,8 +25,6 @@ protected function _construct(): void /** * Retrieves the transaction ID from the payment information. - * - * @return string|null */ public function getTransactionId(): ?string { diff --git a/app/code/core/Mage/Paypal/Helper/Data.php b/app/code/core/Mage/Paypal/Helper/Data.php index 58e34363798..b8d8e86dd5d 100644 --- a/app/code/core/Mage/Paypal/Helper/Data.php +++ b/app/code/core/Mage/Paypal/Helper/Data.php @@ -18,7 +18,6 @@ class Mage_Paypal_Helper_Data extends Mage_Core_Helper_Abstract * Retrieves the PayPal configuration model, optionally for a specific store. * * @param mixed $store The store ID or object. - * @return Mage_Paypal_Model_Config */ public function getConfig(mixed $store = null): Mage_Paypal_Model_Config { @@ -29,7 +28,6 @@ public function getConfig(mixed $store = null): Mage_Paypal_Model_Config * Checks if the PayPal payment method is active and available, optionally for a specific store. * * @param mixed $store The store ID or object. - * @return bool */ public function isAvailable(mixed $store = null): bool { @@ -40,7 +38,6 @@ public function isAvailable(mixed $store = null): bool * Retrieves the configuration settings for the PayPal button, optionally for a specific store. * * @param mixed $store The store ID or object. - * @return array */ public function getButtonConfig(mixed $store = null): array { @@ -51,7 +48,6 @@ public function getButtonConfig(mixed $store = null): array * Formats a numeric price into a string with two decimal places, suitable for the PayPal API. * * @param float $amount The price amount to format. - * @return string */ public function formatPrice(float $amount): string { @@ -63,11 +59,10 @@ public function formatPrice(float $amount): string * * @param string $transactionId The transaction ID. * @param bool $sandbox Whether to use the sandbox environment. - * @return string */ public function getTransactionUrl(string $transactionId, bool $sandbox = false): string { - if (strpos($transactionId, '-') !== false) { + if (str_contains($transactionId, '-')) { $parts = explode('-', $transactionId); $transactionId = $parts[0]; } diff --git a/app/code/core/Mage/Paypal/Model/Api.php b/app/code/core/Mage/Paypal/Model/Api.php index 0a296809e30..54163ac6e87 100644 --- a/app/code/core/Mage/Paypal/Model/Api.php +++ b/app/code/core/Mage/Paypal/Model/Api.php @@ -50,9 +50,7 @@ public function __construct() /** * Create a new PayPal order with a pre-built request * - * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote * @param object $orderRequest Pre-built order request object - * @return ApiResponse|null * @throws Mage_Core_Exception */ public function createOrder( @@ -79,8 +77,6 @@ public function createOrder( * Authorize payment for a PayPal order * * @param string $id PayPal order ID - * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote - * @return ApiResponse|null * @throws Mage_Core_Exception */ public function authorizeOrder( @@ -107,8 +103,6 @@ public function authorizeOrder( * Authorize payment for a PayPal order * * @param string $id PayPal order ID - * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote - * @return ApiResponse|null * @throws Mage_Core_Exception */ public function reAuthorizeOrder( @@ -136,8 +130,6 @@ public function reAuthorizeOrder( * Capture authorized payment for a PayPal order * * @param string $id PayPal order ID - * @param Mage_Sales_Model_Order $order - * @return ApiResponse|null * @throws Mage_Core_Exception */ public function captureAuthorizedPayment(string $id, Mage_Sales_Model_Order $order): ?ApiResponse @@ -161,8 +153,6 @@ public function captureAuthorizedPayment(string $id, Mage_Sales_Model_Order $ord * Capture payment for a PayPal order * * @param string $id PayPal order ID - * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote - * @return ApiResponse|null * @throws Mage_Core_Exception */ public function captureOrder( @@ -193,8 +183,6 @@ public function captureOrder( * @param string $captureId PayPal capture ID * @param float $amount Amount to refund * @param string $currencyCode Currency code - * @param Mage_Sales_Model_Order $order - * @return ApiResponse|null * @throws Mage_Core_Exception */ public function refundCapturedPayment( @@ -225,8 +213,6 @@ public function refundCapturedPayment( * Void an authorization * * @param string $authorizationId PayPal authorization ID - * @param Mage_Sales_Model_Order $order - * @return ApiResponse|null * @throws Mage_Core_Exception */ public function voidPayment(string $authorizationId, Mage_Sales_Model_Order $order): ?ApiResponse @@ -250,7 +236,6 @@ public function voidPayment(string $authorizationId, Mage_Sales_Model_Order $ord /** * Get PayPal API client instance with lazy loading * - * @return PaypalServerSdkClient * @throws Mage_Core_Exception */ public function getClient(): PaypalServerSdkClient @@ -300,7 +285,6 @@ private function _initializeClient(): void /** * Validate quote object * - * @param mixed $quote * @throws Mage_Core_Exception */ private function _validateQuote(mixed $quote): void @@ -313,7 +297,6 @@ private function _validateQuote(mixed $quote): void /** * Validate order ID * - * @param string $id * @throws Mage_Core_Exception */ private function _validateOrderId(string $id): void @@ -326,7 +309,6 @@ private function _validateOrderId(string $id): void /** * Validate capture ID * - * @param string $captureId * @throws Mage_Core_Exception */ private function _validateCaptureId(string $captureId): void @@ -339,7 +321,6 @@ private function _validateCaptureId(string $captureId): void /** * Validate authorization ID * - * @param string $authorizationId * @throws Mage_Core_Exception */ private function _validateAuthorizationId(string $authorizationId): void @@ -352,7 +333,6 @@ private function _validateAuthorizationId(string $authorizationId): void /** * Validate amount * - * @param float $amount * @throws Mage_Core_Exception */ private function _validateAmount(float $amount): void @@ -365,8 +345,6 @@ private function _validateAmount(float $amount): void /** * Build refund request body * - * @param float $amount - * @param string $currencyCode * @return array */ private function _buildRefundBody(float $amount, string $currencyCode): array @@ -382,8 +360,6 @@ private function _buildRefundBody(float $amount, string $currencyCode): array /** * Log error and throw exception * - * @param string $message - * @param Exception $e * @throws Exception */ private function _logAndThrowError(string $message, Exception $e): never diff --git a/app/code/core/Mage/Paypal/Model/Api/Helper.php b/app/code/core/Mage/Paypal/Model/Api/Helper.php index 982bf64241a..1d43c2cdb1a 100644 --- a/app/code/core/Mage/Paypal/Model/Api/Helper.php +++ b/app/code/core/Mage/Paypal/Model/Api/Helper.php @@ -38,7 +38,6 @@ public function __construct() * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote Quote or order object. * @param mixed $request Request object or data sent to the API. * @param ApiResponse|null $response API response, if available. - * @return void */ public function logDebug( string $action, @@ -87,7 +86,6 @@ public function logDebug( * * @param string $message The error message. * @param Exception $exception The exception object. - * @return void */ public function logError(string $message, Exception $exception): void { diff --git a/app/code/core/Mage/Paypal/Model/Cart.php b/app/code/core/Mage/Paypal/Model/Cart.php index f0caa45f1ea..480966f7d94 100644 --- a/app/code/core/Mage/Paypal/Model/Cart.php +++ b/app/code/core/Mage/Paypal/Model/Cart.php @@ -43,7 +43,6 @@ class Mage_Paypal_Model_Cart /** * Initializes the cart model with a sales entity (order or quote). * - * @param array $params * @throws Exception */ public function __construct(array $params = []) @@ -63,8 +62,6 @@ public function __construct(array $params = []) /** * Validates that the quote's currency is supported by PayPal. - * - * @return self */ protected function _validateCurrency(): self { @@ -83,8 +80,6 @@ protected function _validateCurrency(): self /** * Retrieves all prepared items for the PayPal request. Items are prepared if not already. - * - * @return array */ public function getAllItems(): array { @@ -96,8 +91,6 @@ public function getAllItems(): array /** * Retrieves all prepared totals (subtotal, tax, shipping, discount). Totals are prepared if not already. - * - * @return array */ public function getAmounts(): array { @@ -109,8 +102,6 @@ public function getAmounts(): array /** * Prepares the line items from the quote for the PayPal API request. - * - * @return self */ protected function _prepareItems(): self { @@ -135,7 +126,7 @@ protected function _prepareItems(): self } $description = $item->getDescription(); if ($description) { - $itemBuilder->description(substr($description, 0, 127)); + $itemBuilder->description(substr((string) $description, 0, 127)); } $this->_items[] = $itemBuilder->build(); } @@ -145,8 +136,6 @@ protected function _prepareItems(): self /** * Prepares the cart totals from the quote for the PayPal API request. - * - * @return self */ protected function _prepareTotals(): self { @@ -177,8 +166,6 @@ protected function _prepareTotals(): self /** * Get the sales entity (quote or order) object associated with this cart. - * - * @return Mage_Sales_Model_Order|Mage_Sales_Model_Quote */ public function getQuote(): Mage_Sales_Model_Order|Mage_Sales_Model_Quote { diff --git a/app/code/core/Mage/Paypal/Model/Config.php b/app/code/core/Mage/Paypal/Model/Config.php index c61788b8dde..1dbffeb8941 100644 --- a/app/code/core/Mage/Paypal/Model/Config.php +++ b/app/code/core/Mage/Paypal/Model/Config.php @@ -80,8 +80,6 @@ public function getApiCredentials(): array /** * Checks if debug mode is enabled. - * - * @return bool */ public function isDebugEnabled(): bool { @@ -90,8 +88,6 @@ public function isDebugEnabled(): bool /** * Checks if sandbox mode is enabled. - * - * @return bool */ public function isSandbox(): bool { @@ -100,8 +96,6 @@ public function isSandbox(): bool /** * Retrieves the configured payment action (e.g., 'authorize', 'capture'). - * - * @return string */ public function getPaymentAction(): string { @@ -110,8 +104,6 @@ public function getPaymentAction(): string /** * Retrieves the PayPal API endpoint URL based on the sandbox mode. - * - * @return string */ public function getEndpoint(): string { @@ -139,7 +131,6 @@ public function getButtonConfiguration(): array * Checks if the PayPal payment method is active for the given store. * * @param mixed|null $store The store ID or object to check for. - * @return bool */ public function isActive(mixed $store = null): bool { @@ -161,7 +152,6 @@ public function getAllowedCurrencyCodes(): array * * @param string $field The configuration field to retrieve. * @param mixed|null $store The store ID or object. - * @return mixed */ protected function getConfigData(string $field, mixed $store = null): mixed { diff --git a/app/code/core/Mage/Paypal/Model/Exception.php b/app/code/core/Mage/Paypal/Model/Exception.php index b35e224f35a..22dab9c7197 100644 --- a/app/code/core/Mage/Paypal/Model/Exception.php +++ b/app/code/core/Mage/Paypal/Model/Exception.php @@ -24,8 +24,6 @@ public function __construct($message = '', $debugData = []) /** * Get debug data - * - * @return array */ public function getDebugData(): array { diff --git a/app/code/core/Mage/Paypal/Model/Paypal.php b/app/code/core/Mage/Paypal/Model/Paypal.php index 142c0cb3553..d5fe6dc2eb0 100644 --- a/app/code/core/Mage/Paypal/Model/Paypal.php +++ b/app/code/core/Mage/Paypal/Model/Paypal.php @@ -99,7 +99,6 @@ public function create(Mage_Sales_Model_Quote $quote): array * Capture PayPal payment via API * * @param string $orderId PayPal order ID - * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote * @throws Mage_Core_Exception */ public function captureOrder(string $orderId, Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote): void @@ -120,7 +119,6 @@ public function captureOrder(string $orderId, Mage_Sales_Model_Quote|Mage_Sales_ * Authorize PayPal payment via API * * @param string $orderId PayPal order ID - * @param Mage_Sales_Model_Quote $quote * @throws Mage_Core_Exception */ public function authorizePayment(string $orderId, Mage_Sales_Model_Quote $quote): void @@ -222,7 +220,6 @@ public function validate(): static * * @param Varien_Object $payment Payment object * @param float $amount Refund amount - * @return static * @throws Mage_Core_Exception */ public function refund(Varien_Object $payment, $amount): static @@ -260,7 +257,6 @@ public function refund(Varien_Object $payment, $amount): static * * @param Varien_Object $payment Payment object * @param float $amount Capture amount - * @return static * @throws Mage_Core_Exception */ public function capture(Varien_Object $payment, $amount): static @@ -297,7 +293,6 @@ public function capture(Varien_Object $payment, $amount): static * Void payment method * * @param Varien_Object $payment Payment object - * @return static * @throws Mage_Core_Exception */ public function void(Varien_Object $payment): static @@ -334,7 +329,6 @@ public function void(Varien_Object $payment): static * Cancel payment method * * @param Varien_Object $payment Payment object - * @return static * @throws Mage_Core_Exception */ public function cancel(Varien_Object $payment): static @@ -350,7 +344,6 @@ public function cancel(Varien_Object $payment): static * Check if payment method is available * * @param Mage_Sales_Model_Quote|null $quote - * @return bool */ public function isAvailable($quote = null): bool { @@ -395,7 +388,6 @@ private function _getQuote(): Mage_Sales_Model_Quote /** * Validate quote for PayPal payment processing * - * @param Mage_Sales_Model_Quote $quote * @throws Mage_Core_Exception */ private function _validateQuoteForPayment(Mage_Sales_Model_Quote $quote): void @@ -411,9 +403,6 @@ private function _validateQuoteForPayment(Mage_Sales_Model_Quote $quote): void /** * Update payment object with PayPal order information - * - * @param Mage_Sales_Model_Quote_Payment $payment - * @param ApiResponse $response */ private function _updatePaymentWithOrderInfo(Mage_Sales_Model_Quote_Payment $payment, ApiResponse $response): void { @@ -429,7 +418,6 @@ private function _updatePaymentWithOrderInfo(Mage_Sales_Model_Quote_Payment $pay /** * Build a purchase unit using PayPal SDK builders * - * @param Mage_Sales_Model_Quote $quote * @param string|null $referenceId Optional reference ID * @return object The built purchase unit object */ @@ -538,10 +526,7 @@ private function _buildAmountBreakdown(array $totals): object /** * Build amount with breakdown * - * @param string $currency - * @param float $totalAmount * @param object $breakdown Built breakdown object - * @return object */ private function _buildAmountWithBreakdown(string $currency, float $totalAmount, object $breakdown): object { @@ -555,7 +540,6 @@ private function _buildAmountWithBreakdown(string $currency, float $totalAmount, /** * Build a complete PayPal order request using SDK builders * - * @param Mage_Sales_Model_Quote $quote * @param string|null $referenceId Optional reference ID * @return object The built order request object */ @@ -577,9 +561,6 @@ private function _buildOrderRequest(Mage_Sales_Model_Quote $quote, ?string $refe /** * Build payer object from billing address - * - * @param Mage_Sales_Model_Quote $quote - * @return object|null */ private function _buildPayerFromBillingAddress(Mage_Sales_Model_Quote $quote): ?object { @@ -630,7 +611,6 @@ private function _getPaymentIntent(): string * Extract capture ID from API result * * @param mixed $result API result - * @return string|null */ private function _extractCaptureId(mixed $result): ?string { @@ -659,7 +639,6 @@ private function _extractCaptureId(mixed $result): ?string /** * Update payment object after successful capture * - * @param Mage_Sales_Model_Quote_Payment|Mage_Sales_Model_Order_Payment $payment * @param ApiResponse $response API result * @param string $orderId PayPal order ID * @param string $captureId Capture ID @@ -691,7 +670,6 @@ private function _updatePaymentAfterCapture( /** * Update payment object after successful authorization * - * @param Mage_Sales_Model_Quote_Payment $payment * @param ApiResponse $response API result */ private function _updatePaymentAfterAuthorization(Mage_Sales_Model_Quote_Payment $payment, ApiResponse $response): void @@ -718,7 +696,6 @@ private function _updatePaymentAfterAuthorization(Mage_Sales_Model_Quote_Payment /** * Add order status comment * - * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote * @param string $action Action performed (captured, authorized, etc.) * @param string|null $transactionId Transaction ID */ @@ -783,7 +760,6 @@ private function _createRefundTransaction(Varien_Object $payment, ApiResponse $r * Update payment after authorized capture * * @param Varien_Object $payment Payment object - * @param ApiResponse $response * @param string $authorizationId Authorization ID */ private function _updatePaymentAfterAuthorizedCapture(Varien_Object $payment, ApiResponse $response, string $authorizationId): void @@ -804,7 +780,6 @@ private function _updatePaymentAfterAuthorizedCapture(Varien_Object $payment, Ap * Create capture transaction record * * @param Varien_Object $payment Payment object - * @param ApiResponse $response * @param string $authorizationId Authorization ID */ private function _createCaptureTransaction(Varien_Object $payment, ApiResponse $response, string $authorizationId): void @@ -866,8 +841,6 @@ private function _createVoidTransaction(Varien_Object $payment, ApiResponse $res /** * Handle multishipping notification - * - * @param Mage_Sales_Model_Quote|null $quote */ private function _handleMultishippingNotification(?Mage_Sales_Model_Quote $quote): void { @@ -888,7 +861,6 @@ private function _handleMultishippingNotification(?Mage_Sales_Model_Quote $quote * * @param ApiResponse $response API response * @param string $defaultMessage Default error message - * @return string */ private function _extractErrorMessage(ApiResponse $response, string $defaultMessage): string { diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php index 9a31472b314..df2e3309d0b 100644 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php @@ -13,8 +13,6 @@ class Mage_Paypal_Model_System_Config_Source_MerchantCountry /** * Get list of allowed merchant countries * https://developer.paypal.com/docs/multiparty/seller-onboarding/#country-eligibility - * - * @return array */ public function toOptionArray(): array { diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/DebugController.php b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/DebugController.php index 1584d4f8f74..7ec1861c350 100644 --- a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/DebugController.php +++ b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/DebugController.php @@ -29,8 +29,6 @@ protected function _initAction(): self /** * Renders the PayPal debug log grid page. - * - * @return void */ public function indexAction(): void { @@ -41,8 +39,6 @@ public function indexAction(): void /** * Renders the debug log grid for AJAX requests. - * - * @return void */ public function gridAction(): void { @@ -54,8 +50,6 @@ public function gridAction(): void /** * Handles the mass deletion of selected debug log entries. - * - * @return void */ public function massDeleteAction(): void { @@ -79,8 +73,6 @@ public function massDeleteAction(): void /** * Handles the deletion of all debug log entries. - * - * @return void */ public function deleteAllAction(): void { @@ -98,8 +90,6 @@ public function deleteAllAction(): void /** * Checks if the current user has permission to access this controller. - * - * @return bool */ protected function _isAllowed(): bool { diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php index 214b5d53579..a4273ed3019 100644 --- a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php +++ b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php @@ -18,8 +18,6 @@ class Mage_Paypal_Adminhtml_Paypal_TransactionController extends Mage_Adminhtml_ * Handles the reauthorization of a PayPal payment for a specific order. * It validates the order and payment details, triggers the reauthorization process, * and redirects the user back to the order view with a success or error message. - * - * @return void */ public function reauthorizeAction(): void { @@ -63,8 +61,6 @@ public function reauthorizeAction(): void /** * Checks if the current user has permission to access this controller's actions. - * - * @return bool */ protected function _isAllowed(): bool { diff --git a/app/code/core/Mage/Paypal/controllers/PaymentController.php b/app/code/core/Mage/Paypal/controllers/PaymentController.php index a93d12f44d5..8d6d5c3d312 100644 --- a/app/code/core/Mage/Paypal/controllers/PaymentController.php +++ b/app/code/core/Mage/Paypal/controllers/PaymentController.php @@ -34,8 +34,6 @@ class Mage_Paypal_PaymentController extends Mage_Core_Controller_Front_Action /** * Handles the AJAX request to create a PayPal order. * Validates the quote and creates a PayPal order via the PayPal model. - * - * @return void */ public function createAction(): void { @@ -104,7 +102,6 @@ public function createAction(): void * Processes the PayPal payment after customer approval on the PayPal side. * This action will either authorize or capture the payment based on the store's configuration. * - * @return void * @throws Exception */ public function processAction(): void @@ -145,7 +142,6 @@ public function processAction(): void * Places the Magento order after the PayPal payment has been successfully processed. * It handles guest, new customer, and existing customer checkouts, creates the order, * and redirects to the success or cart page. - * @return void */ public function placeOrderAction(): void { @@ -261,8 +257,6 @@ public function placeOrderAction(): void /** * Retrieves the checkout session model. - * - * @return Mage_Checkout_Model_Session */ protected function _getCheckoutSession(): Mage_Checkout_Model_Session { @@ -271,8 +265,6 @@ protected function _getCheckoutSession(): Mage_Checkout_Model_Session /** * Return checkout quote object - * - * @return Mage_Sales_Model_Quote */ private function _getQuote(): Mage_Sales_Model_Quote { @@ -284,8 +276,6 @@ private function _getQuote(): Mage_Sales_Model_Quote /** * Retrieves the PayPal model instance. - * - * @return Mage_Paypal_Model_Paypal */ private function _getPaypal(): Mage_Paypal_Model_Paypal { @@ -297,8 +287,6 @@ private function _getPaypal(): Mage_Paypal_Model_Paypal /** * Prepares the quote for a guest checkout. - * - * @return self */ protected function _prepareGuestQuote(): self { @@ -311,8 +299,6 @@ protected function _prepareGuestQuote(): self /** * Prepares the quote for a new customer registration during checkout. - * - * @return self */ protected function _prepareNewCustomerQuote(): self { @@ -374,8 +360,6 @@ protected function _prepareNewCustomerQuote(): self /** * Prepares the quote for an existing, logged-in customer. - * - * @return self */ protected function _prepareCustomerQuote(): self { @@ -413,8 +397,6 @@ protected function _prepareCustomerQuote(): self /** * Retrieves the customer session model. - * - * @return Mage_Customer_Model_Session */ public function getCustomerSession(): Mage_Customer_Model_Session { @@ -428,7 +410,6 @@ public function getCustomerSession(): Mage_Customer_Model_Session * Checks if a customer with the given email address already exists for the current website. * * @param string $email The customer email to check. - * @return bool */ protected function _customerEmailExists(string $email): bool { @@ -461,8 +442,6 @@ protected function _lookupCustomerId(): ?int /** * Sets the quote addresses to ignore validation during the order placement process. - * - * @return void */ private function _ignoreAddressValidation(): void { @@ -473,8 +452,6 @@ private function _ignoreAddressValidation(): void } /** * Redirects the user to the customer login page. - * - * @return void */ protected function _redirectLogin(): void { @@ -489,8 +466,6 @@ protected function _redirectLogin(): void /** * Handles the post-order actions for a newly registered customer, such as sending confirmation emails. - * - * @return self */ protected function _involveNewCustomer(): self { From c83a1e6d3920e7751d991b96ec2a832118e617e5 Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Sun, 22 Jun 2025 02:47:00 +0200 Subject: [PATCH 09/40] fix: update meta files --- .phpstorm.meta.php/magento_blocks.meta.php | 2 -- .../magento_blocks_methods.meta.php | 2 -- .phpstorm.meta.php/magento_models.meta.php | 8 ----- .../magento_models_methods.meta.php | 36 ------------------- 4 files changed, 48 deletions(-) diff --git a/.phpstorm.meta.php/magento_blocks.meta.php b/.phpstorm.meta.php/magento_blocks.meta.php index 72af9f9d38a..87b824c1d58 100644 --- a/.phpstorm.meta.php/magento_blocks.meta.php +++ b/.phpstorm.meta.php/magento_blocks.meta.php @@ -1116,8 +1116,6 @@ 'paypal/adminhtml_grid_renderer_json' => \Mage_Paypal_Block_Adminhtml_Grid_Renderer_Json::class, 'paypal/adminhtml_grid_renderer_order' => \Mage_Paypal_Block_Adminhtml_Grid_Renderer_Order::class, 'paypal/adminhtml_info' => \Mage_Paypal_Block_Adminhtml_Info::class, - 'paypal/adminhtml_system_config_field_country' => \Mage_Paypal_Block_Adminhtml_System_Config_Field_Country::class, - 'paypal/button' => \Mage_Paypal_Block_Button::class, 'paypal/form' => \Mage_Paypal_Block_Form::class, 'paypal/info' => \Mage_Paypal_Block_Info::class, 'persistent/form_remember' => \Mage_Persistent_Block_Form_Remember::class, diff --git a/.phpstorm.meta.php/magento_blocks_methods.meta.php b/.phpstorm.meta.php/magento_blocks_methods.meta.php index 9811549474b..30625cce2e0 100644 --- a/.phpstorm.meta.php/magento_blocks_methods.meta.php +++ b/.phpstorm.meta.php/magento_blocks_methods.meta.php @@ -1116,8 +1116,6 @@ 'paypal/adminhtml_grid_renderer_json' => \Mage_Paypal_Block_Adminhtml_Grid_Renderer_Json::class, 'paypal/adminhtml_grid_renderer_order' => \Mage_Paypal_Block_Adminhtml_Grid_Renderer_Order::class, 'paypal/adminhtml_info' => \Mage_Paypal_Block_Adminhtml_Info::class, - 'paypal/adminhtml_system_config_field_country' => \Mage_Paypal_Block_Adminhtml_System_Config_Field_Country::class, - 'paypal/button' => \Mage_Paypal_Block_Button::class, 'paypal/form' => \Mage_Paypal_Block_Form::class, 'paypal/info' => \Mage_Paypal_Block_Info::class, 'persistent/form_remember' => \Mage_Persistent_Block_Form_Remember::class, diff --git a/.phpstorm.meta.php/magento_models.meta.php b/.phpstorm.meta.php/magento_models.meta.php index 65fcd688ccf..3d868506360 100644 --- a/.phpstorm.meta.php/magento_models.meta.php +++ b/.phpstorm.meta.php/magento_models.meta.php @@ -1936,7 +1936,6 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, @@ -1956,9 +1955,6 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, - 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, - 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -5051,7 +5047,6 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, @@ -5071,9 +5066,6 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, - 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, - 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, diff --git a/.phpstorm.meta.php/magento_models_methods.meta.php b/.phpstorm.meta.php/magento_models_methods.meta.php index 2e843c5d4a3..e3aa5d3b355 100644 --- a/.phpstorm.meta.php/magento_models_methods.meta.php +++ b/.phpstorm.meta.php/magento_models_methods.meta.php @@ -1936,7 +1936,6 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, @@ -1956,9 +1955,6 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, - 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, - 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -5051,7 +5047,6 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, @@ -5071,9 +5066,6 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, - 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, - 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -8166,7 +8158,6 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, @@ -8186,9 +8177,6 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, - 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, - 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -11281,7 +11269,6 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, @@ -11301,9 +11288,6 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, - 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, - 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -14396,7 +14380,6 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, @@ -14416,9 +14399,6 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, - 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, - 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -17511,7 +17491,6 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, @@ -17531,9 +17510,6 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, - 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, - 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -20626,7 +20602,6 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, @@ -20646,9 +20621,6 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, - 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, - 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -23741,7 +23713,6 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, @@ -23761,9 +23732,6 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, - 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, - 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -26856,7 +26824,6 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_exception' => \Mage_Paypal_Model_Api_Exception::class, 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, @@ -26876,9 +26843,6 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, - 'paypal/validator_api' => \Mage_Paypal_Model_Validator_Api::class, - 'paypal/validator_payment' => \Mage_Paypal_Model_Validator_Payment::class, - 'paypal/webhook_log' => \Mage_Paypal_Model_Webhook_Log::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, From 2caa7663479ebb533708334ba678cdd8904f934f Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Sun, 22 Jun 2025 03:05:52 +0200 Subject: [PATCH 10/40] fix: fix CI errors --- .phpstan.dist.baseline.neon | 228 ------------------ .phpstan.dist.neon | 2 - .../System/Config/Source/MerchantCountry.php | 1 - 3 files changed, 231 deletions(-) diff --git a/.phpstan.dist.baseline.neon b/.phpstan.dist.baseline.neon index 4f9d022673f..02303740093 100644 --- a/.phpstan.dist.baseline.neon +++ b/.phpstan.dist.baseline.neon @@ -3828,48 +3828,6 @@ parameters: count: 1 path: app/code/core/Mage/Payment/Model/Recurring/Profile.php - - - message: '#^Parameter \#2 \$value of method Mage_Core_Model_Config\:\:saveConfig\(\) expects string, int given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Paypal/Block/Adminhtml/System/Config/Fieldset/Deprecated.php - - - - message: '#^Return type \(false\) of method Mage_Paypal_Block_Hosted_Pro_Info\:\:getCcTypeName\(\) should be compatible with return type \(string\|null\) of method Mage_Paypal_Block_Payment_Info\:\:getCcTypeName\(\)$#' - identifier: method.childReturnType - count: 1 - path: app/code/core/Mage/Paypal/Block/Hosted/Pro/Info.php - - - - message: '#^Return type \(false\) of method Mage_Paypal_Block_Payflow_Link_Info\:\:getCcTypeName\(\) should be compatible with return type \(string\|null\) of method Mage_Paypal_Block_Payment_Info\:\:getCcTypeName\(\)$#' - identifier: method.childReturnType - count: 1 - path: app/code/core/Mage/Paypal/Block/Payflow/Link/Info.php - - - - message: '#^Parameter \#1 \$setToken of method Mage_Paypal_Controller_Express_Abstract\:\:_initToken\(\) expects string\|null, false given\.$#' - identifier: argument.type - count: 2 - path: app/code/core/Mage/Paypal/Controller/Express/Abstract.php - - - - message: '#^Call to an undefined method Mage_Paypal_Model_Api_Nvp\:\:_export\(\)\.$#' - identifier: method.notFound - count: 1 - path: app/code/core/Mage/Paypal/Model/Api/Nvp.php - - - - message: '#^Call to an undefined method Mage_Paypal_Model_Api_Nvp\:\:_import\(\)\.$#' - identifier: method.notFound - count: 1 - path: app/code/core/Mage/Paypal/Model/Api/Nvp.php - - - - message: '#^Parameter \#1 \$array \(non\-empty\-list\) of array_values is already a list, call has no effect\.$#' - identifier: arrayValues.list - count: 1 - path: app/code/core/Mage/Paypal/Model/Api/Nvp.php - - message: '#^Call to an undefined method Varien_Object\:\:isNominal\(\)\.$#' identifier: method.notFound @@ -3894,192 +3852,12 @@ parameters: count: 1 path: app/code/core/Mage/Paypal/Model/Config.php - - - message: '#^If condition is always false\.$#' - identifier: if.alwaysFalse - count: 1 - path: app/code/core/Mage/Paypal/Model/Express.php - - - - message: '#^Parameter \#1 \$amount of method Mage_Paypal_Model_Express\:\:_callDoAuthorize\(\) expects int, float given\.$#' - identifier: argument.type - count: 2 - path: app/code/core/Mage/Paypal/Model/Express.php - - - - message: '#^Parameter \#1 \$datetime of class DateTime constructor expects string, null given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Paypal/Model/Express.php - - - - message: '#^Cannot call method getData\(\) on array\.$#' - identifier: method.nonObject - count: 2 - path: app/code/core/Mage/Paypal/Model/Express/Checkout.php - - - - message: '#^Cannot call method getExportedKeys\(\) on array\.$#' - identifier: method.nonObject - count: 2 - path: app/code/core/Mage/Paypal/Model/Express/Checkout.php - - - - message: '#^Parameter \#1 \$message of static method Mage\:\:throwException\(\) expects string, array given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Paypal/Model/Express/Checkout.php - - - - message: '#^Return type \(bool\) of method Mage_Paypal_Model_Hostedpro\:\:getAllowedCcTypes\(\) should be compatible with return type \(string\) of method Mage_Paypal_Model_Direct\:\:getAllowedCcTypes\(\)$#' - identifier: method.childReturnType - count: 1 - path: app/code/core/Mage/Paypal/Model/Hostedpro.php - - - - message: '#^Return type \(bool\) of method Mage_Paypal_Model_Hostedpro\:\:validate\(\) should be compatible with return type \(\$this\(Mage_Payment_Model_Method_Cc\)\) of method Mage_Payment_Model_Method_Cc\:\:validate\(\)$#' - identifier: method.childReturnType - count: 1 - path: app/code/core/Mage/Paypal/Model/Hostedpro.php - - - - message: '#^Binary operation "\-" between array\|string and array\|string results in an error\.$#' - identifier: binaryOp.invalid - count: 1 - path: app/code/core/Mage/Paypal/Model/Ipn.php - - - - message: '#^Parameter \#1 \$amount of method Mage_Sales_Model_Order_Payment\:\:registerCaptureNotification\(\) expects float, array\|string given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Paypal/Model/Ipn.php - - - - message: '#^Parameter \#2 \$url of method Zend_Http_Client_Adapter_Interface\:\:write\(\) expects Zend_Uri_Http, string given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Paypal/Model/Ipn.php - - - - message: '#^Parameter \#1 \$payment of method Mage_Paypal_Model_Method_Agreement\:\:_placeOrder\(\) expects Mage_Sales_Model_Order_Payment, Varien_Object given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Paypal/Model/Method/Agreement.php - - - - message: '#^Parameter \#1 \$spec of method Zend_Controller_Response_Abstract\:\:getBody\(\) expects bool, string given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Paypal/Model/Observer.php - - - - message: '#^Return type \(bool\) of method Mage_Paypal_Model_Payflowlink\:\:validate\(\) should be compatible with return type \(\$this\(Mage_Payment_Model_Method_Cc\)\) of method Mage_Payment_Model_Method_Cc\:\:validate\(\)$#' - identifier: method.childReturnType - count: 1 - path: app/code/core/Mage/Paypal/Model/Payflowlink.php - - - - message: '#^Parameter \#1 \$payment of method Mage_Paypal_Model_Payflowpro\:\:_buildBasicRequest\(\) expects Mage_Sales_Model_Order_Payment, Mage_Payment_Model_Info given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Paypal/Model/Payflowpro.php - - - - message: '#^Parameter \#1 \$payment of method Mage_Paypal_Model_Payflowpro\:\:void\(\) expects Mage_Sales_Model_Order_Payment, Varien_Object given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Paypal/Model/Payflowpro.php - - - - message: '#^Parameter \#2 \$storeId of method Mage_Payment_Model_Method_Abstract\:\:getConfigData\(\) expects int\|Mage_Core_Model_Store\|string\|null, false given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Paypal/Model/Payflowpro.php - - - - message: '#^Parameter \#3 \$map of static method Varien_Object_Mapper\:\:accumulateByMap\(\) expects array, string given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Paypal/Model/Payflowpro.php - - - - message: '#^Property Mage_Paypal_Model_Payflowpro\:\:\$_centinelFieldMap \(string\) does not accept default value of type array\\.$#' - identifier: property.defaultValue - count: 1 - path: app/code/core/Mage/Paypal/Model/Payflowpro.php - - - - message: '#^Method Mage_Paypal_Model_Pro\:\:capture\(\) should return false\|null but return statement is missing\.$#' - identifier: return.missing - count: 1 - path: app/code/core/Mage/Paypal/Model/Pro.php - - - - message: '#^Parameter \#2 \$payment of method Mage_Paypal_Model_Pro\:\:_importCaptureResultToPayment\(\) expects Mage_Sales_Model_Order_Payment, Varien_Object given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Paypal/Model/Pro.php - - - - message: '#^Parameter \#2 \$payment of method Mage_Paypal_Model_Pro\:\:_importRefundResultToPayment\(\) expects Mage_Sales_Model_Order_Payment, Varien_Object given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Paypal/Model/Pro.php - - - - message: '#^Parameter \#2 \$to of method Mage_Paypal_Model_Pro\:\:importPaymentInfo\(\) expects Mage_Payment_Model_Info, Varien_Object given\.$#' - identifier: argument.type - count: 1 - path: app/code/core/Mage/Paypal/Model/Pro.php - - - - message: '#^Method Varien_Data_Collection\:\:toOptionArray\(\) invoked with 1 parameter, 0 required\.$#' - identifier: arguments.count - count: 1 - path: app/code/core/Mage/Paypal/Model/System/Config/Source/BuyerCountry.php - - message: '#^Method Varien_Data_Collection\:\:toOptionArray\(\) invoked with 1 parameter, 0 required\.$#' identifier: arguments.count count: 1 path: app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php - - - message: '#^Access to protected property Mage_Paypal_Model_Api_Nvp\:\:\$_setExpressCheckoutResponse\.$#' - identifier: property.protected - count: 1 - path: app/code/core/Mage/PaypalUk/Model/Api/Express/Nvp.php - - - - message: '#^Access to protected property Mage_Paypal_Model_Api_Nvp\:\:\$_doCaptureResponse\.$#' - identifier: property.protected - count: 1 - path: app/code/core/Mage/PaypalUk/Model/Api/Nvp.php - - - - message: '#^Access to protected property Mage_Paypal_Model_Api_Nvp\:\:\$_getTransactionDetailsResponse\.$#' - identifier: property.protected - count: 1 - path: app/code/core/Mage/PaypalUk/Model/Api/Nvp.php - - - - message: '#^Access to protected property Mage_Paypal_Model_Api_Nvp\:\:\$_paymentInformationResponse\.$#' - identifier: property.protected - count: 1 - path: app/code/core/Mage/PaypalUk/Model/Api/Nvp.php - - - - message: '#^Access to protected property Mage_Paypal_Model_Api_Nvp\:\:\$_refundTransactionResponse\.$#' - identifier: property.protected - count: 1 - path: app/code/core/Mage/PaypalUk/Model/Api/Nvp.php - - - - message: '#^Return type \(void\) of method Mage_PaypalUk_Model_Pro\:\:fetchTransactionInfo\(\) should be compatible with return type \(array\) of method Mage_Paypal_Model_Pro\:\:fetchTransactionInfo\(\)$#' - identifier: method.childReturnType - count: 1 - path: app/code/core/Mage/PaypalUk/Model/Pro.php - - message: '#^Method Mage_ProductAlert_Helper_Data\:\:createBlock\(\) should return Mage_ProductAlert_Block_Email_Price\|Mage_ProductAlert_Block_Email_Stock but returns Mage_Core_Block_Abstract\.$#' identifier: return.type @@ -5844,12 +5622,6 @@ parameters: count: 1 path: app/design/frontend/base/default/template/googleanalytics/ga.phtml - - - message: '#^Class Mage_Paypal_Block_Express_Form referenced with incorrect case\: Mage_PayPal_Block_Express_Form\.$#' - identifier: class.nameCase - count: 1 - path: app/design/frontend/base/default/template/paypal/payment/redirect.phtml - - message: '#^Cannot call method isEnabled\(\) on Mage_Core_Block_Abstract\|false\.$#' identifier: method.nonObject diff --git a/.phpstan.dist.neon b/.phpstan.dist.neon index ac155db64d8..ff27775883f 100644 --- a/.phpstan.dist.neon +++ b/.phpstan.dist.neon @@ -126,12 +126,10 @@ parameters: - app/design/frontend/base/default/template/customer/wishlist.phtml - app/design/frontend/base/default/template/directory/currency/switch.phtml - app/design/frontend/base/default/template/page/redirect.phtml - - app/design/frontend/base/default/template/paypal/hss/review/button.phtml - app/design/frontend/rwd/default/template/checkout/cart/render/default.phtml - app/design/frontend/rwd/default/template/checkout/cart/render/simple.phtml - app/design/frontend/rwd/default/template/customer/form/address.phtml - app/design/frontend/rwd/default/template/customer/form/changepassword.phtml - - app/design/frontend/rwd/default/template/paypal/express/review/address.phtml - app/design/install/default/default/template/page.phtml - identifier: phpunit.coversMethod diff --git a/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php b/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php index df2e3309d0b..ce4a499e8d3 100644 --- a/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php +++ b/app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php @@ -107,7 +107,6 @@ public function toOptionArray(): array 'UY', 'VN', ]; - ; return array_filter($countries, function ($country) use ($supportedCountries) { return in_array($country['value'], $supportedCountries); From bae786b084912ece3fff6c075f9661860b129ec1 Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Sun, 22 Jun 2025 15:59:53 +0200 Subject: [PATCH 11/40] fix: fix CI errors and guest checkout bugs --- .phpstan.dist.neon | 1 - app/code/core/Mage/Paypal/Model/Api.php | 2 +- app/code/core/Mage/Paypal/Model/Paypal.php | 12 ++++++++++-- .../Mage/Paypal/controllers/PaymentController.php | 4 ++-- app/code/core/Mage/Persistent/Model/Observer.php | 4 ---- app/code/core/Mage/Persistent/etc/config.xml | 8 -------- .../default/default/template/paypal/info.phtml | 2 +- .../frontend/base/default/template/paypal/info.phtml | 2 +- .../base/default/template/paypal/payment.phtml | 2 +- js/paypal/payment.js | 4 ++-- 10 files changed, 18 insertions(+), 23 deletions(-) diff --git a/.phpstan.dist.neon b/.phpstan.dist.neon index ff27775883f..404acdaa0ad 100644 --- a/.phpstan.dist.neon +++ b/.phpstan.dist.neon @@ -55,7 +55,6 @@ parameters: - app/code/core/Mage/Centinel/Model/Api/Client.php # Class phpseclib\Net\SSH2 not found. - - app/code/core/Mage/Paypal/Model/Report/Settlement.php - lib/Varien/Io/Sftp.php # Dataflow/Model/Convert/Iterator.php diff --git a/app/code/core/Mage/Paypal/Model/Api.php b/app/code/core/Mage/Paypal/Model/Api.php index 54163ac6e87..d2151c1e538 100644 --- a/app/code/core/Mage/Paypal/Model/Api.php +++ b/app/code/core/Mage/Paypal/Model/Api.php @@ -337,7 +337,7 @@ private function _validateAuthorizationId(string $authorizationId): void */ private function _validateAmount(float $amount): void { - if (!is_numeric($amount) || $amount <= 0) { + if ($amount <= 0) { throw new Mage_Core_Exception(self::ERROR_INVALID_AMOUNT); } } diff --git a/app/code/core/Mage/Paypal/Model/Paypal.php b/app/code/core/Mage/Paypal/Model/Paypal.php index d5fe6dc2eb0..57a176f74e2 100644 --- a/app/code/core/Mage/Paypal/Model/Paypal.php +++ b/app/code/core/Mage/Paypal/Model/Paypal.php @@ -596,7 +596,7 @@ private function _buildPayerFromBillingAddress(Mage_Sales_Model_Quote $quote): ? private function _getPaymentIntent(): string { // Always use capture for multishipping orders - if ($this->_getQuote()?->getIsMultiShipping()) { + if ($this->_getQuote()->getIsMultiShipping()) { return CheckoutPaymentIntent::CAPTURE; } @@ -640,7 +640,6 @@ private function _extractCaptureId(mixed $result): ?string * Update payment object after successful capture * * @param ApiResponse $response API result - * @param string $orderId PayPal order ID * @param string $captureId Capture ID */ private function _updatePaymentAfterCapture( @@ -743,6 +742,9 @@ private function _createRefundTransaction(Varien_Object $payment, ApiResponse $r { $result = $response->getResult(); $transaction = Mage::getModel('sales/order_payment_transaction'); + /** + * @var Mage_Sales_Model_Order_Payment $payment + */ $transaction->setOrderPaymentObject($payment) ->setTxnId($result->getId()) ->setParentTxnId($payment->getParentTransactionId()) @@ -786,6 +788,9 @@ private function _createCaptureTransaction(Varien_Object $payment, ApiResponse $ { $result = $response->getResult(); $transaction = Mage::getModel('sales/order_payment_transaction'); + /** + * @var Mage_Sales_Model_Order_Payment $payment + */ $transaction->setOrderPaymentObject($payment) ->setTxnId($result->getId()) ->setParentTxnId($authorizationId) @@ -821,6 +826,9 @@ private function _createVoidTransaction(Varien_Object $payment, ApiResponse $res { $transaction = Mage::getModel('sales/order_payment_transaction'); $result = $response->getResult(); + /** + * @var Mage_Sales_Model_Order_Payment $payment + */ $transaction->setOrderPaymentObject($payment) ->setTxnId($payment->getTransactionId()) ->setParentTxnId($result->getId()) diff --git a/app/code/core/Mage/Paypal/controllers/PaymentController.php b/app/code/core/Mage/Paypal/controllers/PaymentController.php index 8d6d5c3d312..b23f533a71d 100644 --- a/app/code/core/Mage/Paypal/controllers/PaymentController.php +++ b/app/code/core/Mage/Paypal/controllers/PaymentController.php @@ -290,9 +290,9 @@ private function _getPaypal(): Mage_Paypal_Model_Paypal */ protected function _prepareGuestQuote(): self { - $quote = $this->_quote; + $quote = $this->_getQuote(); $quote->setCustomerEmail($quote->getBillingAddress()->getEmail()) - ->setCustomerIsGuest(true) + ->setCustomerIsGuest(1) ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID); return $this; } diff --git a/app/code/core/Mage/Persistent/Model/Observer.php b/app/code/core/Mage/Persistent/Model/Observer.php index e20f8a4889f..ac238b5f375 100644 --- a/app/code/core/Mage/Persistent/Model/Observer.php +++ b/app/code/core/Mage/Persistent/Model/Observer.php @@ -338,10 +338,6 @@ public function preventExpressCheckout($observer) Mage::helper('persistent')->__('To proceed to Checkout, please log in using your email address.'), ); $controllerAction->redirectLogin(); - if ($controllerAction instanceof Mage_Paypal_Controller_Express_Abstract) { - Mage::getSingleton('customer/session') - ->setBeforeAuthUrl(Mage::getUrl('persistent/index/expressCheckout')); - } } } diff --git a/app/code/core/Mage/Persistent/etc/config.xml b/app/code/core/Mage/Persistent/etc/config.xml index 88325ad5395..dd3f93356cb 100644 --- a/app/code/core/Mage/Persistent/etc/config.xml +++ b/app/code/core/Mage/Persistent/etc/config.xml @@ -205,14 +205,6 @@ - - - - persistent/observer - preventExpressCheckout - - - diff --git a/app/design/adminhtml/default/default/template/paypal/info.phtml b/app/design/adminhtml/default/default/template/paypal/info.phtml index aab6ae4e2df..f1b948ff53c 100644 --- a/app/design/adminhtml/default/default/template/paypal/info.phtml +++ b/app/design/adminhtml/default/default/template/paypal/info.phtml @@ -8,7 +8,7 @@ /** * @see Mage_Paypal_Block_Adminhtml_Info - * @var $this Mage_Paypal_Block_Adminhtml_Info + * @var Mage_Paypal_Block_Adminhtml_Info $this */ ?>
diff --git a/app/design/frontend/base/default/template/paypal/info.phtml b/app/design/frontend/base/default/template/paypal/info.phtml index 3973a20dcb1..99af35d8923 100644 --- a/app/design/frontend/base/default/template/paypal/info.phtml +++ b/app/design/frontend/base/default/template/paypal/info.phtml @@ -9,7 +9,7 @@ /** * @see Mage_Paypal_Block_Info - * @var $this Mage_Paypal_Block_Info + * @var Mage_Paypal_Block_Info $this */ ?>

escapeHtml($this->getMethod()->getTitle()) ?>

diff --git a/app/design/frontend/base/default/template/paypal/payment.phtml b/app/design/frontend/base/default/template/paypal/payment.phtml index 21a24b94b65..e7c7740ec7d 100644 --- a/app/design/frontend/base/default/template/paypal/payment.phtml +++ b/app/design/frontend/base/default/template/paypal/payment.phtml @@ -8,7 +8,7 @@ */ /** - * @var $this Mage_Paypal_Block_Form + * @var Mage_Paypal_Block_Form $this */ ?> diff --git a/js/paypal/payment.js b/js/paypal/payment.js index 3f70d90e117..1fed53c0f29 100644 --- a/js/paypal/payment.js +++ b/js/paypal/payment.js @@ -52,7 +52,7 @@ PayPalPayment.prototype = { this.reviewContainerInterval = null; } - const maxAttempts = 20; + const maxAttempts = 100; let attempts = 0; const checkForContainer = () => { @@ -71,7 +71,7 @@ PayPalPayment.prototype = { checkForContainer(); if (!$(this.config.reviewButtonContainerId)) { - this.reviewContainerInterval = setInterval(checkForContainer, 500); + this.reviewContainerInterval = setInterval(checkForContainer, 100); } }); }, From 578521478e7f6ae313dd973e479534fcab425371 Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Sun, 22 Jun 2025 16:46:41 +0200 Subject: [PATCH 12/40] refactor: clean old paypal module files from phpstan config --- .phpstan.dist.baseline.neon | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/.phpstan.dist.baseline.neon b/.phpstan.dist.baseline.neon index 02303740093..e8d7c0764ed 100644 --- a/.phpstan.dist.baseline.neon +++ b/.phpstan.dist.baseline.neon @@ -3828,36 +3828,6 @@ parameters: count: 1 path: app/code/core/Mage/Payment/Model/Recurring/Profile.php - - - message: '#^Call to an undefined method Varien_Object\:\:isNominal\(\)\.$#' - identifier: method.notFound - count: 1 - path: app/code/core/Mage/Paypal/Model/Cart.php - - - - message: '#^Empty array passed to foreach\.$#' - identifier: foreach.emptyArray - count: 1 - path: app/code/core/Mage/Paypal/Model/Cart.php - - - - message: '#^Left side of && is always true\.$#' - identifier: booleanAnd.leftAlwaysTrue - count: 1 - path: app/code/core/Mage/Paypal/Model/Cart.php - - - - message: '#^Negated boolean expression is always true\.$#' - identifier: booleanNot.alwaysTrue - count: 1 - path: app/code/core/Mage/Paypal/Model/Config.php - - - - message: '#^Method Varien_Data_Collection\:\:toOptionArray\(\) invoked with 1 parameter, 0 required\.$#' - identifier: arguments.count - count: 1 - path: app/code/core/Mage/Paypal/Model/System/Config/Source/MerchantCountry.php - - message: '#^Method Mage_ProductAlert_Helper_Data\:\:createBlock\(\) should return Mage_ProductAlert_Block_Email_Price\|Mage_ProductAlert_Block_Email_Stock but returns Mage_Core_Block_Abstract\.$#' identifier: return.type From ec810aca8895ea02a413530ce2eb5f1142a03be4 Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Sun, 22 Jun 2025 20:21:18 +0200 Subject: [PATCH 13/40] fix: fix sonarqube suggestions and optimize admin order view page payment info block --- .phpstorm.meta.php/magento_blocks.meta.php | 2 +- .../magento_blocks_methods.meta.php | 2 +- .../Paypal/Block/Adminhtml/Debug/Grid.php | 2 +- .../Renderer/{Exception.php => Message.php} | 2 +- .../core/Mage/Paypal/Model/Api/Helper.php | 16 +- app/code/core/Mage/Paypal/Model/Paypal.php | 137 ++++++++++-------- .../Paypal/TransactionController.php | 80 +++++++--- .../Paypal/controllers/PaymentController.php | 49 +++---- .../sql/paypal_setup/install-2.0.0.0.php | 13 +- .../default/template/paypal/info.phtml | 12 +- 10 files changed, 181 insertions(+), 134 deletions(-) rename app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/{Exception.php => Message.php} (84%) diff --git a/.phpstorm.meta.php/magento_blocks.meta.php b/.phpstorm.meta.php/magento_blocks.meta.php index 87b824c1d58..c18209301a1 100644 --- a/.phpstorm.meta.php/magento_blocks.meta.php +++ b/.phpstorm.meta.php/magento_blocks.meta.php @@ -1110,7 +1110,7 @@ 'payment/info_purchaseorder' => \Mage_Payment_Block_Info_Purchaseorder::class, 'paypal/adminhtml_debug' => \Mage_Paypal_Block_Adminhtml_Debug::class, 'paypal/adminhtml_debug_grid' => \Mage_Paypal_Block_Adminhtml_Debug_Grid::class, - 'paypal/adminhtml_debug_grid_renderer_exception' => \Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Exception::class, + 'paypal/adminhtml_debug_grid_renderer_message' => \Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Message::class, 'paypal/adminhtml_debug_grid_renderer_request' => \Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Request::class, 'paypal/adminhtml_debug_grid_renderer_response' => \Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Response::class, 'paypal/adminhtml_grid_renderer_json' => \Mage_Paypal_Block_Adminhtml_Grid_Renderer_Json::class, diff --git a/.phpstorm.meta.php/magento_blocks_methods.meta.php b/.phpstorm.meta.php/magento_blocks_methods.meta.php index 30625cce2e0..9e66779a2e7 100644 --- a/.phpstorm.meta.php/magento_blocks_methods.meta.php +++ b/.phpstorm.meta.php/magento_blocks_methods.meta.php @@ -1110,7 +1110,7 @@ 'payment/info_purchaseorder' => \Mage_Payment_Block_Info_Purchaseorder::class, 'paypal/adminhtml_debug' => \Mage_Paypal_Block_Adminhtml_Debug::class, 'paypal/adminhtml_debug_grid' => \Mage_Paypal_Block_Adminhtml_Debug_Grid::class, - 'paypal/adminhtml_debug_grid_renderer_exception' => \Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Exception::class, + 'paypal/adminhtml_debug_grid_renderer_message' => \Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Message::class, 'paypal/adminhtml_debug_grid_renderer_request' => \Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Request::class, 'paypal/adminhtml_debug_grid_renderer_response' => \Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Response::class, 'paypal/adminhtml_grid_renderer_json' => \Mage_Paypal_Block_Adminhtml_Grid_Renderer_Json::class, diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php index a280b24dbb9..c84ed539990 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid.php @@ -88,7 +88,7 @@ protected function _prepareColumns(): self $this->addColumn('exception_message', [ 'header' => Mage::helper('paypal')->__('Exception'), 'index' => 'exception_message', - 'renderer' => 'paypal/adminhtml_debug_grid_renderer_exception', + 'renderer' => 'paypal/adminhtml_debug_grid_renderer_message', ]); $this->addColumn('created_at', [ diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Message.php similarity index 84% rename from app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php rename to app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Message.php index 06a648fa224..93149729798 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Exception.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Debug/Grid/Renderer/Message.php @@ -12,7 +12,7 @@ /** * Renderer for exception_message column with copy functionality */ -class Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Exception extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract +class Mage_Paypal_Block_Adminhtml_Debug_Grid_Renderer_Message extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract { /** * Renders the exception_message column with copy functionality diff --git a/app/code/core/Mage/Paypal/Model/Api/Helper.php b/app/code/core/Mage/Paypal/Model/Api/Helper.php index 1d43c2cdb1a..e979abc0aae 100644 --- a/app/code/core/Mage/Paypal/Model/Api/Helper.php +++ b/app/code/core/Mage/Paypal/Model/Api/Helper.php @@ -36,27 +36,17 @@ public function __construct() * * @param string $action Action being performed (e.g., 'Create Order'). * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote Quote or order object. - * @param mixed $request Request object or data sent to the API. + * @param array $request Request object or data sent to the API. * @param ApiResponse|null $response API response, if available. */ public function logDebug( string $action, Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote, - mixed $request, + array $request, ?ApiResponse $response = null ): void { if (Mage::getStoreConfigFlag('payment/paypal/debug')) { - $requestData = ''; - - if (is_object($request) && method_exists($request, 'jsonSerialize')) { - $requestData = json_encode($request->jsonSerialize()); - } elseif (is_object($request)) { - $requestData = json_encode($request); - } elseif (is_string($request)) { - $requestData = $request; - } elseif (is_array($request)) { - $requestData = json_encode($request); - } + $requestData = json_encode($request); $debug = Mage::getModel('paypal/debug'); if ($quote instanceof Mage_Sales_Model_Quote) { $debug->setQuoteId($quote->getId()); diff --git a/app/code/core/Mage/Paypal/Model/Paypal.php b/app/code/core/Mage/Paypal/Model/Paypal.php index 57a176f74e2..375795b76ad 100644 --- a/app/code/core/Mage/Paypal/Model/Paypal.php +++ b/app/code/core/Mage/Paypal/Model/Paypal.php @@ -169,7 +169,7 @@ public function reauthorizePayment(string $orderId, Mage_Sales_Model_Order $orde ])->getShouldCloseParentTransaction(); $payment->save(); - $transaction = Mage::getModel('sales/order_payment_transaction'); + $transaction = $this->_getTransaction(); $transaction->setOrderPaymentObject($payment) ->setTxnId($authorizationId) ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH) @@ -241,7 +241,7 @@ public function refund(Varien_Object $payment, $amount): static $result = $response->getResult(); $this->_updatePaymentAfterRefund($payment, $result); - $this->_createRefundTransaction($payment, $response, $amount); + $this->_createRefundTransaction($payment, $response); } catch (Exception $e) { Mage::logException($e); throw new Mage_Core_Exception( @@ -262,11 +262,10 @@ public function refund(Varien_Object $payment, $amount): static public function capture(Varien_Object $payment, $amount): static { $addInfo = $payment->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS); - if (is_array($addInfo) && isset($addInfo['intent'])) { - if ($addInfo['intent'] === CheckoutPaymentIntent::CAPTURE) { - return $this; - } + if (($addInfo['intent'] ?? null) === CheckoutPaymentIntent::CAPTURE) { + return $this; } + $order = $payment->getOrder(); $authorizationId = $payment->getAdditionalInformation(self::PAYPAL_PAYMENT_AUTHORIZATION_ID); @@ -417,43 +416,56 @@ private function _updatePaymentWithOrderInfo(Mage_Sales_Model_Quote_Payment $pay /** * Build a purchase unit using PayPal SDK builders - * - * @param string|null $referenceId Optional reference ID - * @return object The built purchase unit object */ private function _buildPurchaseUnit(Mage_Sales_Model_Quote $quote, ?string $referenceId = null): object { $cart = Mage::getModel('paypal/cart', [$quote]); - $totals = $cart->getAmounts(); $currency = $quote->getOrderCurrencyCode() ?: $quote->getQuoteCurrencyCode(); - $items = $cart->getAllItems(); - // Amount check + + $adjustedCartData = $this->_adjustCartTotalsForTaxDiscrepancy($cart, $currency); + $totals = $adjustedCartData['totals']; + $items = $adjustedCartData['items']; + + $breakdown = $this->_buildAmountBreakdown($totals); + $amount = $this->_buildAmountWithBreakdown($currency, $quote->getGrandTotal(), $breakdown); + + $purchaseUnitBuilder = PurchaseUnitRequestBuilder::init($amount) + ->items($items) + ->referenceId($referenceId ?: (string) $quote->getId()) + ->invoiceId($referenceId ?: (string) $quote->getId()); + + return $purchaseUnitBuilder->build(); + } + + /** + * Adjust tax totals and items for rounding discrepancies + * + * @return array{totals: array, items: array} + */ + private function _adjustCartTotalsForTaxDiscrepancy(Mage_Paypal_Model_Cart $cart, string $currency): array + { + $totals = $cart->getAmounts(); + $items = $cart->getAllItems(); + $taxCalculated = 0.00; - $taxDifference = 0.00; - $taxAmount = 0.00; - if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_TAX])) { - $taxAmount = (float) $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->getValue(); - } + $taxAmount = isset($totals[Mage_Paypal_Model_Cart::TOTAL_TAX]) + ? (float) $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->getValue() + : 0.00; + foreach ($items as $item) { - /** - * @var PaypalServerSdkLib\Models\Item $item - */ + /** @var PaypalServerSdkLib\Models\Item $item */ if ($item->getTax()) { - $qty = (int) $item->getQuantity(); - $taxValue = (float) $item->getTax()->getValue(); + $qty = (int) $item->getQuantity(); + $taxValue = (float) $item->getTax()->getValue(); $taxCalculated += $taxValue * $qty; } } - if ($taxCalculated !== $taxAmount) { - $taxDifference = round($taxAmount - $taxCalculated, 2); - $taxAmount = $taxCalculated; - } + + $taxDifference = round($taxAmount - $taxCalculated, 2); + if ($taxDifference < 0) { - if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_TAX])) { - $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->setValue( - number_format($taxCalculated, 2, '.', ''), - ); - } + $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->setValue(number_format($taxCalculated, 2, '.', '')); + if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT])) { $totalDiscount = (float) $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]->getValue(); $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]->setValue( @@ -465,32 +477,25 @@ private function _buildPurchaseUnit(Mage_Sales_Model_Quote $quote, ?string $refe number_format(abs($taxDifference), 2, '.', ''), )->build(); } - } else { - $moneyBuilder = MoneyBuilder::init( - $currency, - number_format(abs($taxDifference), 2, '.', ''), - ); - $itemBuilder = ItemBuilder::init(Mage::helper('paypal')->__('Rounding'), $moneyBuilder->build(), '1') + } elseif ($taxDifference > 0) { + $moneyBuilder = MoneyBuilder::init($currency, number_format(abs($taxDifference), 2, '.', '')); + $roundingItem = ItemBuilder::init( + Mage::helper('paypal')->__('Rounding'), + $moneyBuilder->build(), + '1', + ) ->sku(Mage::helper('paypal')->__('Rounding')) - ->category(ItemCategory::DIGITAL_GOODS); - $items[] = $itemBuilder->build(); - if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_TAX])) { - $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->setValue( - number_format($taxCalculated, 2, '.', ''), - ); - } - } - $breakdown = $this->_buildAmountBreakdown($totals); - $amount = $this->_buildAmountWithBreakdown($currency, $quote->getGrandTotal(), $breakdown); - $purchaseUnitBuilder = PurchaseUnitRequestBuilder::init($amount); - if (!empty($items)) { - $purchaseUnitBuilder->items($items); + ->category(ItemCategory::DIGITAL_GOODS) + ->build(); + + $items[] = $roundingItem; + $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->setValue(number_format($taxCalculated, 2, '.', '')); } - $purchaseUnitBuilder->referenceId($referenceId ?: (string) $quote->getId()); - $purchaseUnitBuilder->invoiceId($referenceId ?: (string) $quote->getId()); - return $purchaseUnitBuilder->build(); + + return ['totals' => $totals, 'items' => $items]; } + /** * Build amount breakdown from cart totals * @@ -736,12 +741,11 @@ private function _updatePaymentAfterRefund(Varien_Object $payment, Refund $resul * * @param Varien_Object $payment Payment object * @param ApiResponse $response API result - * @param float $amount Refund amount */ - private function _createRefundTransaction(Varien_Object $payment, ApiResponse $response, float $amount): void + private function _createRefundTransaction(Varien_Object $payment, ApiResponse $response): void { $result = $response->getResult(); - $transaction = Mage::getModel('sales/order_payment_transaction'); + $transaction = $this->_getTransaction(); /** * @var Mage_Sales_Model_Order_Payment $payment */ @@ -766,8 +770,16 @@ private function _createRefundTransaction(Varien_Object $payment, ApiResponse $r */ private function _updatePaymentAfterAuthorizedCapture(Varien_Object $payment, ApiResponse $response, string $authorizationId): void { + /** + * @var Mage_Sales_Model_Order_Payment $payment + */ $result = $response->getResult(); $captureId = $result->getId(); + $additionalInfo = $payment->getAdditionalInformation(); + unset($additionalInfo[self::PAYPAL_PAYMENT_STATUS]); + unset($additionalInfo[self::PAYPAL_PAYMENT_AUTHORIZATION_ID]); + unset($additionalInfo[self::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME]); + $payment->setAdditionalInformation($additionalInfo); $payment->setTransactionId($captureId) ->setParentTransactionId($authorizationId) ->setIsTransactionClosed(true) @@ -787,7 +799,7 @@ private function _updatePaymentAfterAuthorizedCapture(Varien_Object $payment, Ap private function _createCaptureTransaction(Varien_Object $payment, ApiResponse $response, string $authorizationId): void { $result = $response->getResult(); - $transaction = Mage::getModel('sales/order_payment_transaction'); + $transaction = $this->_getTransaction(); /** * @var Mage_Sales_Model_Order_Payment $payment */ @@ -824,7 +836,7 @@ private function _updatePaymentAfterVoid(Varien_Object $payment): void */ private function _createVoidTransaction(Varien_Object $payment, ApiResponse $response): void { - $transaction = Mage::getModel('sales/order_payment_transaction'); + $transaction = $this->_getTransaction(); $result = $response->getResult(); /** * @var Mage_Sales_Model_Order_Payment $payment @@ -899,4 +911,13 @@ private function _prepareRawDetails(string $details): array $decoded ?? [], ); } + /** + * Get order payment transaction model + * + * @throws Mage_Core_Exception + **/ + private function _getTransaction(): Mage_Sales_Model_Order_Payment_Transaction + { + return Mage::getModel('sales/order_payment_transaction'); + } } diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php index a4273ed3019..e39a53df8f7 100644 --- a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php +++ b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php @@ -14,56 +14,90 @@ */ class Mage_Paypal_Adminhtml_Paypal_TransactionController extends Mage_Adminhtml_Controller_Action { + private const PAYMENT_METHOD_CODE = 'paypal'; + /** - * Handles the reauthorization of a PayPal payment for a specific order. - * It validates the order and payment details, triggers the reauthorization process, - * and redirects the user back to the order view with a success or error message. + * Reauthorize a PayPal payment for a specific order. */ public function reauthorizeAction(): void { - $orderId = $this->getRequest()->getParam('order_id'); + $orderId = (int) $this->getRequest()->getParam('order_id'); if (!$orderId) { - $this->_getSession()->addError($this->__('Order ID is required')); - $this->_redirect('*/sales_order/'); + $this->_getSession()->addError($this->__('Order ID is required.')); + $this->_redirect('*/*/sales_order'); return; } try { - $order = Mage::getModel('sales/order')->load($orderId); - if (!$order->getId()) { - throw new Exception($this->__('Order not found')); - } - + $order = $this->_loadOrder($orderId); $payment = $order->getPayment(); - if ($payment->getMethod() !== 'paypal') { - throw new Exception($this->__('This order was not placed using PayPal')); - } + + $this->_validatePaymentMethod($payment); $authorizationId = $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID); if (!$authorizationId) { - throw new Exception($this->__('This order does not have a PayPal authorization')); + Mage::throwException($this->__('This order does not have a PayPal authorization.')); } - $paypalModel = Mage::getModel('paypal/paypal'); - $result = $paypalModel->reauthorizePayment($authorizationId, $order); + $result = $this->_getPaypalModel()->reauthorizePayment($authorizationId, $order); - if ($result['success']) { - $this->_getSession()->addSuccess($this->__('Payment has been successfully reauthorized. New authorization ID: %s', $result['authorization_id'])); + if (!empty($result['success'])) { + $this->_getSession()->addSuccess( + $this->__('Payment successfully reauthorized. New authorization ID: %s', $result['authorization_id']), + ); } else { - throw new Exception($result['error'] ?? $this->__('Failed to reauthorize payment')); + Mage::throwException($result['error'] ?? $this->__('Failed to reauthorize payment.')); } - } catch (Exception $e) { + } catch (Mage_Core_Exception $e) { $this->_getSession()->addError($e->getMessage()); + } catch (Exception $e) { + Mage::logException($e); + $this->_getSession()->addError($this->__('An unexpected error occurred.')); } $this->_redirect('*/sales_order/view', ['order_id' => $orderId]); } /** - * Checks if the current user has permission to access this controller's actions. + * Load order by ID or throw exception. + * + * @throws Mage_Core_Exception + */ + protected function _loadOrder(int $orderId): Mage_Sales_Model_Order + { + /** @var Mage_Sales_Model_Order $order */ + $order = Mage::getModel('sales/order')->load($orderId); + if (!$order->getId()) { + Mage::throwException($this->__('Order not found.')); + } + return $order; + } + + /** + * Validate if the payment method is PayPal. + * + * @throws Mage_Core_Exception + */ + protected function _validatePaymentMethod(Mage_Sales_Model_Order_Payment $payment): void + { + if ($payment->getMethod() !== self::PAYMENT_METHOD_CODE) { + Mage::throwException($this->__('This order was not placed using PayPal.')); + } + } + + /** + * Get PayPal model instance. + */ + protected function _getPaypalModel(): Mage_Paypal_Model_Paypal + { + return Mage::getModel('paypal/paypal'); + } + + /** + * Check controller permissions. */ protected function _isAllowed(): bool { - return true; + return Mage::getSingleton('admin/session')->isAllowed('sales/order'); } } diff --git a/app/code/core/Mage/Paypal/controllers/PaymentController.php b/app/code/core/Mage/Paypal/controllers/PaymentController.php index b23f533a71d..449aab34a36 100644 --- a/app/code/core/Mage/Paypal/controllers/PaymentController.php +++ b/app/code/core/Mage/Paypal/controllers/PaymentController.php @@ -31,6 +31,8 @@ class Mage_Paypal_PaymentController extends Mage_Core_Controller_Front_Action */ protected $_paypal = null; + private const CONTENT_TYPE_JSON = 'application/json'; + /** * Handles the AJAX request to create a PayPal order. * Validates the quote and creates a PayPal order via the PayPal model. @@ -43,7 +45,7 @@ public function createAction(): void } if (!$this->getRequest()->isPost() || !$this->getRequest()->getParam('form_key')) { - Mage::throwException(Mage::helper('core')->__('Invalid form key')); + Mage::throwException(Mage::helper('paypal')->__('Invalid form key')); } if (!$this->_getQuote()->hasItems() || $this->_getQuote()->getHasError()) { @@ -61,7 +63,7 @@ public function createAction(): void $this->_getQuote()->removeAllAddresses(); } - $customer = Mage::getSingleton('customer/session')->getCustomer(); + $customer = $this->_getCustomerSession()->getCustomer(); $quoteCheckoutMethod = Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod(); if ($customer && $customer->getId()) { $this->_getQuote()->assignCustomerWithAddressChange($customer, $this->_getQuote()->getBillingAddress(), $this->_getQuote()->getShippingAddress()); @@ -76,21 +78,20 @@ public function createAction(): void Mage::helper('paypal')->__('To proceed to Checkout, please log in using your email address.'), ); $this->_redirectLogin(); - Mage::getSingleton('customer/session') - ->setBeforeAuthUrl(Mage::getUrl('*/*/*', ['_current' => true])); + $this->_getCustomerSession()->setBeforeAuthUrl(Mage::getUrl('*/*/*', ['_current' => true])); return; } $result = $this->_getPaypal()->create($this->_getQuote()); $this->getResponse() - ->setHeader('Content-Type', 'application/json') + ->setHeader('Content-Type', self::CONTENT_TYPE_JSON) ->setBody(Mage::helper('core')->jsonEncode($result)); } catch (Exception $e) { Mage::logException($e); $this->getResponse() - ->setHeader('Content-Type', 'application/json') + ->setHeader('Content-Type', self::CONTENT_TYPE_JSON) ->setBody(Mage::helper('core')->jsonEncode([ 'success' => false, 'error' => $e->getMessage(), @@ -111,10 +112,10 @@ public function processAction(): void $paymentAction = Mage::getSingleton('paypal/config')->getPaymentAction(); if (!$orderId) { - throw new Exception('PayPal order ID is required'); + Mage::throwException(Mage::helper('paypal')->__('PayPal order ID is required')); } if (!$this->getRequest()->isPost() || !$this->getRequest()->getParam('form_key')) { - Mage::throwException(Mage::helper('core')->__('Invalid form key')); + Mage::throwException(Mage::helper('paypal')->__('Invalid form key')); } if ($paymentAction === strtolower(CheckoutPaymentIntent::AUTHORIZE)) { @@ -124,14 +125,14 @@ public function processAction(): void } $this->getResponse() - ->setHeader('Content-Type', 'application/json')->setBody(Mage::helper('core')->jsonEncode([ + ->setHeader('Content-Type', self::CONTENT_TYPE_JSON)->setBody(Mage::helper('core')->jsonEncode([ 'success' => true, ])); } catch (Exception $e) { Mage::logException($e); $this->getResponse() - ->setHeader('Content-Type', 'application/json')->setBody(Mage::helper('core')->jsonEncode([ + ->setHeader('Content-Type', self::CONTENT_TYPE_JSON)->setBody(Mage::helper('core')->jsonEncode([ 'success' => false, 'message' => $e->getMessage(), ])); @@ -308,7 +309,7 @@ protected function _prepareNewCustomerQuote(): self $customerId = $this->_lookupCustomerId(); if ($customerId && !$this->_customerEmailExists($quote->getCustomerEmail())) { - $this->getCustomerSession()->loginById($customerId); + $this->_getCustomerSession()->loginById($customerId); return $this->_prepareCustomerQuote(); } @@ -326,19 +327,15 @@ protected function _prepareNewCustomerQuote(): self } elseif ($shipping) { $customerBilling->setIsDefaultShipping(true); } - /** - * @todo integration with dynamica attributes customer_dob, customer_taxvat, customer_gender - */ - if ($quote->getCustomerDob() && !$billing->getCustomerDob()) { - $billing->setCustomerDob($quote->getCustomerDob()); - } - if ($quote->getCustomerTaxvat() && !$billing->getCustomerTaxvat()) { - $billing->setCustomerTaxvat($quote->getCustomerTaxvat()); - } + $dynamicAttributes = ['customer_dob', 'customer_taxvat', 'customer_gender']; + foreach ($dynamicAttributes as $attributeCode) { + $quoteValue = $quote->getData($attributeCode); + $billingValue = $billing->getData($attributeCode); - if ($quote->getCustomerGender() && !$billing->getCustomerGender()) { - $billing->setCustomerGender($quote->getCustomerGender()); + if ($quoteValue && !$billingValue) { + $billing->setData($attributeCode, $quoteValue); + } } Mage::helper('core')->copyFieldset('checkout_onepage_billing', 'to_customer', $billing, $customer); @@ -367,7 +364,7 @@ protected function _prepareCustomerQuote(): self $billing = $quote->getBillingAddress(); $shipping = $quote->isVirtual() ? null : $quote->getShippingAddress(); - $customer = $this->getCustomerSession()->getCustomer(); + $customer = $this->_getCustomerSession()->getCustomer(); if (!$billing->getCustomerId() || $billing->getSaveInAddressBook()) { $customerBilling = $billing->exportCustomerAddress(); $customer->addAddress($customerBilling); @@ -398,7 +395,7 @@ protected function _prepareCustomerQuote(): self /** * Retrieves the customer session model. */ - public function getCustomerSession(): Mage_Customer_Model_Session + private function _getCustomerSession(): Mage_Customer_Model_Session { if (is_null($this->_customerSession)) { $this->_customerSession = Mage::getSingleton('customer/session'); @@ -473,12 +470,12 @@ protected function _involveNewCustomer(): self if ($customer->isConfirmationRequired()) { $customer->sendNewAccountEmail('confirmation', '', $this->_quote->getStoreId()); $url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail()); - $this->getCustomerSession()->addSuccess( + $this->_getCustomerSession()->addSuccess( Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please click here.', $url), ); } else { $customer->sendNewAccountEmail('registered', '', $this->_quote->getStoreId()); - $this->getCustomerSession()->loginById($customer->getId()); + $this->_getCustomerSession()->loginById($customer->getId()); } return $this; } diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php b/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php index c013099e30a..523f39bf70b 100644 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php +++ b/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php @@ -17,11 +17,12 @@ /* @var $installer Mage_Paypal_Model_Resource_Setup */ $installer->startSetup(); +$debugTableName = 'paypal/debug'; -$installer->getConnection()->dropTable($installer->getTable('paypal/debug')); +$installer->getConnection()->dropTable($installer->getTable($debugTableName)); $debugTable = $installer->getConnection() - ->newTable($installer->getTable('paypal/debug')) + ->newTable($installer->getTable($debugTableName)) ->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [ 'identity' => true, 'unsigned' => true, @@ -55,15 +56,15 @@ 'default' => Varien_Db_Ddl_Table::TIMESTAMP_INIT, ], 'Created At') ->addIndex( - $installer->getIdxName('paypal/debug', ['quote_id']), + $installer->getIdxName($debugTableName, ['quote_id']), ['quote_id'], ) ->addIndex( - $installer->getIdxName('paypal/debug', ['increment_id']), + $installer->getIdxName($debugTableName, ['increment_id']), ['increment_id'], ) ->addForeignKey( - $installer->getFkName('paypal/debug', 'quote_id', 'sales/quote', 'entity_id'), + $installer->getFkName($debugTableName, 'quote_id', 'sales/quote', 'entity_id'), 'quote_id', $installer->getTable('sales/quote'), 'entity_id', @@ -71,7 +72,7 @@ Varien_Db_Ddl_Table::ACTION_CASCADE, ) ->addForeignKey( - $installer->getFkName('paypal/debug', 'increment_id', 'sales/order', 'increment_id'), + $installer->getFkName($debugTableName, 'increment_id', 'sales/order', 'increment_id'), 'increment_id', $installer->getTable('sales/order'), 'increment_id', diff --git a/app/design/adminhtml/default/default/template/paypal/info.phtml b/app/design/adminhtml/default/default/template/paypal/info.phtml index f1b948ff53c..b3edb3f0831 100644 --- a/app/design/adminhtml/default/default/template/paypal/info.phtml +++ b/app/design/adminhtml/default/default/template/paypal/info.phtml @@ -1,4 +1,5 @@
+
+ escapeHtml($this->getMethod()->getTitle()) ?> +
getTransactionId()): ?>
__('Transaction ID') ?>: @@ -48,10 +52,6 @@
\ No newline at end of file From 8d8d15482401324166e44a835068e8a121ce1399 Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Sun, 22 Jun 2025 22:08:26 +0200 Subject: [PATCH 14/40] refactor: split Mage_Paypal_Model_Paypal into smaller classes to improve maintainability --- .phpstorm.meta.php/magento_models.meta.php | 10 +- .../magento_models_methods.meta.php | 45 +- .../core/Mage/Paypal/Block/Adminhtml/Info.php | 16 +- app/code/core/Mage/Paypal/Model/Api.php | 4 +- .../core/Mage/Paypal/Model/Api/Helper.php | 95 --- app/code/core/Mage/Paypal/Model/Helper.php | 268 ++++++ app/code/core/Mage/Paypal/Model/Order.php | 270 ++++++ app/code/core/Mage/Paypal/Model/Payment.php | 283 +++++++ app/code/core/Mage/Paypal/Model/Paypal.php | 784 +----------------- .../core/Mage/Paypal/Model/Transaction.php | 246 ++++++ .../Paypal/TransactionController.php | 2 +- .../Paypal/controllers/PaymentController.php | 4 +- 12 files changed, 1144 insertions(+), 883 deletions(-) delete mode 100644 app/code/core/Mage/Paypal/Model/Api/Helper.php create mode 100644 app/code/core/Mage/Paypal/Model/Helper.php create mode 100644 app/code/core/Mage/Paypal/Model/Order.php create mode 100644 app/code/core/Mage/Paypal/Model/Payment.php create mode 100644 app/code/core/Mage/Paypal/Model/Transaction.php diff --git a/.phpstorm.meta.php/magento_models.meta.php b/.phpstorm.meta.php/magento_models.meta.php index 3d868506360..4252700a150 100644 --- a/.phpstorm.meta.php/magento_models.meta.php +++ b/.phpstorm.meta.php/magento_models.meta.php @@ -1936,11 +1936,13 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, 'paypal/debug' => \Mage_Paypal_Model_Debug::class, 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/helper' => \Mage_Paypal_Model_Helper::class, + 'paypal/order' => \Mage_Paypal_Model_Order::class, + 'paypal/payment' => \Mage_Paypal_Model_Payment::class, 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, @@ -1955,6 +1957,7 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, + 'paypal/transaction' => \Mage_Paypal_Model_Transaction::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -5047,11 +5050,13 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, 'paypal/debug' => \Mage_Paypal_Model_Debug::class, 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/helper' => \Mage_Paypal_Model_Helper::class, + 'paypal/order' => \Mage_Paypal_Model_Order::class, + 'paypal/payment' => \Mage_Paypal_Model_Payment::class, 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, @@ -5066,6 +5071,7 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, + 'paypal/transaction' => \Mage_Paypal_Model_Transaction::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, diff --git a/.phpstorm.meta.php/magento_models_methods.meta.php b/.phpstorm.meta.php/magento_models_methods.meta.php index e3aa5d3b355..e2ae45ec583 100644 --- a/.phpstorm.meta.php/magento_models_methods.meta.php +++ b/.phpstorm.meta.php/magento_models_methods.meta.php @@ -1936,11 +1936,13 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, 'paypal/debug' => \Mage_Paypal_Model_Debug::class, 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/helper' => \Mage_Paypal_Model_Helper::class, + 'paypal/order' => \Mage_Paypal_Model_Order::class, + 'paypal/payment' => \Mage_Paypal_Model_Payment::class, 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, @@ -1955,6 +1957,7 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, + 'paypal/transaction' => \Mage_Paypal_Model_Transaction::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -5047,11 +5050,13 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, 'paypal/debug' => \Mage_Paypal_Model_Debug::class, 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/helper' => \Mage_Paypal_Model_Helper::class, + 'paypal/order' => \Mage_Paypal_Model_Order::class, + 'paypal/payment' => \Mage_Paypal_Model_Payment::class, 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, @@ -5066,6 +5071,7 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, + 'paypal/transaction' => \Mage_Paypal_Model_Transaction::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -8158,11 +8164,13 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, 'paypal/debug' => \Mage_Paypal_Model_Debug::class, 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/helper' => \Mage_Paypal_Model_Helper::class, + 'paypal/order' => \Mage_Paypal_Model_Order::class, + 'paypal/payment' => \Mage_Paypal_Model_Payment::class, 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, @@ -8177,6 +8185,7 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, + 'paypal/transaction' => \Mage_Paypal_Model_Transaction::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -11269,11 +11278,13 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, 'paypal/debug' => \Mage_Paypal_Model_Debug::class, 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/helper' => \Mage_Paypal_Model_Helper::class, + 'paypal/order' => \Mage_Paypal_Model_Order::class, + 'paypal/payment' => \Mage_Paypal_Model_Payment::class, 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, @@ -11288,6 +11299,7 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, + 'paypal/transaction' => \Mage_Paypal_Model_Transaction::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -14380,11 +14392,13 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, 'paypal/debug' => \Mage_Paypal_Model_Debug::class, 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/helper' => \Mage_Paypal_Model_Helper::class, + 'paypal/order' => \Mage_Paypal_Model_Order::class, + 'paypal/payment' => \Mage_Paypal_Model_Payment::class, 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, @@ -14399,6 +14413,7 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, + 'paypal/transaction' => \Mage_Paypal_Model_Transaction::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -17491,11 +17506,13 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, 'paypal/debug' => \Mage_Paypal_Model_Debug::class, 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/helper' => \Mage_Paypal_Model_Helper::class, + 'paypal/order' => \Mage_Paypal_Model_Order::class, + 'paypal/payment' => \Mage_Paypal_Model_Payment::class, 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, @@ -17510,6 +17527,7 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, + 'paypal/transaction' => \Mage_Paypal_Model_Transaction::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -20602,11 +20620,13 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, 'paypal/debug' => \Mage_Paypal_Model_Debug::class, 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/helper' => \Mage_Paypal_Model_Helper::class, + 'paypal/order' => \Mage_Paypal_Model_Order::class, + 'paypal/payment' => \Mage_Paypal_Model_Payment::class, 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, @@ -20621,6 +20641,7 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, + 'paypal/transaction' => \Mage_Paypal_Model_Transaction::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -23713,11 +23734,13 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, 'paypal/debug' => \Mage_Paypal_Model_Debug::class, 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/helper' => \Mage_Paypal_Model_Helper::class, + 'paypal/order' => \Mage_Paypal_Model_Order::class, + 'paypal/payment' => \Mage_Paypal_Model_Payment::class, 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, @@ -23732,6 +23755,7 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, + 'paypal/transaction' => \Mage_Paypal_Model_Transaction::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, @@ -26824,11 +26848,13 @@ 'payment/source_cctype' => \Mage_Payment_Model_Source_Cctype::class, 'payment/source_invoice' => \Mage_Payment_Model_Source_Invoice::class, 'paypal/api' => \Mage_Paypal_Model_Api::class, - 'paypal/api_helper' => \Mage_Paypal_Model_Api_Helper::class, 'paypal/cart' => \Mage_Paypal_Model_Cart::class, 'paypal/config' => \Mage_Paypal_Model_Config::class, 'paypal/debug' => \Mage_Paypal_Model_Debug::class, 'paypal/exception' => \Mage_Paypal_Model_Exception::class, + 'paypal/helper' => \Mage_Paypal_Model_Helper::class, + 'paypal/order' => \Mage_Paypal_Model_Order::class, + 'paypal/payment' => \Mage_Paypal_Model_Payment::class, 'paypal/paypal' => \Mage_Paypal_Model_Paypal::class, 'paypal/resource_debug' => \Mage_Paypal_Model_Resource_Debug::class, 'paypal_resource/debug' => \Mage_Paypal_Model_Resource_Debug::class, @@ -26843,6 +26869,7 @@ 'paypal/system_config_source_buttonShapes' => \Mage_Paypal_Model_System_Config_Source_ButtonShapes::class, 'paypal/system_config_source_merchantCountry' => \Mage_Paypal_Model_System_Config_Source_MerchantCountry::class, 'paypal/system_config_source_paymentActions' => \Mage_Paypal_Model_System_Config_Source_PaymentActions::class, + 'paypal/transaction' => \Mage_Paypal_Model_Transaction::class, 'persistent/observer' => \Mage_Persistent_Model_Observer::class, 'persistent/observer_session' => \Mage_Persistent_Model_Observer_Session::class, 'persistent/persistent_config' => \Mage_Persistent_Model_Persistent_Config::class, diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php index 50e7d41c2e1..a3ecdaa7f90 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php @@ -52,16 +52,16 @@ public function getPaymentInfo(): array { $payment = $this->getInfo(); $info = []; - if ($payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_STATUS)) { + if ($payment->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_STATUS)) { $info[Mage::helper('paypal')->__('Status')] = - $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_STATUS); + $payment->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_STATUS); } - if ($payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID)) { + if ($payment->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_AUTHORIZATION_ID)) { $info[Mage::helper('paypal')->__('Authorization ID')] = - $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID); - if ($payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME)) { + $payment->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_AUTHORIZATION_ID); + if ($payment->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME)) { $expirationTime = - $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME); + $payment->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME); $info[Mage::helper('paypal')->__('Authorization Expires')] = $this->formatExpirationDate($expirationTime); } } @@ -94,12 +94,12 @@ public function canReauthorize(): bool if ( $payment->getMethod() !== 'paypal' || - !$payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID) + !$payment->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_AUTHORIZATION_ID) ) { return false; } - $expirationTime = $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME); + $expirationTime = $payment->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME); if ($expirationTime) { $now = new DateTime(); $expDate = new DateTime($expirationTime); diff --git a/app/code/core/Mage/Paypal/Model/Api.php b/app/code/core/Mage/Paypal/Model/Api.php index d2151c1e538..7dc8310b15a 100644 --- a/app/code/core/Mage/Paypal/Model/Api.php +++ b/app/code/core/Mage/Paypal/Model/Api.php @@ -33,7 +33,7 @@ class Mage_Paypal_Model_Api extends Varien_Object public const ERROR_EMPTY_AUTH_ID = 'Authorization ID cannot be empty'; public const ERROR_INVALID_AMOUNT = 'Amount must be greater than 0'; - private readonly Mage_Paypal_Model_Api_Helper $helper; + private readonly Mage_Paypal_Model_Helper $helper; private readonly Mage_Paypal_Model_Config $config; private ?PaypalServerSdkClient $client = null; @@ -43,7 +43,7 @@ class Mage_Paypal_Model_Api extends Varien_Object public function __construct() { parent::__construct(); - $this->helper = Mage::getSingleton('paypal/api_helper'); + $this->helper = Mage::getSingleton('paypal/helper'); $this->config = Mage::getSingleton('paypal/config'); } diff --git a/app/code/core/Mage/Paypal/Model/Api/Helper.php b/app/code/core/Mage/Paypal/Model/Api/Helper.php deleted file mode 100644 index e979abc0aae..00000000000 --- a/app/code/core/Mage/Paypal/Model/Api/Helper.php +++ /dev/null @@ -1,95 +0,0 @@ -_helper = Mage::helper('paypal'); - } - - /** - * Logs debug information for a PayPal API request if debugging is enabled. - * - * @param string $action Action being performed (e.g., 'Create Order'). - * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote Quote or order object. - * @param array $request Request object or data sent to the API. - * @param ApiResponse|null $response API response, if available. - */ - public function logDebug( - string $action, - Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote, - array $request, - ?ApiResponse $response = null - ): void { - if (Mage::getStoreConfigFlag('payment/paypal/debug')) { - $requestData = json_encode($request); - $debug = Mage::getModel('paypal/debug'); - if ($quote instanceof Mage_Sales_Model_Quote) { - $debug->setQuoteId($quote->getId()); - } elseif ($quote instanceof Mage_Sales_Model_Order) { - $debug->setIncrementId($quote->getIncrementId()); - } - - $debug->setAction($action) - ->setRequestBody($requestData); - Mage::log($response, null, 'paypal.log'); - if ($response instanceof ApiResponse) { - $result = $response->getResult(); - if ($response->isError()) { - $debug->setTransactionId($result['debug_id']) - ->setResponseBody(json_encode($result)); - } else { - $debug->setTransactionId($response->getResult()->getId() ?? null) - ->setResponseBody(json_encode($response->getResult())); - } - } - $debug->save(); - } - } - - /** - * Logs an error message and exception details if debugging is enabled. - * - * @param string $message The error message. - * @param Exception $exception The exception object. - */ - public function logError(string $message, Exception $exception): void - { - if (Mage::getStoreConfigFlag('payment/paypal/debug')) { - $errorData = [ - 'message' => $message, - 'error' => $exception->getMessage(), - ]; - - if ($exception instanceof Mage_Paypal_Model_Exception) { - $errorData['debug_data'] = $exception->getDebugData(); - } - - Mage::log($message, Zend_Log::ERR, 'paypal.log', true); - } - } -} diff --git a/app/code/core/Mage/Paypal/Model/Helper.php b/app/code/core/Mage/Paypal/Model/Helper.php new file mode 100644 index 00000000000..1c88c8e8a48 --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Helper.php @@ -0,0 +1,268 @@ +_helper = Mage::helper('paypal'); + } + + /** + * Logs debug information for a PayPal API request if debugging is enabled. + * + * @param string $action Action being performed (e.g., 'Create Order'). + * @param Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote Quote or order object. + * @param array $request Request object or data sent to the API. + * @param ApiResponse|null $response API response, if available. + */ + public function logDebug( + string $action, + Mage_Sales_Model_Order|Mage_Sales_Model_Quote $quote, + array $request, + ?ApiResponse $response = null + ): void { + if (Mage::getStoreConfigFlag('payment/paypal/debug')) { + $requestData = json_encode($request); + $debug = Mage::getModel('paypal/debug'); + if ($quote instanceof Mage_Sales_Model_Quote) { + $debug->setQuoteId($quote->getId()); + } elseif ($quote instanceof Mage_Sales_Model_Order) { + $debug->setIncrementId($quote->getIncrementId()); + } + + $debug->setAction($action) + ->setRequestBody($requestData); + Mage::log($response, null, 'paypal.log'); + if ($response instanceof ApiResponse) { + $result = $response->getResult(); + if ($response->isError()) { + $debug->setTransactionId($result['debug_id']) + ->setResponseBody(json_encode($result)); + } else { + $debug->setTransactionId($response->getResult()->getId() ?? null) + ->setResponseBody(json_encode($response->getResult())); + } + } + $debug->save(); + } + } + + /** + * Logs an error message and exception details if debugging is enabled. + * + * @param string $message The error message. + * @param Exception $exception The exception object. + */ + public function logError(string $message, Exception $exception): void + { + if (Mage::getStoreConfigFlag('payment/paypal/debug')) { + $errorData = [ + 'message' => $message, + 'error' => $exception->getMessage(), + ]; + + if ($exception instanceof Mage_Paypal_Model_Exception) { + $errorData['debug_data'] = $exception->getDebugData(); + } + + Mage::log($message, Zend_Log::ERR, 'paypal.log', true); + } + } + + /** + * Validate quote for PayPal payment processing + * + * @throws Mage_Core_Exception + */ + public function validateQuoteForPayment(Mage_Sales_Model_Quote $quote): void + { + $quote->collectTotals(); + + if (!$quote->getGrandTotal() && !$quote->hasNominalItems()) { + throw new Mage_Core_Exception( + Mage::helper('paypal')->__(self::ERROR_ZERO_AMOUNT), + ); + } + } + + /** + * Handle API error response + * + * @param ApiResponse $response API response + * @param string $defaultMessage Default error message + * @throws Mage_Core_Exception + */ + public function handleApiError(ApiResponse $response, string $defaultMessage): never + { + $errorMsg = $this->extractErrorMessage($response, $defaultMessage); + throw new Mage_Core_Exception($errorMsg); + } + + /** + * Extract error message from API response + * + * @param ApiResponse $response API response + * @param string $defaultMessage Default error message + */ + public function extractErrorMessage(ApiResponse $response, string $defaultMessage): string + { + $result = $response->getResult(); + + return match (true) { + is_array($result) && isset($result['message']) => $result['message'] ?: $defaultMessage, + is_object($result) && method_exists($result, 'getMessage') => $result->getMessage() ?: $defaultMessage, + is_string($result) => $result ?: $defaultMessage, + default => $defaultMessage + }; + } + + /** + * Extract capture ID from API result + * + * @param mixed $result API result + */ + public function extractCaptureId(mixed $result): ?string + { + if ( + !method_exists($result, 'getPurchaseUnits') || + !is_array($result->getPurchaseUnits()) || + empty($result->getPurchaseUnits()) + ) { + return null; + } + + $purchaseUnit = $result->getPurchaseUnits()[0]; + $payments = $purchaseUnit->getPayments(); + + if ( + !method_exists($payments, 'getCaptures') || + !is_array($payments->getCaptures()) || + empty($payments->getCaptures()) + ) { + return null; + } + + return $payments->getCaptures()[0]->getId(); + } + + /** + * Prepare raw details for storage + * + * @param string $details JSON details object + * @return array + */ + public function prepareRawDetails(string $details): array + { + $decoded = json_decode($details, true); + if (isset($decoded['links'])) { + unset($decoded['links']); + } + return array_map( + fn($v) => is_array($v) ? json_encode($v) : $v, + $decoded ?? [], + ); + } + + /** + * Add order status comment + * + * @param string $action Action performed (captured, authorized, etc.) + * @param string|null $transactionId Transaction ID + */ + public function addOrderComment( + Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote, + string $action, + ?string $transactionId + ): void { + if ($quote instanceof Mage_Sales_Model_Order && $transactionId) { + $message = match ($action) { + 'captured' => 'PayPal payment captured successfully. Capture ID: %s', + 'authorized' => 'PayPal payment authorized successfully. Authorization ID: %s', + default => 'PayPal payment %s successfully. Transaction ID: %s' + }; + + $quote->addStatusHistoryComment( + Mage::helper('paypal')->__($message, $transactionId), + false, + ); + } + } + + /** + * Handle multishipping notification + */ + public function handleMultishippingNotification(?Mage_Sales_Model_Quote $quote): void + { + if ( + $quote?->getIsMultiShipping() && + Mage::getSingleton('paypal/config')->getPaymentAction() === strtolower(CheckoutPaymentIntent::AUTHORIZE) + ) { + Mage::getSingleton('core/session')->addNotice( + Mage::helper('paypal')->__( + 'PayPal will process multishipping orders as immediate capture regardless of your authorization setting.', + ), + ); + } + } + + /** + * Get payment intent based on payment action configuration + */ + public function getPaymentIntent(): string + { + // Always use capture for multishipping orders + if ($this->getQuote()->getIsMultiShipping()) { + return CheckoutPaymentIntent::CAPTURE; + } + + $paymentAction = Mage::getSingleton('paypal/config')->getPaymentAction(); + + return $paymentAction === strtolower(CheckoutPaymentIntent::AUTHORIZE) + ? CheckoutPaymentIntent::AUTHORIZE + : CheckoutPaymentIntent::CAPTURE; + } + + /** + * Get PayPal API instance + */ + public function getApi(): Mage_Paypal_Model_Api + { + return Mage::getSingleton('paypal/api'); + } + + /** + * Get current quote + */ + public function getQuote(): Mage_Sales_Model_Quote + { + return Mage::getSingleton('checkout/session')->getQuote(); + } +} diff --git a/app/code/core/Mage/Paypal/Model/Order.php b/app/code/core/Mage/Paypal/Model/Order.php new file mode 100644 index 00000000000..bd34eb842fe --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Order.php @@ -0,0 +1,270 @@ +getHelper()->validateQuoteForPayment($quote); + + $quote->reserveOrderId()->save(); + $api = $this->getHelper()->getApi(); + $orderRequest = $this->buildOrderRequest($quote, $quote->getReservedOrderId()); + + $response = $api->createOrder($quote, $orderRequest); + $result = $response->getResult(); + + if ($response->isError()) { + throw new Mage_Core_Exception($result['message'] ?? 'Error creating PayPal order'); + } + + $this->updatePaymentWithOrderInfo($quote->getPayment(), $response); + + return [ + 'success' => true, + 'id' => $result->getId(), + ]; + } catch (Exception $e) { + Mage::logException($e); + return [ + 'success' => false, + 'error' => $e->getMessage(), + ]; + } + } + + /** + * Build a complete PayPal order request using SDK builders + * + * @param string|null $referenceId Optional reference ID + * @return object The built order request object + */ + public function buildOrderRequest(Mage_Sales_Model_Quote $quote, ?string $referenceId = null): object + { + $purchaseUnit = $this->buildPurchaseUnit($quote, $referenceId); + $orderRequestBuilder = OrderRequestBuilder::init( + $this->getHelper()->getPaymentIntent(), + [$purchaseUnit], + ); + + $payer = $this->buildPayerFromBillingAddress($quote); + if ($payer !== null) { + $orderRequestBuilder->payer($payer); + } + + return $orderRequestBuilder->build(); + } + + /** + * Build a purchase unit using PayPal SDK builders + */ + public function buildPurchaseUnit(Mage_Sales_Model_Quote $quote, ?string $referenceId = null): object + { + $cart = Mage::getModel('paypal/cart', [$quote]); + $currency = $quote->getOrderCurrencyCode() ?: $quote->getQuoteCurrencyCode(); + + $adjustedCartData = $this->adjustCartTotalsForTaxDiscrepancy($cart, $currency); + $totals = $adjustedCartData['totals']; + $items = $adjustedCartData['items']; + + $breakdown = $this->buildAmountBreakdown($totals); + $amount = $this->buildAmountWithBreakdown($currency, $quote->getGrandTotal(), $breakdown); + + $purchaseUnitBuilder = PurchaseUnitRequestBuilder::init($amount) + ->items($items) + ->referenceId($referenceId ?: (string) $quote->getId()) + ->invoiceId($referenceId ?: (string) $quote->getId()); + + return $purchaseUnitBuilder->build(); + } + + /** + * Build amount breakdown from cart totals + * + * @param array $totals Cart totals + * @return object Built breakdown object + */ + public function buildAmountBreakdown(array $totals): object + { + $breakdownBuilder = AmountBreakdownBuilder::init(); + + if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_SUBTOTAL])) { + $breakdownBuilder->itemTotal($totals[Mage_Paypal_Model_Cart::TOTAL_SUBTOTAL]); + } + + if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_TAX])) { + $breakdownBuilder->taxTotal($totals[Mage_Paypal_Model_Cart::TOTAL_TAX]); + } + + if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_SHIPPING])) { + $breakdownBuilder->shipping($totals[Mage_Paypal_Model_Cart::TOTAL_SHIPPING]); + } + + if ( + isset($totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]) && + $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]->getValue() > 0 + ) { + $breakdownBuilder->discount($totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]); + } + + return $breakdownBuilder->build(); + } + + /** + * Build amount with breakdown + * + * @param object $breakdown Built breakdown object + */ + public function buildAmountWithBreakdown(string $currency, float $totalAmount, object $breakdown): object + { + $formattedTotal = number_format($totalAmount, 2, '.', ''); + + return AmountWithBreakdownBuilder::init($currency, $formattedTotal) + ->breakdown($breakdown) + ->build(); + } + + /** + * Build payer object from billing address + */ + public function buildPayerFromBillingAddress(Mage_Sales_Model_Quote $quote): ?object + { + $billingAddress = $quote->getBillingAddress(); + + if ($billingAddress->validate() !== true) { + return null; + } + + $name = NameBuilder::init() + ->givenName($billingAddress->getFirstname()) + ->surname($billingAddress->getLastname()) + ->build(); + + $address = AddressBuilder::init($billingAddress->getCountryId()) + ->addressLine1($billingAddress->getStreetLine(1)) + ->addressLine2($billingAddress->getStreetLine(2)) + ->adminArea2($billingAddress->getCity()) + ->adminArea1($billingAddress->getRegionCode()) + ->postalCode($billingAddress->getPostcode()) + ->build(); + + return PayerBuilder::init() + ->emailAddress($quote->getEmail()) + ->name($name) + ->address($address) + ->build(); + } + + /** + * Adjust tax totals and items for rounding discrepancies + * + * @return array{totals: array, items: array} + */ + public function adjustCartTotalsForTaxDiscrepancy(Mage_Paypal_Model_Cart $cart, string $currency): array + { + $totals = $cart->getAmounts(); + $items = $cart->getAllItems(); + + $taxCalculated = 0.00; + $taxAmount = isset($totals[Mage_Paypal_Model_Cart::TOTAL_TAX]) + ? (float) $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->getValue() + : 0.00; + + foreach ($items as $item) { + /** @var PaypalServerSdkLib\Models\Item $item */ + if ($item->getTax()) { + $qty = (int) $item->getQuantity(); + $taxValue = (float) $item->getTax()->getValue(); + $taxCalculated += $taxValue * $qty; + } + } + + $taxDifference = round($taxAmount - $taxCalculated, 2); + + if ($taxDifference < 0) { + $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->setValue(number_format($taxCalculated, 2, '.', '')); + + if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT])) { + $totalDiscount = (float) $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]->getValue(); + $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]->setValue( + number_format(abs($taxDifference) + $totalDiscount, 2, '.', ''), + ); + } else { + $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT] = MoneyBuilder::init( + $currency, + number_format(abs($taxDifference), 2, '.', ''), + )->build(); + } + } elseif ($taxDifference > 0) { + $moneyBuilder = MoneyBuilder::init($currency, number_format(abs($taxDifference), 2, '.', '')); + $roundingItem = ItemBuilder::init( + Mage::helper('paypal')->__('Rounding'), + $moneyBuilder->build(), + '1', + ) + ->sku(Mage::helper('paypal')->__('Rounding')) + ->category(ItemCategory::DIGITAL_GOODS) + ->build(); + + $items[] = $roundingItem; + $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->setValue(number_format($taxCalculated, 2, '.', '')); + } + + return ['totals' => $totals, 'items' => $items]; + } + + /** + * Update payment object with PayPal order information + */ + public function updatePaymentWithOrderInfo(Mage_Sales_Model_Quote_Payment $payment, ApiResponse $response): void + { + $result = $response->getResult(); + $payment->setPaypalCorrelationId($result->getId()) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->getHelper()->prepareRawDetails($response->getBody()), + ) + ->save(); + } + + /** + * Get PayPal Helper instance + */ + private function getHelper(): Mage_Paypal_Model_Helper + { + return Mage::getSingleton('paypal/helper'); + } +} diff --git a/app/code/core/Mage/Paypal/Model/Payment.php b/app/code/core/Mage/Paypal/Model/Payment.php new file mode 100644 index 00000000000..768d19cc7ff --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Payment.php @@ -0,0 +1,283 @@ +getHelper()->getApi(); + $response = $api->captureOrder($orderId, $quote); + $result = $response->getResult(); + + if ($response->isError()) { + $this->getHelper()->handleApiError($response, 'Capture failed'); + } + $captureId = $this->getHelper()->extractCaptureId($result); + $this->getTransactionManager()->updatePaymentAfterCapture($quote->getPayment(), $response, $captureId); + $quote->collectTotals()->save(); + } + + /** + * Authorize PayPal payment via API + * + * @param string $orderId PayPal order ID + * @throws Mage_Core_Exception + */ + public function authorizePayment(string $orderId, Mage_Sales_Model_Quote $quote): void + { + $api = $this->getHelper()->getApi(); + $response = $api->authorizeOrder($orderId, $quote); + $result = $response->getResult(); + + if ($response->isError()) { + $this->getHelper()->handleApiError($response, 'Authorization failed'); + } + + $this->getTransactionManager()->updatePaymentAfterAuthorization($quote->getPayment(), $response); + $quote->collectTotals()->save(); + + $authorization = $result->getPurchaseUnits()[0]->getPayments()->getAuthorizations()[0]; + $this->getHelper()->addOrderComment($quote, 'authorized', $authorization->getId()); + } + + /** + * Reauthorize a payment after the initial authorization has expired + * + * @param string $orderId PayPal order ID + * @param Mage_Sales_Model_Order $order Magento order + * @return array{success: bool, authorization_id?: string, error?: string} + */ + public function reauthorizePayment(string $orderId, Mage_Sales_Model_Order $order): array + { + try { + $api = $this->getHelper()->getApi(); + $response = $api->reAuthorizeOrder($orderId, $order); + $result = $response->getResult(); + + if ($response->isError()) { + $this->getHelper()->handleApiError($response, 'Reauthorization failed'); + } + + $authorization = $result->getPurchaseUnits()[0]->getPayments()->getAuthorizations()[0]; + $authorizationId = $authorization->getId(); + $expirationTime = $authorization->getExpirationTime(); + + $payment = $order->getPayment(); + $payment->setAdditionalInformation([ + self::PAYPAL_PAYMENT_STATUS => $authorization->getStatus(), + self::PAYPAL_PAYMENT_AUTHORIZATION_ID => $authorizationId, + self::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME => $expirationTime, + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->getHelper()->prepareRawDetails($response->getBody()), + ])->getShouldCloseParentTransaction(); + $payment->save(); + + $transaction = $this->getTransactionManager()->getTransaction(); + $transaction->setOrderPaymentObject($payment) + ->setTxnId($authorizationId) + ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH) + ->setIsClosed(0) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->getHelper()->prepareRawDetails($response->getBody()), + ); + $transaction->save(); + + $storeTimezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE); + $date = new DateTime($expirationTime, new DateTimeZone('UTC')); + $date->setTimezone(new DateTimeZone($storeTimezone)); + + $order->addStatusHistoryComment( + Mage::helper('paypal')->__( + 'PayPal payment has been reauthorized. New authorization ID: %s. Expires on: %s', + $authorizationId, + $date->format('Y-m-d H:i:s'), + ), + false, + )->save(); + + return [ + 'success' => true, + 'authorization_id' => $authorizationId, + ]; + } catch (Exception $e) { + Mage::logException($e); + return [ + 'success' => false, + 'error' => $e->getMessage(), + ]; + } + } + + /** + * Process refund payment method + * + * @param Varien_Object $payment Payment object + * @param float $amount Refund amount + * @throws Mage_Core_Exception + */ + public function processRefund(Varien_Object $payment, $amount): static + { + try { + if (is_string($amount)) { + $amount = (float) $amount; + } + $response = $this->getHelper()->getApi()->refundCapturedPayment( + $payment->getParentTransactionId(), + $amount, + $payment->getOrder()->getOrderCurrencyCode(), + $payment->getOrder(), + ); + + if ($response->isError()) { + throw new Mage_Core_Exception($response->getResult()->getMessage()); + } + + $result = $response->getResult(); + $this->getTransactionManager()->updatePaymentAfterRefund($payment, $result); + $this->getTransactionManager()->createRefundTransaction($payment, $response); + } catch (Exception $e) { + Mage::logException($e); + throw new Mage_Core_Exception( + Mage::helper('paypal')->__('Refund error: %s', $e->getMessage()), + ); + } + + return $this; + } + + /** + * Process capture payment method + * + * @param Varien_Object $payment Payment object + * @param float $amount Capture amount + * @throws Mage_Core_Exception + */ + public function processCapture(Varien_Object $payment, $amount): static + { + $addInfo = $payment->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS); + if (($addInfo['intent'] ?? null) === CheckoutPaymentIntent::CAPTURE) { + return $this; + } + + $order = $payment->getOrder(); + $authorizationId = $payment->getAdditionalInformation(self::PAYPAL_PAYMENT_AUTHORIZATION_ID); + + if (!$authorizationId) { + throw new Mage_Core_Exception( + Mage::helper('paypal')->__(self::ERROR_NO_AUTHORIZATION_ID), + ); + } + + $api = $this->getHelper()->getApi(); + $response = $api->captureAuthorizedPayment($authorizationId, $order); + + if ($response->isError()) { + $this->getHelper()->handleApiError($response, 'Capture failed'); + } + + $this->getTransactionManager()->updatePaymentAfterAuthorizedCapture($payment, $response, $authorizationId); + $this->getTransactionManager()->createCaptureTransaction($payment, $response, $authorizationId); + + return $this; + } + + /** + * Process void payment method + * + * @param Varien_Object $payment Payment object + * @throws Mage_Core_Exception + */ + public function processVoid(Varien_Object $payment): static + { + // PayPal will handle void transaction + $transactionId = str_contains($payment->getTransactionId(), '-void') + ? str_replace('-void', '', $payment->getTransactionId()) + : $payment->getTransactionId(); + + try { + $response = $this->getHelper()->getApi()->voidPayment($transactionId, $payment->getOrder()); + + if ($response->isError()) { + throw new Mage_Core_Exception($response->getResult()->getMessage()); + } + + $this->getTransactionManager()->updatePaymentAfterVoid($payment); + $this->getTransactionManager()->createVoidTransaction($payment, $response); + $payment->getOrder()->addStatusHistoryComment( + Mage::helper('paypal')->__('PayPal payment voided successfully. Transaction ID: %s', $transactionId), + false, + )->save(); + } catch (Exception $e) { + Mage::logException($e); + throw new Mage_Core_Exception( + Mage::helper('paypal')->__('Void error: %s', $e->getMessage()), + ); + } + + return $this; + } + + /** + * Process cancel payment method + * + * @param Varien_Object $payment Payment object + * @throws Mage_Core_Exception + */ + public function processCancel(Varien_Object $payment): static + { + if ($payment->getIsTransactionClosed() && $payment->getShouldCloseParentTransaction()) { + return $this; + } + $this->processVoid($payment); + return $this; + } + + /** + * Get PayPal Helper instance + */ + private function getHelper(): Mage_Paypal_Model_Helper + { + return Mage::getSingleton('paypal/helper'); + } + + /** + * Get PayPal Transaction Manager instance + */ + private function getTransactionManager(): Mage_Paypal_Model_Transaction + { + return Mage::getSingleton('paypal/transaction'); + } +} \ No newline at end of file diff --git a/app/code/core/Mage/Paypal/Model/Paypal.php b/app/code/core/Mage/Paypal/Model/Paypal.php index 375795b76ad..1d47794b795 100644 --- a/app/code/core/Mage/Paypal/Model/Paypal.php +++ b/app/code/core/Mage/Paypal/Model/Paypal.php @@ -9,28 +9,12 @@ declare(strict_types=1); -use PaypalServerSdkLib\Models\Builders\PurchaseUnitRequestBuilder; -use PaypalServerSdkLib\Models\Builders\OrderRequestBuilder; use PaypalServerSdkLib\Models\CheckoutPaymentIntent; -use PaypalServerSdkLib\Models\Builders\AmountBreakdownBuilder; -use PaypalServerSdkLib\Models\Builders\AmountWithBreakdownBuilder; -use PaypalServerSdkLib\Models\Builders\PayerBuilder; -use PaypalServerSdkLib\Models\Builders\AddressBuilder; -use PaypalServerSdkLib\Models\Builders\NameBuilder; -use PaypalServerSdkLib\Http\ApiResponse; -use PaypalServerSdkLib\Models\Builders\MoneyBuilder; -use PaypalServerSdkLib\Models\Builders\ItemBuilder; -use PaypalServerSdkLib\Models\ItemCategory; -use PaypalServerSdkLib\Models\{ - Refund, - PaypalWalletResponse -}; /** * PayPal Payment Method Model * - * Handles PayPal order creation, authorization, capture, refund and void operations - * * + * Main payment method interface that delegates to specialized classes */ class Mage_Paypal_Model_Paypal extends Mage_Payment_Model_Method_Abstract { @@ -48,15 +32,6 @@ class Mage_Paypal_Model_Paypal extends Mage_Payment_Model_Method_Abstract protected $_isGateway = true; protected $_canUseCheckout = true; - // Payment information transport keys - public const PAYPAL_PAYMENT_STATUS = 'paypal_payment_status'; - public const PAYPAL_PAYMENT_AUTHORIZATION_ID = 'paypal_payment_authorization_id'; - public const PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME = 'paypal_payment_authorization_expires_time'; - - // Error messages - private const ERROR_ZERO_AMOUNT = 'PayPal does not support processing orders with zero amount. To complete your purchase, proceed to the standard checkout process.'; - private const ERROR_NO_AUTHORIZATION_ID = 'No authorization ID found. Cannot capture payment.'; - /** * Create PayPal order via API * @@ -66,33 +41,7 @@ class Mage_Paypal_Model_Paypal extends Mage_Payment_Model_Method_Abstract */ public function create(Mage_Sales_Model_Quote $quote): array { - try { - $this->_validateQuoteForPayment($quote); - - $quote->reserveOrderId()->save(); - $api = $this->_getApi(); - $orderRequest = $this->_buildOrderRequest($quote, $quote->getReservedOrderId()); - - $response = $api->createOrder($quote, $orderRequest); - $result = $response->getResult(); - - if ($response->isError()) { - throw new Mage_Core_Exception($result['message'] ?? 'Error creating PayPal order'); - } - - $this->_updatePaymentWithOrderInfo($quote->getPayment(), $response); - - return [ - 'success' => true, - 'id' => $result->getId(), - ]; - } catch (Exception $e) { - Mage::logException($e); - return [ - 'success' => false, - 'error' => $e->getMessage(), - ]; - } + return $this->getOrderHandler()->createOrder($quote); } /** @@ -103,16 +52,7 @@ public function create(Mage_Sales_Model_Quote $quote): array */ public function captureOrder(string $orderId, Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote): void { - $api = $this->_getApi(); - $response = $api->captureOrder($orderId, $quote); - $result = $response->getResult(); - - if ($response->isError()) { - $this->_handleApiError($response, 'Capture failed'); - } - $captureId = $this->_extractCaptureId($result); - $this->_updatePaymentAfterCapture($quote->getPayment(), $response, $captureId); - $quote->collectTotals()->save(); + $this->getPaymentProcessor()->captureOrder($orderId, $quote); } /** @@ -123,19 +63,7 @@ public function captureOrder(string $orderId, Mage_Sales_Model_Quote|Mage_Sales_ */ public function authorizePayment(string $orderId, Mage_Sales_Model_Quote $quote): void { - $api = $this->_getApi(); - $response = $api->authorizeOrder($orderId, $quote); - $result = $response->getResult(); - - if ($response->isError()) { - $this->_handleApiError($response, 'Authorization failed'); - } - - $this->_updatePaymentAfterAuthorization($quote->getPayment(), $response); - $quote->collectTotals()->save(); - - $authorization = $result->getPurchaseUnits()[0]->getPayments()->getAuthorizations()[0]; - $this->_addOrderComment($quote, 'authorized', $authorization->getId()); + $this->getPaymentProcessor()->authorizePayment($orderId, $quote); } /** @@ -147,63 +75,7 @@ public function authorizePayment(string $orderId, Mage_Sales_Model_Quote $quote) */ public function reauthorizePayment(string $orderId, Mage_Sales_Model_Order $order): array { - try { - $api = $this->_getApi(); - $response = $api->reAuthorizeOrder($orderId, $order); - $result = $response->getResult(); - - if ($response->isError()) { - $this->_handleApiError($response, 'Reauthorization failed'); - } - - $authorization = $result->getPurchaseUnits()[0]->getPayments()->getAuthorizations()[0]; - $authorizationId = $authorization->getId(); - $expirationTime = $authorization->getExpirationTime(); - - $payment = $order->getPayment(); - $payment->setAdditionalInformation([ - self::PAYPAL_PAYMENT_STATUS => $authorization->getStatus(), - self::PAYPAL_PAYMENT_AUTHORIZATION_ID => $authorizationId, - self::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME => $expirationTime, - Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->_prepareRawDetails($response->getBody()), - ])->getShouldCloseParentTransaction(); - $payment->save(); - - $transaction = $this->_getTransaction(); - $transaction->setOrderPaymentObject($payment) - ->setTxnId($authorizationId) - ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH) - ->setIsClosed(0) - ->setAdditionalInformation( - Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->_prepareRawDetails($response->getBody()), - ); - $transaction->save(); - - $storeTimezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE); - $date = new DateTime($expirationTime, new DateTimeZone('UTC')); - $date->setTimezone(new DateTimeZone($storeTimezone)); - - $order->addStatusHistoryComment( - Mage::helper('paypal')->__( - 'PayPal payment has been reauthorized. New authorization ID: %s. Expires on: %s', - $authorizationId, - $date->format('Y-m-d H:i:s'), - ), - false, - )->save(); - - return [ - 'success' => true, - 'authorization_id' => $authorizationId, - ]; - } catch (Exception $e) { - Mage::logException($e); - return [ - 'success' => false, - 'error' => $e->getMessage(), - ]; - } + return $this->getPaymentProcessor()->reauthorizePayment($orderId, $order); } /** @@ -224,31 +96,7 @@ public function validate(): static */ public function refund(Varien_Object $payment, $amount): static { - try { - if (is_string($amount)) { - $amount = (float) $amount; - } - $response = $this->_getApi()->refundCapturedPayment( - $payment->getParentTransactionId(), - $amount, - $payment->getOrder()->getOrderCurrencyCode(), - $payment->getOrder(), - ); - - if ($response->isError()) { - throw new Mage_Core_Exception($response->getResult()->getMessage()); - } - - $result = $response->getResult(); - $this->_updatePaymentAfterRefund($payment, $result); - $this->_createRefundTransaction($payment, $response); - } catch (Exception $e) { - Mage::logException($e); - throw new Mage_Core_Exception( - Mage::helper('paypal')->__('Refund error: %s', $e->getMessage()), - ); - } - + $this->getPaymentProcessor()->processRefund($payment, $amount); return $this; } @@ -261,30 +109,7 @@ public function refund(Varien_Object $payment, $amount): static */ public function capture(Varien_Object $payment, $amount): static { - $addInfo = $payment->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS); - if (($addInfo['intent'] ?? null) === CheckoutPaymentIntent::CAPTURE) { - return $this; - } - - $order = $payment->getOrder(); - $authorizationId = $payment->getAdditionalInformation(self::PAYPAL_PAYMENT_AUTHORIZATION_ID); - - if (!$authorizationId) { - throw new Mage_Core_Exception( - Mage::helper('paypal')->__(self::ERROR_NO_AUTHORIZATION_ID), - ); - } - - $api = $this->_getApi(); - $response = $api->captureAuthorizedPayment($authorizationId, $order); - - if ($response->isError()) { - $this->_handleApiError($response, 'Capture failed'); - } - - $this->_updatePaymentAfterAuthorizedCapture($payment, $response, $authorizationId); - $this->_createCaptureTransaction($payment, $response, $authorizationId); - + $this->getPaymentProcessor()->processCapture($payment, $amount); return $this; } @@ -296,31 +121,7 @@ public function capture(Varien_Object $payment, $amount): static */ public function void(Varien_Object $payment): static { - // PayPal will handle void transaction - $transactionId = str_contains($payment->getTransactionId(), '-void') - ? str_replace('-void', '', $payment->getTransactionId()) - : $payment->getTransactionId(); - - try { - $response = $this->_getApi()->voidPayment($transactionId, $payment->getOrder()); - - if ($response->isError()) { - throw new Mage_Core_Exception($response->getResult()->getMessage()); - } - - $this->_updatePaymentAfterVoid($payment); - $this->_createVoidTransaction($payment, $response); - $payment->getOrder()->addStatusHistoryComment( - Mage::helper('paypal')->__('PayPal payment voided successfully. Transaction ID: %s', $transactionId), - false, - )->save(); - } catch (Exception $e) { - Mage::logException($e); - throw new Mage_Core_Exception( - Mage::helper('paypal')->__('Void error: %s', $e->getMessage()), - ); - } - + $this->getPaymentProcessor()->processVoid($payment); return $this; } @@ -332,10 +133,7 @@ public function void(Varien_Object $payment): static */ public function cancel(Varien_Object $payment): static { - if ($payment->getIsTransactionClosed() && $payment->getShouldCloseParentTransaction()) { - return $this; - } - $this->void($payment); + $this->getPaymentProcessor()->processCancel($payment); return $this; } @@ -350,574 +148,32 @@ public function isAvailable($quote = null): bool return false; } - $this->_handleMultishippingNotification($quote); + $this->getHelper()->handleMultishippingNotification($quote); return parent::isAvailable($quote); } /** - * Get PayPal API instance - */ - private function _getApi(): Mage_Paypal_Model_Api - { - return Mage::getSingleton('paypal/api'); - } - - /** - * Handle API error response - * - * @param ApiResponse $response API response - * @param string $defaultMessage Default error message - * @throws Mage_Core_Exception - */ - private function _handleApiError(ApiResponse $response, string $defaultMessage): never - { - $errorMsg = $this->_extractErrorMessage($response, $defaultMessage); - throw new Mage_Core_Exception($errorMsg); - } - - /** - * Get current quote - */ - private function _getQuote(): Mage_Sales_Model_Quote - { - return Mage::getSingleton('checkout/session')->getQuote(); - } - - /** - * Validate quote for PayPal payment processing - * - * @throws Mage_Core_Exception - */ - private function _validateQuoteForPayment(Mage_Sales_Model_Quote $quote): void - { - $quote->collectTotals(); - - if (!$quote->getGrandTotal() && !$quote->hasNominalItems()) { - throw new Mage_Core_Exception( - Mage::helper('paypal')->__(self::ERROR_ZERO_AMOUNT), - ); - } - } - - /** - * Update payment object with PayPal order information - */ - private function _updatePaymentWithOrderInfo(Mage_Sales_Model_Quote_Payment $payment, ApiResponse $response): void - { - $result = $response->getResult(); - $payment->setPaypalCorrelationId($result->getId()) - ->setAdditionalInformation( - Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->_prepareRawDetails($response->getBody()), - ) - ->save(); - } - - /** - * Build a purchase unit using PayPal SDK builders - */ - private function _buildPurchaseUnit(Mage_Sales_Model_Quote $quote, ?string $referenceId = null): object - { - $cart = Mage::getModel('paypal/cart', [$quote]); - $currency = $quote->getOrderCurrencyCode() ?: $quote->getQuoteCurrencyCode(); - - $adjustedCartData = $this->_adjustCartTotalsForTaxDiscrepancy($cart, $currency); - $totals = $adjustedCartData['totals']; - $items = $adjustedCartData['items']; - - $breakdown = $this->_buildAmountBreakdown($totals); - $amount = $this->_buildAmountWithBreakdown($currency, $quote->getGrandTotal(), $breakdown); - - $purchaseUnitBuilder = PurchaseUnitRequestBuilder::init($amount) - ->items($items) - ->referenceId($referenceId ?: (string) $quote->getId()) - ->invoiceId($referenceId ?: (string) $quote->getId()); - - return $purchaseUnitBuilder->build(); - } - - /** - * Adjust tax totals and items for rounding discrepancies - * - * @return array{totals: array, items: array} - */ - private function _adjustCartTotalsForTaxDiscrepancy(Mage_Paypal_Model_Cart $cart, string $currency): array - { - $totals = $cart->getAmounts(); - $items = $cart->getAllItems(); - - $taxCalculated = 0.00; - $taxAmount = isset($totals[Mage_Paypal_Model_Cart::TOTAL_TAX]) - ? (float) $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->getValue() - : 0.00; - - foreach ($items as $item) { - /** @var PaypalServerSdkLib\Models\Item $item */ - if ($item->getTax()) { - $qty = (int) $item->getQuantity(); - $taxValue = (float) $item->getTax()->getValue(); - $taxCalculated += $taxValue * $qty; - } - } - - $taxDifference = round($taxAmount - $taxCalculated, 2); - - if ($taxDifference < 0) { - $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->setValue(number_format($taxCalculated, 2, '.', '')); - - if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT])) { - $totalDiscount = (float) $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]->getValue(); - $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]->setValue( - number_format(abs($taxDifference) + $totalDiscount, 2, '.', ''), - ); - } else { - $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT] = MoneyBuilder::init( - $currency, - number_format(abs($taxDifference), 2, '.', ''), - )->build(); - } - } elseif ($taxDifference > 0) { - $moneyBuilder = MoneyBuilder::init($currency, number_format(abs($taxDifference), 2, '.', '')); - $roundingItem = ItemBuilder::init( - Mage::helper('paypal')->__('Rounding'), - $moneyBuilder->build(), - '1', - ) - ->sku(Mage::helper('paypal')->__('Rounding')) - ->category(ItemCategory::DIGITAL_GOODS) - ->build(); - - $items[] = $roundingItem; - $totals[Mage_Paypal_Model_Cart::TOTAL_TAX]->setValue(number_format($taxCalculated, 2, '.', '')); - } - - return ['totals' => $totals, 'items' => $items]; - } - - - /** - * Build amount breakdown from cart totals - * - * @param array $totals Cart totals - * @return object Built breakdown object - */ - private function _buildAmountBreakdown(array $totals): object - { - $breakdownBuilder = AmountBreakdownBuilder::init(); - - if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_SUBTOTAL])) { - $breakdownBuilder->itemTotal($totals[Mage_Paypal_Model_Cart::TOTAL_SUBTOTAL]); - } - - if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_TAX])) { - $breakdownBuilder->taxTotal($totals[Mage_Paypal_Model_Cart::TOTAL_TAX]); - } - - if (isset($totals[Mage_Paypal_Model_Cart::TOTAL_SHIPPING])) { - $breakdownBuilder->shipping($totals[Mage_Paypal_Model_Cart::TOTAL_SHIPPING]); - } - - if ( - isset($totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]) && - $totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]->getValue() > 0 - ) { - $breakdownBuilder->discount($totals[Mage_Paypal_Model_Cart::TOTAL_DISCOUNT]); - } - - return $breakdownBuilder->build(); - } - - /** - * Build amount with breakdown - * - * @param object $breakdown Built breakdown object - */ - private function _buildAmountWithBreakdown(string $currency, float $totalAmount, object $breakdown): object - { - $formattedTotal = number_format($totalAmount, 2, '.', ''); - - return AmountWithBreakdownBuilder::init($currency, $formattedTotal) - ->breakdown($breakdown) - ->build(); - } - - /** - * Build a complete PayPal order request using SDK builders - * - * @param string|null $referenceId Optional reference ID - * @return object The built order request object - */ - private function _buildOrderRequest(Mage_Sales_Model_Quote $quote, ?string $referenceId = null): object - { - $purchaseUnit = $this->_buildPurchaseUnit($quote, $referenceId); - $orderRequestBuilder = OrderRequestBuilder::init( - $this->_getPaymentIntent(), - [$purchaseUnit], - ); - - $payer = $this->_buildPayerFromBillingAddress($quote); - if ($payer !== null) { - $orderRequestBuilder->payer($payer); - } - - return $orderRequestBuilder->build(); - } - - /** - * Build payer object from billing address - */ - private function _buildPayerFromBillingAddress(Mage_Sales_Model_Quote $quote): ?object - { - $billingAddress = $quote->getBillingAddress(); - - if ($billingAddress->validate() !== true) { - return null; - } - - $name = NameBuilder::init() - ->givenName($billingAddress->getFirstname()) - ->surname($billingAddress->getLastname()) - ->build(); - - $address = AddressBuilder::init($billingAddress->getCountryId()) - ->addressLine1($billingAddress->getStreetLine(1)) - ->addressLine2($billingAddress->getStreetLine(2)) - ->adminArea2($billingAddress->getCity()) - ->adminArea1($billingAddress->getRegionCode()) - ->postalCode($billingAddress->getPostcode()) - ->build(); - - return PayerBuilder::init() - ->emailAddress($quote->getEmail()) - ->name($name) - ->address($address) - ->build(); - } - - /** - * Get payment intent based on payment action configuration - */ - private function _getPaymentIntent(): string - { - // Always use capture for multishipping orders - if ($this->_getQuote()->getIsMultiShipping()) { - return CheckoutPaymentIntent::CAPTURE; - } - - $paymentAction = Mage::getSingleton('paypal/config')->getPaymentAction(); - - return $paymentAction === strtolower(CheckoutPaymentIntent::AUTHORIZE) - ? CheckoutPaymentIntent::AUTHORIZE - : CheckoutPaymentIntent::CAPTURE; - } - - /** - * Extract capture ID from API result - * - * @param mixed $result API result - */ - private function _extractCaptureId(mixed $result): ?string - { - if ( - !method_exists($result, 'getPurchaseUnits') || - !is_array($result->getPurchaseUnits()) || - empty($result->getPurchaseUnits()) - ) { - return null; - } - - $purchaseUnit = $result->getPurchaseUnits()[0]; - $payments = $purchaseUnit->getPayments(); - - if ( - !method_exists($payments, 'getCaptures') || - !is_array($payments->getCaptures()) || - empty($payments->getCaptures()) - ) { - return null; - } - - return $payments->getCaptures()[0]->getId(); - } - - /** - * Update payment object after successful capture - * - * @param ApiResponse $response API result - * @param string $captureId Capture ID - */ - private function _updatePaymentAfterCapture( - Mage_Sales_Model_Quote_Payment|Mage_Sales_Model_Order_Payment $payment, - ApiResponse $response, - string $captureId - ): void { - $result = $response->getResult(); - $payment->setMethod($this->_code) - ->setPaypalCorrelationId($captureId) - ->setTransactionId($captureId) - ->setIsTransactionClosed(true) - ->setAdditionalInformation( - Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->_prepareRawDetails($response->getBody()), - ); - $paymentSource = $result->getPaymentSource(); - if ($paymentSource->getPaypal() instanceof PaypalWalletResponse) { - $paypalWallet = $paymentSource->getPaypal(); - $payment->setPaypalPayerId($paypalWallet->getAccountId()) - ->setPaypalPayerStatus($paypalWallet->getAccountStatus()); - } - - $payment->save(); - } - - /** - * Update payment object after successful authorization - * - * @param ApiResponse $response API result - */ - private function _updatePaymentAfterAuthorization(Mage_Sales_Model_Quote_Payment $payment, ApiResponse $response): void - { - $result = $response->getResult(); - $authorization = $result->getPurchaseUnits()[0]->getPayments()->getAuthorizations()[0]; - $paymentSource = $result->getPaymentSource(); - - if ($paymentSource->getPaypal() instanceof PaypalWalletResponse) { - $paypalWallet = $paymentSource->getPaypal(); - $payment->setPaypalPayerId($paypalWallet->getAccountId()) - ->setPaypalPayerStatus($paypalWallet->getAccountStatus()); - } - - $payment->setAdditionalInformation([ - self::PAYPAL_PAYMENT_STATUS => $authorization->getStatus(), - self::PAYPAL_PAYMENT_AUTHORIZATION_ID => $authorization->getId(), - self::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME => $authorization->getExpirationTime(), - Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->_prepareRawDetails($response->getBody()), - ]); - $payment->save(); - } - - /** - * Add order status comment - * - * @param string $action Action performed (captured, authorized, etc.) - * @param string|null $transactionId Transaction ID - */ - private function _addOrderComment( - Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote, - string $action, - ?string $transactionId - ): void { - if ($quote instanceof Mage_Sales_Model_Order && $transactionId) { - $message = match ($action) { - 'captured' => 'PayPal payment captured successfully. Capture ID: %s', - 'authorized' => 'PayPal payment authorized successfully. Authorization ID: %s', - default => 'PayPal payment %s successfully. Transaction ID: %s' - }; - - $quote->addStatusHistoryComment( - Mage::helper('paypal')->__($message, $transactionId), - false, - ); - } - } - - /** - * Update payment after refund - * - * @param Varien_Object $payment Payment object - * @param Refund $result API result - */ - private function _updatePaymentAfterRefund(Varien_Object $payment, Refund $result): void - { - $payment->setTransactionId($result->getId()) - ->setIsTransactionClosed(1) - ->setShouldCloseParentTransaction(1) - ->setSkipTransactionCreation(true); - } - - /** - * Create refund transaction record - * - * @param Varien_Object $payment Payment object - * @param ApiResponse $response API result - */ - private function _createRefundTransaction(Varien_Object $payment, ApiResponse $response): void - { - $result = $response->getResult(); - $transaction = $this->_getTransaction(); - /** - * @var Mage_Sales_Model_Order_Payment $payment - */ - $transaction->setOrderPaymentObject($payment) - ->setTxnId($result->getId()) - ->setParentTxnId($payment->getParentTransactionId()) - ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND) - ->setIsClosed(1) - ->setAdditionalInformation( - Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->_prepareRawDetails($response->getBody()), - ); - - $transaction->save(); - } - - /** - * Update payment after authorized capture - * - * @param Varien_Object $payment Payment object - * @param string $authorizationId Authorization ID + * Get PayPal Order Handler instance */ - private function _updatePaymentAfterAuthorizedCapture(Varien_Object $payment, ApiResponse $response, string $authorizationId): void + private function getOrderHandler(): Mage_Paypal_Model_Order { - /** - * @var Mage_Sales_Model_Order_Payment $payment - */ - $result = $response->getResult(); - $captureId = $result->getId(); - $additionalInfo = $payment->getAdditionalInformation(); - unset($additionalInfo[self::PAYPAL_PAYMENT_STATUS]); - unset($additionalInfo[self::PAYPAL_PAYMENT_AUTHORIZATION_ID]); - unset($additionalInfo[self::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME]); - $payment->setAdditionalInformation($additionalInfo); - $payment->setTransactionId($captureId) - ->setParentTransactionId($authorizationId) - ->setIsTransactionClosed(true) - ->setShouldCloseParentTransaction(true) - ->setAdditionalInformation( - Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->_prepareRawDetails($response->getBody()), - ); + return Mage::getSingleton('paypal/order'); } /** - * Create capture transaction record - * - * @param Varien_Object $payment Payment object - * @param string $authorizationId Authorization ID + * Get PayPal Payment Processor instance */ - private function _createCaptureTransaction(Varien_Object $payment, ApiResponse $response, string $authorizationId): void + private function getPaymentProcessor(): Mage_Paypal_Model_Payment { - $result = $response->getResult(); - $transaction = $this->_getTransaction(); - /** - * @var Mage_Sales_Model_Order_Payment $payment - */ - $transaction->setOrderPaymentObject($payment) - ->setTxnId($result->getId()) - ->setParentTxnId($authorizationId) - ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE) - ->setIsClosed(1) - ->setAdditionalInformation( - Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->_prepareRawDetails($response->getBody()), - ); - - $transaction->save(); + return Mage::getSingleton('paypal/payment'); } /** - * Update payment after void - * - * @param Varien_Object $payment Payment object + * Get PayPal Helper instance */ - private function _updatePaymentAfterVoid(Varien_Object $payment): void - { - $payment->setIsTransactionClosed(1) - ->setShouldCloseParentTransaction(1) - ->setSkipTransactionCreation(true); - } - - /** - * Create void transaction record - * - * @param Varien_Object $payment Payment object - * @param ApiResponse $response API response - */ - private function _createVoidTransaction(Varien_Object $payment, ApiResponse $response): void - { - $transaction = $this->_getTransaction(); - $result = $response->getResult(); - /** - * @var Mage_Sales_Model_Order_Payment $payment - */ - $transaction->setOrderPaymentObject($payment) - ->setTxnId($payment->getTransactionId()) - ->setParentTxnId($result->getId()) - ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID) - ->setIsClosed(1) - ->setAdditionalInformation( - Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->_prepareRawDetails($response->getBody()), - ); - $transaction->save(); - - $parentTxn = $transaction->loadByTxnId($result->getId()); - if ($parentTxn->getId()) { - $parentTxn->setIsClosed(1); - $parentTxn->save(); - } - } - - /** - * Handle multishipping notification - */ - private function _handleMultishippingNotification(?Mage_Sales_Model_Quote $quote): void - { - if ( - $quote?->getIsMultiShipping() && - Mage::getSingleton('paypal/config')->getPaymentAction() === strtolower(CheckoutPaymentIntent::AUTHORIZE) - ) { - Mage::getSingleton('core/session')->addNotice( - Mage::helper('paypal')->__( - 'PayPal will process multishipping orders as immediate capture regardless of your authorization setting.', - ), - ); - } - } - - /** - * Extract error message from API response - * - * @param ApiResponse $response API response - * @param string $defaultMessage Default error message - */ - private function _extractErrorMessage(ApiResponse $response, string $defaultMessage): string - { - $result = $response->getResult(); - - return match (true) { - is_array($result) && isset($result['message']) => $result['message'] ?: $defaultMessage, - is_object($result) && method_exists($result, 'getMessage') => $result->getMessage() ?: $defaultMessage, - is_string($result) => $result ?: $defaultMessage, - default => $defaultMessage - }; - } - - /** - * Prepare raw details for storage - * - * @param string $details JSON details object - * @return array - */ - private function _prepareRawDetails(string $details): array - { - $decoded = json_decode($details, true); - if (isset($decoded['links'])) { - unset($decoded['links']); - } - return array_map( - fn($v) => is_array($v) ? json_encode($v) : $v, - $decoded ?? [], - ); - } - /** - * Get order payment transaction model - * - * @throws Mage_Core_Exception - **/ - private function _getTransaction(): Mage_Sales_Model_Order_Payment_Transaction + private function getHelper(): Mage_Paypal_Model_Helper { - return Mage::getModel('sales/order_payment_transaction'); + return Mage::getSingleton('paypal/helper'); } -} +} \ No newline at end of file diff --git a/app/code/core/Mage/Paypal/Model/Transaction.php b/app/code/core/Mage/Paypal/Model/Transaction.php new file mode 100644 index 00000000000..964f9ac27f5 --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Transaction.php @@ -0,0 +1,246 @@ +getResult(); + $transaction = $this->getTransaction(); + /** + * @var Mage_Sales_Model_Order_Payment $payment + */ + $transaction->setOrderPaymentObject($payment) + ->setTxnId($result->getId()) + ->setParentTxnId($payment->getParentTransactionId()) + ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND) + ->setIsClosed(1) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->getHelper()->prepareRawDetails($response->getBody()), + ); + + $transaction->save(); + } + + /** + * Create capture transaction record + * + * @param Varien_Object $payment Payment object + * @param ApiResponse $response API response + * @param string $authorizationId Authorization ID + */ + public function createCaptureTransaction(Varien_Object $payment, ApiResponse $response, string $authorizationId): void + { + $result = $response->getResult(); + $transaction = $this->getTransaction(); + /** + * @var Mage_Sales_Model_Order_Payment $payment + */ + $transaction->setOrderPaymentObject($payment) + ->setTxnId($result->getId()) + ->setParentTxnId($authorizationId) + ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE) + ->setIsClosed(1) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->getHelper()->prepareRawDetails($response->getBody()), + ); + + $transaction->save(); + } + + /** + * Create void transaction record + * + * @param Varien_Object $payment Payment object + * @param ApiResponse $response API response + */ + public function createVoidTransaction(Varien_Object $payment, ApiResponse $response): void + { + $transaction = $this->getTransaction(); + $result = $response->getResult(); + /** + * @var Mage_Sales_Model_Order_Payment $payment + */ + $transaction->setOrderPaymentObject($payment) + ->setTxnId($payment->getTransactionId()) + ->setParentTxnId($result->getId()) + ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID) + ->setIsClosed(1) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->getHelper()->prepareRawDetails($response->getBody()), + ); + $transaction->save(); + + $parentTxn = $transaction->loadByTxnId($result->getId()); + if ($parentTxn->getId()) { + $parentTxn->setIsClosed(1); + $parentTxn->save(); + } + } + + /** + * Update payment object after successful capture + * + * @param ApiResponse $response API result + * @param string $captureId Capture ID + */ + public function updatePaymentAfterCapture( + Mage_Sales_Model_Quote_Payment|Mage_Sales_Model_Order_Payment $payment, + ApiResponse $response, + string $captureId + ): void { + $result = $response->getResult(); + $payment->setMethod('paypal') + ->setPaypalCorrelationId($captureId) + ->setTransactionId($captureId) + ->setIsTransactionClosed(true) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->getHelper()->prepareRawDetails($response->getBody()), + ); + $paymentSource = $result->getPaymentSource(); + if ($paymentSource->getPaypal() instanceof PaypalWalletResponse) { + $paypalWallet = $paymentSource->getPaypal(); + $payment->setPaypalPayerId($paypalWallet->getAccountId()) + ->setPaypalPayerStatus($paypalWallet->getAccountStatus()); + } + + $payment->save(); + } + + /** + * Update payment object after successful authorization + * + * @param ApiResponse $response API result + */ + public function updatePaymentAfterAuthorization(Mage_Sales_Model_Quote_Payment $payment, ApiResponse $response): void + { + $result = $response->getResult(); + $authorization = $result->getPurchaseUnits()[0]->getPayments()->getAuthorizations()[0]; + $paymentSource = $result->getPaymentSource(); + + if ($paymentSource->getPaypal() instanceof PaypalWalletResponse) { + $paypalWallet = $paymentSource->getPaypal(); + $payment->setPaypalPayerId($paypalWallet->getAccountId()) + ->setPaypalPayerStatus($paypalWallet->getAccountStatus()); + } + + $payment->setAdditionalInformation([ + self::PAYPAL_PAYMENT_STATUS => $authorization->getStatus(), + self::PAYPAL_PAYMENT_AUTHORIZATION_ID => $authorization->getId(), + self::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME => $authorization->getExpirationTime(), + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->getHelper()->prepareRawDetails($response->getBody()), + ]); + $payment->save(); + } + + /** + * Update payment after refund + * + * @param Varien_Object $payment Payment object + * @param Refund $result API result + */ + public function updatePaymentAfterRefund(Varien_Object $payment, Refund $result): void + { + $payment->setTransactionId($result->getId()) + ->setIsTransactionClosed(1) + ->setShouldCloseParentTransaction(1) + ->setSkipTransactionCreation(true); + } + + /** + * Update payment after authorized capture + * + * @param Varien_Object $payment Payment object + * @param ApiResponse $response API response + * @param string $authorizationId Authorization ID + */ + public function updatePaymentAfterAuthorizedCapture(Varien_Object $payment, ApiResponse $response, string $authorizationId): void + { + /** + * @var Mage_Sales_Model_Order_Payment $payment + */ + $result = $response->getResult(); + $captureId = $result->getId(); + $additionalInfo = $payment->getAdditionalInformation(); + unset($additionalInfo[self::PAYPAL_PAYMENT_STATUS]); + unset($additionalInfo[self::PAYPAL_PAYMENT_AUTHORIZATION_ID]); + unset($additionalInfo[self::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME]); + $payment->setAdditionalInformation($additionalInfo); + $payment->setTransactionId($captureId) + ->setParentTransactionId($authorizationId) + ->setIsTransactionClosed(true) + ->setShouldCloseParentTransaction(true) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->getHelper()->prepareRawDetails($response->getBody()), + ); + } + + /** + * Update payment after void + * + * @param Varien_Object $payment Payment object + */ + public function updatePaymentAfterVoid(Varien_Object $payment): void + { + $additionalInfo = $payment->getAdditionalInformation(); + unset($additionalInfo[self::PAYPAL_PAYMENT_STATUS]); + unset($additionalInfo[self::PAYPAL_PAYMENT_AUTHORIZATION_ID]); + unset($additionalInfo[self::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME]); + $payment->setAdditionalInformation($additionalInfo); + $payment->setIsTransactionClosed(1) + ->setShouldCloseParentTransaction(1) + ->setSkipTransactionCreation(true); + } + + /** + * Get order payment transaction model + * + * @throws Mage_Core_Exception + */ + public function getTransaction(): Mage_Sales_Model_Order_Payment_Transaction + { + return Mage::getModel('sales/order_payment_transaction'); + } + + /** + * Get PayPal Helper instance + */ + private function getHelper(): Mage_Paypal_Model_Helper + { + return Mage::getSingleton('paypal/helper'); + } +} diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php index e39a53df8f7..c15d807bf08 100644 --- a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php +++ b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php @@ -34,7 +34,7 @@ public function reauthorizeAction(): void $this->_validatePaymentMethod($payment); - $authorizationId = $payment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID); + $authorizationId = $payment->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_AUTHORIZATION_ID); if (!$authorizationId) { Mage::throwException($this->__('This order does not have a PayPal authorization.')); } diff --git a/app/code/core/Mage/Paypal/controllers/PaymentController.php b/app/code/core/Mage/Paypal/controllers/PaymentController.php index 449aab34a36..29c92e606df 100644 --- a/app/code/core/Mage/Paypal/controllers/PaymentController.php +++ b/app/code/core/Mage/Paypal/controllers/PaymentController.php @@ -198,11 +198,11 @@ public function placeOrderAction(): void } if ($isAuthorize) { $transaction->setOrderPaymentObject($orderPayment) - ->setTxnId($orderPayment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_ID)) + ->setTxnId($orderPayment->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_AUTHORIZATION_ID)) ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH) ->setIsClosed(false); $storeTimezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE); - $expirationTime = $orderPayment->getAdditionalInformation(Mage_Paypal_Model_Paypal::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME); + $expirationTime = $orderPayment->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME); $date = new DateTime($expirationTime, new DateTimeZone('UTC')); $date->setTimezone(new DateTimeZone($storeTimezone)); From 3e94602aa225f2cf808f5365e1b790046273050b Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Sun, 22 Jun 2025 22:12:44 +0200 Subject: [PATCH 15/40] fix: php-cs-fixer --- app/code/core/Mage/Paypal/Model/Payment.php | 2 +- app/code/core/Mage/Paypal/Model/Paypal.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/code/core/Mage/Paypal/Model/Payment.php b/app/code/core/Mage/Paypal/Model/Payment.php index 768d19cc7ff..abeb4942ff1 100644 --- a/app/code/core/Mage/Paypal/Model/Payment.php +++ b/app/code/core/Mage/Paypal/Model/Payment.php @@ -280,4 +280,4 @@ private function getTransactionManager(): Mage_Paypal_Model_Transaction { return Mage::getSingleton('paypal/transaction'); } -} \ No newline at end of file +} diff --git a/app/code/core/Mage/Paypal/Model/Paypal.php b/app/code/core/Mage/Paypal/Model/Paypal.php index 1d47794b795..988c2db4876 100644 --- a/app/code/core/Mage/Paypal/Model/Paypal.php +++ b/app/code/core/Mage/Paypal/Model/Paypal.php @@ -176,4 +176,4 @@ private function getHelper(): Mage_Paypal_Model_Helper { return Mage::getSingleton('paypal/helper'); } -} \ No newline at end of file +} From 215d841e6dd198085e672fa2f7933a7a8c474758 Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Sun, 22 Jun 2025 23:18:13 +0200 Subject: [PATCH 16/40] fix: resolve SonarQube issues --- .../Paypal/controllers/PaymentController.php | 4 - .../default/template/paypal/info.phtml | 36 +- .../base/default/template/paypal/info.phtml | 2 +- .../default/template/paypal/payment.phtml | 39 +- js/paypal/payment.js | 592 ++++++++++-------- 5 files changed, 379 insertions(+), 294 deletions(-) diff --git a/app/code/core/Mage/Paypal/controllers/PaymentController.php b/app/code/core/Mage/Paypal/controllers/PaymentController.php index 29c92e606df..d04b67856b4 100644 --- a/app/code/core/Mage/Paypal/controllers/PaymentController.php +++ b/app/code/core/Mage/Paypal/controllers/PaymentController.php @@ -40,10 +40,6 @@ class Mage_Paypal_PaymentController extends Mage_Core_Controller_Front_Action public function createAction(): void { try { - if (!$this->getRequest()->isAjax()) { - throw new Mage_Core_Exception('Invalid request.'); - } - if (!$this->getRequest()->isPost() || !$this->getRequest()->getParam('form_key')) { Mage::throwException(Mage::helper('paypal')->__('Invalid form key')); } diff --git a/app/design/adminhtml/default/default/template/paypal/info.phtml b/app/design/adminhtml/default/default/template/paypal/info.phtml index b3edb3f0831..05ac82c0cd1 100644 --- a/app/design/adminhtml/default/default/template/paypal/info.phtml +++ b/app/design/adminhtml/default/default/template/paypal/info.phtml @@ -31,14 +31,12 @@ getPaymentInfo()): ?>
- +
getPaymentInfo() as $label => $value): ?> -
- - - +
escapeHtml($label) ?>
+
escapeHtml($value) ?>
-
escapeHtml($label) ?>:escapeHtml($value) ?>
+
@@ -56,13 +54,29 @@ margin-bottom: 10px; } - .paypal-payment-info table { - width: 100%; + .paypal-payment-info .payment-details { + margin: 0; } - .paypal-payment-info td:first-child { - width: 40%; + .paypal-payment-info dt { font-weight: bold; + display: inline; + color: #333; + } + + .paypal-payment-info dt:after { + content: ": "; + } + + .paypal-payment-info dd { + display: inline; + margin: 0; + color: #666; + } + + .paypal-payment-info dd:after { + content: "\A"; + white-space: pre; } .paypal-reauthorize { @@ -80,4 +94,4 @@ .paypal-method { margin-bottom: 10px; } - \ No newline at end of file + diff --git a/app/design/frontend/base/default/template/paypal/info.phtml b/app/design/frontend/base/default/template/paypal/info.phtml index 99af35d8923..f053dc3420d 100644 --- a/app/design/frontend/base/default/template/paypal/info.phtml +++ b/app/design/frontend/base/default/template/paypal/info.phtml @@ -15,4 +15,4 @@

escapeHtml($this->getMethod()->getTitle()) ?>

getTransactionId()): ?>

__('Transaction ID: %s', $this->escapeHtml($this->getTransactionId())) ?>

- \ No newline at end of file + diff --git a/app/design/frontend/base/default/template/paypal/payment.phtml b/app/design/frontend/base/default/template/paypal/payment.phtml index e7c7740ec7d..f0c9cd3813f 100644 --- a/app/design/frontend/base/default/template/paypal/payment.phtml +++ b/app/design/frontend/base/default/template/paypal/payment.phtml @@ -13,24 +13,21 @@ ?> \ No newline at end of file + new PayPalPayment( + $this->getFormKey(), + 'methodCode' => $this->getMethodCode(), + 'sdkUrl' => $this->getSdkUrl(), + 'buttonLayout' => $this->getButtonConfig()['layout'], + 'buttonColor' => $this->getButtonConfig()['color'], + 'buttonShape' => $this->getButtonConfig()['shape'], + 'buttonLabel' => $this->getButtonConfig()['label'], + 'buttonMessage' => (bool)$this->getButtonConfig()['message'], + 'createOrderUrl' => $this->getUrl('paypal/payment/create'), + 'captureUrl' => $this->getUrl('paypal/payment/process'), + 'placeOrderUrl' => $this->getUrl('paypal/payment/placeOrder'), + 'errorMessage' => $this->__('An error occurred while processing your payment. Please try again.'), + 'containerId' => 'paypal-button-container', + 'reviewButtonContainerId' => 'review-buttons-container' + ], JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP) ?>); + diff --git a/js/paypal/payment.js b/js/paypal/payment.js index 1fed53c0f29..0681d054ca3 100644 --- a/js/paypal/payment.js +++ b/js/paypal/payment.js @@ -11,53 +11,61 @@ * @license https://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ -/** - * Optimized PayPal payment integration - */ -var PayPalPayment = Class.create(); -PayPalPayment.prototype = { - initialize: function (config) { - this.config = config || {}; +class PayPalPayment { + constructor(config = {}) { + this.config = config; this.buttonInitialized = false; this.sdkLoaded = false; this.renderPromise = null; this.reviewContainerInterval = null; + this.abortController = new AbortController(); - document.readyState === 'loading' - ? document.observe('dom:loaded', this.onDOMReady.bind(this)) - : this.onDOMReady(); - }, + this.init(); + } - onDOMReady: function () { - this.setupPaymentMethodHandling(); - this.setupPaymentButtonHandling(); - this.checkAndInitialize(); - }, - - setupPaymentButtonHandling: function () { - const paymentButton = $$('button[onclick="payment.save()"]')[0]; - if (paymentButton) { - paymentButton.observe('click', () => { - if (this.getCurrentPaymentMethod() === this.config.methodCode) { - this.waitForReviewContainer().then(() => this.init()); - } + async init() { + if (document.readyState === 'loading') { + await new Promise(resolve => { + document.addEventListener('DOMContentLoaded', resolve, { once: true }); }); } - }, - waitForReviewContainer: function () { - return new Promise(resolve => { - if (this.reviewContainerInterval) { - clearInterval(this.reviewContainerInterval); - this.reviewContainerInterval = null; + this.setupEventListeners(); + this.checkAndInitialize(); + } + + setupEventListeners() { + this.setupPaymentMethodHandling(); + this.setupPaymentButtonHandling(); + } + + setupPaymentButtonHandling() { + const paymentButton = document.querySelector('button[onclick="payment.save()"]'); + if (!paymentButton) return; + + paymentButton.addEventListener('click', async () => { + if (this.getCurrentPaymentMethod() === this.config.methodCode) { + const container = await this.waitForReviewContainer(); + if (container) { + await this.initializePayPalButton(); + } } + }, { signal: this.abortController.signal }); + } - const maxAttempts = 100; - let attempts = 0; + async waitForReviewContainer() { + if (this.reviewContainerInterval) { + clearInterval(this.reviewContainerInterval); + this.reviewContainerInterval = null; + } + + const maxAttempts = 100; + let attempts = 0; + return new Promise(resolve => { const checkForContainer = () => { attempts++; - const reviewContainer = $(this.config.reviewButtonContainerId); + const reviewContainer = document.getElementById(this.config.reviewButtonContainerId); if (reviewContainer || attempts >= maxAttempts) { if (this.reviewContainerInterval) { @@ -70,37 +78,41 @@ PayPalPayment.prototype = { checkForContainer(); - if (!$(this.config.reviewButtonContainerId)) { + if (!document.getElementById(this.config.reviewButtonContainerId)) { this.reviewContainerInterval = setInterval(checkForContainer, 100); } }); - }, + } - checkAndInitialize: function () { - this.getCurrentPaymentMethod() === this.config.methodCode && this.init(); - }, + checkAndInitialize() { + if (this.getCurrentPaymentMethod() === this.config.methodCode) { + this.initializePayPalButton(); + } + } - getCurrentPaymentMethod: function () { - const checkedInput = $$('input[name="payment[method]"]:checked')[0]; - return checkedInput ? checkedInput.value : null; - }, + getCurrentPaymentMethod() { + const checkedInput = document.querySelector('input[name="payment[method]"]:checked'); + return checkedInput?.value ?? null; + } - init: function () { - if (this.buttonInitialized) return Promise.resolve(); + async initializePayPalButton() { + if (this.buttonInitialized) return; - return this.loadPayPalSDK() - .then(() => this.renderButton()) - .catch(() => { }); - }, + try { + await this.loadPayPalSDK(); + await this.renderButton(); + } catch (error) { + this.showError('Failed to load PayPal. Please try another payment method.'); + } + } + async loadPayPalSDK() { + if (typeof paypal !== 'undefined') { + this.sdkLoaded = true; + return; + } - loadPayPalSDK: function () { return new Promise((resolve, reject) => { - if (typeof paypal !== 'undefined') { - this.sdkLoaded = true; - return resolve(); - } - const script = document.createElement('script'); script.src = this.config.sdkUrl; script.async = true; @@ -108,275 +120,334 @@ PayPalPayment.prototype = { this.sdkLoaded = true; resolve(); }; - script.onerror = reject; - document.body.appendChild(script); + script.onerror = () => reject(new Error('Failed to load PayPal SDK')); + document.head.appendChild(script); }); - }, + } - renderButton: function () { - this.renderPromise = null; + async renderButton() { if (!this.sdkLoaded) { - return Promise.reject(new Error('SDK not loaded')); + throw new Error('PayPal SDK not loaded'); } - const reviewContainer = $(this.config.reviewButtonContainerId); + const reviewContainer = document.getElementById(this.config.reviewButtonContainerId); if (!reviewContainer) { - return Promise.reject(new Error('Review container not found')); + throw new Error('Review container not found'); } this.removePayPalButton(); - const checkoutButton = reviewContainer.down('button.btn-checkout'); - - const paypalContainer = new Element('div', { - 'id': this.config.containerId, - 'class': 'paypal-button-container', - 'style': 'margin: 0; min-height: 35px;' - }); + const checkoutButton = reviewContainer.querySelector('button.btn-checkout'); + const paypalContainer = this.createPayPalContainer(); if (!checkoutButton) { - reviewContainer.insert({ top: paypalContainer }); + reviewContainer.prepend(paypalContainer); } else { checkoutButton.remove(); - const pleaseWaitSpan = reviewContainer.down('span.please-wait'); - pleaseWaitSpan - ? pleaseWaitSpan.insert({ before: paypalContainer }) - : reviewContainer.insert({ top: paypalContainer }); - } + const pleaseWaitSpan = reviewContainer.querySelector('span.please-wait'); - return this.createPayPalButton(paypalContainer, reviewContainer); - }, - - createPayPalButton: function (paypalContainer, reviewContainer) { - this.renderPromise = new Promise((resolve, reject) => { - try { - const buttonWrapper = new Element('div', { 'class': 'paypal-button-wrapper' }); - paypalContainer.insert(buttonWrapper); - - paypal.Buttons({ - style: { - layout: this.config.buttonLayout || 'vertical', - color: this.config.buttonColor || 'gold', - shape: this.config.buttonShape || 'rect', - label: this.config.buttonLabel || 'paypal', - height: this.config.buttonHeight || 40 - }, - createOrder: () => this.createOrder(), - onApprove: data => this.onApprove(data), - onError: error => this.onButtonError(error), - onCancel: data => this.onCancel(data) - }).render(buttonWrapper) - .then(() => { - this.buttonInitialized = true; - resolve(); - }) - .catch(error => { - this.handleRenderError(error, reviewContainer, paypalContainer); - reject(error); - }); - } catch (error) { - this.handleRenderError(error, reviewContainer, paypalContainer); - reject(error); + if (pleaseWaitSpan) { + pleaseWaitSpan.before(paypalContainer); + } else { + reviewContainer.prepend(paypalContainer); } - }); - - return this.renderPromise; - }, + } - handleRenderError: function (error, reviewContainer, paypalContainer) { - if (paypalContainer && paypalContainer.parentNode) { - paypalContainer.remove(); + try { + await this.createPayPalButton(paypalContainer, reviewContainer); + } catch (error) { + this.handleRenderError(error, reviewContainer, paypalContainer); + throw error; } + } + + createPayPalContainer() { + const container = document.createElement('div'); + container.id = this.config.containerId; + container.className = 'paypal-button-container'; + container.style.cssText = 'margin: 0; min-height: 35px;'; + return container; + } + async createPayPalButton(paypalContainer, reviewContainer) { + const buttonWrapper = document.createElement('div'); + buttonWrapper.className = 'paypal-button-wrapper'; + paypalContainer.appendChild(buttonWrapper); + + await paypal.Buttons({ + style: { + layout: this.config.buttonLayout || 'vertical', + color: this.config.buttonColor || 'gold', + shape: this.config.buttonShape || 'rect', + label: this.config.buttonLabel || 'paypal', + height: parseInt(this.config.buttonHeight, 10) || 40 + }, + createOrder: () => this.createOrder(), + onApprove: (data) => this.onApprove(data), + onError: (error) => this.onButtonError(error), + onCancel: () => this.onCancel() + }).render(buttonWrapper); + + this.buttonInitialized = true; + } + + handleRenderError(error, reviewContainer, paypalContainer) { + paypalContainer?.remove(); this.recreateCheckoutButton(reviewContainer); this.buttonInitialized = false; - }, - - recreateCheckoutButton: function (reviewContainer) { - if (reviewContainer.down('button.btn-checkout')) return; - - const checkoutButton = new Element('button', { - 'type': 'submit', - 'title': 'Place Order', - 'class': 'button btn-checkout', - 'onclick': 'review.save();' - }).insert( - new Element('span').insert( - new Element('span').update('Place Order') - ) - ); - - const pleaseWaitSpan = reviewContainer.down('span.please-wait'); - pleaseWaitSpan - ? pleaseWaitSpan.insert({ before: checkoutButton }) - : reviewContainer.insert({ top: checkoutButton }); - }, - - createOrder: function () { + } + + recreateCheckoutButton(reviewContainer) { + if (reviewContainer.querySelector('button.btn-checkout')) return; + + const checkoutButton = document.createElement('button'); + checkoutButton.type = 'submit'; + checkoutButton.title = 'Place Order'; + checkoutButton.className = 'button btn-checkout'; + checkoutButton.onclick = () => review.save(); + + const span1 = document.createElement('span'); + const span2 = document.createElement('span'); + span2.textContent = 'Place Order'; + span1.appendChild(span2); + checkoutButton.appendChild(span1); + + const pleaseWaitSpan = reviewContainer.querySelector('span.please-wait'); + if (pleaseWaitSpan) { + pleaseWaitSpan.before(checkoutButton); + } else { + reviewContainer.prepend(checkoutButton); + } + } + + async createOrder() { this.showLoadingMask(); - return new Promise((resolve, reject) => { + try { if (!this.validateForm()) { - this.hideLoadingMask(); - return reject(new Error('Form validation failed')); + throw new Error('Form validation failed'); } - new Ajax.Request(this.config.createOrderUrl, { - method: 'post', - parameters: { form_key: this.config.formKey }, - onSuccess: response => { - const result = response.responseJSON; - result?.success && result.id - ? resolve(result.id) - : reject(new Error(result?.message || 'Failed to create PayPal order')); + + const response = await fetch(this.config.createOrderUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', }, - onFailure: () => reject(new Error('Failed to create PayPal order')), - onComplete: () => this.hideLoadingMask() + body: new URLSearchParams({ + form_key: this.config.formKey + }), + signal: this.abortController.signal }); - }); - }, - onApprove: function (data) { + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + const result = await response.json(); + + if (!result?.success || !result?.id) { + throw new Error(result?.message || 'Failed to create PayPal order'); + } + + return result.id; + } catch (error) { + console.error('Create order error:', error); + throw error; + } finally { + this.hideLoadingMask(); + } + } + + async onApprove(data) { this.showLoadingMask(); - return new Promise((resolve, reject) => { - new Ajax.Request(this.config.captureUrl, { - method: 'post', - parameters: { order_id: data.orderID, form_key: this.config.formKey }, - onSuccess: response => { - const result = response.responseJSON; - if (result?.success) { - this.submitPlaceOrderForm(data.orderID); - resolve(result); - } else { - this.showError(result?.message); - this.hideLoadingMask(); - reject(new Error('Payment capture failed')); - } + + try { + const response = await fetch(this.config.captureUrl, { + method: 'POST', + headers: { + 'Content-Type': 'application/x-www-form-urlencoded', }, - onFailure: () => { - this.showError(); - this.hideLoadingMask(); - reject(new Error('Payment capture failed')); - } + body: new URLSearchParams({ + order_id: data.orderID, + form_key: this.config.formKey + }), + signal: this.abortController.signal }); - }); - }, - submitPlaceOrderForm: function (orderId) { - const form = new Element('form', { - method: 'post', - action: this.config.placeOrderUrl, - style: 'display: none' - }); + if (!response.ok) { + throw new Error(`HTTP error! status: ${response.status}`); + } + + const result = await response.json(); + + if (!result?.success) { + throw new Error(result?.message || 'Payment capture failed'); + } + + this.submitPlaceOrderForm(data.orderID); + return result; + } catch (error) { + console.error('Payment approval error:', error); + this.showError(error.message); + throw error; + } + } + + submitPlaceOrderForm(orderId) { + const form = document.createElement('form'); + form.method = 'POST'; + form.action = this.config.placeOrderUrl; + form.style.display = 'none'; - form.insert(new Element('input', { - type: 'hidden', - name: 'id', - value: orderId - })); + const orderIdInput = document.createElement('input'); + orderIdInput.type = 'hidden'; + orderIdInput.name = 'id'; + orderIdInput.value = orderId; - form.insert(new Element('input', { - type: 'hidden', - name: 'form_key', - value: this.config.formKey - })); + const formKeyInput = document.createElement('input'); + formKeyInput.type = 'hidden'; + formKeyInput.name = 'form_key'; + formKeyInput.value = this.config.formKey; + form.append(orderIdInput, formKeyInput); document.body.appendChild(form); form.submit(); - }, + } - onButtonError: function () { - this.showError(); - }, + onButtonError(error) { + console.error('PayPal button error:', error); + this.showError('PayPal payment failed. Please try again or use another payment method.'); + } - onCancel: function () { + onCancel() { this.hideLoadingMask(); - }, + console.log('PayPal payment cancelled by user'); + } + + validateForm() { + const form = document.getElementById('firecheckout-form') || + document.getElementById('co-payment-form'); - validateForm: function () { - const form = $('firecheckout-form') || $('co-payment-form'); if (!form) return false; - const validator = new Validation(form); - return validator.validate(); - }, + const isValid = form.checkValidity(); + if (!isValid) { + form.reportValidity(); + } - setupPaymentMethodHandling: function () { - $$('input[name="payment[method]"]').each(input => { - input.observe('click', () => this.handlePaymentMethodChange(input.value)); - }); + if (typeof Validation !== 'undefined') { + const validator = new Validation(form); + return validator.validate() && isValid; + } - document.observe('payment-method:switched', event => { - const methodCode = event.memo?.method_code; - methodCode && this.handlePaymentMethodChange(methodCode); + return isValid; + } + + setupPaymentMethodHandling() { + const paymentInputs = document.querySelectorAll('input[name="payment[method]"]'); + + paymentInputs.forEach(input => { + input.addEventListener('change', () => { + this.handlePaymentMethodChange(input.value); + }, { signal: this.abortController.signal }); }); + document.addEventListener('payment-method:switched', (event) => { + const methodCode = event.detail?.method_code; + if (methodCode) { + this.handlePaymentMethodChange(methodCode); + } + }, { signal: this.abortController.signal }); + const currentMethod = this.getCurrentPaymentMethod(); - currentMethod && this.handlePaymentMethodChange(currentMethod); - }, + if (currentMethod) { + this.handlePaymentMethodChange(currentMethod); + } + } - handlePaymentMethodChange: function (selectedMethod) { - const reviewContainer = $(this.config.reviewButtonContainerId); + handlePaymentMethodChange(selectedMethod) { + const reviewContainer = document.getElementById(this.config.reviewButtonContainerId); if (!reviewContainer) return; this.buttonInitialized = false; reviewContainer.remove(); - }, + } - removePayPalButton: function () { - const container = $(this.config.containerId); + removePayPalButton() { + const container = document.getElementById(this.config.containerId); if (container) { container.remove(); this.buttonInitialized = false; } - }, + } + + showLoadingMask() { + let mask = document.getElementById('loading-mask'); - showLoadingMask: function () { - let mask = $('loading-mask'); if (!mask) { - mask = new Element('div', { - 'id': 'loading-mask', - 'class': 'loading-mask', - 'style': 'position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 9999; display: flex; align-items: center; justify-content: center;' - }).insert( - new Element('div', { - 'class': 'loading-mask-loader', - 'style': 'color: white; font-size: 18px;' - }).update('Processing...') - ); + mask = document.createElement('div'); + mask.id = 'loading-mask'; + mask.className = 'loading-mask'; + mask.style.cssText = ` + position: fixed; + top: 0; + left: 0; + width: 100%; + height: 100%; + background: rgba(0,0,0,0.5); + z-index: 9999; + display: flex; + align-items: center; + justify-content: center; + `; + + const loader = document.createElement('div'); + loader.className = 'loading-mask-loader'; + loader.style.cssText = 'color: white; font-size: 18px;'; + loader.textContent = 'Processing...'; + + mask.appendChild(loader); document.body.appendChild(mask); } - mask.show(); - }, - - hideLoadingMask: function () { - const mask = $('loading-mask'); - if (mask) mask.hide(); - }, - showError: function (message) { - const errorId = this.config.containerId + '-error'; - $(errorId)?.remove(); + mask.style.display = 'flex'; + } - const container = $(this.config.containerId); - if (container) { - const errorDiv = new Element('div', { - 'id': errorId, - 'class': 'paypal-error', - 'style': 'color: red; margin: 10px 0; padding: 10px; border: 1px solid red; background: #ffe6e6;' - }); - container.insert({ after: errorDiv }); - errorDiv.update(message || this.config.errorMessage || 'An error occurred. Please try again later.'); + hideLoadingMask() { + const mask = document.getElementById('loading-mask'); + if (mask) { + mask.style.display = 'none'; } - }, - - destroy: function () { + } - $$('input[name="payment[method]"]').each(input => { - input.stopObserving('click'); - }); + showError(message) { + const errorId = `${this.config.containerId}-error`; + const existingError = document.getElementById(errorId); + existingError?.remove(); + + const container = document.getElementById(this.config.containerId); + if (!container) return; + + const errorDiv = document.createElement('div'); + errorDiv.id = errorId; + errorDiv.className = 'paypal-error'; + errorDiv.style.cssText = ` + color: red; + margin: 10px 0; + padding: 10px; + border: 1px solid red; + background: #ffe6e6; + border-radius: 4px; + `; + errorDiv.textContent = message || this.config.errorMessage || 'An error occurred. Please try again later.'; + + container.after(errorDiv); + + setTimeout(() => errorDiv?.remove(), 10000); + } - const paymentButton = $$('button[onclick="payment.save()"]')[0]; - paymentButton?.stopObserving('click'); + destroy() { + this.abortController.abort(); if (this.reviewContainerInterval) { clearInterval(this.reviewContainerInterval); @@ -384,5 +455,12 @@ PayPalPayment.prototype = { } this.removePayPalButton(); + + const mask = document.getElementById('loading-mask'); + mask?.remove(); } -}; \ No newline at end of file +} + +if (typeof window !== 'undefined') { + window.PayPalPayment = PayPalPayment; +} \ No newline at end of file From 8ab11b01e402258ab10cae60c9144908fae4c4e1 Mon Sep 17 00:00:00 2001 From: hirale <22028058+hirale@users.noreply.github.com> Date: Mon, 23 Jun 2025 04:52:07 +0200 Subject: [PATCH 17/40] feat: add automated PayPal authorization lifecycle management --- .../core/Mage/Paypal/Block/Adminhtml/Info.php | 45 --- app/code/core/Mage/Paypal/Model/Config.php | 14 +- app/code/core/Mage/Paypal/Model/Cron.php | 301 ++++++++++++++++++ app/code/core/Mage/Paypal/Model/Payment.php | 104 +++--- app/code/core/Mage/Paypal/Model/Paypal.php | 3 +- .../core/Mage/Paypal/Model/Transaction.php | 30 ++ .../Paypal/TransactionController.php | 103 ------ app/code/core/Mage/Paypal/etc/config.xml | 12 + .../sql/paypal_setup/install-2.0.0.0.php | 22 ++ .../default/template/paypal/info.phtml | 9 - 10 files changed, 421 insertions(+), 222 deletions(-) create mode 100644 app/code/core/Mage/Paypal/Model/Cron.php delete mode 100644 app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php diff --git a/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php b/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php index a3ecdaa7f90..2eb2da9ce62 100644 --- a/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php +++ b/app/code/core/Mage/Paypal/Block/Adminhtml/Info.php @@ -82,49 +82,4 @@ protected function formatExpirationDate(string $expirationTime): string $date->setTimezone(new DateTimeZone($storeTimezone)); return $date->format('Y-m-d H:i:s'); } - - /** - * Determines if the payment can be reauthorized based on its method, authorization ID, and expiration/creation time. - * - * @return bool True if the payment can be reauthorized, false otherwise. - */ - public function canReauthorize(): bool - { - $payment = $this->getInfo(); - - if ( - $payment->getMethod() !== 'paypal' || - !$payment->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_AUTHORIZATION_ID) - ) { - return false; - } - - $expirationTime = $payment->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME); - if ($expirationTime) { - $now = new DateTime(); - $expDate = new DateTime($expirationTime); - $daysDiff = $now->diff($expDate)->days; - return $daysDiff <= 26; - } - - $authTime = $payment->getCreatedAt(); - $now = new DateTime(); - $authDate = new DateTime($authTime); - $daysDiff = $now->diff($authDate)->days; - - return $daysDiff >= 3; - } - - /** - * Generates the URL for reauthorizing the payment. - * - * @return string The reauthorization URL. - */ - public function getReauthorizeUrl(): string - { - return Mage::getUrl('*/paypal_transaction/reauthorize', [ - 'order_id' => $this->getInfo()->getOrder()->getId(), - '_secure' => true, - ]); - } } diff --git a/app/code/core/Mage/Paypal/Model/Config.php b/app/code/core/Mage/Paypal/Model/Config.php index 1dbffeb8941..6b5d5a65ce5 100644 --- a/app/code/core/Mage/Paypal/Model/Config.php +++ b/app/code/core/Mage/Paypal/Model/Config.php @@ -29,6 +29,7 @@ class Mage_Paypal_Model_Config extends Varien_Object public const BUTTON_LABEL_BUYNOW = 'buynow'; public const BUTTON_LABEL_PAY = 'pay'; public const BUTTON_LABEL_INSTALLMENT = 'installment'; + protected $_cachedCredentials = null; /** * Supported currencies for PayPal transactions @@ -70,12 +71,13 @@ class Mage_Paypal_Model_Config extends Varien_Object */ public function getApiCredentials(): array { - return [ - 'client_id' => $this->getConfigData('client_id'), - 'client_secret' => Mage::helper('core')->decrypt( - $this->getConfigData('client_secret'), - ), - ]; + if ($this->_cachedCredentials === null) { + $this->_cachedCredentials = [ + 'client_id' => $this->getConfigData('client_id'), + 'client_secret' => Mage::helper('core')->decrypt($this->getConfigData('client_secret')), + ]; + } + return $this->_cachedCredentials; } /** diff --git a/app/code/core/Mage/Paypal/Model/Cron.php b/app/code/core/Mage/Paypal/Model/Cron.php new file mode 100644 index 00000000000..380ab5fa835 --- /dev/null +++ b/app/code/core/Mage/Paypal/Model/Cron.php @@ -0,0 +1,301 @@ + + * @copyright Copyright (c) 2005-2024 Magento Inc. (https://www.magentocommerce.com) + * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) + * @link https://magento.com + */ +class Mage_Paypal_Model_Cron +{ + /** + * @var array + */ + protected $_emailAlerts = []; + + /** + * Main method to process PayPal authorization lifecycle + * + * @param Mage_Cron_Model_Schedule $schedule + * @return void + */ + public function processAuthorizationLifecycle($schedule) + { + $this->_emailAlerts = []; + + $transactions = $this->_getActivePayPalAuthorizations(); + + foreach ($transactions as $transaction) { + $this->_processTransaction($transaction); + } + if (!empty($this->_emailAlerts)) { + $this->_sendEmailAlerts(); + } + } + + /** + * Get active PayPal authorization transactions + */ + protected function _getActivePayPalAuthorizations(): Mage_Core_Model_Resource_Db_Collection_Abstract + { + return Mage::getModel('sales/order_payment_transaction')->getCollection() + ->join( + ['payment' => 'sales/order_payment'], + 'main_table.payment_id = payment.entity_id', + ['method', 'parent_id'], + ) + ->join( + ['order' => 'sales/order'], + 'payment.parent_id = order.entity_id', + ['increment_id', 'state', 'status', 'store_id'], + ) + ->addFieldToFilter('main_table.txn_type', Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH) + ->addFieldToFilter('main_table.is_closed', 0) + ->addFieldToFilter('payment.method', 'paypal') + ->addFieldToFilter('order.state', [ + 'in' => [ + Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, + ], + ]); + } + + /** + * Process individual transaction based on its age + * + * @param Mage_Sales_Model_Order_Payment_Transaction $transaction + * @return void + */ + protected function _processTransaction($transaction) + { + $order = Mage::getModel('sales/order')->load($transaction->getData('parent_id')); + $payment = $order->getPayment(); + + $hoursFromAuth = $this->_calculateHoursFromAuthorization($transaction); + $hoursUntilExpiry = $this->_calculateHoursUntilExpiry($transaction, $order->getStoreId()); + + if ($hoursUntilExpiry <= 0) { + // Authorization expired (29+ days) - close transaction + $this->_handleExpiredAuthorization($payment); + } elseif ($hoursUntilExpiry <= 72) { + // Within 3 days of expiration - send email alert + $this->_addExpirationAlert($order, $transaction, $hoursUntilExpiry); + } elseif ($hoursFromAuth >= 72 && !$this->_hasBeenReauthorized($transaction)) { + // Past honor period (3+ days) - attempt reauthorization + $this->_attemptReauthorization($order, $transaction); + } + } + + /** + * Calculate hours from authorization creation + * + * @param Mage_Sales_Model_Order_Payment_Transaction $transaction + * @return float + */ + protected function _calculateHoursFromAuthorization($transaction) + { + $authCreated = $transaction->getCreatedAt(); + $createdTimestamp = strtotime((string) $authCreated); + $nowTimestamp = time(); + + return ($nowTimestamp - $createdTimestamp) / 3600; + } + + /** + * Calculate hours until expiry with timezone conversion + * + * @param Mage_Sales_Model_Order_Payment_Transaction $transaction + * @param int $storeId + * @return float + */ + protected function _calculateHoursUntilExpiry($transaction, $storeId) + { + $additionalInfo = $transaction->getAdditionalInformation(); + $authExpiry = $additionalInfo[Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME] ?? null; + + if (!$authExpiry) { + $createdTimestamp = strtotime((string) $transaction->getCreatedAt()); + $expiryTimestamp = $createdTimestamp + (29 * 24 * 3600); + return ($expiryTimestamp - time()) / 3600; + } + $storeTimezone = Mage::app()->getStore($storeId)->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE); + $expiryDateTime = new DateTime($authExpiry, new DateTimeZone('UTC')); + $expiryDateTime->setTimezone(new DateTimeZone($storeTimezone)); + $nowDateTime = new DateTime('now', new DateTimeZone($storeTimezone)); + + return ($expiryDateTime->getTimestamp() - $nowDateTime->getTimestamp()) / 3600; + } + + /** + * Check if transaction has been reauthorized + * + * @param Mage_Sales_Model_Order_Payment_Transaction $transaction + * @return bool + */ + protected function _hasBeenReauthorized($transaction) + { + $additionalInfo = $transaction->getAdditionalInformation(); + return isset($additionalInfo[Mage_Paypal_Model_Payment::PAYPAL_PAYMENT_AUTHORIZATION_ID]) && $additionalInfo[Mage_Paypal_Model_Payment::PAYPAL_PAYMENT_AUTHORIZATION_ID]; + } + + /** + * Attempt to reauthorize payment after honor period + * + * @param Mage_Sales_Model_Order $order + * @param Mage_Sales_Model_Order_Payment_Transaction $transaction + * @return void + */ + protected function _attemptReauthorization($order, $transaction) + { + try { + $authorizationId = $transaction->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_AUTHORIZATION_ID); + if (!$authorizationId) { + return; + } + + $paypalModel = Mage::getModel('paypal/paypal'); + $result = $paypalModel->reauthorizePayment($authorizationId, $order); + + Mage::log([ + 'order_id' => $order->getIncrementId(), + 'old_auth_id' => $authorizationId, + 'new_auth_id' => $result, + 'message' => 'Auto-reauthorization successful', + ], Zend_Log::INFO, 'paypal_auto_reauth.log'); + } catch (Exception $e) { + Mage::logException($e); + $order->addStatusHistoryComment( + 'PayPal auto-reauthorization failed due to system error. Please check log and go to PayPal site to reauthorize manually.', + false, + )->save(); + } + } + + /** + * Add expiration alert to email queue + * + * @param Mage_Sales_Model_Order $order + * @param Mage_Sales_Model_Order_Payment_Transaction $transaction + * @param float $hoursUntilExpiry + * @return void + */ + protected function _addExpirationAlert($order, $transaction, $hoursUntilExpiry) + { + $daysUntilExpiry = round($hoursUntilExpiry / 24, 1); + + $this->_emailAlerts[] = [ + 'order' => $order, + 'transaction' => $transaction, + 'days_until_expiry' => $daysUntilExpiry, + 'hours_until_expiry' => $hoursUntilExpiry, + ]; + } + + /** + * Handle expired authorization (29+ days) + * + * @param Mage_Sales_Model_Order_Payment $payment + * @return void + */ + protected function _handleExpiredAuthorization($payment) + { + try { + $transactionModel = Mage::getSingleton('paypal/transaction'); + $transactionModel->updateExpiredTransaction($payment); + + $order = $payment->getOrder(); + $message = sprintf( + 'PayPal authorization %s has expired after 29 days. Transaction closed.', + $payment->getLastTransId(), + ); + + $order->setState( + Mage_Sales_Model_Order::STATE_HOLDED, + 'paypal_auth_expired', + $message, + false, + )->save(); + + Mage::log([ + 'order_id' => $order->getIncrementId(), + 'message' => 'Authorization expired and closed', + ], Zend_Log::WARN, 'paypal_expired_auth.log'); + } catch (Exception $e) { + Mage::logException($e); + } + } + + /** + * Send email alerts for orders approaching expiration + * + * @return void + */ + protected function _sendEmailAlerts() + { + $subject = 'PayPal Authorization Expiring Soon - Action Required'; + $body = $this->_buildAlertEmailBody(); + + $mail = Mage::getModel('core/email') + ->setToEmail(Mage::getStoreConfig('trans_email/ident_general/email')) + ->setToName(Mage::getStoreConfig('trans_email/ident_general/name')) + ->setFromEmail(Mage::getStoreConfig('trans_email/ident_general/email')) + ->setFromName(Mage::getStoreConfig('general/store_information/name')) + ->setSubject($subject) + ->setBody($body) + ->setType('text'); + + try { + $mail->send(); + } catch (Exception $e) { + Mage::logException($e); + } + } + + /** + * Build email body for expiration alerts + * + * @return string + */ + protected function _buildAlertEmailBody() + { + $body = "PayPal Authorization Expiration Alert\n"; + $body .= 'Generated: ' . date('Y-m-d H:i:s') . "\n"; + $body .= str_repeat('=', 50) . "\n\n"; + + $body .= "The following orders have PayPal authorizations expiring within 3 days:\n\n"; + foreach ($this->_emailAlerts as $alert) { + $order = $alert['order']; + $transaction = $alert['transaction']; + $orderNumber = $order->getIncrementId(); + $customerName = $order->getCustomerName(); + + $orderAmount = $order->getBaseCurrencyCode() . ' ' . number_format((float) $order->getGrandTotal(), 2); + $transactionId = $transaction->getTxnId(); + $daysRemaining = $alert['days_until_expiry']; + + $body .= 'Order: #' . $orderNumber . "\n"; + $body .= 'Customer: ' . $customerName . "\n"; + $body .= 'Amount: ' . $orderAmount . "\n"; + $body .= 'Transaction ID: ' . $transactionId . "\n"; + $body .= 'Expires in: ' . $daysRemaining . " days\n"; + $body .= "Action: CAPTURE PAYMENT IMMEDIATELY\n\n"; + } + $body .= str_repeat('=', 50) . "\n"; + $body .= "Note: Authorizations expire after 29 days and cannot be recovered.\n"; + $body .= "Capture payments as soon as possible to avoid losing the transaction.\n\n"; + + return $body . 'This is an automated alert from your PayPal payment system.'; + } +} diff --git a/app/code/core/Mage/Paypal/Model/Payment.php b/app/code/core/Mage/Paypal/Model/Payment.php index abeb4942ff1..5311f971078 100644 --- a/app/code/core/Mage/Paypal/Model/Payment.php +++ b/app/code/core/Mage/Paypal/Model/Payment.php @@ -26,6 +26,8 @@ class Mage_Paypal_Model_Payment extends Mage_Core_Model_Abstract public const PAYPAL_PAYMENT_STATUS = 'paypal_payment_status'; public const PAYPAL_PAYMENT_AUTHORIZATION_ID = 'paypal_payment_authorization_id'; public const PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME = 'paypal_payment_authorization_expires_time'; + public const PAYPAL_PAYMENT_AUTHORIZATION_REAUTHROIZED = 'paypal_payment_authorization_reauthorized'; + // Error messages private const ERROR_NO_AUTHORIZATION_ID = 'No authorization ID found. Cannot capture payment.'; @@ -78,67 +80,55 @@ public function authorizePayment(string $orderId, Mage_Sales_Model_Quote $quote) * * @param string $orderId PayPal order ID * @param Mage_Sales_Model_Order $order Magento order - * @return array{success: bool, authorization_id?: string, error?: string} + * @todo Waiting for test, after test, transaction and payment part should be moved to transaction manager */ - public function reauthorizePayment(string $orderId, Mage_Sales_Model_Order $order): array + public function reauthorizePayment(string $orderId, Mage_Sales_Model_Order $order): string { - try { - $api = $this->getHelper()->getApi(); - $response = $api->reAuthorizeOrder($orderId, $order); - $result = $response->getResult(); - - if ($response->isError()) { - $this->getHelper()->handleApiError($response, 'Reauthorization failed'); - } - - $authorization = $result->getPurchaseUnits()[0]->getPayments()->getAuthorizations()[0]; - $authorizationId = $authorization->getId(); - $expirationTime = $authorization->getExpirationTime(); - - $payment = $order->getPayment(); - $payment->setAdditionalInformation([ - self::PAYPAL_PAYMENT_STATUS => $authorization->getStatus(), - self::PAYPAL_PAYMENT_AUTHORIZATION_ID => $authorizationId, - self::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME => $expirationTime, - Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->getHelper()->prepareRawDetails($response->getBody()), - ])->getShouldCloseParentTransaction(); - $payment->save(); - - $transaction = $this->getTransactionManager()->getTransaction(); - $transaction->setOrderPaymentObject($payment) - ->setTxnId($authorizationId) - ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH) - ->setIsClosed(0) - ->setAdditionalInformation( - Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, - $this->getHelper()->prepareRawDetails($response->getBody()), - ); - $transaction->save(); - - $storeTimezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE); - $date = new DateTime($expirationTime, new DateTimeZone('UTC')); - $date->setTimezone(new DateTimeZone($storeTimezone)); - - $order->addStatusHistoryComment( - Mage::helper('paypal')->__( - 'PayPal payment has been reauthorized. New authorization ID: %s. Expires on: %s', - $authorizationId, - $date->format('Y-m-d H:i:s'), - ), - false, - )->save(); + $api = $this->getHelper()->getApi(); + $response = $api->reAuthorizeOrder($orderId, $order); + $result = $response->getResult(); - return [ - 'success' => true, - 'authorization_id' => $authorizationId, - ]; - } catch (Exception $e) { - Mage::logException($e); - return [ - 'success' => false, - 'error' => $e->getMessage(), - ]; + if ($response->isError()) { + $this->getHelper()->handleApiError($response, 'Reauthorization failed'); } + + $authorization = $result->getPurchaseUnits()[0]->getPayments()->getAuthorizations()[0]; + $authorizationId = $authorization->getId(); + $expirationTime = $authorization->getExpirationTime(); + + $payment = $order->getPayment(); + $payment->setAdditionalInformation([ + self::PAYPAL_PAYMENT_STATUS => $authorization->getStatus(), + self::PAYPAL_PAYMENT_AUTHORIZATION_ID => $authorizationId, + self::PAYPAL_PAYMENT_AUTHORIZATION_EXPIRATION_TIME => $expirationTime, + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS => $this->getHelper()->prepareRawDetails($response->getBody()), + ])->getShouldCloseParentTransaction(); + + $transaction = $this->getTransactionManager()->getTransaction(); + $transaction->setOrderPaymentObject($payment) + ->setTxnId($authorizationId) + ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH) + ->setIsClosed(0) + ->setAdditionalInformation(self::PAYPAL_PAYMENT_AUTHORIZATION_REAUTHROIZED, true) + ->setAdditionalInformation( + Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, + $this->getHelper()->prepareRawDetails($response->getBody()), + ); + $transaction->save(); + $payment->setLastTransId($transaction->getTxnId())->save(); + $storeTimezone = Mage::app()->getStore()->getConfig(Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE); + $date = new DateTime($expirationTime, new DateTimeZone('UTC')); + $date->setTimezone(new DateTimeZone($storeTimezone)); + + $order->addStatusHistoryComment( + Mage::helper('paypal')->__( + 'PayPal payment has been reauthorized. New authorization ID: %s. Expires on: %s', + $authorizationId, + $date->format('Y-m-d H:i:s'), + ), + false, + )->save(); + return $authorizationId; } /** diff --git a/app/code/core/Mage/Paypal/Model/Paypal.php b/app/code/core/Mage/Paypal/Model/Paypal.php index 988c2db4876..7de9eead1de 100644 --- a/app/code/core/Mage/Paypal/Model/Paypal.php +++ b/app/code/core/Mage/Paypal/Model/Paypal.php @@ -71,9 +71,8 @@ public function authorizePayment(string $orderId, Mage_Sales_Model_Quote $quote) * * @param string $orderId PayPal order ID * @param Mage_Sales_Model_Order $order Magento order - * @return array{success: bool, authorization_id?: string, error?: string} */ - public function reauthorizePayment(string $orderId, Mage_Sales_Model_Order $order): array + public function reauthorizePayment(string $orderId, Mage_Sales_Model_Order $order): string { return $this->getPaymentProcessor()->reauthorizePayment($orderId, $order); } diff --git a/app/code/core/Mage/Paypal/Model/Transaction.php b/app/code/core/Mage/Paypal/Model/Transaction.php index 964f9ac27f5..a0167ada6c6 100644 --- a/app/code/core/Mage/Paypal/Model/Transaction.php +++ b/app/code/core/Mage/Paypal/Model/Transaction.php @@ -226,6 +226,36 @@ public function updatePaymentAfterVoid(Varien_Object $payment): void ->setSkipTransactionCreation(true); } + /** + * Update expired transaction record + * + * @param Varien_Object $payment Payment object + */ + public function updateExpiredTransaction(Varien_Object $payment): void + { + $transaction = $this->getTransaction(); + $transactionId = $payment->getLastTransId() . '-expired'; + + /** + * @var Mage_Sales_Model_Order_Payment $payment + */ + $transaction->setOrderPaymentObject($payment) + ->setTxnId($transactionId) + ->setParentTxnId($payment->getTransactionId()) + ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID) + ->setIsClosed(1); + $transaction->save(); + $payment->setLastTransId($transactionId) + ->setAdditionalInformation(self::PAYPAL_PAYMENT_STATUS, 'EXPIRED') + ->save(); + + $parentTxn = $transaction->loadByTxnId($payment->getLastTransId()); + if ($parentTxn->getId()) { + $parentTxn->setIsClosed(1); + $parentTxn->save(); + } + } + /** * Get order payment transaction model * diff --git a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php b/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php deleted file mode 100644 index c15d807bf08..00000000000 --- a/app/code/core/Mage/Paypal/controllers/Adminhtml/Paypal/TransactionController.php +++ /dev/null @@ -1,103 +0,0 @@ -getRequest()->getParam('order_id'); - if (!$orderId) { - $this->_getSession()->addError($this->__('Order ID is required.')); - $this->_redirect('*/*/sales_order'); - return; - } - - try { - $order = $this->_loadOrder($orderId); - $payment = $order->getPayment(); - - $this->_validatePaymentMethod($payment); - - $authorizationId = $payment->getAdditionalInformation(Mage_Paypal_Model_Transaction::PAYPAL_PAYMENT_AUTHORIZATION_ID); - if (!$authorizationId) { - Mage::throwException($this->__('This order does not have a PayPal authorization.')); - } - - $result = $this->_getPaypalModel()->reauthorizePayment($authorizationId, $order); - - if (!empty($result['success'])) { - $this->_getSession()->addSuccess( - $this->__('Payment successfully reauthorized. New authorization ID: %s', $result['authorization_id']), - ); - } else { - Mage::throwException($result['error'] ?? $this->__('Failed to reauthorize payment.')); - } - } catch (Mage_Core_Exception $e) { - $this->_getSession()->addError($e->getMessage()); - } catch (Exception $e) { - Mage::logException($e); - $this->_getSession()->addError($this->__('An unexpected error occurred.')); - } - - $this->_redirect('*/sales_order/view', ['order_id' => $orderId]); - } - - /** - * Load order by ID or throw exception. - * - * @throws Mage_Core_Exception - */ - protected function _loadOrder(int $orderId): Mage_Sales_Model_Order - { - /** @var Mage_Sales_Model_Order $order */ - $order = Mage::getModel('sales/order')->load($orderId); - if (!$order->getId()) { - Mage::throwException($this->__('Order not found.')); - } - return $order; - } - - /** - * Validate if the payment method is PayPal. - * - * @throws Mage_Core_Exception - */ - protected function _validatePaymentMethod(Mage_Sales_Model_Order_Payment $payment): void - { - if ($payment->getMethod() !== self::PAYMENT_METHOD_CODE) { - Mage::throwException($this->__('This order was not placed using PayPal.')); - } - } - - /** - * Get PayPal model instance. - */ - protected function _getPaypalModel(): Mage_Paypal_Model_Paypal - { - return Mage::getModel('paypal/paypal'); - } - - /** - * Check controller permissions. - */ - protected function _isAllowed(): bool - { - return Mage::getSingleton('admin/session')->isAllowed('sales/order'); - } -} diff --git a/app/code/core/Mage/Paypal/etc/config.xml b/app/code/core/Mage/Paypal/etc/config.xml index 1c4254ca932..bc3f5bd20a8 100644 --- a/app/code/core/Mage/Paypal/etc/config.xml +++ b/app/code/core/Mage/Paypal/etc/config.xml @@ -139,4 +139,16 @@ + + + + + 0 */3 * * * + + + paypal/cron::processAuthorizationLifecycle + + + + \ No newline at end of file diff --git a/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php b/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php index 523f39bf70b..fd5b3a88bde 100644 --- a/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php +++ b/app/code/core/Mage/Paypal/sql/paypal_setup/install-2.0.0.0.php @@ -62,6 +62,9 @@ ->addIndex( $installer->getIdxName($debugTableName, ['increment_id']), ['increment_id'], + )->addIndex( + $installer->getIdxName($debugTableName, ['transaction_id']), + ['transaction_id'], ) ->addForeignKey( $installer->getFkName($debugTableName, 'quote_id', 'sales/quote', 'entity_id'), @@ -86,6 +89,25 @@ $installer->getTable('core_resource'), $installer->getConnection()->quoteInto('code = ?', 'paypaluk_setup'), ); +$status = 'paypal_auth_expired'; +$statusLabel = 'PayPal Authorization Expired'; + +$installer->getConnection()->insert( + $installer->getTable('sales/order_status'), + [ + 'status' => $status, + 'label' => $statusLabel, + ], +); + +$installer->getConnection()->insert( + $installer->getTable('sales/order_status_state'), + [ + 'status' => $status, + 'state' => Mage_Sales_Model_Order::STATE_HOLDED, + 'is_default' => 0, + ], +); $installer->getConnection()->delete( $installer->getTable('core/config_data'), diff --git a/app/design/adminhtml/default/default/template/paypal/info.phtml b/app/design/adminhtml/default/default/template/paypal/info.phtml index 05ac82c0cd1..3808d5d286d 100644 --- a/app/design/adminhtml/default/default/template/paypal/info.phtml +++ b/app/design/adminhtml/default/default/template/paypal/info.phtml @@ -39,15 +39,6 @@
- - canReauthorize()): ?> -
- -

__('PayPal authorizations expire after 3 days. Reauthorize to extend the authorization period.') ?>

-
-