Skip to content

Commit 8c6a861

Browse files
committed
fix: fix as tony suggests
1 parent 29247a9 commit 8c6a861

13 files changed

+716
-14
lines changed

app/code/core/Mage/Paypal/controllers/PaymentController.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,12 @@ public function placeOrderAction(): void
157157
break;
158158
}
159159
$this->_ignoreAddressValidation();
160-
$this->_quote->collectTotals();
160+
$this->_getQuote()->collectTotals();
161161
$session = $this->_getCheckoutSession();
162162
$service = Mage::getModel('sales/service_quote', $this->_getQuote());
163163

164164
$service->submitAll();
165-
$this->_quote->save();
165+
$this->_getQuote()->save();
166166
if ($isNewCustomer) {
167167
try {
168168
$this->_involveNewCustomer();
@@ -177,7 +177,7 @@ public function placeOrderAction(): void
177177
return;
178178
}
179179

180-
$quotePayment = $this->_quote->getPayment();
180+
$quotePayment = $this->_getQuote()->getPayment();
181181
$orderPayment = $order->getPayment();
182182
$orderPayment->setQuotePaymentId($quotePayment->getId())
183183
->setLastTransId($quotePayment->getPaypalCorrelationId());
@@ -235,8 +235,8 @@ public function placeOrderAction(): void
235235
}
236236

237237
$session->clearHelperData();
238-
$session->setLastQuoteId($this->_quote->getId())
239-
->setLastSuccessQuoteId($this->_quote->getId())
238+
$session->setLastQuoteId($this->_getQuote()->getId())
239+
->setLastSuccessQuoteId($this->_getQuote()->getId())
240240
->setLastOrderId($order->getId())
241241
->setLastRealOrderId($order->getIncrementId());
242242
$order->queueNewOrderEmail();
@@ -246,7 +246,7 @@ public function placeOrderAction(): void
246246
} catch (Exception $e) {
247247
Mage::logException($e);
248248

249-
Mage::helper('checkout')->sendPaymentFailedEmail($this->_quote, $e->getMessage());
249+
Mage::helper('checkout')->sendPaymentFailedEmail($this->_getQuote(), $e->getMessage());
250250
$session->addError($e->getMessage());
251251
$this->_redirect('checkout/cart');
252252
}
@@ -299,7 +299,7 @@ protected function _prepareGuestQuote(): self
299299
*/
300300
protected function _prepareNewCustomerQuote(): self
301301
{
302-
$quote = $this->_quote;
302+
$quote = $this->_getQuote();
303303
$billing = $quote->getBillingAddress();
304304
$shipping = $quote->isVirtual() ? null : $quote->getShippingAddress();
305305

@@ -429,7 +429,7 @@ protected function _lookupCustomerId(): ?int
429429
{
430430
return Mage::getModel('customer/customer')
431431
->setWebsiteId(Mage::app()->getWebsite()->getId())
432-
->loadByEmail($this->_quote->getCustomerEmail())
432+
->loadByEmail($this->_getQuote()->getCustomerEmail())
433433
->getId();
434434
}
435435

@@ -438,9 +438,9 @@ protected function _lookupCustomerId(): ?int
438438
*/
439439
private function _ignoreAddressValidation(): void
440440
{
441-
$this->_quote->getBillingAddress()->setShouldIgnoreValidation(true);
442-
if (!$this->_quote->getIsVirtual()) {
443-
$this->_quote->getShippingAddress()->setShouldIgnoreValidation(true);
441+
$this->_getQuote()->getBillingAddress()->setShouldIgnoreValidation(true);
442+
if (!$this->_getQuote()->getIsVirtual()) {
443+
$this->_getQuote()->getShippingAddress()->setShouldIgnoreValidation(true);
444444
}
445445
}
446446
/**
@@ -462,15 +462,15 @@ protected function _redirectLogin(): void
462462
*/
463463
protected function _involveNewCustomer(): self
464464
{
465-
$customer = $this->_quote->getCustomer();
465+
$customer = $this->_getQuote()->getCustomer();
466466
if ($customer->isConfirmationRequired()) {
467-
$customer->sendNewAccountEmail('confirmation', '', $this->_quote->getStoreId());
467+
$customer->sendNewAccountEmail('confirmation', '', $this->_getQuote()->getStoreId());
468468
$url = Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
469469
$this->_getCustomerSession()->addSuccess(
470470
Mage::helper('customer')->__('Account confirmation is required. Please, check your e-mail for confirmation link. To resend confirmation email please <a href="%s">click here</a>.', $url),
471471
);
472472
} else {
473-
$customer->sendNewAccountEmail('registered', '', $this->_quote->getStoreId());
473+
$customer->sendNewAccountEmail('registered', '', $this->_getQuote()->getStoreId());
474474
$this->_getCustomerSession()->loginById($customer->getId());
475475
}
476476
return $this;
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<?php
2+
3+
/**
4+
* @copyright For copyright and license information, read the COPYING.txt file.
5+
* @link /COPYING.txt
6+
* @license Open Software License (OSL 3.0)
7+
* @package Mage_Paypal
8+
*/
9+
10+
/** @var Mage_Paypal_Model_Resource_Setup $installer */
11+
$installer = $this;
12+
$installer->startSetup();
13+
14+
/**
15+
* Create table 'paypal/settlement_report'
16+
*/
17+
$table = $installer->getConnection()
18+
->newTable($installer->getTable('paypal/settlement_report'))
19+
->addColumn('report_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [
20+
'identity' => true,
21+
'unsigned' => true,
22+
'nullable' => false,
23+
'primary' => true,
24+
], 'Report Id')
25+
->addColumn('report_date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [
26+
], 'Report Date')
27+
->addColumn('account_id', Varien_Db_Ddl_Table::TYPE_TEXT, 64, [
28+
], 'Account Id')
29+
->addColumn('filename', Varien_Db_Ddl_Table::TYPE_TEXT, 24, [
30+
], 'Filename')
31+
->addColumn('last_modified', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [
32+
], 'Last Modified')
33+
->addIndex(
34+
$installer->getIdxName('paypal/settlement_report', ['report_date', 'account_id'], Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE),
35+
['report_date', 'account_id'],
36+
['type' => Varien_Db_Adapter_Interface::INDEX_TYPE_UNIQUE],
37+
)
38+
->setComment('Paypal Settlement Report Table');
39+
$installer->getConnection()->createTable($table);
40+
41+
/**
42+
* Create table 'paypal/settlement_report_row'
43+
*/
44+
$table = $installer->getConnection()
45+
->newTable($installer->getTable('paypal/settlement_report_row'))
46+
->addColumn('row_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [
47+
'identity' => true,
48+
'unsigned' => true,
49+
'nullable' => false,
50+
'primary' => true,
51+
], 'Row Id')
52+
->addColumn('report_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, [
53+
'unsigned' => true,
54+
'nullable' => false,
55+
], 'Report Id')
56+
->addColumn('transaction_id', Varien_Db_Ddl_Table::TYPE_TEXT, 19, [
57+
], 'Transaction Id')
58+
->addColumn('invoice_id', Varien_Db_Ddl_Table::TYPE_TEXT, 127, [
59+
], 'Invoice Id')
60+
->addColumn('paypal_reference_id', Varien_Db_Ddl_Table::TYPE_TEXT, 19, [
61+
], 'Paypal Reference Id')
62+
->addColumn('paypal_reference_id_type', Varien_Db_Ddl_Table::TYPE_TEXT, 3, [
63+
], 'Paypal Reference Id Type')
64+
->addColumn('transaction_event_code', Varien_Db_Ddl_Table::TYPE_TEXT, 5, [
65+
], 'Transaction Event Code')
66+
->addColumn('transaction_initiation_date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [
67+
], 'Transaction Initiation Date')
68+
->addColumn('transaction_completion_date', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [
69+
], 'Transaction Completion Date')
70+
->addColumn('transaction_debit_or_credit', Varien_Db_Ddl_Table::TYPE_TEXT, 2, [
71+
'nullable' => false,
72+
'default' => 'CR',
73+
], 'Transaction Debit Or Credit')
74+
->addColumn('gross_transaction_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '20,6', [
75+
'nullable' => false,
76+
'default' => '0.000000',
77+
], 'Gross Transaction Amount')
78+
->addColumn('gross_transaction_currency', Varien_Db_Ddl_Table::TYPE_TEXT, 3, [
79+
'default' => '',
80+
], 'Gross Transaction Currency')
81+
->addColumn('fee_debit_or_credit', Varien_Db_Ddl_Table::TYPE_TEXT, 2, [
82+
], 'Fee Debit Or Credit')
83+
->addColumn('fee_amount', Varien_Db_Ddl_Table::TYPE_DECIMAL, '20,6', [
84+
'nullable' => false,
85+
'default' => '0.000000',
86+
], 'Fee Amount')
87+
->addColumn('fee_currency', Varien_Db_Ddl_Table::TYPE_TEXT, 3, [
88+
], 'Fee Currency')
89+
->addColumn('custom_field', Varien_Db_Ddl_Table::TYPE_TEXT, 255, [
90+
], 'Custom Field')
91+
->addColumn('consumer_id', Varien_Db_Ddl_Table::TYPE_TEXT, 127, [
92+
], 'Consumer Id')
93+
->addIndex(
94+
$installer->getIdxName('paypal/settlement_report_row', ['report_id']),
95+
['report_id'],
96+
)
97+
->addForeignKey(
98+
$installer->getFkName('paypal/settlement_report_row', 'report_id', 'paypal/settlement_report', 'report_id'),
99+
'report_id',
100+
$installer->getTable('paypal/settlement_report'),
101+
'report_id',
102+
Varien_Db_Ddl_Table::ACTION_CASCADE,
103+
Varien_Db_Ddl_Table::ACTION_CASCADE,
104+
)
105+
->setComment('Paypal Settlement Report Row Table');
106+
$installer->getConnection()->createTable($table);
107+
108+
/**
109+
* Create table 'paypal/cert'
110+
*/
111+
$table = $installer->getConnection()
112+
->newTable($installer->getTable('paypal/cert'))
113+
->addColumn('cert_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [
114+
'identity' => true,
115+
'unsigned' => true,
116+
'nullable' => false,
117+
'primary' => true,
118+
], 'Cert Id')
119+
->addColumn('website_id', Varien_Db_Ddl_Table::TYPE_SMALLINT, null, [
120+
'unsigned' => true,
121+
'nullable' => false,
122+
'default' => '0',
123+
], 'Website Id')
124+
->addColumn('content', Varien_Db_Ddl_Table::TYPE_TEXT, '64K', [
125+
], 'Content')
126+
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, [
127+
], 'Updated At')
128+
->addIndex(
129+
$installer->getIdxName('paypal/cert', ['website_id']),
130+
['website_id'],
131+
)
132+
->addForeignKey(
133+
$installer->getFkName('paypal/cert', 'website_id', 'core/website', 'website_id'),
134+
'website_id',
135+
$installer->getTable('core/website'),
136+
'website_id',
137+
Varien_Db_Ddl_Table::ACTION_CASCADE,
138+
Varien_Db_Ddl_Table::ACTION_CASCADE,
139+
)
140+
->setComment('Paypal Certificate Table');
141+
$installer->getConnection()->createTable($table);
142+
143+
/**
144+
* Add paypal attributes to the:
145+
* - sales/flat_quote_payment_item table
146+
* - sales/flat_order table
147+
*/
148+
$installer->addAttribute('quote_payment', 'paypal_payer_id', []);
149+
$installer->addAttribute('quote_payment', 'paypal_payer_status', []);
150+
$installer->addAttribute('quote_payment', 'paypal_correlation_id', []);
151+
$installer->addAttribute('order', 'paypal_ipn_customer_notified', ['type' => 'int', 'visible' => false, 'default' => 0]);
152+
153+
/**
154+
* Prepare database after install
155+
*/
156+
$installer->endSetup();
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
/**
4+
* @copyright For copyright and license information, read the COPYING.txt file.
5+
* @link /COPYING.txt
6+
* @license Open Software License (OSL 3.0)
7+
* @package Mage_Paypal
8+
*/
9+
10+
/** @var Mage_Paypal_Model_Resource_Setup $installer */
11+
$installer = $this;
12+
$installer->startSetup();
13+
14+
$installer->run("
15+
16+
-- DROP TABLE IF EXISTS `{$this->getTable('paypal_api_debug')}`;
17+
CREATE TABLE `{$this->getTable('paypal_api_debug')}` (
18+
`debug_id` int(10) unsigned NOT NULL auto_increment,
19+
`debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
20+
`request_body` text,
21+
`response_body` text,
22+
PRIMARY KEY (`debug_id`),
23+
KEY `debug_at` (`debug_at`)
24+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
25+
26+
");
27+
28+
$installer->endSetup();
29+
30+
$installer->addAttribute('quote_payment', 'paypal_payer_id', []);
31+
$installer->addAttribute('quote_payment', 'paypal_payer_status', []);
32+
$installer->addAttribute('quote_payment', 'paypal_correlation_id', []);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/**
4+
* @copyright For copyright and license information, read the COPYING.txt file.
5+
* @link /COPYING.txt
6+
* @license Open Software License (OSL 3.0)
7+
* @package Mage_Paypal
8+
*/
9+
10+
/** @var Mage_Paypal_Model_Resource_Setup $installer */
11+
$installer = $this;
12+
$installer->startSetup();
13+
14+
$installer->run("
15+
CREATE TABLE `{$this->getTable('paypal_api_debug')}` (
16+
`debug_id` int(10) unsigned NOT NULL auto_increment,
17+
`debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
18+
`request_body` text,
19+
`response_body` text,
20+
PRIMARY KEY (`debug_id`),
21+
KEY `debug_at` (`debug_at`)
22+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
23+
24+
$installer->addAttribute('quote_payment', 'paypal_payer_id', []);
25+
$installer->addAttribute('quote_payment', 'paypal_payer_status', []);
26+
$installer->addAttribute('quote_payment', 'paypal_correlation_id', []);
27+
$installer->addAttribute('order', 'paypal_ipn_customer_notified', ['type' => 'int', 'visible' => false, 'default' => 0]);
28+
29+
$installer->endSetup();
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
/**
4+
* @copyright For copyright and license information, read the COPYING.txt file.
5+
* @link /COPYING.txt
6+
* @license Open Software License (OSL 3.0)
7+
* @package Mage_Paypal
8+
*/
9+
10+
/** @var Mage_Paypal_Model_Resource_Setup $installer */
11+
$installer = $this;
12+
$installer->startSetup();
13+
$installer->addAttribute('order', 'paypal_ipn_customer_notified', ['type' => 'int', 'visible' => false, 'default' => 0]);
14+
$installer->endSetup();
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/**
4+
* @copyright For copyright and license information, read the COPYING.txt file.
5+
* @link /COPYING.txt
6+
* @license Open Software License (OSL 3.0)
7+
* @package Mage_Paypal
8+
*/
9+
10+
/** @var Mage_Paypal_Model_Resource_Setup $installer */
11+
$installer = $this;
12+
$installer->startSetup();
13+
14+
$installer->addAttribute('order_payment', 'cc_secure_verify', []);
15+
16+
// move paypal style settings to new paths
17+
foreach ([
18+
'paypal/wpp/page_style' => 'paypal/style/page_style',
19+
'paypal/wps/logo_url' => 'paypal/style/logo_url',
20+
] as $from => $to
21+
) {
22+
$installer->run("
23+
UPDATE {$installer->getTable('core/config_data')} SET `path` = '{$to}'
24+
WHERE `path` = '{$from}'
25+
");
26+
}
27+
$installer->endSetup();

0 commit comments

Comments
 (0)