247119f646a9429826c2d9ee9eda603e - Version 1.0.1

Version Notes

Magento 1.9.x - Masterpass Plugin

Release Version : 1.0.1

Download this release

Release Info

Developer Kanchan
Extension 247119f646a9429826c2d9ee9eda603e
Version 1.0.1
Comparing to
See all releases


Version 1.0.1

Files changed (53) hide show
  1. app/code/local/MasterCard/Countriesmapping/etc/config.xml +37 -0
  2. app/code/local/MasterCard/Countriesmapping/sql/mastercard_countriesmapping_setup/directory_country_region.csv +55 -0
  3. app/code/local/MasterCard/Countriesmapping/sql/mastercard_countriesmapping_setup/mysql4-install-0.1.0.php +52 -0
  4. app/code/local/MasterCard/Masterpass/Block/Button.php +53 -0
  5. app/code/local/MasterCard/Masterpass/Block/Checkout/Checkout.php +47 -0
  6. app/code/local/MasterCard/Masterpass/Block/Checkout/Precheckout.php +308 -0
  7. app/code/local/MasterCard/Masterpass/Block/Checkout/Review/Details.php +30 -0
  8. app/code/local/MasterCard/Masterpass/Block/Checkout/Shipping.php +13 -0
  9. app/code/local/MasterCard/Masterpass/Block/Customer/Link.php +20 -0
  10. app/code/local/MasterCard/Masterpass/Block/Customer/Wrapper.php +31 -0
  11. app/code/local/MasterCard/Masterpass/Block/Onepage/Link.php +20 -0
  12. app/code/local/MasterCard/Masterpass/Block/Onepage/Links.php +19 -0
  13. app/code/local/MasterCard/Masterpass/Block/Onepage/Sidebar.php +22 -0
  14. app/code/local/MasterCard/Masterpass/Helper/Data.php +653 -0
  15. app/code/local/MasterCard/Masterpass/Model/Masterpass.php +175 -0
  16. app/code/local/MasterCard/Masterpass/Model/Mpservice/Connector.php +438 -0
  17. app/code/local/MasterCard/Masterpass/Model/Mpservice/Masterpassservice.php +357 -0
  18. app/code/local/MasterCard/Masterpass/Model/Observer.php +183 -0
  19. app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Acceptancemarksize.php +67 -0
  20. app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Acceptedcards.php +60 -0
  21. app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Buttonsize.php +51 -0
  22. app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Environment.php +40 -0
  23. app/code/local/MasterCard/Masterpass/Model/System/Config/Source/PaymentGateways.php +49 -0
  24. app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Transactionurl.php +38 -0
  25. app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Trueorfalse.php +40 -0
  26. app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Userflows.php +45 -0
  27. app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Xmlversion.php +36 -0
  28. app/code/local/MasterCard/Masterpass/controllers/IndexController.php +376 -0
  29. app/code/local/MasterCard/Masterpass/controllers/MasterpasspairingController.php +663 -0
  30. app/code/local/MasterCard/Masterpass/etc/adminhtml.xml +26 -0
  31. app/code/local/MasterCard/Masterpass/etc/config.xml +133 -0
  32. app/code/local/MasterCard/Masterpass/etc/system.xml +492 -0
  33. app/code/local/MasterCard/Masterpass/sql/mastercard_masterpass_setup/mysql4-install-0.1.0.php +32 -0
  34. app/design/frontend/rwd/default/layout/masterpass/masterpass.xml +211 -0
  35. app/design/frontend/rwd/default/template/masterpass/ajax/details.phtml +49 -0
  36. app/design/frontend/rwd/default/template/masterpass/ajax/shipping_method.phtml +82 -0
  37. app/design/frontend/rwd/default/template/masterpass/cart/button.phtml +12 -0
  38. app/design/frontend/rwd/default/template/masterpass/cart/buttonbottom.phtml +75 -0
  39. app/design/frontend/rwd/default/template/masterpass/customer/pair_after_register.phtml +65 -0
  40. app/design/frontend/rwd/default/template/masterpass/customer/wrapper.phtml +71 -0
  41. app/design/frontend/rwd/default/template/masterpass/onepage/checkout.phtml +96 -0
  42. app/design/frontend/rwd/default/template/masterpass/onepage/login.phtml +163 -0
  43. app/design/frontend/rwd/default/template/masterpass/onepage/shipping_form.phtml +140 -0
  44. app/design/frontend/rwd/default/template/masterpass/onepage/success.phtml +63 -0
  45. app/design/frontend/rwd/default/template/masterpass/precheckout/pairWallet.phtml +108 -0
  46. app/design/frontend/rwd/default/template/masterpass/precheckout/precheckout.phtml +514 -0
  47. app/design/frontend/rwd/default/template/masterpass/precheckout/shipping.phtml +127 -0
  48. app/design/frontend/rwd/default/template/masterpass/precheckout/shipping_method.phtml +106 -0
  49. app/design/frontend/rwd/default/template/masterpass/review/details.phtml +49 -0
  50. app/etc/modules/MasterCard_Countriesmapping.xml +9 -0
  51. app/etc/modules/MasterCard_Masterpass.xml +9 -0
  52. package.xml +47 -0
  53. skin/frontend/rwd/default/css/masterpass/masterpassclient.css +178 -0
app/code/local/MasterCard/Countriesmapping/etc/config.xml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ To change this license header, choose License Headers in Project Properties.
4
+ To change this template file, choose Tools | Templates
5
+ and open the template in the editor.
6
+ -->
7
+ <config>
8
+ <modules>
9
+ <MasterCard_Countriesmapping>
10
+ <version>0.1.0</version>
11
+ </MasterCard_Countriesmapping>
12
+ </modules>
13
+ <global>
14
+ <resources>
15
+ <mastercard_countriesmapping_setup>
16
+ <setup>
17
+ <module>MasterCard_Countriesmapping</module>
18
+ <class>Mage_Customer_Model_Entity_Setup</class>
19
+ </setup>
20
+ <connection>
21
+ <use>core_setup</use>
22
+ </connection>
23
+ </mastercard_countriesmapping_setup>
24
+ <mastercard_countriesmapping_write>
25
+ <connection>
26
+ <use>core_write</use>
27
+ </connection>
28
+ </mastercard_countriesmapping_write>
29
+ <mastercard_countriesmapping_read>
30
+ <connection>
31
+ <use>core_read</use>
32
+ </connection>
33
+ </mastercard_countriesmapping_read>
34
+ </resources>
35
+ </global>
36
+
37
+ </config>
app/code/local/MasterCard/Countriesmapping/sql/mastercard_countriesmapping_setup/directory_country_region.csv ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ AU,ACT,Australia Capital Territory
2
+ AU,NSW,New South Wales
3
+ AU,NT,Northern Territory
4
+ AU,QLD,Queensland
5
+ AU,SA,South Australia
6
+ AU,TAS,Tasmania
7
+ AU,VIC,Victoria
8
+ AU,WA,Western Australia
9
+ JP,23,Aichi
10
+ JP,5,Akita
11
+ JP,2,Aomori
12
+ JP,12,Chiba
13
+ JP,38,Ehime
14
+ JP,18,Fukui
15
+ JP,40,Fukuoka
16
+ JP,7,Fukushima
17
+ JP,21,Gifu
18
+ JP,10,Gunma
19
+ JP,34,Hiroshima
20
+ JP,1,Hokkaido
21
+ JP,28,Hyogo
22
+ JP,8,Ibaraki
23
+ JP,17,Ishikawa
24
+ JP,3,Iwate
25
+ JP,37,Kagawa
26
+ JP,46,Kagoshima
27
+ JP,14,Kanagawa
28
+ JP,39,Kochi
29
+ JP,43,Kumamoto
30
+ JP,26,Kyoto
31
+ JP,24,Mie
32
+ JP,4,Miyagi
33
+ JP,45,Miyazaki
34
+ JP,20,Nagano
35
+ JP,42,Nagasaki
36
+ JP,29,Nara
37
+ JP,15,Niigata
38
+ JP,44,Oita
39
+ JP,33,Okayama
40
+ JP,47,Okinawa
41
+ JP,27,Osaka
42
+ JP,41,Saga
43
+ JP,11,Saitama
44
+ JP,25,Shiga
45
+ JP,32,Shimane
46
+ JP,22,Shizuoka
47
+ JP,9,Tochigi
48
+ JP,36,Tokushima
49
+ JP,13,Tokyo
50
+ JP,31,Tottori
51
+ JP,16,Toyama
52
+ JP,30,Wakayama
53
+ JP,6,Yamagata
54
+ JP,35,Yamaguchi
55
+ JP,19,Yamanashi
app/code/local/MasterCard/Countriesmapping/sql/mastercard_countriesmapping_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this license header, choose License Headers in Project Properties.
5
+ * To change this template file, choose Tools | Templates
6
+ * and open the template in the editor.
7
+ */
8
+ $installer = $this;
9
+
10
+ $installer->startSetup();
11
+
12
+ $setup = new Mage_Eav_Model_Entity_Setup('core_setup');
13
+ $installer->run("
14
+ DELETE FROM `{$this->getTable('directory_country_region')}` WHERE country_id = 'AU';"); // remove Australia's states
15
+ $installer->run("
16
+ DELETE FROM `{$this->getTable('directory_country_region')}` WHERE country_id = 'JP';"); // remove Japan's states
17
+
18
+
19
+ $regionfile = dirname(__FILE__) . '/directory_country_region.csv';
20
+
21
+
22
+ $arr=array();
23
+ $row = -1;
24
+ $i=0;
25
+ if (($handle = fopen($regionfile, "r")) !== FALSE) {
26
+ while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
27
+ $num = count($data);
28
+
29
+ $row++;
30
+ for ($c = 0; $c < $num; $c++) {
31
+ $arr[$row][$c]= $data[$c];
32
+
33
+ }
34
+
35
+ $i++;
36
+ }
37
+ fclose($handle);
38
+
39
+ foreach ($arr as $data){
40
+ if(is_numeric($data[1]) && strlen($data[1])<2){
41
+ $code = '0'.$data[1];
42
+ }else{
43
+ $code = $data[1];
44
+ }
45
+ $regionValue = "('".$data[0]."','".$code."','".$data[2]."')";
46
+
47
+ $installer->run("INSERT INTO {$this->getTable('directory_country_region')} (country_id, code, default_name) VALUES ". $regionValue . ";");
48
+ }
49
+ }
50
+
51
+
52
+ $installer->endSetup();
app/code/local/MasterCard/Masterpass/Block/Button.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Developer: Pavith Lovan
5
+ */
6
+
7
+ class MasterCard_Masterpass_Block_Button extends Mage_Core_Block_Template {
8
+
9
+ //checkout type
10
+ const EXPRESS_CHECKOUT = '3';
11
+ const CONNECTED_CHECKOUT = '2';
12
+ const STANDARD_CHECKOUT = '1';
13
+
14
+ protected function _construct() {
15
+
16
+ parent::_construct();
17
+ }
18
+
19
+ // checkout if user flow is set to express
20
+ public function checkUserFlows() {
21
+ if (Mage::helper('masterpass')->isMasterpassEnabled()) {
22
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
23
+ if (Mage::getStoreConfig('masterpass/config/userflows') == self::CONNECTED_CHECKOUT || Mage::getStoreConfig('masterpass/config/userflows') == self::EXPRESS_CHECKOUT) {
24
+ return true;
25
+ } elseif (Mage::getStoreConfig('masterpass/config/userflows') == self::STANDARD_CHECKOUT) {
26
+ return false;
27
+ }
28
+ } else {
29
+ if ($this->getQuote()->isAllowedGuestCheckout()) {
30
+ return false;
31
+ } else {
32
+ return true;
33
+ }
34
+ }
35
+ } else {
36
+ return false;
37
+ }
38
+ }
39
+
40
+ public function walletIsPaired() {
41
+ return Mage::helper('masterpass')->checkWallet();
42
+ }
43
+
44
+ public function getQuote() {
45
+ return Mage::getSingleton('checkout/session')->getQuote();
46
+ }
47
+
48
+ //if digital product
49
+ public function digitalItem() {
50
+ return $this->getQuote()->isVirtual();
51
+ }
52
+
53
+ }
app/code/local/MasterCard/Masterpass/Block/Checkout/Checkout.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Developer: Pavith Lovan
5
+ */
6
+ /*
7
+ * To change this template, choose Tools | Templates
8
+ * and open the template in the editor.
9
+ */
10
+
11
+ class MasterCard_Masterpass_Block_Checkout_Checkout extends Mage_Checkout_Block_Onepage_Abstract {
12
+
13
+ public function _construct() {
14
+
15
+ $this->setMasterpasscheckoutUrl(Mage::getUrl('', array('_secure' => true)) . "masterpass/index/placeorder/");
16
+
17
+ parent::_construct();
18
+ }
19
+
20
+ public function getBilling() {
21
+ return $this->getQuote()->getBillingAddress();
22
+ }
23
+
24
+ public function getShipping() {
25
+ return $this->getQuote()->getShippingAddress();
26
+ }
27
+
28
+ public function getPaymentHtml() {
29
+ return $this->getChildHtml('payment_info');
30
+ }
31
+ public function getAddress() {
32
+ if (is_null($this->_address)) {
33
+ if ($this->isCustomerLoggedIn()) {
34
+ $this->_address = $this->getQuote()->getShippingAddress();
35
+ } else {
36
+ $ship = $this->getQuote()->getShippingAddress();
37
+ $ship_country = $ship->getCountryId();
38
+ if (!empty($ship_country))
39
+ $this->_address = $ship;
40
+ else
41
+ $this->_address = Mage::getModel('sales/quote_address');
42
+ }
43
+ }
44
+
45
+ return $this->_address;
46
+ }
47
+ }
app/code/local/MasterCard/Masterpass/Block/Checkout/Precheckout.php ADDED
@@ -0,0 +1,308 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Developer: Pavith Lovan
5
+ */
6
+ /*
7
+ * To change this template, choose Tools | Templates
8
+ * and open the template in the editor.
9
+ */
10
+
11
+ class MasterCard_Masterpass_Block_Checkout_Precheckout extends Mage_Checkout_Block_Cart_Totals {
12
+
13
+ public $cards;
14
+ public $address;
15
+ public $reward;
16
+ public $profile;
17
+ public $longaccesstoken;
18
+ public $walletname;
19
+ public $precheckoutTransactionId;
20
+ public $consumerWalletId;
21
+ public $masterpassImage;
22
+ public $partnerLogo;
23
+
24
+ /**
25
+ * @var Mage_Sales_Model_Quote
26
+ */
27
+ protected $_quote = null;
28
+
29
+ /**
30
+ * @var Mage_Sales_Model_Quote_Address
31
+ */
32
+ protected $_shippingAddress = null;
33
+
34
+ /**
35
+ * Currently selected shipping rate.
36
+ *
37
+ * @var Mage_Sales_Model_Quote_Address_Rate
38
+ */
39
+ protected $_currentShippingRate = null;
40
+
41
+ public function _construct() {
42
+ if (Mage::getStoreConfig('masterpass/config/userflows') == '2') {
43
+ $this->setPostexpresscheckout("");
44
+ } elseif (Mage::getStoreConfig('masterpass/config/userflows') == '3') {
45
+ $this->setPostexpresscheckout(Mage::getUrl('', array('_secure' => true)) . "masterpass/masterpasspairing/placeorder");
46
+ }
47
+ parent::_construct();
48
+ }
49
+
50
+ public function getPrecheckoutdata() {
51
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
52
+ $lonAccessToken = $customer->getData('longtoken');
53
+ $result = false;
54
+ if ($lonAccessToken) {
55
+ try {
56
+
57
+ $preCheckoutData = Mage::helper('masterpass')->postPreCheckoutData($lonAccessToken);
58
+
59
+ if (!empty($preCheckoutData)) {
60
+
61
+ if (Mage::getStoreConfig('masterpass/config/cfcard')) {
62
+ $this->cards = $preCheckoutData->PrecheckoutData->Cards;
63
+ if (!$this->cards) {
64
+ //save long access token
65
+ Mage::helper('masterpass')->removeMpLongaccesstoken();
66
+ }
67
+ }
68
+ if (Mage::getStoreConfig('masterpass/config/cfprofile')) {
69
+ $this->profile = $preCheckoutData->PrecheckoutData->Contact;
70
+ }
71
+ if (Mage::getStoreConfig('masterpass/config/cfaddress')) {
72
+ $this->address = $preCheckoutData->PrecheckoutData->ShippingAddresses;
73
+ }
74
+ if (Mage::getStoreConfig('masterpass/config/exreward')) {
75
+ $this->reward = $preCheckoutData->PrecheckoutData->RewardPrograms;
76
+ }
77
+ $this->masterpassImage = $preCheckoutData->MasterpassLogoUrl;
78
+ $this->partnerLogo = $preCheckoutData->WalletPartnerLogoUrl;
79
+ // store partner logo for order confirmation page
80
+ Mage::getSingleton('core/session')->setPartnerLogo(htmlentities($preCheckoutData->WalletPartnerLogoUrl));
81
+
82
+ $this->longaccesstoken = $preCheckoutData->LongAccessToken;
83
+ $this->walletname = $preCheckoutData->PrecheckoutData->WalletName;
84
+ $this->precheckoutTransactionId = $preCheckoutData->PrecheckoutData->PrecheckoutTransactionId;
85
+ $this->consumerWalletId = $preCheckoutData->PrecheckoutData->ConsumerWalletId;
86
+
87
+ $result = true;
88
+ } else {
89
+ return false;
90
+ }
91
+ } catch (Exception $e) {
92
+ Mage::log($e->getMessage());
93
+ //remove longaccesstoken
94
+ Mage::helper('masterpass')->removeMpLongaccesstoken();
95
+
96
+ Mage::getSingleton('core/session')->addError(Mage::getStoreConfig('masterpass/config/checkouterrormessage'));
97
+ $domain = Mage::getUrl('', array(
98
+ '_secure' => true
99
+ ));
100
+ $url = $domain . "checkout/onepage/";
101
+ Mage::app()->getFrontController()->getResponse()->setRedirect($url);
102
+ }
103
+ }
104
+ return $result;
105
+ }
106
+
107
+ public function getLongToken() {
108
+ return $this->longaccesstoken;
109
+ }
110
+
111
+ public function getPreCheckoutTranId() {
112
+ return $this->precheckoutTransactionId;
113
+ }
114
+
115
+ public function getConWalletId() {
116
+ return $this->consumerWalletId;
117
+ }
118
+
119
+ public function partnerLogo() {
120
+ return $this->partnerLogo;
121
+ }
122
+
123
+ public function masterPassLogo() {
124
+ return $this->masterpassImage;
125
+ }
126
+
127
+ public function getWalletName() {
128
+ return $this->walletname;
129
+ }
130
+
131
+ public function connectedCallBackUrl() {
132
+ return Mage::getUrl('', array('_secure' => true)) . "masterpass/masterpasspairing/connectedcheckout";
133
+ }
134
+
135
+ public function getPreCards() {
136
+ if (!empty($this->cards)) {
137
+
138
+ $cards = json_decode(json_encode((array) $this->cards), 1);
139
+ if (is_array($cards) && !empty($cards['Card'][0])) {
140
+ return $cards['Card'];
141
+ } else {
142
+ return $cards;
143
+ }
144
+ } else {
145
+ return null;
146
+ }
147
+ }
148
+
149
+ //get shipping address list
150
+ public function getPreAddress() {
151
+ //check if it's a virtual product
152
+ $quote = $this->getQuote();
153
+
154
+ if (!$quote->getIsVirtual()) {
155
+
156
+ if (!empty($this->address)) {
157
+ $address = json_decode(json_encode((array) $this->address), 1);
158
+ Mage::getSingleton('customer/session')->setPreaddress($address);
159
+ if (is_array($address) && !empty($address['ShippingAddress'][0])) {
160
+ return $address['ShippingAddress'];
161
+ } else {
162
+ return $address;
163
+ }
164
+ } else {
165
+ return null;
166
+ }
167
+ } else {
168
+ return null;
169
+ }
170
+ }
171
+
172
+ //set default shippping address
173
+ public function mpShippingAddress() {
174
+ $shipping = array();
175
+ if (!empty($this->address)) {
176
+ $address = json_decode(json_encode((array) $this->address), 1);
177
+
178
+ if (is_array($address) && !empty($address['ShippingAddress'][0])) {
179
+ $shipping = $address['ShippingAddress'][0];
180
+ } else {
181
+ $shipping = $address['ShippingAddress'];
182
+ }
183
+ }
184
+
185
+ $shippingAdd = Mage::getSingleton('checkout/type_onepage');
186
+
187
+ $name = explode(' ', $shipping['RecipientName']);
188
+ if ($name[1] == '') {
189
+ $name[1] = $name[0];
190
+ }
191
+ //check address line2
192
+ if (!is_array($shipping['Line2'])) {
193
+ $lin2 = $shipping['Line2'];
194
+ } else {
195
+ $lin2 = '';
196
+ }
197
+ $mpData = Mage::getModel('masterpass/masterpass');
198
+
199
+ // get shipping address
200
+
201
+ $regionIdS = $this->checkMasterpassData($mpData->statesMapping($shipping['CountrySubdivision']));
202
+ $regionS = $this->checkMasterpassData($mpData->getMasterpassRegion($shipping['CountrySubdivision']));
203
+ $shippingPhone = $mpData->getRemoveDash($this->checkMasterpassData($shipping['RecipientPhoneNumber']));
204
+ $data = array(
205
+ 'firstname' => $name[0],
206
+ 'lastname' => $name[1],
207
+ 'street' => array(0 => $shipping['Line1'], 1 => $lin2),
208
+ 'city' => $shipping['City'],
209
+ 'region_id' => $regionIdS,
210
+ 'region' => $regionS,
211
+ 'postcode' => $shipping['PostalCode'],
212
+ 'country_id' => $shipping['Country'],
213
+ 'telephone' => $shippingPhone
214
+ );
215
+
216
+ $shippingAdd->saveShipping($data, null);
217
+ }
218
+
219
+ public function getPreProfile() {
220
+ if (!empty($this->profile)) {
221
+ $profile = json_decode(json_encode((array) $this->profile), 1);
222
+ if (is_array($profile)) {
223
+ return $profile;
224
+ } else {
225
+ return $profile;
226
+ }
227
+ } else {
228
+ return null;
229
+ }
230
+ }
231
+
232
+ public function getPreReward() {
233
+ if (!empty($this->reward)) {
234
+ $reward = json_decode(json_encode((array) $this->reward), 1);
235
+ if (is_array($reward) && !empty($reward['RewardProgram'][0])) {
236
+ return $reward['RewardProgram'];
237
+ } else {
238
+ return $reward;
239
+ }
240
+ } else {
241
+ return null;
242
+ }
243
+ }
244
+
245
+ /**
246
+ * Get checkout quote object.
247
+ *
248
+ * @return Mage_Sales_Model_Quote
249
+ */
250
+ public function getQuote() {
251
+ if ($this->_quote === null) {
252
+ $this->_quote = Mage::getSingleton("checkout/session")->getQuote();
253
+ }
254
+ return $this->_quote;
255
+ }
256
+
257
+ /**
258
+ * Get shipping address from quote.
259
+ * Returns null if the quote only contains virtual products.
260
+ *
261
+ * @return Mage_Sales_Model_Quote_Address
262
+ */
263
+ public function canbeShipped() {
264
+ if ($this->getQuote()->isVirtual()) {
265
+ return false;
266
+ } else {
267
+ return true;
268
+ }
269
+ // return $this->getQuote()->getShippingAddress();
270
+ }
271
+
272
+ public function acceptanceMark() {
273
+ return '<img src="https://www.mastercard.com/mc_us/wallet/img/en/US/mp_mc_acc_' . Mage::getStoreConfig('masterpass/config/acceptancemark') . '_gif.gif" alt=" MasterPass Checkout"/>';
274
+ }
275
+
276
+ protected function _beforeToHtml() {
277
+
278
+
279
+ $quote = $this->getQuote();
280
+
281
+ if ($quote->getIsVirtual()) {
282
+ $this->setShippingRateRequired(false);
283
+ } else {
284
+ $this->setShippingRateRequired(true);
285
+
286
+ // misc shipping parameters
287
+ $this->setShippingMethodSubmitUrl($this->getUrl("masterpass/masterpasspairing/saveShippingMethod"))
288
+ ->setCanEditShippingAddress(false) // MasterPass doesn't let the customer return to edit details at present.
289
+ ->setCanEditShippingMethod(true); // MasterPass doesn't support handling shipping methods at present, so this must always be true.
290
+ }
291
+
292
+ $this->setPlaceOrderUrl($this->getUrl("masterpass/masterpasspairing/placeOrder"));
293
+
294
+ return parent::_beforeToHtml();
295
+ }
296
+
297
+ public function checkMasterpassData($mpData) {
298
+ if (!is_array($mpData)) {
299
+ $mpAfterCheck = $mpData;
300
+ } else {
301
+ $mpAfterCheck = '';
302
+ }
303
+ return $mpAfterCheck;
304
+ }
305
+
306
+ }
307
+
308
+ ?>
app/code/local/MasterCard/Masterpass/Block/Checkout/Review/Details.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class MasterCard_Masterpass_Block_Checkout_Review_Details extends Mage_Checkout_Block_Cart_Totals
5
+ {
6
+ protected $_address = null;
7
+
8
+ /**
9
+ * Get shipping address from quote.
10
+ *
11
+ * @return Mage_Sales_Model_Order_Address
12
+ */
13
+ public function getAddress()
14
+ {
15
+ if ($this->_address === null) {
16
+ $this->_address = $this->getQuote()->getShippingAddress();
17
+ }
18
+ return $this->_address;
19
+ }
20
+
21
+ /**
22
+ * Return review quote totals.
23
+ *
24
+ * @return array
25
+ */
26
+ public function getTotals()
27
+ {
28
+ return $this->getQuote()->getTotals();
29
+ }
30
+ }
app/code/local/MasterCard/Masterpass/Block/Checkout/Shipping.php ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MasterCard_Masterpass_Block_Checkout_Shipping extends Mage_Checkout_Block_Onepage_Shipping {
4
+
5
+ public function getAddress() {
6
+ if (is_null($this->_address)) {
7
+ $this->_address = Mage::helper('masterpass')-> returnAddress();
8
+ }
9
+
10
+ return $this->_address;
11
+ }
12
+
13
+ }
app/code/local/MasterCard/Masterpass/Block/Customer/Link.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ Pavith Lovan
5
+ */
6
+
7
+ class MasterCard_Masterpass_Block_Customer_Link extends Mage_Core_Block_Template {
8
+
9
+ public function addProfileLink() {
10
+ $private_key = Mage::helper('masterpass')->checkPrivateKey();
11
+ if ($private_key) {
12
+ if (Mage::helper('masterpass')->isMasterpassEnabled() && Mage::helper('masterpass')->isExpressEnabled()) {
13
+ $navigation = $this->getParentBlock();
14
+
15
+ $navigation->addLink('masterpass', 'masterpass/masterpasspairing', $this->__("Connect With MasterPass"), array('_secure' => true));
16
+ }
17
+ }
18
+ }
19
+
20
+ }
app/code/local/MasterCard/Masterpass/Block/Customer/Wrapper.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ // Pavith Lovan
5
+ */
6
+
7
+ class MasterCard_Masterpass_Block_Customer_Wrapper extends Mage_Core_Block_Template {
8
+
9
+ public function getPairingButton() {
10
+ if (Mage::getStoreConfig('masterpass/config/enabled')) {
11
+ return true;
12
+ } else {
13
+ return false;
14
+ }
15
+ }
16
+
17
+ public function pairingcallbackUrl() {
18
+ return Mage::getUrl('', array('_secure' => true)) . "masterpass/masterpasspairing/pairingcallback";
19
+ }
20
+
21
+ public function isWalletPaired() {
22
+ return Mage::helper('masterpass')->checkWallet();
23
+ }
24
+
25
+ public function pairingData() {
26
+ $pairingData = Mage::helper('masterpass')->pairingDataTypes();
27
+ $pairingData = explode(',', $pairingData);
28
+ return $pairingData;
29
+ }
30
+
31
+ }
app/code/local/MasterCard/Masterpass/Block/Onepage/Link.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MasterCard_Masterpass_Block_Onepage_Link extends Mage_Checkout_Block_Onepage_Link {
4
+
5
+ public function getCheckoutUrl() {
6
+ //check if customer already paired wallet with masterpass
7
+
8
+ if (!$this->helper('masterpass')->isMasterpassEnabled()) {
9
+ return parent::getCheckoutUrl();
10
+ }
11
+ $masterpass_CheckoutUrl = Mage::helper('masterpass')->getMasterpassCheckoutUrl();
12
+
13
+ if ($masterpass_CheckoutUrl!=null) {
14
+ return $this->getUrl($masterpass_CheckoutUrl, array('_secure' => true));
15
+ }else{
16
+ return parent::getCheckoutUrl();
17
+ }
18
+ }
19
+
20
+ }
app/code/local/MasterCard/Masterpass/Block/Onepage/Links.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MasterCard_Masterpass_Block_Onepage_Links extends Mage_Checkout_Block_Onepage_Link {
4
+
5
+ public function getCheckoutUrl() {
6
+ return $this->getUrl('checkout/onepage', array('_secure' => true));
7
+ }
8
+
9
+ /**
10
+ * Add link on checkout page to parent block
11
+ *
12
+ * @return Mage_Checkout_Block_Links
13
+ */
14
+ public function addCheckoutLink() {
15
+
16
+ return $this;
17
+ }
18
+
19
+ }
app/code/local/MasterCard/Masterpass/Block/Onepage/Sidebar.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MasterCard_Masterpass_Block_Onepage_Sidebar extends Mage_Checkout_Block_Cart_Sidebar
3
+ {
4
+
5
+ public function getCheckoutUrl()
6
+ {
7
+
8
+ //check if customer already paired wallet with masterpass
9
+
10
+
11
+ if (!$this->helper('masterpass')->isMasterpassEnabled()) {
12
+ return parent::getCheckoutUrl();
13
+ }
14
+ $masterpass_CheckoutUrl = Mage::helper('masterpass')->getMasterpassCheckoutUrl();
15
+
16
+ if ($masterpass_CheckoutUrl!=null) {
17
+ return $this->getUrl($masterpass_CheckoutUrl, array('_secure' => true));
18
+ }else{
19
+ return parent::getCheckoutUrl();
20
+ }
21
+ }
22
+ }
app/code/local/MasterCard/Masterpass/Helper/Data.php ADDED
@@ -0,0 +1,653 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Developer: Pavith Lovan
5
+ */
6
+
7
+ class MasterCard_Masterpass_Helper_Data extends Mage_Core_Helper_Abstract {
8
+
9
+ public $service;
10
+ public $appData;
11
+ public $xmlVersion;
12
+
13
+ //checkout type
14
+ const EXPRESS_CHECKOUT = '3';
15
+ const CONNECTED_CHECKOUT = '2';
16
+ //card types
17
+ const DINERS = 'diners';
18
+ const MASTER = 'master';
19
+ const VISA = 'visa';
20
+ const MAESTRO = 'maestro';
21
+ const DISCOVER = 'discover';
22
+ const AMEX = 'amex';
23
+ const OTHER = 'OT'; // other type can be use for private label card
24
+
25
+ public function __construct() {
26
+
27
+ // masterpass api version
28
+ $this->xmlVersion = Mage::getStoreConfig('masterpass/config/masterpassxml');
29
+
30
+ $this->service = Mage::getModel('masterpass/mpservice_masterpassservice');
31
+ }
32
+
33
+ // check if MasterPass is enabled
34
+ public function isMasterpassEnabled() {
35
+ $checkPv_key = $this->checkPrivateKey();
36
+
37
+ if (Mage::getStoreConfig('masterpass/config/enabled') && $checkPv_key) {
38
+ return true;
39
+ } else {
40
+ return false;
41
+ }
42
+ }
43
+
44
+ public function isExpressEnabled() {
45
+ if (Mage::getStoreConfig('masterpass/config/userflows') == self::CONNECTED_CHECKOUT || Mage::getStoreConfig('masterpass/config/userflows') == self::EXPRESS_CHECKOUT) {
46
+ return true;
47
+ } else {
48
+ return false;
49
+ }
50
+ }
51
+
52
+ //get recipien name
53
+ public function getRecipienName($reecipientName) {
54
+ $name = explode(' ', $reecipientName);
55
+ if ($name[1] == '') {
56
+ $name[1] = $name[0];
57
+ }
58
+ return $name;
59
+ }
60
+
61
+ public function checkIfSensitiveRequest(Mage_Core_Controller_Request_Http $request) {
62
+
63
+ if ($request->getRequestedRouteName() == "masterpass") {
64
+ return false;
65
+ } else {
66
+ return true;
67
+ }
68
+ }
69
+ //check masterpass wallet status
70
+ public function checkWallet(){
71
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
72
+ $customerData = Mage::getModel('customer/customer')->load($customer->getId());
73
+ $longtoken = $customerData->getData('longtoken');
74
+
75
+ // check if wallet is unpaired
76
+ if ($longtoken) {
77
+ $preCheckoutData = $this->postPreCheckoutData($longtoken);
78
+
79
+ if (empty($preCheckoutData)) {
80
+ $this->removeMpLongaccesstoken();
81
+ $longtoken = null;
82
+ }
83
+ }
84
+ if (!empty($longtoken)) {
85
+ return true;
86
+ } else {
87
+ return false;
88
+ }
89
+ }
90
+ public function checkMasterpassData($mpData) {
91
+ if (!is_array($mpData)) {
92
+ $mpAfterCheck = $mpData;
93
+ } else {
94
+ $mpAfterCheck = '';
95
+ }
96
+ return $mpAfterCheck;
97
+ }
98
+ //return address
99
+ public function returnAddress() {
100
+ $_address = null;
101
+ if ($this->isCustomerLoggedIn()) {
102
+ $_address = $this->getQuote()->getShippingAddress();
103
+ } else {
104
+ $ship = $this->getQuote()->getShippingAddress();
105
+ $ship_country = $ship->getCountryId();
106
+ if (!empty($ship_country))
107
+ $_address = $ship;
108
+ else
109
+ $_address = Mage::getModel('sales/quote_address');
110
+ }
111
+ Mage::log("return address " . $_address);
112
+
113
+ return $_address;
114
+ }
115
+
116
+ // make sure all session is unset
117
+ public function resetMasterData() {
118
+
119
+ Mage::getSingleton('core/session')->unsProfileName();
120
+ Mage::getSingleton('core/session')->unsPrecheckout();
121
+ Mage::getSingleton('checkout/session')->unsMasterPassCard();
122
+ Mage::getSingleton('checkout/session')->unsPostBackData();
123
+ Mage::getSingleton('checkout/session')->unsCardMask();
124
+ Mage::getSingleton('customer/session')->unsPreaddress();
125
+ }
126
+
127
+ //validate privatekey password
128
+ public function checkPrivateKey() {
129
+ $keystore = Mage::getModel('masterpass/mpservice_connector')->merchantPrivateKey();
130
+
131
+ if ($keystore['pkey']) {
132
+ return true;
133
+ } else {
134
+ Mage::log('Invalid private key password');
135
+ return false;
136
+ }
137
+ }
138
+
139
+ //remove existing long eccesstokem
140
+ public function removeMpLongaccesstoken() {
141
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
142
+ $customerData = Mage::getModel('customer/customer')->load($customer->getId());
143
+ $longAccessToken = null;
144
+ $customerData->setData('longtoken', $longAccessToken);
145
+
146
+ $customerData->save();
147
+ return $this;
148
+ }
149
+
150
+ // request masterpass token
151
+
152
+ public function getMasterpassToken() {
153
+ $module_path = Mage::getModuleDir('', 'MasterCard_Masterpass');
154
+
155
+ $prefix = 'https://';
156
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
157
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment') . ".";
158
+ $consumerKey = Mage::helper('core')->decrypt(Mage::getStoreConfig('masterpass/config/sbconsumerkey'));
159
+ } else {
160
+ $consumerKey = Mage::helper('core')->decrypt(Mage::getStoreConfig('masterpass/config/prconsumerkey'));
161
+ }
162
+
163
+ $requestUrl = $prefix . "api.mastercard.com/oauth/consumer/v1/request_token";
164
+ $callbackUrl = Mage::getUrl('', array('_secure' => true)) . "masterpass/index/callback";
165
+ try {
166
+ $requestToken = $this->service->GetRequestToken($requestUrl, $callbackUrl);
167
+
168
+ return $requestToken;
169
+ } catch (Exception $e) {
170
+ Mage::log($e->getMessage());
171
+
172
+ return $requestToken = null;
173
+ }
174
+ }
175
+
176
+ /* get magento shopping */
177
+
178
+ public function getShoppingCart() {
179
+
180
+ $cart = Mage::getSingleton('checkout/session')->getQuote();
181
+ // Number of items
182
+ $numberOfItems = $cart->getItemsCount();
183
+ $requestToken = null;
184
+
185
+ $xml_cart = '';
186
+ if ($numberOfItems > 0 && isset($this->getMasterpassToken()->requestToken)) {
187
+ $requestToken = $this->getMasterpassToken()->requestToken;
188
+
189
+ $xml_cart = "<?xml version=\"1.0\"?><ShoppingCartRequest><OAuthToken>" . $requestToken . "</OAuthToken><ShoppingCart>";
190
+
191
+ $currencyCode = $cart->getGlobalCurrencyCode();
192
+
193
+ $xml_cart .= "<CurrencyCode>" . $currencyCode . "</CurrencyCode>";
194
+ $subTotal = $cart->getGrandTotal();
195
+ $subTotal = $subTotal * 100;
196
+ $xml_cart .= "<Subtotal>" . $subTotal . "</Subtotal>";
197
+
198
+ $all_items = $cart->getAllVisibleItems();
199
+ $generic_error_message = Mage::getStoreConfig('masterpass/config/checkouterrormessage');
200
+
201
+ foreach ($all_items as $item) {
202
+ $xml_cart .= "<ShoppingCartItem>";
203
+ $productId = $item->getProductId();
204
+ $productPrice = $item->getPrice();
205
+ $description = htmlentities($item->getName());
206
+ $value = $item->getPrice();
207
+
208
+ $quantity = $item->getQty();
209
+ $value = $value * $quantity;
210
+ $value = $value * 100;
211
+ $imageUrl = htmlentities(Mage::helper('catalog/image')->init($item->getProduct(), 'thumbnail'));
212
+ $xml_cart .= "<Description>" . $description . "</Description><Quantity>" . $quantity . "</Quantity><Value>" . $value . "</Value><ImageURL>" . $imageUrl . "</ImageURL>";
213
+ $xml_cart .= "</ShoppingCartItem>";
214
+ }
215
+ // if coupon
216
+ $discount = $cart->getTotals();
217
+ if (isset($discount['discount'])) {
218
+
219
+ $discountAmount = $discount['discount']->getValue() * 100;
220
+ $discountAmount = $discountAmount; //*-1;
221
+ if (isset($discountAmount)) {
222
+ $xml_cart .= '<ShoppingCartItem><Description>Discount</Description><Quantity>1</Quantity><Value>' . $discountAmount . '</Value><ImageURL></ImageURL></ShoppingCartItem>';
223
+ }
224
+ }
225
+ $xml_cart .= "</ShoppingCart><OriginUrl>" . Mage::getBaseUrl() . "</OriginUrl></ShoppingCartRequest>";
226
+
227
+ return $xml_cart;
228
+ } else {
229
+ return $requestToken;
230
+ }
231
+ }
232
+
233
+ // post shopping cart to MasterPass
234
+ public function postShoppingCart() {
235
+
236
+ $shoppingCartRequest = $this->getShoppingCart();
237
+
238
+ if (!empty($shoppingCartRequest)) {
239
+ $prefix = 'https://';
240
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
241
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment') . ".";
242
+ $consumerKey = Mage::helper('core')->decrypt(Mage::getStoreConfig('masterpass/config/sbconsumerkey'));
243
+ }
244
+ $shoppingCartUrl = $prefix . "api.mastercard.com/masterpass/" . $this->xmlVersion . "/shopping-cart";
245
+
246
+ try {
247
+ $service = Mage::getModel('masterpass/mpservice_masterpassservice');
248
+ $shoppingCartResponse = $service->postShoppingCartData($shoppingCartUrl, $shoppingCartRequest);
249
+ $data = simplexml_load_string($shoppingCartResponse);
250
+ $data = json_decode(json_encode((array) $data), 1);
251
+ return $data['OAuthToken'];
252
+ } catch (Exception $e) {
253
+ Mage::log($e->getMessage());
254
+ return null;
255
+ }
256
+ } else {
257
+ return null;
258
+ }
259
+ }
260
+
261
+ public function acceptedCards() {
262
+ $acceptedCards = Mage::getStoreConfig('masterpass/config/acceptedcards');
263
+ $privateLabel = Mage::getStoreConfig('masterpass/config/privatelabel');
264
+ if ($privateLabel) {
265
+ $acceptedCards = $acceptedCards . ',' . $privateLabel;
266
+ }
267
+ return $acceptedCards;
268
+ }
269
+
270
+ public function getMerchantSettings() {
271
+ if (Mage::getStoreConfig('masterpass/config/requestbasiccheckout') == 'true') {
272
+ $basicchk = '1';
273
+ } else {
274
+ $basicchk = '';
275
+ }
276
+ $data = array('checkout_id' => '',
277
+ 'suppressShipping' => '',
278
+ 'loyaltyEnabled' => Mage::getStoreConfig('masterpass/config/rewards'),
279
+ 'loyaltyProgram' => Mage::getStoreConfig('masterpass/config/loyaltyprogram'),
280
+ 'requestBasicCheckout' => $basicchk,
281
+ 'version' => Mage::getStoreConfig('masterpass/config/masterpassxml'));
282
+
283
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
284
+ $data['checkout_id'] = Mage::helper('core')->decrypt(Mage::getStoreConfig('masterpass/config/sbcheckoutidentifier'));
285
+ } else {
286
+ $data['checkout_id'] = Mage::helper('core')->decrypt(Mage::getStoreConfig('masterpass/config/prcheckoutidentifier'));
287
+ }
288
+ if ($this->getQuote()->isVirtual()) {
289
+ $data['suppressShipping'] = 'true';
290
+ } else {
291
+ if (Mage::getStoreConfig('masterpass/config/shippingsuppression') == 'true') {
292
+ $data['suppressShipping'] = 'true';
293
+ } else {
294
+ $data['suppressShipping'] = 'false';
295
+ }
296
+ }
297
+ $data['loyaltyEnabled'] = Mage::getStoreConfig('masterpass/config/rewards');
298
+ return $data;
299
+ }
300
+
301
+ public function getQuote() {
302
+ return Mage::getSingleton('checkout/session')->getQuote();
303
+ }
304
+
305
+ // get access token from masterpass
306
+ public function getAccessToken($requestToken, $requestVerifier) {
307
+
308
+
309
+ $prefix = 'https://';
310
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
311
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment') . ".";
312
+ }
313
+ $accessUrl = $prefix . "api.mastercard.com/oauth/consumer/v1/access_token";
314
+
315
+ try {
316
+ $getAccessToken = $this->service->GetAccessToken($accessUrl, $requestToken, $requestVerifier);
317
+ return $getAccessToken;
318
+ } catch (Exception $e) {
319
+ Mage::log($e->getMessage());
320
+ return null;
321
+ }
322
+ }
323
+
324
+ public function getCheckoutData($checkoutResourceUrl, $accessToken) {
325
+ $checkoutObject = $this->service->GetPaymentShippingResource($checkoutResourceUrl, $accessToken);
326
+
327
+ return $checkoutObject;
328
+ }
329
+
330
+ /**
331
+ *
332
+ * Used to format the Errors XML for display
333
+ *
334
+ * @return formatted error message
335
+ */
336
+ // Used to format the Error XML for display
337
+ public function formatError($errorMessage) {
338
+ if (preg_match(Connector::ERRORS_TAG, $errorMessage) > 0) {
339
+ $errorMessage = $this->formatXML($errorMessage);
340
+ }
341
+ return $errorMessage;
342
+ }
343
+
344
+ // formate xml
345
+ public function formatXML($resources) {
346
+ if ($resources != null) {
347
+ $dom = new DOMDocument;
348
+ $dom->preserveWhiteSpace = FALSE;
349
+ $dom->loadXML($resources);
350
+ $dom->formatOutput = TRUE;
351
+ $resources = $dom->saveXml();
352
+
353
+ $resources = htmlentities($resources);
354
+ }
355
+ return $resources;
356
+ }
357
+
358
+ //******************************EXPRESS CHECKOUT ********************************************
359
+ // express call back url
360
+ public function expresscallBackurl() {
361
+ return Mage::getUrl('', array('_secure' => true)) . "masterpass/index/expresscallback";
362
+ }
363
+
364
+ public function postMerchantInitData() {
365
+ $pairingToken = $this->getMasterpassToken()->requestToken;
366
+ if ($pairingToken) {
367
+ $merchantInitRequest = $this->parseMerchantInitXML($pairingToken);
368
+
369
+ $prefix = 'https://';
370
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
371
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment') . ".";
372
+ }
373
+ $merchantInitUrl = $prefix . "api.mastercard.com/masterpass/" . $this->xmlVersion . "/merchant-initialization";
374
+
375
+ $merchantInitResponse = $this->service->postMerchantInitData($merchantInitUrl, $merchantInitRequest);
376
+ $merchantInitResponse = simplexml_load_string($merchantInitResponse);
377
+ $merchantInitResponse = json_decode(json_encode((array) $merchantInitResponse), 1);
378
+ return $merchantInitResponse['OAuthToken'];
379
+ } else {
380
+ return false;
381
+ }
382
+ }
383
+
384
+ public function parseMerchantInitXML($pairingToken) {
385
+
386
+ $originUrl = Mage::getUrl('', array('_secure' => true));
387
+ $merchantInitData = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><MerchantInitializationRequest><OAuthToken>' . $pairingToken . '</OAuthToken><PreCheckoutTransactionId/><OriginUrl>' . $originUrl . '</OriginUrl></MerchantInitializationRequest>';
388
+
389
+ return $merchantInitData;
390
+ }
391
+
392
+ //masterpass checkout url
393
+ public function getMasterpassCheckoutUrl() {
394
+ //check if customer already paired wallet with masterpass
395
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
396
+ $lonAccessToken = $customer->getData('longtoken');
397
+
398
+ $url = null;
399
+ if (!empty($lonAccessToken) && Mage::getStoreConfig('masterpass/config/userflows') == self::CONNECTED_CHECKOUT) {
400
+ $url = 'masterpass/masterpasspairing/precheckout';
401
+ } elseif (!empty($lonAccessToken) && Mage::getStoreConfig('masterpass/config/userflows') == self::EXPRESS_CHECKOUT) {
402
+ $url = 'masterpass/masterpasspairing/precheckout';
403
+ }
404
+ return $url;
405
+ }
406
+
407
+ public function pairingDataTypes() {
408
+ $pairingDataType = ''; //["CARD,PROFILE,ADDRESS,REWARD_PROGRAM"],
409
+ if (Mage::getStoreConfig('masterpass/config/cfcard')) {
410
+ $pairingDataType .= 'CARD,';
411
+ }
412
+ if (Mage::getStoreConfig('masterpass/config/cfprofile')) {
413
+ $pairingDataType .= 'PROFILE,';
414
+ }
415
+ if (Mage::getStoreConfig('masterpass/config/cfaddress')) {
416
+ $pairingDataType .= 'ADDRESS,';
417
+ }
418
+ if (Mage::getStoreConfig('masterpass/config/exreward')) {
419
+ $pairingDataType .= 'REWARD_PROGRAM,';
420
+ }
421
+ $pairingDataType = substr($pairingDataType, 0, -1);
422
+ return $pairingDataType;
423
+ }
424
+
425
+ public function requestExpressCheckout() {
426
+ $xpr = 'false';
427
+ if (Mage::getStoreConfig('masterpass/config/userflows') == self::EXPRESS_CHECKOUT) {
428
+ $xpr = 'true';
429
+ }
430
+ return $xpr;
431
+ }
432
+
433
+ public function postPreCheckoutData($longAccessToken) {
434
+ $preCheckoutRequest = $this->parsePrecheckoutXml();
435
+ $prefix = 'https://';
436
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
437
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment') . ".";
438
+ }
439
+ $preCheckoutUrl = $prefix . "api.mastercard.com/masterpass/" . $this->xmlVersion . "/precheckout";
440
+
441
+ try {
442
+ $preCheckoutResponse = $this->service->getPreCheckoutData($preCheckoutUrl, $preCheckoutRequest, $longAccessToken);
443
+
444
+ // Special syntax for working with SimpleXMLElement objects
445
+ $preCheckoutResponse = simplexml_load_string($preCheckoutResponse);
446
+
447
+ if(Mage::getStoreConfig ( 'masterpass/config/userflows' ) == self::EXPRESS_CHECKOUT)
448
+ {
449
+ $this->requestToken = $this->postMerchantInitData();
450
+ Mage::getSingleton('core/session')->setExpToken($this->requestToken);
451
+ }
452
+ if ($preCheckoutResponse != null) {
453
+ $this->saveLongToken ( $preCheckoutResponse->LongAccessToken );
454
+ return $preCheckoutResponse;
455
+ }
456
+
457
+ } catch (Exception $e) {
458
+ Mage::log($e->getMessage());
459
+
460
+ }
461
+ }
462
+
463
+ protected function saveLongToken($longToken) {
464
+ //save long access token
465
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
466
+ $customerData = Mage::getModel('customer/customer')->load($customer->getId());
467
+ $customerData->setData('longtoken', $longToken);
468
+ try {
469
+ $customerData->save();
470
+ } catch (Exception $e) {
471
+ Mage::log($e->getMessage());
472
+ }
473
+ }
474
+
475
+ public function postExpressCheckoutData($post) {
476
+
477
+ Mage::getSingleton ( 'customer/session' )->setExprsFormData($post);
478
+ $response = null;
479
+ $longAccessToken = $post['longaccesstoken'];
480
+
481
+ $prefix = 'https://';
482
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
483
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment') . ".";
484
+ $checkout_id = Mage::helper('core')->decrypt(Mage::getStoreConfig('masterpass/config/sbcheckoutidentifier'));
485
+ } else {
486
+ $checkout_id = Mage::helper('core')->decrypt(Mage::getStoreConfig('masterpass/config/prcheckoutidentifier'));
487
+ }
488
+ $expressCheckoutUrl = $prefix . "api.mastercard.com/masterpass/" . $this->xmlVersion . "/expresscheckout";
489
+
490
+ $cart = Mage::getSingleton('checkout/session')->getQuote();
491
+ $subTotal = $cart->getGrandTotal();
492
+ $subTotal = $subTotal * 100;
493
+
494
+ //check if noshipping required
495
+ $noshipping = false;
496
+ $quote = Mage::getSingleton("checkout/session")->getQuote();
497
+ if ($quote->isVirtual()) {
498
+ $noshipping = true;
499
+ } elseif (!$quote->isVirtual() && !Mage::getStoreConfig('masterpass/config/cfaddress')) {
500
+ $noshipping = true;
501
+ }
502
+ $expressCheckoutRequest = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
503
+ <ExpressCheckoutRequest>
504
+ <MerchantCheckoutId>' . $checkout_id . '</MerchantCheckoutId>
505
+ <PrecheckoutTransactionId>' . $post['precheckoutid'] . '</PrecheckoutTransactionId>
506
+ <CurrencyCode>' . Mage::app()->getStore($storeID)->getCurrentCurrencyCode() . '</CurrencyCode>
507
+ <OrderAmount>' . $subTotal . '</OrderAmount>
508
+ <CardId>' . $post['cards'] . '</CardId>';
509
+ if ($noshipping) {
510
+ $expressCheckoutRequest .= '<DigitalGoods>' . $noshipping . '</DigitalGoods>';
511
+ } else {
512
+ $expressCheckoutRequest .= '<ShippingAddressId>' . $post['address'] . '</ShippingAddressId>';
513
+ }
514
+ if (isset($post['rewardprogram'])) {
515
+ $expressCheckoutRequest .= '<RewardProgramId>' . $post['rewardprogram'] . '</RewardProgramId>';
516
+ }
517
+ $expressCheckoutRequest .= '<WalletId>' . $post['walletid'] . '</WalletId>
518
+ <AdvancedCheckoutOverride>false</AdvancedCheckoutOverride>
519
+ <OriginUrl>' . Mage::getBaseUrl() . '</OriginUrl>
520
+ </ExpressCheckoutRequest>';
521
+
522
+ Mage::getSingleton ( "core/session" )->setpreTransId ( $post ['precheckoutid'] );
523
+ Mage::getSingleton("customer/session")->setData("expressData", $post);
524
+
525
+ try {
526
+ $expressCheckoutResponse = $this->service->getExpressCheckoutData($expressCheckoutUrl, $expressCheckoutRequest, $longAccessToken);
527
+ $response = simplexml_load_string($expressCheckoutResponse);
528
+
529
+ if (isset ( $response->Errors->Error )) {
530
+ if ($response->Errors->Error->Source == "3DS Needed") {
531
+ Mage::getSingleton ( 'core/session' )->setExpSecure ( true );
532
+ }
533
+ }else {
534
+ Mage::getSingleton( 'core/session' )->setExpSecure ( false );
535
+ }
536
+ $this->saveLongToken($response->LongAccessToken);
537
+ return $response;
538
+ } catch (Exception $e) {
539
+ Mage::log($e->getMessage());
540
+ // return;
541
+ }
542
+ }
543
+
544
+ public function parsePrecheckoutXml() {
545
+ $typesXml = "";
546
+ $pairingData = $this->pairingDataTypes();
547
+ $pairingData = explode(',', $pairingData);
548
+
549
+ foreach ($pairingData as $dataType) {
550
+ $typesXml = $typesXml . sprintf("<PairingDataType><Type>%s</Type></PairingDataType>", $dataType);
551
+ }
552
+ $preCheckoutRequest = simplexml_load_string(sprintf("<PrecheckoutDataRequest><PairingDataTypes>%s</PairingDataTypes></PrecheckoutDataRequest>", $typesXml));
553
+
554
+ return $preCheckoutRequest->asXML();
555
+ }
556
+
557
+ // post transaction back to masterpass
558
+ public function postTransaction($post, $TransactionStatus, $ApprovalCode) {
559
+
560
+
561
+ $prefix = 'https://';
562
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
563
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment') . ".";
564
+ }
565
+ $postbackUrl = $prefix . "api.mastercard.com/masterpass/" . $this->xmlVersion . "/transaction";
566
+
567
+ $sentXml = '';
568
+ try {
569
+ $consumerKey = $this->service->getConsumerKey();
570
+ $currency = Mage::app()->getStore()->getCurrentCurrencyCode();
571
+ $nowString = date(DATE_ATOM);
572
+
573
+ $orderReference = Mage::getSingleton('checkout/session')->getLastRealOrderId();
574
+ $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
575
+ $order = Mage::getSingleton('sales/order');
576
+ $order->load($lastOrderId);
577
+ $_totalData = $order->getData();
578
+ $subTotal = $_totalData['grand_total'];
579
+
580
+ $subTotal = str_replace(',', '', $subTotal);
581
+ $orderAmount = $subTotal * 100;
582
+
583
+ //if expree checkout
584
+ if (Mage::getStoreConfig('masterpass/config/userflows') == self::EXPRESS_CHECKOUT) {
585
+ $expresschk = "true";
586
+ } else {
587
+ $expresschk = "false";
588
+ }
589
+
590
+ $sentXml = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><MerchantTransactions><MerchantTransactions><TransactionId>' . $post['transaction_id'] . '</TransactionId><ConsumerKey>' . $consumerKey . '</ConsumerKey><Currency>' . $currency . '</Currency><OrderAmount>' . $orderAmount . '</OrderAmount><PurchaseDate>' . $nowString . '</PurchaseDate><TransactionStatus>' . $TransactionStatus . '</TransactionStatus><ApprovalCode>' . $ApprovalCode . '</ApprovalCode><PreCheckoutTransactionId>' . $post['precheckout_id'] . '</PreCheckoutTransactionId>
591
+ <ExpressCheckoutIndicator>' . $expresschk . '</ExpressCheckoutIndicator></MerchantTransactions></MerchantTransactions>';
592
+ $resources = $this->service->PostCheckoutTransaction($postbackUrl, $sentXml);
593
+
594
+ Mage::getSingleton('checkout/session')->setPostBackMp(true);
595
+ } catch (Exception $e) {
596
+
597
+ Mage::log($e->getMessage());
598
+ Mage::getSingleton('checkout/session')->setPostBackMp(false);
599
+ return;
600
+ }
601
+
602
+ return $this->postback;
603
+ }
604
+
605
+ public function ifPostback() {
606
+ return Mage::getSingleton('checkout/session')->getPostBackMp();
607
+ }
608
+
609
+ public function getCardData($brandId) {
610
+
611
+
612
+ $cardType = null;
613
+ $cdata = null;
614
+ if ($brandId == null) {
615
+ $preData = Mage::getSingleton('checkout/session')->getMasterPassCard();
616
+ } else {
617
+ $preData = $brandId;
618
+ }
619
+ if ($preData['BrandId'] == self::DINERS) {
620
+ $cardType = 'OT';
621
+ } elseif ($preData['BrandId'] == self::MASTER) {
622
+ $cardType = 'MC';
623
+ } elseif ($preData['BrandId'] == self::VISA) {
624
+ $cardType = 'VI';
625
+ } elseif ($preData['BrandId'] == self::MAESTRO) {
626
+ $cardType = 'SM';
627
+ } elseif ($preData['BrandId'] == self::DISCOVER) {
628
+ $cardType = 'DI';
629
+ } elseif ($preData['BrandId'] == self::AMEX) {
630
+ $cardType = 'AE';
631
+ } else {
632
+ $cardType = 'OT';
633
+ }
634
+
635
+ $nameOnCard = $preData['CardHolderName'];
636
+ $ccNum = $preData['AccountNumber'];
637
+ $expMonth = $preData['ExpiryMonth'];
638
+ $expYear = $preData['ExpiryYear'];
639
+
640
+ $cdata = array(
641
+ 'method' => Mage::getStoreConfig('masterpass/config/paymentgateway'),
642
+ 'cc_owner' => $nameOnCard,
643
+ 'cc_type' => $cardType,
644
+ 'cc_number' => $ccNum,
645
+ 'cc_number_enc' => Mage::getSingleton('payment/info')->encrypt($ccNum),
646
+ 'cc_last4' => substr($ccNum, -4),
647
+ 'cc_exp_month' => $expMonth,
648
+ 'cc_exp_year' => $expYear
649
+ );
650
+ return $cdata;
651
+ }
652
+
653
+ }
app/code/local/MasterCard/Masterpass/Model/Masterpass.php ADDED
@@ -0,0 +1,175 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Developer: Pavith Lovan
5
+ */
6
+
7
+ class MasterCard_Masterpass_Model_Masterpass extends Mage_Core_Model_Abstract {
8
+
9
+ public function __construct() {
10
+ $this->_init('masterpass/masterpass');
11
+ parent::__construct();
12
+ }
13
+
14
+ public function getCustomerWallet() {
15
+ $masterPassData = Mage::getSingleton('checkout/session')->getMasterPassData();
16
+
17
+ return $masterPassData;
18
+ }
19
+
20
+ public function getCreditCardDetail() {
21
+ $arrayCard = array(
22
+ '0' => '2323'
23
+ );
24
+ $xmlCard = $this->getCustomerWallet();
25
+ $arrayCard = array(
26
+ 'BrandName' => (string) $xmlCard->Card->BrandName,
27
+ 'AccountNumber' => (string) $xmlCard->Card->AccountNumber,
28
+ 'CardHolderName' => (string) $xmlCard->Card->CardHolderName,
29
+ 'ExpiryMonth' => (string) $xmlCard->Card->ExpiryMonth,
30
+ 'ExpiryYear' => (string) $xmlCard->Card->ExpiryYear
31
+ );
32
+ $this->_masterPass = setBrandName((string) $xmlCard->Card->BrandName);
33
+ $this->_masterPass = setAccountNumber((string) $xmlCard->Card->AccountNumber);
34
+ $this->_masterPass = setCardHolderName((string) $xmlCard->Card->CardHolderName);
35
+ $this->_masterPass = setExpiryMonth((string) $xmlCard->Card->ExpiryMonth);
36
+ $this->_masterPass = setExpiryYear((string) $xmlCard->Card->ExpiryYear);
37
+ return $this->_masterPass;
38
+ }
39
+
40
+ public function getBrandName() {
41
+ $_Card = $this->getCustomerWallet();
42
+ try {
43
+ return (string) $_Card ['Card'] ['BrandName'];
44
+ } catch (Exception $e) {
45
+ return null;
46
+ }
47
+ }
48
+
49
+ public function getAccountNumber() {
50
+ $_Card = $this->getCustomerWallet();
51
+ try {
52
+ return (string) $_Card ['Card'] ['AccountNumber'];
53
+ } catch (Exception $e) {
54
+ return null;
55
+ }
56
+ }
57
+
58
+ public function getCardHolderName() {
59
+ $_Card = $this->getCustomerWallet();
60
+ try {
61
+ return (string) $_Card ['Card'] ['CardHolderName'];
62
+ } catch (Exception $e) {
63
+ return null;
64
+ }
65
+ }
66
+
67
+ public function noExpirydate() {
68
+ $_Card = $this->getCustomerWallet();
69
+ if ($_Card ['Card'] ['ExpiryMonth'] == '') {
70
+ return false;
71
+ } else {
72
+ return true;
73
+ }
74
+ }
75
+
76
+ public function getExpiryMonth() {
77
+ $_Card = $this->getCustomerWallet();
78
+
79
+ try {
80
+ if ($_Card ['Card'] ['ExpiryMonth'] == '') {
81
+ $expiryMonth = '04';
82
+ } else {
83
+ $expiryMonth = $_Card ['Card'] ['ExpiryMonth'];
84
+ }
85
+ return (string) $expiryMonth;
86
+ } catch (Exception $e) {
87
+ return null;
88
+ }
89
+ }
90
+
91
+ public function getExpiryYear() {
92
+ $_Card = $this->getCustomerWallet();
93
+ try {
94
+ if ($_Card ['Card'] ['ExpiryYear'] == '') {
95
+ $expiryYear = date('Y') + 4;
96
+ } else {
97
+ $expiryYear = $_Card ['Card'] ['ExpiryYear'];
98
+ }
99
+ return (string) $expiryYear;
100
+ } catch (Exception $e) {
101
+ return null;
102
+ }
103
+ }
104
+
105
+ public function getAutho() {
106
+ $autho = Mage::getSingleton('core/session');
107
+
108
+ return $autho->getAutho();
109
+ }
110
+
111
+ public function getRemoveDash($string) {
112
+ if (strstr($string, '-')) {
113
+ $master = explode('-', $string);
114
+ return $master [1];
115
+ } else {
116
+ return $string;
117
+ }
118
+ }
119
+
120
+ public function statesMapping($stateCode) {
121
+ $regionId = null;
122
+ if (preg_match('/-/', $stateCode)) {
123
+ $countryCode = explode('-', $stateCode);
124
+ $stateCode = $this->getRemoveDash($stateCode);
125
+ if ($countryCode [0]) {
126
+ $regionCollection = Mage::getModel('directory/region_api')->items($countryCode [0]);
127
+ foreach ($regionCollection as $region) {
128
+ if ($stateCode == $region ['code'] || $region['name'] == ucwords($stateCode)) {
129
+ $regionId = $region ['region_id'];
130
+ }
131
+ }
132
+ }
133
+ } else {
134
+ $regionId = '';
135
+ }
136
+
137
+ return $regionId;
138
+ }
139
+
140
+ //if not code try code
141
+ public function getMasterpassRegion($stateCode) {
142
+ $region = null;
143
+ if (preg_match('/-/', $stateCode)) {
144
+ $region = '';
145
+ } else {
146
+ $region = $stateCode;
147
+ }
148
+
149
+ return $region;
150
+ }
151
+
152
+ /**
153
+ * Update the shipping method set on the customer's quote.
154
+ *
155
+ * @param Mage_Sales_Model_Quote $quote
156
+ * @param string $methodCode
157
+ */
158
+ public function updateShippingMethod(Mage_Sales_Model_Quote $quote, $methodCode) {
159
+ Mage::dispatchEvent("mastercard_masterpass_update_shipping_method_before", array("quote" => $quote, "shipping_method" => $methodCode));
160
+
161
+ $changed = false;
162
+ if (!$quote->getIsVirtual() && $shippingAddress = $quote->getShippingAddress()) {
163
+ if ($methodCode != $shippingAddress->getShippingMethod()) {
164
+ $shippingAddress->setShippingMethod($methodCode)->setCollectShippingRates(true);
165
+ $quote->collectTotals()->save();
166
+ $changed = true;
167
+ }
168
+ }
169
+
170
+ Mage::dispatchEvent("mastsercard_masterpass_update_shipping_method_after", array("quote" => $quote, "shipping_method" => $methodCode, "changed" => $changed));
171
+ }
172
+
173
+ }
174
+
175
+ ?>
app/code/local/MasterCard/Masterpass/Model/Mpservice/Connector.php ADDED
@@ -0,0 +1,438 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MasterCard_Masterpass_Model_Mpservice_Connector extends Mage_Core_Model_Abstract {
4
+
5
+ const AMP = "&";
6
+ const QUESTION = "?";
7
+ const EMPTY_STRING = "";
8
+ const EQUALS = "=";
9
+ const DOUBLE_QUOTE = '"';
10
+ const COMMA = ',';
11
+ const ENCODED_TILDE = '%7E';
12
+ const TILDE = '~';
13
+ const COLON = ':';
14
+ const SPACE = ' ';
15
+ const UTF_8 = 'UTF-8';
16
+ const V1 = 'v1';
17
+ const OAUTH_START_STRING = 'OAuth ';
18
+ const REALM = 'realm';
19
+ const ACCEPT = 'Accept';
20
+ const CONTENT_TYPE = 'Content-Type';
21
+ const SSL_CA_CER_PATH_LOCATION = '';
22
+ const POST = "POST";
23
+ const PUT = "PUT";
24
+ const GET = "GET";
25
+ const PKEY = 'pkey';
26
+ const STRNATCMP = "strnatcmp";
27
+ const SHA1 = "SHA1";
28
+ const APPLICATION_XML = "application/xml";
29
+ const AUTHORIZATION = "Authorization";
30
+ const OAUTH_BODY_HASH = "oauth_body_hash";
31
+ const BODY = "body";
32
+ const MESSAGE = 'Message';
33
+ // Signature Base String
34
+ const OAUTH_SIGNATURE = "oauth_signature";
35
+ const OAUTH_CONSUMER_KEY = 'oauth_consumer_key';
36
+ const OAUTH_NONCE = 'oauth_nonce';
37
+ const SIGNATURE_METHOD = 'oauth_signature_method';
38
+ const OAUTH_TIMESTAMP = 'oauth_timestamp';
39
+ const OAUTH_CALLBACK = "oauth_callback";
40
+ const OAUTH_SIGNATURE_METHOD = 'oauth_signature_method';
41
+ const OAUTH_VERSION = 'oauth_version';
42
+ // Srings to detect errors in the service calls
43
+ const ERRORS_TAG = "<Errors>";
44
+ const HTML_TAG = "<html>";
45
+ const HTML_BODY_OPEN = '<body>';
46
+ const HTML_BODY_CLOSE = '</body>';
47
+ // Error Messages
48
+ const EMPTY_REQUEST_TOKEN_ERROR_MESSAGE = 'Invalid Request Token';
49
+ const INVALID_AUTH_URL = 'Invalid Auth Url';
50
+ const POSTBACK_ERROR_MESSAGE = 'Postback Transaction Call was unsuccessful';
51
+ //Connection Strings
52
+ const CONTENT_TYPE_APPLICATION_XML = 'Content-Type: application/xml';
53
+ const SSL_ERROR_MESSAGE = "SSL Error Code: %s %sSSL Error Message: %s";
54
+
55
+ public $signatureBaseString;
56
+ public $authHeader;
57
+ protected $consumerKey;
58
+ private $privateKey;
59
+ public $keystorePath;
60
+ public $keystorePassword;
61
+ private $version = '1.0';
62
+ private $signatureMethod = 'RSA-SHA1';
63
+ public $realm = "eWallet"; // This value is static
64
+
65
+ /**
66
+ * Constructor for Connector
67
+ * @param string $consumerKey
68
+ * @param string $privateKey
69
+ */
70
+
71
+ public function __construct() {
72
+ $this->consumerKey = $this->getConsumerKey();
73
+ $this->privateKey = $this->getPrivateKey();
74
+ }
75
+
76
+ private function getPrivateKey() {
77
+ $keystore = $this->merchantPrivateKey();
78
+ if ($keystore['pkey']) {
79
+ return $keystore['pkey'];
80
+ } else {
81
+ Mage::log('Invalid private key password');
82
+ return null;
83
+ }
84
+ }
85
+ public function merchantPrivateKey() {
86
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
87
+ $thispath = Mage::getBaseDir() . "/shell/certs/" . Mage::getStoreConfig('masterpass/config/sbkeystorepath');
88
+ $keystorePassword = Mage::helper('core')->decrypt(Mage::getStoreConfig('masterpass/config/sbkeystorepassword'));
89
+ } else {
90
+ $thispath = Mage::getBaseDir() . "/shell/certs/" . Mage::getStoreConfig('masterpass/config/prkeystorepath');
91
+ $keystorePassword = Mage::helper('core')->decrypt(Mage::getStoreConfig('masterpass/config/prkeystorepassword'));
92
+ }
93
+ try {
94
+ if (strstr($keystorePassword, '.sh')) {
95
+ $key_pw = exec('sh ' . escapeshellarg($keystorePassword));
96
+ } elseif (strstr($keystorePassword, '.bat')) {
97
+ $key_pw = exec(escapeshellarg($keystorePassword));
98
+ }
99
+ $keystore = array();
100
+
101
+ $path = realpath($thispath);
102
+ //error_log("PATH IS " . $path);
103
+ $pkcs12 = file_get_contents($path);
104
+ trim(openssl_pkcs12_read($pkcs12, $keystore, $key_pw));
105
+ //error_log("GOT TO HERE - " . $keystore['pkey']);
106
+ } catch (Exception $e) {
107
+ Mage::log('Invalid private key password');
108
+ }
109
+ return $keystore;
110
+ }
111
+ public function getConsumerKey() {
112
+
113
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
114
+ $consumerKey = Mage::helper('core')->decrypt(Mage::getStoreConfig('masterpass/config/sbconsumerkey'));
115
+ } else {
116
+ $consumerKey = Mage::helper('core')->decrypt(Mage::getStoreConfig('masterpass/config/prconsumerkey'));
117
+ }
118
+ return $consumerKey;
119
+ }
120
+
121
+ /**
122
+ * Method to convert strings 'true' and 'false' to a boolean value
123
+ * If parameter string is not 'true' (case insensitive), then false will be returned
124
+ *
125
+ * @param String : $str
126
+ *
127
+ * @return boolean
128
+ */
129
+ public static function str_to_bool($str) {
130
+ return (strcasecmp($str, TRUE) == 0) ? true : false;
131
+ }
132
+
133
+ public static function formatXML($resources) {
134
+
135
+ if ($resources != null) {
136
+ $resources = Mage::helper('masterpass')->formatXML($resources);
137
+ }
138
+ return $resources;
139
+ }
140
+
141
+ protected function doSimpleRequest($url, $requestMethod, $body = null) {
142
+ return self::doRequest(array(), $url, $requestMethod, $body);
143
+ }
144
+
145
+ /* * ************* Private Methods **************************************************************************************************************************** */
146
+
147
+ /**
148
+ * Method used for all Http connections
149
+ *
150
+ * @param $params
151
+ * @param $url
152
+ * @param $requestMethod
153
+ * @param $body
154
+ *
155
+ * @throws Exception - When connection error
156
+ *
157
+ * @return mixed - Raw data returned from the HTTP connection
158
+ */
159
+ public function doRequest($params, $url, $requestMethod, $body = null) {
160
+
161
+ if ($body != null) {
162
+ $params[self::OAUTH_BODY_HASH] = $this->generateBodyHash($body);
163
+ }
164
+
165
+ try {
166
+ return $this->connect($params, $this->realm, $url, $requestMethod, $body);
167
+ } catch (Exception $e) {
168
+ throw $this->checkForErrors($e);
169
+ }
170
+ }
171
+
172
+ /**
173
+ * SDK:
174
+ * Method to generate the body hash
175
+ *
176
+ * @param $body
177
+ *
178
+ * @return string
179
+ */
180
+ protected function generateBodyHash($body) {
181
+ $sha1Hash = sha1($body, true);
182
+ return base64_encode($sha1Hash);
183
+ }
184
+
185
+ /**
186
+ * This method generates and returns a unique nonce value to be used in
187
+ * Wallet API OAuth calls.
188
+ *
189
+ * @param $length
190
+ *
191
+ * @return string
192
+ */
193
+ private function generateNonce($length) {
194
+ if (function_exists('com_create_guid') === true) {
195
+ return trim(com_create_guid(), '{}');
196
+ } else {
197
+ $u = md5(uniqid('nonce_', true));
198
+ return substr($u, 0, $length);
199
+ }
200
+ }
201
+
202
+ /**
203
+ * Builds a Auth Header used in connection to MasterPass services
204
+ *
205
+ * @param $params
206
+ * @param $realm
207
+ * @param $url
208
+ * @param $requestMethod
209
+ * @param $body
210
+ *
211
+ * @return string - Auth header
212
+ */
213
+ private function buildAuthHeaderString($params, $realm, $url, $requestMethod, $body) {
214
+
215
+ $params = array_merge($this->OAuthParametersFactory(), $params);
216
+
217
+ $signature = $this->generateAndSignSignature($params, $url, $requestMethod, $this->privateKey, $body);
218
+ $params[self::OAUTH_SIGNATURE] = $signature;
219
+
220
+ $startString = self::OAUTH_START_STRING;
221
+ if (!empty($realm)) {
222
+ $startString = $startString . self::REALM . self::EQUALS . self::DOUBLE_QUOTE . $realm . self::DOUBLE_QUOTE . self::COMMA;
223
+ }
224
+
225
+ foreach ($params as $key => $value) {
226
+ $startString = $startString . $key . self::EQUALS . self::DOUBLE_QUOTE . $this->RFC3986urlencode($value) . self::DOUBLE_QUOTE . self::COMMA;
227
+ }
228
+
229
+ $this->authHeader = substr($startString, 0, strlen($startString) - 1);
230
+
231
+ return $this->authHeader;
232
+ }
233
+
234
+ /**
235
+ * Method to generate base string and generate the signature
236
+ *
237
+ * @param $params
238
+ * @param $url
239
+ * @param $requestMethod
240
+ * @param $privateKey
241
+ * @param $body
242
+ *
243
+ * @return string
244
+ */
245
+ private function generateAndSignSignature($params, $url, $requestMethod, $privateKey, $body) {
246
+ $baseString = $this->generateBaseString($params, $url, $requestMethod);
247
+ $this->signatureBaseString = $baseString;
248
+
249
+ $signature = $this->sign($baseString, $privateKey);
250
+
251
+ return $signature;
252
+ }
253
+
254
+ /**
255
+ * Method to sign string
256
+ *
257
+ * @param $string
258
+ * @param $privateKey
259
+ *
260
+ * @return string
261
+ */
262
+ private function sign($string, $privateKey) {
263
+ $privatekeyid = openssl_get_privatekey($privateKey);
264
+ openssl_sign($string, $signature, $privatekeyid, OPENSSL_ALGO_SHA1);
265
+
266
+ return base64_encode($signature);
267
+ }
268
+
269
+ /**
270
+ * Method to generate the signature base string
271
+ *
272
+ * @param $params
273
+ * @param $url
274
+ * @param $requestMethod
275
+ *
276
+ * @return string
277
+ */
278
+ private function generateBaseString($params, $url, $requestMethod) {
279
+ $urlMap = parse_url($url);
280
+
281
+ $url = $this->formatUrl($url, $params);
282
+
283
+ $params = $this->parseUrlParameters($urlMap, $params);
284
+
285
+
286
+ $baseString = strtoupper($requestMethod) . self::AMP . $this->RFC3986urlencode($url) . self::AMP;
287
+ ksort($params);
288
+
289
+ $parameters = self::EMPTY_STRING;
290
+ foreach ($params as $key => $value) {
291
+ $parameters = $parameters . $key . self::EQUALS . $this->RFC3986urlencode($value) . self::AMP;
292
+ }
293
+ $parameters = $this->RFC3986urlencode(substr($parameters, 0, strlen($parameters) - 1));
294
+ return $baseString . $parameters;
295
+ }
296
+
297
+ /**
298
+ * Method to extract the URL parameters and add them to the params array
299
+ *
300
+ * @param string $urlMap
301
+ * @param string $params
302
+ *
303
+ * @return string|multitype:
304
+ */
305
+ function parseUrlParameters($urlMap, $params) {
306
+ if (empty($urlMap['query'])) {
307
+ return $params;
308
+ } else {
309
+ $str = $urlMap['query'];
310
+ parse_str($str, $urlParamsArray);
311
+ foreach ($urlParamsArray as $key => $value) {
312
+ $urlParamsArray[$key] = $this->RFC3986urlencode($value);
313
+ }
314
+ return array_merge($params, $urlParamsArray);
315
+ }
316
+ }
317
+
318
+ /**
319
+ * Method to format the URL that is included in the signature base string
320
+ *
321
+ * @param string $url
322
+ * @param string $params
323
+ *
324
+ * @return string|string
325
+ */
326
+ function formatUrl($url, $params) {
327
+ if (!parse_url($url)) {
328
+ return $url;
329
+ }
330
+ $urlMap = parse_url($url);
331
+ return $urlMap['scheme'] . '://' . $urlMap['host'] . $urlMap['path'];
332
+ }
333
+
334
+ /**
335
+ * URLEncoder that conforms to the RFC3986 spec.
336
+ * PHP's internal function, rawurlencode, does not conform to RFC3986 for PHP 5.2
337
+ *
338
+ * @param unknown $string
339
+ *
340
+ * @return unknown|mixed
341
+ */
342
+ function RFC3986urlencode($string) {
343
+ if ($string === false) {
344
+ return $string;
345
+ } else {
346
+ return str_replace(self::ENCODED_TILDE, self::TILDE, rawurlencode($string));
347
+ }
348
+ }
349
+
350
+ /**
351
+ * Method to create all default parameters used in the base string and auth header
352
+ *
353
+ * @return array
354
+ */
355
+ protected function OAuthParametersFactory() {
356
+ $nonce = $this->generateNonce(16);
357
+ $time = time();
358
+
359
+ $params = array(
360
+ self::OAUTH_CONSUMER_KEY => $this->consumerKey,
361
+ self::OAUTH_SIGNATURE_METHOD => $this->signatureMethod,
362
+ self::OAUTH_NONCE => $nonce,
363
+ self::OAUTH_TIMESTAMP => $time,
364
+ self::OAUTH_VERSION => $this->version
365
+ );
366
+
367
+ return $params;
368
+ }
369
+
370
+ /**
371
+ * General method to handle all HTTP connections
372
+ *
373
+ * @param unknown $params
374
+ * @param unknown $realm
375
+ * @param unknown $url
376
+ * @param unknown $requestMethod
377
+ * @param string $body
378
+ *
379
+ * @throws Exception - If connection fails or receives a HTTP status code > 300
380
+ *
381
+ * @return mixed
382
+ */
383
+ private function connect($params, $realm, $url, $requestMethod, $body = null) {
384
+ $curl = curl_init($url);
385
+
386
+ // Adds the CA cert bundle to authenticate the SSL cert
387
+ //curl_setopt($curl, CURLOPT_CAINFO, __DIR__ .self::SSL_CA_CER_PATH_LOCATION);
388
+
389
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
390
+ curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2);
391
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); // This should always be TRUE to secure SSL connections
392
+
393
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array(
394
+ self::ACCEPT . self::COLON . self::SPACE . self::APPLICATION_XML,
395
+ self::CONTENT_TYPE . self::COLON . self::SPACE . self::APPLICATION_XML . ";charset=\"UTF-8\"",
396
+ self::AUTHORIZATION . self::COLON . self::SPACE . $this->buildAuthHeaderString($params, $realm, $url, $requestMethod, $body)
397
+ ));
398
+
399
+ if ($requestMethod == self::GET) {
400
+ curl_setopt($curl, CURLOPT_HTTPGET, TRUE);
401
+ } else {
402
+ curl_setopt($curl, CURLOPT_CUSTOMREQUEST, strtoupper($requestMethod));
403
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $body);
404
+ }
405
+
406
+ $result = curl_exec($curl);
407
+
408
+ // Check if any error occurred
409
+ if (curl_errno($curl)) {
410
+ throw new Exception(sprintf(self::SSL_ERROR_MESSAGE, curl_errno($curl), PHP_EOL, curl_error($curl)), curl_errno($curl));
411
+ }
412
+
413
+
414
+ // Check for errors and throw an exception
415
+ if (($errorCode = curl_getinfo($curl, CURLINFO_HTTP_CODE)) > 300) {
416
+ throw new Exception($result, $errorCode);
417
+ }
418
+
419
+ return $result;
420
+ }
421
+
422
+ /**
423
+ * Method to check for HTML content in the exception message and remove everything except the body
424
+ *
425
+ * @param Exception $e
426
+ *
427
+ * @return Exception
428
+ */
429
+ private function checkForErrors(Exception $e) {
430
+ if (strpos($e->getMessage(), self::HTML_TAG) !== false) {
431
+ $body = substr($e->getMessage(), strpos($e->getMessage(), self::HTML_BODY_OPEN) + 6, strpos($e->getMessage(), self::HTML_BODY_CLOSE));
432
+ return new Exception($body);
433
+ } else {
434
+ return $e;
435
+ }
436
+ }
437
+
438
+ }
app/code/local/MasterCard/Masterpass/Model/Mpservice/Masterpassservice.php ADDED
@@ -0,0 +1,357 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class MasterCard_Masterpass_Model_Mpservice_Masterpassservice extends MasterCard_Masterpass_Model_Mpservice_Connector {
4
+
5
+ //Request Token Response
6
+ const XOAUTH_REQUEST_AUTH_URL = "xoauth_request_auth_url";
7
+ const OAUTH_CALLBACK_CONFIRMED = "oauth_callback_confirmed";
8
+ const OAUTH_EXPIRES_IN = "oauth_expires_in";
9
+ //Request Token Response
10
+ const OAUTH_TOKEN_SECRET = "oauth_token_secret";
11
+ const ORIGIN_URL = "origin_url";
12
+ // Callback URL parameters
13
+ const OAUTH_TOKEN = "oauth_token";
14
+ const OAUTH_VERIFIER = "oauth_verifier";
15
+ const CHECKOUT_RESOURCE_URL = "checkout_resource_url";
16
+ const REDIRECT_URL = "redirect_url";
17
+ const PAIRING_TOKEN = "pairing_token";
18
+ const PAIRING_VERIFIER = "pairing_verifier";
19
+ // Redirect Parameters
20
+ const CHECKOUT_IDENTIFIER = 'checkout_identifier';
21
+ const ACCEPTABLE_CARDS = 'acceptable_cards';
22
+ const OAUTH_VERSION = 'oauth_version';
23
+ const VERSION = 'version';
24
+ const SUPPRESS_SHIPPING_ADDRESS = 'suppress_shipping_address';
25
+ const ACCEPT_REWARDS_PROGRAM = 'accept_reward_program';
26
+ const SHIPPING_LOCATION_PROFILE = 'shipping_location_profile';
27
+ const WALLET_SELECTOR = 'wallet_selector_bypass';
28
+ const DEFAULT_XMLVERSION = "v1";
29
+ const AUTH_LEVEL = "auth_level";
30
+ const BASIC = "basic";
31
+ const XML_VERSION_REGEX = "/v[0-9]+/";
32
+ const REALM_TYPE = "eWallet";
33
+ const APPROVAL_CODE = "sample";
34
+ const POST = "POST";
35
+ const GET = "GET";
36
+ const OAUTH_BODY_HASH = "oauth_body_hash";
37
+ const AMP = "&";
38
+ const EQUALS = "=";
39
+
40
+ public $originUrl;
41
+ public $requestToken;
42
+ public $verifier;
43
+ public $checkoutResourceUrl;
44
+ public $accessToken;
45
+ public $paymentShippingResource;
46
+ public $oAuthSecret;
47
+ public $accessTokenCallAuthHeader;
48
+ public $accessTokenCallSignatureBaseString;
49
+ //public $requestToken;
50
+ public $authorizeUrl;
51
+ public $callbackConfirmed;
52
+ public $oAuthExpiresIn;
53
+ //public $oAuthSecret;
54
+ public $redirectUrl;
55
+
56
+ public function __construct() {
57
+ $this->_init('masterpass/mpservice_masterpassservice');
58
+ $consumerKey = $this->getConsumerKey();
59
+
60
+
61
+ $originUrl = Mage::getUrl('', array(
62
+ '_secure' => true
63
+ ));
64
+
65
+ parent::__construct($consumerKey);
66
+ $this->originUrl = $originUrl;
67
+ }
68
+
69
+ public function getConsumerKey() {
70
+
71
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
72
+ $consumerKey = Mage::helper('core')->decrypt(Mage::getStoreConfig('masterpass/config/sbconsumerkey'));
73
+ } else {
74
+ $consumerKey = Mage::helper('core')->decrypt(Mage::getStoreConfig('masterpass/config/prconsumerkey'));
75
+ }
76
+ return $consumerKey;
77
+ }
78
+
79
+ /**
80
+ * SDK:
81
+ * This method captures the Checkout Resource URL and Request Token Verifier
82
+ * and uses these to request the Access Token.
83
+ * @param $requestToken
84
+ * @param $verifier
85
+ * @return Output is Access Token
86
+ */
87
+ public function GetAccessToken($accessUrl, $requestToken, $verifier) {
88
+
89
+ $params = array(
90
+ self::OAUTH_VERIFIER => $verifier,
91
+ self::OAUTH_TOKEN => $requestToken
92
+ );
93
+
94
+ $return = ''; //new AccessTokenResponse();
95
+ $response = $this->doRequest($params, $accessUrl, POST, null);
96
+ $responseObject = $this->parseConnectionResponse($response);
97
+
98
+ $return->accessToken = isset($responseObject[self::OAUTH_TOKEN]) ? $responseObject[self::OAUTH_TOKEN] : "";
99
+ $return->oAuthSecret = isset($responseObject[self::OAUTH_TOKEN]) ? $responseObject[self::OAUTH_TOKEN_SECRET] : "";
100
+ return $return;
101
+ }
102
+
103
+ /**
104
+ * SDK:
105
+ * This method gets a request token and constructs the redirect URL
106
+ * @param $requestUrl
107
+ * @param $callbackUrl
108
+ * @param $acceptableCards
109
+ * @param $checkoutProjectId
110
+ * @param $xmlVersion
111
+ * @param $shippingSuppression
112
+ * @param $rewardsProgram
113
+ * @param $authLevelBasic
114
+ * @param $shippingLocationProfile
115
+ * @param $walletSelector
116
+ * @return Output is a RequestTokenResponse object containing all data returned from this method
117
+ */
118
+ public function getRequestTokenAndRedirectUrl($requestUrl, $callbackUrl, $acceptableCards, $checkoutProjectId, $xmlVersion, $shippingSuppression, $rewardsProgram, $authLevelBasic, $shippingLocationProfile, $walletSelector) {
119
+
120
+ $return = $this->getRequestToken($requestUrl, $callbackUrl);
121
+ $return->redirectURL = $this->getConsumerSignInUrl($acceptableCards, $checkoutProjectId, $xmlVersion, $shippingSuppression, $rewardsProgram, $authLevelBasic, $shippingLocationProfile, $walletSelector);
122
+ return $return;
123
+ }
124
+
125
+ /**
126
+ * Method used to parse the connection response and return a array of the data
127
+ *
128
+ * @param $responseString
129
+ *
130
+ * @return Array with all response parameters
131
+ */
132
+ public function parseConnectionResponse($responseString) {
133
+
134
+ $token = array();
135
+ foreach (explode(self::AMP, $responseString) as $p) {
136
+ @list($name, $value) = explode(self::EQUALS, $p, 2);
137
+ $token[$name] = urldecode($value);
138
+ }
139
+ return $token;
140
+ }
141
+
142
+ /**
143
+ * SDK:
144
+ * This method posts the Shopping Cart data to MasterCard services
145
+ * and is used to display the shopping cart in the wallet site.
146
+ * @param $ShoppingCartXml
147
+ * @return Output is the response from MasterCard services
148
+ */
149
+ public function postShoppingCartData($shoppingCartUrl, $shoppingCartXml) {
150
+ $params = array(
151
+ // Connector::OAUTH_BODY_HASH => $this->generateBodyHash($shoppingCartXml)
152
+ );
153
+ $response = $this->doRequest($params, $shoppingCartUrl, self::POST, $shoppingCartXml);
154
+ return $response;
155
+ }
156
+
157
+ public function postMerchantInitData($merchantInitUrl, $merchantInitXml) {
158
+ $params = array(
159
+ OAUTH_BODY_HASH => $this->generateBodyHash($merchantInitXml)
160
+ );
161
+ $response = $this->doRequest($params, $merchantInitUrl, self::POST, $merchantInitXml);
162
+ return $response;
163
+ }
164
+
165
+ /**
166
+ * SDK:
167
+ * This method retrieves the payment and shipping information
168
+ * for the current user/session.
169
+ * @param unknown $accessToken
170
+ * @param unknown $checkoutResourceUrl
171
+ * @return Output is the Checkout XML string containing the users billing and shipping information
172
+ */
173
+ public function GetPaymentShippingResource($checkoutResourceUrl, $accessToken) {
174
+ $params = array(
175
+ self::OAUTH_TOKEN => $accessToken
176
+ );
177
+
178
+ $response = $this->doRequest($params, $checkoutResourceUrl, self::GET, null);
179
+ return $response;
180
+ }
181
+
182
+ /**
183
+ * This method submits the receipt transaction list to MasterCard as a final step
184
+ * in the Wallet process.
185
+ * @param $merchantTransactions
186
+ * @return Output is the response from MasterCard services
187
+ */
188
+ public function PostCheckoutTransaction($postbackurl, $merchantTransactions) {
189
+ $params = array(
190
+ self::OAUTH_BODY_HASH => $this->generateBodyHash($merchantTransactions)
191
+ );
192
+
193
+ $response = $this->doRequest($params, $postbackurl, self::POST, $merchantTransactions);
194
+
195
+ return $response;
196
+
197
+ }
198
+
199
+ public function getPreCheckoutData($preCheckoutUrl, $preCheckoutXml, $accessToken) {
200
+ $params = array(
201
+ self::OAUTH_TOKEN => $accessToken
202
+ );
203
+ $response = $this->doRequest($params, $preCheckoutUrl, self::POST, $preCheckoutXml);
204
+ return $response;
205
+ }
206
+
207
+ public function getExpressCheckoutData($expressCheckoutUrl, $expressCheckoutXml, $accessToken) {
208
+ $params = array(
209
+ self::OAUTH_TOKEN => $accessToken
210
+ );
211
+
212
+ $response = $this->doRequest($params, $expressCheckoutUrl, self::POST, $expressCheckoutXml);
213
+ return $response;
214
+ }
215
+
216
+ protected function OAuthParametersFactory() {
217
+
218
+ $params = parent::OAuthParametersFactory();
219
+
220
+ $params[self::ORIGIN_URL] = $this->originUrl;
221
+
222
+ return $params;
223
+ }
224
+
225
+ /* * ************* Private Methods **************************************************************************************************************************** */
226
+
227
+ /**
228
+ * SDK:
229
+ * Get the user's request token and store it in the current user session.
230
+ * @param $requestUrl
231
+ * @param $callbackUrl
232
+ * @return RequestTokenResponse
233
+ */
234
+ public function GetRequestToken($requestUrl, $callbackUrl) {
235
+
236
+ $connector = Mage::getModel('masterpass/mpservice_connector');
237
+
238
+ $params = array(
239
+ $connector::OAUTH_CALLBACK => $callbackUrl
240
+ );
241
+
242
+ $response = $connector->doRequest($params, $requestUrl, $connector::POST, null);
243
+
244
+ $requestTokenInfo = $this->parseConnectionResponse($response);
245
+
246
+ $return = ''; //new RequestTokenResponse();
247
+ $return->requestToken = isset($requestTokenInfo[self::OAUTH_TOKEN]) ? $requestTokenInfo[self::OAUTH_TOKEN] : '';
248
+ $return->authorizeUrl = isset($requestTokenInfo[self::XOAUTH_REQUEST_AUTH_URL]) ? $requestTokenInfo[self::XOAUTH_REQUEST_AUTH_URL] : '';
249
+ $return->callbackConfirmed = isset($requestTokenInfo[self::OAUTH_CALLBACK_CONFIRMED]) ? $requestTokenInfo[self::OAUTH_CALLBACK_CONFIRMED] : '';
250
+ $return->oAuthExpiresIn = isset($requestTokenInfo[self::OAUTH_EXPIRES_IN]) ? $requestTokenInfo[self::OAUTH_EXPIRES_IN] : '';
251
+ $return->oAuthSecret = isset($requestTokenInfo[self::OAUTH_TOKEN_SECRET]) ? $requestTokenInfo[self::OAUTH_TOKEN_SECRET] : '';
252
+
253
+
254
+
255
+ $this->requestTokenInfo = $return;
256
+
257
+ // Return the request token response class.
258
+ return $return;
259
+ }
260
+
261
+ /**
262
+ * SDK:
263
+ * Assuming that all due diligence is done and assuming the presence of an established session,
264
+ * successful reception of non-empty request token, and absence of any unanticipated
265
+ * exceptions have been successfully verified, you are ready to go to the authorization
266
+ * link hosted by MasterCard.
267
+ * @param $acceptableCards
268
+ * @param $checkoutProjectId
269
+ * @param $xmlVersion
270
+ * @param $shippingSuppression
271
+ * @param $rewardsProgram
272
+ * @param $authLevelBasic
273
+ * @param $shippingLocationProfile
274
+ * @param $walletSelector
275
+ *
276
+ * @return string - URL to redirect the user to the MasterPass wallet site
277
+ */
278
+ private function GetConsumerSignInUrl($acceptableCards, $checkoutProjectId, $xmlVersion, $shippingSuppression, $rewardsProgram, $authLevelBasic, $shippingLocationProfile, $walletSelector) {
279
+ $baseAuthUrl = $this->requestTokenInfo->authorizeUrl;
280
+
281
+ $xmlVersion = strtolower($xmlVersion);
282
+
283
+ $connector = Mage::getModel('masterpass/mpservice_connector');
284
+ // Use v1 if xmlVersion does not match correct patern
285
+ if (!preg_match(self::XML_VERSION_REGEX, $xmlVersion)) {
286
+ $xmlVersion = self::DEFAULT_XMLVERSION;
287
+ }
288
+
289
+ $token = $this->requestTokenInfo->requestToken;
290
+ if ($token == null || $token == $connector::EMPTY_STRING) {
291
+ throw new Exception($connector::EMPTY_REQUEST_TOKEN_ERROR_MESSAGE);
292
+ }
293
+
294
+ if ($baseAuthUrl == null || $baseAuthUrl == $connector::EMPTY_STRING) {
295
+ throw new Exception($connector::INVALID_AUTH_URL);
296
+ }
297
+
298
+ // construct the Redirect URL
299
+ $finalAuthUrl = $baseAuthUrl .
300
+ $this->getParamString(self::ACCEPTABLE_CARDS, $acceptableCards, true) .
301
+ $this->getParamString(self::CHECKOUT_IDENTIFIER, $checkoutProjectId) .
302
+ $this->getParamString(self::OAUTH_TOKEN, $token) .
303
+ $this->getParamString(self::VERSION, $xmlVersion);
304
+
305
+ // If xmlVersion is v1 (default version), then shipping suppression, rewardsprogram and auth_level are not used
306
+ if (strcasecmp($xmlVersion, self::DEFAULT_XMLVERSION) != $connector::V1) {
307
+
308
+ if ($shippingSuppression == 'true') {
309
+ $finalAuthUrl = $finalAuthUrl . $this->getParamString(self::SUPPRESS_SHIPPING_ADDRESS, $shippingSuppression);
310
+ }
311
+
312
+ if ((int) substr($xmlVersion, 1) >= 4 && $rewardsProgram == 'true') {
313
+ $finalAuthUrl = $finalAuthUrl . $this->getParamString(self::ACCEPT_REWARDS_PROGRAM, $rewardsProgram);
314
+ }
315
+
316
+ if ($authLevelBasic) {
317
+ $finalAuthUrl = $finalAuthUrl . $this->getParamString(self::AUTH_LEVEL, self::BASIC);
318
+ }
319
+
320
+ if ((int) substr($xmlVersion, 1) >= 4 && $shippingLocationProfile != null && !empty($shippingLocationProfile)) {
321
+ $finalAuthUrl = $finalAuthUrl . $this->getParamString(self::SHIPPING_LOCATION_PROFILE, $shippingLocationProfile);
322
+ }
323
+
324
+ if ((int) substr($xmlVersion, 1) >= 5 && $walletSelector == 'true') {
325
+ $finalAuthUrl = $finalAuthUrl . $this->getParamString(self::WALLET_SELECTOR, $walletSelector);
326
+ }
327
+ }
328
+ return $finalAuthUrl;
329
+ }
330
+
331
+ /**
332
+ * SDK:
333
+ * Method to create the URL with GET Parameters
334
+ *
335
+ * @param $key
336
+ * @param $value
337
+ * @param $firstParam
338
+ *
339
+ * @return string
340
+ */
341
+ private function getParamString($key, $value, $firstParam = false) {
342
+ $connector = Mage::getModel('masterpass/mpservice_connector');
343
+ $paramString = $connector::EMPTY_STRING;
344
+
345
+ if ($firstParam) {
346
+ $paramString .= $connector::QUESTION;
347
+ } else {
348
+ $paramString .= $connector::AMP;
349
+ }
350
+ $paramString .= $key . $connector::EQUALS . $value;
351
+
352
+ return $paramString;
353
+ }
354
+
355
+ }
356
+
357
+ ?>
app/code/local/MasterCard/Masterpass/Model/Observer.php ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Developer: Pavith Lovan
5
+ */
6
+ /*
7
+ * To change this template, choose Tools | Templates and open the template in the editor.
8
+ */
9
+
10
+ class MasterCard_Masterpass_Model_Observer {
11
+
12
+ const XML_PATH_EMAIL_RECIPIENT = 'contacts/email/recipient_email';
13
+ const XML_PATH_EMAIL_SENDER = 'contacts/email/sender_email_identity';
14
+ const XML_PATH_EMAIL_TEMPLATE = 'masterpass_email_template';
15
+ const XML_SEVERITY_ICONS_URL_PATH = 'system/adminnotification/severity_icons_url';
16
+
17
+ protected $_severityIconsUrl;
18
+ public function mastterPassToControllerActionPostDispatch(Varien_Event_Observer $observer) {
19
+ if (!Mage::helper('core')->isModuleOutputEnabled('MasterCard_Masterpass')) {
20
+ return $this;
21
+ }
22
+ $controller = $observer->getEvent()->getControllerAction();
23
+
24
+ if (Mage::helper("masterpass")->checkIfSensitiveRequest($controller->getRequest())) {
25
+ Mage::helper('masterpass')->resetMasterData();
26
+ }
27
+ }
28
+ // check if private key is set
29
+ public function checkPrivateKey($observer) {
30
+
31
+ $controller = $observer->getEvent()->getControllerAction();
32
+
33
+ $mp = $controller->getRequest()->getParams();
34
+
35
+ $cache = Mage::app()->getCache();
36
+
37
+ if(!Mage::helper('core')->isModuleOutputEnabled('MasterCard_Masterpass')){
38
+ return $this;
39
+ }
40
+
41
+ if (Mage::getSingleton('admin/session')->isLoggedIn()) {
42
+
43
+ //create log when masterpass configuraution is changed
44
+ $fields = Mage::app()->getRequest()->getParams();
45
+ if (isset($fields['section']) && $fields['section'] == 'masterpass') {
46
+ if (isset($fields['form_key'])) {
47
+ $admin = Mage::getSingleton('admin/session')->getUser();
48
+
49
+ error_log('MasterPass Configuration changed by: ' . $admin->getUsername() . ' on ' . date("F j, Y, g:i a"), 0);
50
+ }
51
+ }
52
+
53
+
54
+ if (Mage::getStoreConfig('masterpass/config/enabled')) {
55
+ if ($cache->load("masterpass_pk") === false) {
56
+ if (!Mage::helper('masterpass')->checkPrivateKey()) {
57
+ $this->getPkeyMessage($mp);
58
+ $this->sendNotification();
59
+ }
60
+ $cache->save('true', 'masterpass_pk', array("masterpass_pk"), $lifeTime = 2);
61
+ }
62
+ }
63
+ }
64
+ }
65
+
66
+ public function getPkeyMessage($mp) {
67
+
68
+ $message = 'Important: Please enter the path location of the private key executable';
69
+ if ($mp['section'] != 'masterpass') {
70
+ $message .= '<script type="text/javascript">
71
+ //<![CDATA[
72
+ var messagePopupClosed = false;
73
+ function openMessagePopup() {
74
+ var height = $("html-body").getHeight();
75
+ $("message-popup-window-mask").setStyle({"height":height+"px"});
76
+ toggleSelectsUnderBlock($("message-popup-window-mask"), false);
77
+ Element.show("message-popup-window-mask");
78
+ $("message-popup-window").addClassName("show");
79
+ }
80
+
81
+ function closeMessagePopup() {
82
+ toggleSelectsUnderBlock($("message-popup-window-mask"), true);
83
+ Element.hide("message-popup-window-mask");
84
+ $("message-popup-window").removeClassName("show");
85
+ messagePopupClosed = true;
86
+ }
87
+
88
+ Event.observe(window, "load", openMessagePopup);
89
+ Event.observe(window, "keyup", function(evt) {
90
+ if(messagePopupClosed) return;
91
+ var code;
92
+ if (evt.keyCode) code = evt.keyCode;
93
+ else if (evt.which) code = evt.which;
94
+ if (code == Event.KEY_ESC) {
95
+ closeMessagePopup();
96
+ }
97
+ });
98
+ //]]>
99
+ </script>';
100
+ $message .= '<div id="message-popup-window-mask" style="display:none;"></div>
101
+ <div id="message-popup-window" class="message-popup">
102
+ <div class="message-popup-head">
103
+ <a href="#" onclick="closeMessagePopup(); return false;" title="close"><span>close</span></a>
104
+ <h2>MasterPass Private Key Executable Path</h2>
105
+ </div>
106
+ <div class="message-popup-content">
107
+ <div class="message">
108
+ <span class="message-icon message-notice" style="background-image:url(' . "'" . $this->getSeverityIconsUrl() . "'" . '">Notice</span>
109
+ <p class="message-text">Important: Please enter the path location of the private key executable</p>
110
+ </div>
111
+ <p class="read-more"><a href="' . Mage::helper("adminhtml")->getUrl("/system_config/edit/section/masterpass/") . '">Click here to enter private key executable path</a></p>
112
+ </div>
113
+ </div>';
114
+ }
115
+ Mage::getSingleton('adminhtml/session')->addNotice($message);
116
+ }
117
+
118
+ public function getSeverityIconsUrl() {
119
+ if (is_null($this->_severityIconsUrl)) {
120
+ $this->_severityIconsUrl = (Mage::app()->getFrontController()->getRequest()->isSecure() ? 'https://' : 'http://')
121
+ . sprintf(Mage::getStoreConfig(self::XML_SEVERITY_ICONS_URL_PATH), Mage::getVersion(), 'SEVERITY_NOTICE')
122
+ ;
123
+ }
124
+ return $this->_severityIconsUrl;
125
+ }
126
+
127
+ // check private key password
128
+ // if private key path file is not set, send email notification to notify merchant
129
+ public function noPassKeyNotification() {
130
+ // check if masterpass is enabled
131
+ if (Mage::getStoreConfig('masterpass/config/enabled')) {
132
+ if (Mage::getStoreConfig('masterpass/config/sbkeystorepassword') == null && Mage::getStoreConfig('masterpass/config/environment') == 'sandbox') {
133
+ $this->sendNotification();
134
+ } elseif (Mage::getStoreConfig('masterpass/config/prkeystorepassword') == null && Mage::getStoreConfig('masterpass/config/environment') == 'production') {
135
+ $this->sendNotification();
136
+ } else {
137
+ return;
138
+ }
139
+ }
140
+ }
141
+
142
+ public function sendNotification() {
143
+
144
+ if (Mage::getStoreConfig('masterpass/config/notification_email') != null) {
145
+
146
+ $subject = 'MasterPass Private Key needed';
147
+ $message = '<div>
148
+ <p>Alert: The path for the private key executable needs to be correctly configured in the Administration Console.
149
+ <br/>The Private Key Executable Path is either empty or the value is incorrect. Please log into the Magento MasterPass
150
+ <br/>administration console and enter the correct path. Make certain the Private Key Executable Path is populated and
151
+ <br/>contains the correct path to the executable that retrieves the private key.
152
+ </p>
153
+ </div>';
154
+ $to = Mage::getStoreConfig('masterpass/config/notification_email');
155
+ $type = 'html'; // or HTML
156
+ $charset = 'utf-8';
157
+
158
+ $mail = Mage::getStoreConfig('trans_email/ident_general/email');
159
+ $uniqid = md5(uniqid(time()));
160
+ $headers = 'From: ' . $mail . "\n";
161
+ $headers .= 'Reply-to: ' . $mail . "\n";
162
+ $headers .= 'Return-Path: ' . $mail . "\n";
163
+ $headers .= 'Message-ID: <' . $uniqid . '@' . $_SERVER['SERVER_NAME'] . ">\n";
164
+ $headers .= 'MIME-Version: 1.0' . "\n";
165
+ $headers .= 'Date: ' . gmdate('D, d M Y H:i:s', time()) . "\n";
166
+ $headers .= 'X-Priority: 3' . "\n";
167
+ $headers .= 'X-MSMail-Priority: Normal' . "\n";
168
+ $headers .= 'Content-Type: multipart/mixed;boundary="----------' . $uniqid . '"' . "\n\n";
169
+ $headers .= '------------' . $uniqid . "\n";
170
+ $headers .= 'Content-type: text/' . $type . ';charset=' . $charset . '' . "\n";
171
+ $headers .= 'Content-transfer-encoding: 7bit';
172
+ try {
173
+ mail($to, $subject, $message, $headers);
174
+ } catch (Exception $e) {
175
+ return;
176
+ }
177
+ }
178
+ return;
179
+ }
180
+
181
+ }
182
+
183
+ ?>
app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Acceptancemarksize.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Used in creating options for Button size config value selection
5
+ *
6
+ */
7
+ class MasterCard_Masterpass_Model_System_Config_Source_Acceptancemarksize {
8
+
9
+ /**
10
+ * Options getter
11
+ *
12
+ * @return array
13
+ * /mp_mc_acc_023px_gif.gif
14
+ */
15
+ public function toOptionArray() {
16
+ return array (
17
+ array (
18
+ 'value' => '023px',
19
+ 'label' => Mage::helper ( 'masterpass' )->__ ( '023px' )
20
+ ),
21
+ array (
22
+ 'value' => '030px',
23
+ 'label' => Mage::helper ( 'masterpass' )->__ ( '030px' )
24
+ ),
25
+ array (
26
+ 'value' => '034px',
27
+ 'label' => Mage::helper ( 'masterpass' )->__ ( '034px' )
28
+ ),
29
+ array (
30
+ 'value' => '038px',
31
+ 'label' => Mage::helper ( 'masterpass' )->__ ( '038px' )
32
+ ),
33
+ array (
34
+ 'value' => '050px',
35
+ 'label' => Mage::helper ( 'masterpass' )->__ ( '050px' )
36
+ ) ,
37
+ array (
38
+ 'value' => '065px',
39
+ 'label' => Mage::helper ( 'masterpass' )->__ ( '065px' )
40
+ ) ,
41
+ array (
42
+ 'value' => '113px',
43
+ 'label' => Mage::helper ( 'masterpass' )->__ ( '113px' )
44
+ )
45
+ )
46
+ ;
47
+ }
48
+
49
+ /**
50
+ * Get options in "key-value" format
51
+ *
52
+ * @return array
53
+ */
54
+ public function toArray() {
55
+ return array (
56
+
57
+ '023px' => Mage::helper ( 'masterpass' )->__ ( '023px' ),
58
+ '030px' => Mage::helper ( 'masterpass' )->__ ( '030px' ),
59
+ '034px' => Mage::helper ( 'masterpass' )->__ ( '034px' ),
60
+ '038px' => Mage::helper ( 'masterpass' )->__ ( '038px' ) ,
61
+ '050px' => Mage::helper ( 'masterpass' )->__ ( '050px' ),
62
+ '065px' => Mage::helper ( 'masterpass' )->__ ( '065px' ),
63
+ '113px' => Mage::helper ( 'masterpass' )->__ ( '113px' )
64
+ )
65
+ ;
66
+ }
67
+ }
app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Acceptedcards.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Used in creating options for MasterCard Masterpass Accepted Cards config value selection
5
+ *
6
+ */
7
+ class MasterCard_Masterpass_Model_System_Config_Source_Acceptedcards {
8
+
9
+ /**
10
+ * Options getter
11
+ *
12
+ * @return array
13
+ */
14
+ public function toOptionArray() {
15
+ return array (
16
+ array (
17
+ 'value' => "master",
18
+ 'label' => Mage::helper ( 'masterpass' )->__ ( 'Master Card' )
19
+ ),
20
+ array (
21
+ 'value' => "amex",
22
+ 'label' => Mage::helper ( 'masterpass' )->__ ( 'American Express' )
23
+ ),
24
+ array (
25
+ 'value' => "diners",
26
+ 'label' => Mage::helper ( 'masterpass' )->__ ( 'Diners' )
27
+ ),
28
+ array (
29
+ 'value' => "discover",
30
+ 'label' => Mage::helper ( 'masterpass' )->__ ( 'Discover' )
31
+ ),
32
+ array (
33
+ 'value' => "maestro",
34
+ 'label' => Mage::helper ( 'masterpass' )->__ ( 'Maestro' )
35
+ ),
36
+ array (
37
+ 'value' => "visa",
38
+ 'label' => Mage::helper ( 'masterpass' )->__ ( 'Visa' )
39
+ )
40
+ )
41
+ ;
42
+ }
43
+
44
+ /**
45
+ * Get options in "key-value" format
46
+ *
47
+ * @return array
48
+ */
49
+ public function toArray() {
50
+ return array (
51
+ 'master' => Mage::helper ( 'masterpass' )->__ ( 'Master Card' ),
52
+ 'amex' => Mage::helper ( 'masterpass' )->__ ( 'American Express' ),
53
+ 'diners' => Mage::helper ( 'masterpass' )->__ ( 'Diners' ),
54
+ 'discover' => Mage::helper ( 'masterpass' )->__ ( 'Discover' ),
55
+ 'maestro' => Mage::helper ( 'masterpass' )->__ ( 'Maestro' ),
56
+ 'visa' => Mage::helper ( 'masterpass' )->__ ( 'Visa' )
57
+ )
58
+ ;
59
+ }
60
+ }
app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Buttonsize.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Used in creating options for Button size config value selection
5
+ *
6
+ */
7
+ class MasterCard_Masterpass_Model_System_Config_Source_Buttonsize {
8
+
9
+ /**
10
+ * Options getter
11
+ *
12
+ * @return array
13
+ */
14
+ public function toOptionArray() {
15
+ return array (
16
+ array (
17
+ 'value' => '147x034px',
18
+ 'label' => Mage::helper ( 'masterpass' )->__ ( '147x034px' )
19
+ ),
20
+ array (
21
+ 'value' => '160x037px',
22
+ 'label' => Mage::helper ( 'masterpass' )->__ ( '160x037px' )
23
+ ),
24
+ array (
25
+ 'value' => '166x038px',
26
+ 'label' => Mage::helper ( 'masterpass' )->__ ( '166x038px' )
27
+ ),
28
+ array (
29
+ 'value' => '180x042px',
30
+ 'label' => Mage::helper ( 'masterpass' )->__ ( '180x042px' )
31
+ )
32
+ )
33
+ ;
34
+ }
35
+
36
+ /**
37
+ * Get options in "key-value" format
38
+ *
39
+ * @return array
40
+ */
41
+ public function toArray() {
42
+ return array (
43
+
44
+ '147x034px' => Mage::helper ( 'masterpass' )->__ ( '147x034px' ),
45
+ '160x037px' => Mage::helper ( 'masterpass' )->__ ( '160x037px' ),
46
+ '166x038px' => Mage::helper ( 'masterpass' )->__ ( '166x038px' ),
47
+ '180x042px' => Mage::helper ( 'masterpass' )->__ ( '180x042px' )
48
+ )
49
+ ;
50
+ }
51
+ }
app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Environment.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Used in creating options for Yes|No config value selection
5
+ *
6
+ */
7
+ class MasterCard_Masterpass_Model_System_Config_Source_Environment {
8
+
9
+ /**
10
+ * Options getter
11
+ *
12
+ * @return array
13
+ */
14
+ public function toOptionArray() {
15
+ return array (
16
+ array (
17
+ 'value' => "sandbox",
18
+ 'label' => Mage::helper ( 'masterpass' )->__ ( 'Sandbox' )
19
+ ),
20
+ array (
21
+ 'value' => "production",
22
+ 'label' => Mage::helper ( 'masterpass' )->__ ( 'Production' )
23
+ )
24
+ )
25
+ ;
26
+ }
27
+
28
+ /**
29
+ * Get options in "key-value" format
30
+ *
31
+ * @return array
32
+ */
33
+ public function toArray() {
34
+ return array (
35
+ 'sandbox' => Mage::helper ( 'masterpass' )->__ ( 'Sandbox' ),
36
+ 'production' => Mage::helper ( 'masterpass' )->__ ( 'Production' )
37
+ )
38
+ ;
39
+ }
40
+ }
app/code/local/MasterCard/Masterpass/Model/System/Config/Source/PaymentGateways.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class MasterCard_Masterpass_Model_System_Config_Source_PaymentGateways
5
+ {
6
+ /**
7
+ * @return array
8
+ */
9
+ public function toOptionArray()
10
+ {
11
+ $request = Mage::app()->getRequest();
12
+ // Show payment methods enabled on store view when viewed by the associated store view scope
13
+ $storeCode = $request->getParam("store", null);
14
+
15
+ if (!$storeCode) {
16
+ $websiteCode = $request->getParam("website", null);
17
+
18
+ if ($websiteCode) {
19
+ $website = Mage::getModel("core/website")->load($websiteCode, "code");
20
+ $storeCode = $website->getDefaultStore();
21
+ }
22
+ }
23
+
24
+ /** @var Mage_Core_Model_Config_Element $paymentMethodConfigXml */
25
+ $paymentMethodConfigXml = Mage::getSingleton("adminhtml/config")->getSection("payment")->groups;
26
+ $methods = Mage::getSingleton("payment/config")->getActiveMethods($storeCode);
27
+
28
+ // Initialise it with an empty value/label so the user can deselect all available methods if desired.
29
+ // Doing so will put the extension in a disabled state.
30
+ $options = array(array("value" => "", "label" => ""));
31
+ foreach ($methods as $key => $method) {
32
+ if (!($method instanceof Mage_Payment_Model_Method_Cc)) {
33
+ continue;
34
+ }
35
+
36
+ if (!empty($paymentMethodConfigXml->{$key}->label)) {
37
+ $label = (string) $paymentMethodConfigXml->{$key}->label;
38
+ } else {
39
+ $label = $method->getTitle();
40
+ }
41
+ $options[] = array(
42
+ "value" => $key,
43
+ "label" => $label,
44
+ );
45
+ }
46
+
47
+ return $options;
48
+ }
49
+ }
app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Transactionurl.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Used in creating options for Yes|No config value selection
5
+ *
6
+ */
7
+ class MasterCard_Masterpass_Model_System_Config_Source_Transactionurl {
8
+
9
+ /**
10
+ * Options getter
11
+ *
12
+ * @return array
13
+ */
14
+ public function toOptionArray() {
15
+ return array (
16
+ array (
17
+ 'value' => 'https://sandbox.api.mastercard.com/online/v2/transaction',
18
+ 'label' => Mage::helper ( 'masterpass' )->__ ( 'Sandbox' )
19
+ ),
20
+ array (
21
+ 'value' => '0',
22
+ 'label' => Mage::helper ( 'masterpass' )->__ ( '0' )
23
+ )
24
+ );
25
+ }
26
+
27
+ /**
28
+ * Get options in "key-value" format
29
+ *
30
+ * @return array
31
+ */
32
+ public function toArray() {
33
+ return array (
34
+ '0' => Mage::helper ( 'masterpass' )->__ ( '0' ),
35
+ 'https://sandbox.api.mastercard.com/online/v2/transaction' => Mage::helper ( 'masterpass' )->__ ( 'Sandbox' )
36
+ );
37
+ }
38
+ }
app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Trueorfalse.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Used in creating options for Shipping suppression config value selection
5
+ *
6
+ */
7
+ class MasterCard_Masterpass_Model_System_Config_Source_Trueorfalse {
8
+
9
+ /**
10
+ * Options getter
11
+ *
12
+ * @return array
13
+ */
14
+ public function toOptionArray() {
15
+ return array (
16
+ array (
17
+ 'value' => "true",
18
+ 'label' => Mage::helper ( 'masterpass' )->__ ( 'true' )
19
+ ),
20
+ array (
21
+ 'value' => "false",
22
+ 'label' => Mage::helper ( 'masterpass' )->__ ( 'false' )
23
+ )
24
+ )
25
+ ;
26
+ }
27
+
28
+ /**
29
+ * Get options in "key-value" format
30
+ *
31
+ * @return array
32
+ */
33
+ public function toArray() {
34
+ return array (
35
+ 'true' => Mage::helper ( 'masterpass' )->__ ( 'true' ),
36
+ 'false' => Mage::helper ( 'masterpass' )->__ ( 'false' )
37
+ )
38
+ ;
39
+ }
40
+ }
app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Userflows.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Used in creating options for User Flows config value selection
5
+ *
6
+ */
7
+ class MasterCard_Masterpass_Model_System_Config_Source_Userflows {
8
+
9
+ /**
10
+ * Options getter
11
+ *
12
+ * @return array
13
+ */
14
+ public function toOptionArray() {
15
+ return array(
16
+ array(
17
+ 'value' => '1',
18
+ 'label' => Mage::helper('masterpass')->__('Standard Checkout')
19
+ ),
20
+ /* array(
21
+ 'value' => '2',
22
+ 'label' => Mage::helper('masterpass')->__('Connected Checkout')
23
+ ), */
24
+ array(
25
+ 'value' => '3',
26
+ 'label' => Mage::helper('masterpass')->__('Express Checkout')
27
+ )
28
+ )
29
+ ;
30
+ }
31
+
32
+ /**
33
+ * Get options in "key-value" format
34
+ *
35
+ * @return array
36
+ */
37
+ public function toArray() {
38
+ return array(
39
+ '1' => Mage::helper('masterpass')->__('Standard Checkout'),
40
+ '2' => Mage::helper('masterpass')->__('Express Checkout')
41
+ )
42
+ ;
43
+ }
44
+
45
+ }
app/code/local/MasterCard/Masterpass/Model/System/Config/Source/Xmlversion.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Used in creating options for Xml version config value selection
5
+ *
6
+ */
7
+ class MasterCard_Masterpass_Model_System_Config_Source_Xmlversion {
8
+
9
+ /**
10
+ * Options getter
11
+ *
12
+ * @return array
13
+ */
14
+ public function toOptionArray() {
15
+ return array (
16
+ array (
17
+ 'value' => "v6",
18
+ 'label' => Mage::helper ( 'masterpass' )->__ ( 'V6' )
19
+ )
20
+
21
+ );
22
+ }
23
+
24
+ /**
25
+ * Get options in "key-value" format
26
+ *
27
+ * @return array
28
+ */
29
+ public function toArray() {
30
+ return array (
31
+ 'v6' => Mage::helper ( 'masterpass' )->__ ( 'V6' )
32
+
33
+ )
34
+ ;
35
+ }
36
+ }
app/code/local/MasterCard/Masterpass/controllers/IndexController.php ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * Developer: Pavith Lovan
5
+ */
6
+
7
+ class MasterCard_Masterpass_IndexController extends Mage_Core_Controller_Front_Action {
8
+ /*
9
+ * this method privides default action.
10
+ */
11
+
12
+ protected $mpshipping;
13
+ protected $_quote = null;
14
+ const APPROVAL_CODE = 'plMGCE';
15
+
16
+ public function indexAction() {
17
+
18
+ $this->_redirect('checkout/cart');
19
+ return $this;
20
+ }
21
+
22
+ public function checkoutAction() {
23
+ //if (!$this->getQuote()->isAllowedGuestCheckout()){
24
+ // $this->_redirect('checkout/onepage');
25
+ //}
26
+ if (!Mage::getSingleton('checkout/session')->getMasterPassCard()) {
27
+ $this->_redirect('checkout/cart');
28
+ return $this;
29
+ }
30
+
31
+ if ($this->getRequest()->isPost()) {
32
+ $data = $this->getRequest()->getPost('shipping', array());
33
+ $customerAddressId = $this->getRequest()->getPost('shipping_address_id', false);
34
+ $this->getOnepage()->saveShipping($data, $customerAddressId);
35
+ }
36
+
37
+ $this->loadLayout();
38
+ $this->_title(Mage::helper('masterpass')->__('Checkout With MasterPass'))
39
+ ->_title('Checkout With MasterPass');
40
+ $this->renderLayout();
41
+ }
42
+
43
+ public function callBackAction() {
44
+ // if customer login and agree to pair
45
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
46
+ $pairing_token = $this->getRequest()->getParam('pairing_token');
47
+ $pairing_verifier = $this->getRequest()->getParam('pairing_verifier');
48
+ //if customer allow pairing
49
+ if ($pairing_token || $pairing_verifier) {
50
+ $this->pairingcallback();
51
+ }
52
+ }
53
+ $requestToken = $this->getRequest()->getParam("oauth_token");
54
+ $requestVerifier = $this->getRequest()->getParam("oauth_verifier");
55
+ $checkoutResourceUrl = $this->getRequest()->getParam("checkout_resource_url");
56
+
57
+ if (!$requestToken || !$requestVerifier || !$checkoutResourceUrl) {
58
+ Mage::getSingleton('core/session')->addError(Mage::getStoreConfig('masterpass/config/checkouterrormessage'));
59
+ $this->_redirect('checkout/cart');
60
+ return $this;
61
+ }
62
+ try {
63
+ $accessTokenResponse = Mage::helper('masterpass')->getAccessToken($requestToken, $requestVerifier);
64
+ if (!$accessTokenResponse) {
65
+ Mage::getSingleton('core/session')->addError(Mage::getStoreConfig('masterpass/config/checkouterrormessage'));
66
+ $this->_redirect('checkout/cart');
67
+ return $this;
68
+ }
69
+ if ($accessTokenResponse->accessToken) {
70
+ $checkoutData = Mage::helper('masterpass')->getCheckoutData($checkoutResourceUrl, $accessTokenResponse->accessToken);
71
+
72
+
73
+ $masterpassData = simplexml_load_string($checkoutData);
74
+ $preData = json_decode(json_encode((array) $masterpassData), 1);
75
+
76
+ //if customer is not logged in set checkout method as a guest
77
+ if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
78
+ $checkout_method = 'guest';
79
+ }
80
+ $result = $this->getOnepage()->saveCheckoutMethod($checkout_method);
81
+
82
+ //save Billing address
83
+ $this->saveBilling($preData);
84
+ // if order is not required shipping address
85
+ if (!$this->getQuote()->getIsVirtual()) { // required shipping
86
+ $this->saveShipping($preData['ShippingAddress']);
87
+ }
88
+
89
+ Mage::getSingleton('checkout/session')->setMasterPassCard($preData['Card']);
90
+ $postback_data = array(
91
+ 'transaction_id' => $preData['TransactionId'],
92
+ 'precheckout_id' => $preData['PreCheckoutTransactionId']
93
+ );
94
+ // store postback_data to post transaction back to masterpass.
95
+ Mage::getSingleton('checkout/session')->setPostBackData($postback_data);
96
+
97
+ $cardMask = array(
98
+ 'cardType' => $preData['Card']['BrandName'],
99
+ 'cardHolder' => $preData['Card']['CardHolderName'],
100
+ 'last4' => substr($preData['Card']['AccountNumber'], -4),
101
+ 'expiryMonth' => $preData['Card']['ExpiryMonth'],
102
+ 'expiryYear' => $preData['Card']['ExpiryYear']);
103
+ if (isset($preData['RewardProgram'])) {
104
+ $cardMask['RewardProgram'] = $preData['RewardProgram'];
105
+ }
106
+ Mage::getSingleton('checkout/session')->setCardMask($cardMask);
107
+
108
+ $this->_redirect('masterpass/index/checkout', array('_secure' => true));
109
+ }
110
+ } catch (Exception $ex) {
111
+ Mage::getSingleton('core/session')->addError(Mage::getStoreConfig('masterpass/config/checkouterrormessage'));
112
+ $this->_redirect('checkout/cart');
113
+ }
114
+ }
115
+
116
+ // create order
117
+ public function placeOrderAction() {
118
+ try {
119
+ $this->savePayment();
120
+
121
+ $cdata = Mage::helper('masterpass')->getCardData($brandId = null);
122
+
123
+ if ($cdata) {
124
+ $cdata['checks'] = Mage_Payment_Model_Method_Abstract::CHECK_USE_CHECKOUT | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY | Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX | Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL;
125
+ $this->getOnepage()->getQuote()->getPayment()->importData($cdata);
126
+ }
127
+
128
+ $this->getOnepage()->saveOrder();
129
+ $this->getOnepage()->getQuote()->save();
130
+
131
+ $TransactionStatus = 'Success';
132
+ Mage::helper('masterpass')->postTransaction(Mage::getSingleton('checkout/session')->getPostBackData(),$TransactionStatus, self::APPROVAL_CODE);
133
+
134
+ $this->_redirect('masterpass/index/success', array('_secure' => true));
135
+ } catch (Exception $e) {
136
+ $TransactionStatus = 'Failure';
137
+ Mage::helper('masterpass')->postTransaction(Mage::getSingleton('checkout/session')->getPostBackData(),$TransactionStatus,self::APPROVAL_CODE);
138
+ Mage::getSingleton('core/session')->addError($e->getMessage());
139
+ $this->_redirect('masterpass/index/checkout', array('_secure' => true));
140
+ return $this;
141
+ }
142
+ }
143
+
144
+ // order summery
145
+ public function reviewAction() {
146
+ $this->loadLayout(false);
147
+ $this->renderLayout();
148
+ }
149
+
150
+ public function saveShippingMethodAction() {
151
+ if ($this->getRequest()->isPost()) {
152
+ $data = $this->getRequest()->getPost('shippingmethod', '');
153
+ $result = $this->getOnepage()->saveShippingMethod($data);
154
+ // $result will contain error data if shipping method is empty
155
+
156
+ $this->getOnepage()->getQuote()->collectTotals()->save();
157
+ // $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
158
+ }
159
+ $this->loadLayout(false);
160
+ $this->renderLayout();
161
+ }
162
+
163
+ protected function saveBilling($preData) {
164
+
165
+ if (!is_array($preData['Card']['BillingAddress']['Line2'])) {
166
+ $line2 = $preData['Card']['BillingAddress']['Line2'];
167
+ } else {
168
+ $line2 = '';
169
+ }
170
+
171
+ $mpData = Mage::getModel('masterpass/masterpass');
172
+ $regionIdb = Mage::helper('masterpass')->checkMasterpassData($mpData->statesMapping($preData['Card']['BillingAddress']['CountrySubdivision']));
173
+ $regionb = Mage::helper('masterpass')->checkMasterpassData($mpData->getMasterpassRegion($preData['Card']['BillingAddress']['CountrySubdivision']));
174
+ $bPhone = $mpData->getRemoveDash(Mage::helper('masterpass')->checkMasterpassData($preData['Contact']['PhoneNumber']));
175
+
176
+ $bdata = array(
177
+ 'firstname' => htmlentities($preData['Contact']['FirstName']),
178
+ 'lastname' => htmlentities($preData['Contact']['LastName']),
179
+ 'street' => array(0 => htmlentities($preData['Card']['BillingAddress']['Line1']), 1 => htmlentities($line2)),
180
+ 'city' => htmlentities($preData['Card']['BillingAddress']['City']),
181
+ 'region_id' => $regionIdb,
182
+ 'region' => htmlentities($regionb),
183
+ 'postcode' => $preData['Card']['BillingAddress']['PostalCode'],
184
+ 'country_id' => htmlentities($preData['Card']['BillingAddress']['Country']),
185
+ 'telephone' => $bPhone,
186
+ //'use_for_shipping' => 1
187
+ );
188
+
189
+ if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
190
+ $bdata['email'] = trim($preData['Contact']['EmailAddress']);
191
+ }
192
+
193
+ try {
194
+ $customerAddressId = null; //$this->getRequest()->getPost('billing_address_id', false);
195
+ $this->getOnepage()->saveBilling($bdata, $customerAddressId);
196
+ } catch (Exception $e) {
197
+ Mage::getSingleton('core/session')->addError(Mage::getStoreConfig('masterpass/config/checkouterrormessage'));
198
+ $this->_redirect('checkout/cart');
199
+ }
200
+ }
201
+
202
+ protected function saveShipping($preData) {
203
+
204
+ $reecipientName = $preData['RecipientName'];
205
+ $name = Mage::helper('masterpass')->getRecipienName($reecipientName);
206
+
207
+ if (!is_array($preData['Line2'])) {
208
+ $lin2 = $preData['Line2'];
209
+ } else {
210
+ $lin2 = null;
211
+ }
212
+
213
+ if (!is_array($preData['Line3'])) {
214
+ $lin3 = $preData['Line3'];
215
+ } else {
216
+ $lin3 = null;
217
+ }
218
+
219
+ $mpData = Mage::getModel('masterpass/masterpass');
220
+ $regionIdS = Mage::helper('masterpass')->checkMasterpassData($mpData->statesMapping($preData['CountrySubdivision']));
221
+ $regionS = Mage::helper('masterpass')->checkMasterpassData($mpData->getMasterpassRegion($preData['CountrySubdivision']));
222
+ $shippingPhone = $mpData->getRemoveDash(Mage::helper('masterpass')->checkMasterpassData($preData['RecipientPhoneNumber']));
223
+ $sdata = array(
224
+ 'firstname' => htmlentities($name[0]),
225
+ 'lastname' => htmlentities($name[1]),
226
+ 'street' => array(0 => htmlentities($preData['Line1']), 1 => htmlentities($lin2), 2 => htmlentities($lin3)),
227
+ 'city' => htmlentities($preData['City']),
228
+ 'region_id' => $regionIdS,
229
+ 'region' => htmlentities($regionS),
230
+ 'postcode' => $preData['PostalCode'],
231
+ 'country_id' => htmlentities($preData['Country']),
232
+ 'telephone' => $shippingPhone,
233
+ );
234
+
235
+ try {
236
+ $customerAddressId = null;
237
+ $this->getOnepage()->saveShipping($sdata, $customerAddressId);
238
+ return true;
239
+ } catch (Exception $e) {
240
+ Mage::getSingleton('core/session')->addError(Mage::getStoreConfig('masterpass/config/checkouterrormessage'));
241
+ $this->_redirect('checkout/cart');
242
+ }
243
+ }
244
+
245
+ protected function savePayment() {
246
+ //save payment
247
+
248
+ $cdata = Mage::helper('masterpass')->getCardData($brandId = null);
249
+
250
+ try {
251
+ $this->getOnepage()->savePayment($cdata);
252
+ } catch (Mage_Core_Exception $e) {
253
+ Mage::getSingleton('core/session')->addError($e->getMessage());
254
+ $this->_redirect('checkout/cart');
255
+ }
256
+ }
257
+
258
+ protected function getOnepage() {
259
+ return Mage::getSingleton('checkout/type_onepage');
260
+ }
261
+
262
+ protected function getQuote() {
263
+ if ($this->_quote === null) {
264
+ $this->_quote = Mage::getSingleton("checkout/session")->getQuote();
265
+ }
266
+ return $this->_quote;
267
+ }
268
+
269
+ protected function pairingcallback() {
270
+
271
+ $pairing_token = $this->getRequest()->getParam('pairing_token');
272
+ $pairing_verifier = $this->getRequest()->getParam('pairing_verifier');
273
+
274
+ $preCheckoutData = null;
275
+ if ($pairing_token || $pairing_verifier) {
276
+
277
+ $longAccessToken = Mage::helper('masterpass')->getAccessToken($pairing_token, $pairing_verifier);
278
+ if ($longAccessToken->accessToken) {
279
+ //save long access token
280
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
281
+ $customerData = Mage::getModel('customer/customer')->load($customer->getId());
282
+ $customerData->setData('longtoken', $longAccessToken->accessToken);
283
+
284
+ try {
285
+ $customerData->save();
286
+ } catch (Exception $e) {
287
+ Mage::log($e->getMessage());
288
+ }
289
+ }
290
+ }
291
+ }
292
+
293
+ protected function checkMasterpassData($mpData) {
294
+ if (!is_array($mpData)) {
295
+ $mpAfterCheck = $mpData;
296
+ } else {
297
+ $mpAfterCheck = '';
298
+ }
299
+ return $mpAfterCheck;
300
+ }
301
+
302
+ // express callback
303
+ public function expresscallbackAction() {
304
+
305
+ if (Mage::getSingleton('customer/session')->isLoggedIn()) {
306
+ $pairing_token = $this->getRequest()->getParam('pairing_token');
307
+ $pairing_verifier = $this->getRequest()->getParam('pairing_verifier');
308
+ $preCheckoutData = null;
309
+ if (!$pairing_token || !$pairing_verifier) {
310
+ Mage::helper('masterpass')->resetMasterData();
311
+ $generic_error_message = Mage::getStoreConfig('masterpass/config/checkouterrormessage');
312
+ Mage::getSingleton('core/session')->addError($generic_error_message);
313
+ $this->_redirect('checkout/cart');
314
+ }
315
+ try {
316
+ $longAccessToken = Mage::helper('masterpass')->getAccessToken($pairing_token, $pairing_verifier);
317
+ if ($longAccessToken->accessToken) {
318
+ //save long access token
319
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
320
+ $customerData = Mage::getModel('customer/customer')->load($customer->getId());
321
+ $customerData->setData('longtoken', $longAccessToken->accessToken);
322
+ $customerData->save();
323
+
324
+ $this->_redirect('masterpass/masterpasspairing/precheckout', array('_secure' => true));
325
+ } else {
326
+ $this->_redirect('checkout/cart');
327
+ }
328
+ } catch (Exception $e) {
329
+ Mage::helper('masterpass')->resetMasterData();
330
+ $generic_error_message = Mage::getStoreConfig('masterpass/config/checkouterrormessage');
331
+ Mage::getSingleton('core/session')->addError($generic_error_message);
332
+ $this->_redirect('checkout/cart');
333
+ }
334
+ } else {
335
+ $this->_redirect('checkout/cart');
336
+ }
337
+ }
338
+
339
+
340
+ //check if privatekey path is empty
341
+ public function validatePkAction() {
342
+ $result = false;
343
+ if (Mage::helper('masterpass')->checkPrivateKey()) {
344
+ $result = true;
345
+ } else {
346
+ Mage::getSingleton('core/session')->addError(Mage::getStoreConfig('masterpass/config/checkouterrormessage'));
347
+ $result = false;
348
+ }
349
+ echo $result;
350
+ }
351
+
352
+ //order confirmation
353
+ public function successAction() {
354
+
355
+ $session = $this->getOnepage()->getCheckout();
356
+ if (!$session->getLastSuccessQuoteId()) {
357
+ $this->_redirect('checkout/cart');
358
+ return;
359
+ }
360
+
361
+ $lastQuoteId = $session->getLastQuoteId();
362
+ $lastOrderId = $session->getLastOrderId();
363
+ $lastRecurringProfiles = $session->getLastRecurringProfileIds();
364
+ if (!$lastQuoteId || (!$lastOrderId && empty($lastRecurringProfiles))) {
365
+ $this->_redirect('checkout/cart');
366
+ return;
367
+ }
368
+
369
+ $session->clear();
370
+ $this->loadLayout();
371
+ $this->_initLayoutMessages('checkout/session');
372
+ Mage::dispatchEvent('checkout_onepage_controller_success_action', array('order_ids' => array($lastOrderId)));
373
+ $this->renderLayout();
374
+ }
375
+
376
+ }
app/code/local/MasterCard/Masterpass/controllers/MasterpasspairingController.php ADDED
@@ -0,0 +1,663 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class MasterCard_Masterpass_MasterpasspairingController extends Mage_Core_Controller_Front_Action {
3
+
4
+ /**
5
+ * Stores the customer's quote data object.
6
+ *
7
+ * @var Mage_Sales_Model_Quote
8
+ */
9
+ protected $_quote = null;
10
+ // make sure customer is login
11
+ protected $_checkout = null;
12
+ const APPROVAL_CODE = 'plMGCE';
13
+
14
+ // if customer is not logged in redirect to loggin page
15
+ public function preDispatch() {
16
+ parent::preDispatch ();
17
+
18
+ if (! Mage::getSingleton ( 'customer/session' )->authenticate ( $this )) {
19
+ $this->getResponse ()->setRedirect ( Mage::helper ( 'customer' )->getLoginUrl () );
20
+ $this->setFlag ( '', self::FLAG_NO_DISPATCH, true );
21
+ }
22
+
23
+ return $this;
24
+ }
25
+ public function getOnepage() {
26
+ return Mage::getSingleton ( 'checkout/type_onepage' );
27
+ }
28
+ public function indexAction() {
29
+ $this->loadLayout ();
30
+
31
+ $this->_title ( Mage::helper ( 'masterpass' )->__ ( 'My MasterPass' ) )->_title ( $methodTitle );
32
+
33
+ $breadcrumbs = $this->getLayout ()->getBlock ( 'breadcrumbs' );
34
+ $breadcrumbs->addCrumb ( 'masterpass', array (
35
+ 'label' => Mage::helper ( 'masterpass' )->__ ( 'My MasterPass Pairing' ),
36
+ 'title' => Mage::helper ( 'masterpass' )->__ ( 'My MasterPass Pairing' ),
37
+ 'link' => Mage::getUrl ( '*/*' )
38
+ ) );
39
+
40
+ $this->renderLayout ();
41
+ }
42
+ public function precheckoutAction() {
43
+ $getOnepage = $this->getOnepage ();
44
+ if ($this->_checkPk ()) {
45
+ $this->_redirect ( "checkout/cart" );
46
+ return $this;
47
+ }
48
+ if (! $getOnepage->getQuote ()->hasItems ()) {
49
+ $this->_redirect ( "checkout/cart" );
50
+ return $this;
51
+ }
52
+ $this->_getQuote ()->setMayEditShippingMethod ( true )->save ();
53
+
54
+ $this->loadLayout ();
55
+ $this->getLayout ()->getBlock ( 'head' )->setTitle ( $this->__ ( 'Checkout With MasterPass' ) );
56
+ $this->renderLayout ();
57
+ }
58
+ private function _checkPk() {
59
+ // if private key path is empty redirect customer to shopping cart page
60
+ $result = false;
61
+ $private_key = Mage::helper ( 'masterpass' )->checkPrivateKey ();
62
+ if (! $private_key) {
63
+ Mage::getSingleton ( 'core/session' )->addError ( Mage::getStoreConfig ( 'masterpass/config/checkouterrormessage' ) );
64
+ // save long access token
65
+ $customer = Mage::getSingleton ( 'customer/session' )->getCustomer ();
66
+ $customerData = Mage::getModel ( 'customer/customer' )->load ( $customer->getId () );
67
+ $longAccessToken = null;
68
+ $customerData->setData ( 'longtoken', $longAccessToken );
69
+
70
+ $customerData->save ();
71
+ // $this->_redirect('checkout/cart');
72
+ // $this->getResponse()->setRedirect(Mage::helper('customer')->getLoginUrl());
73
+ $result = true;
74
+ }
75
+ return $result;
76
+ }
77
+
78
+ // get shipping methods
79
+ public function availableshippingAction() {
80
+ $country = ( string ) $this->getRequest ()->getParam ( 'country_id' );
81
+ $postcode = ( string ) $this->getRequest ()->getParam ( 'postcode' );
82
+ $city = ( string ) $this->getRequest ()->getParam ( 'city' );
83
+ $regionId = ( string ) $this->getRequest ()->getParam ( 'region_id' );
84
+ $region = ( string ) $this->getRequest ()->getParam ( 'region' );
85
+
86
+ $this->_getQuote ()->getShippingAddress ()->setCountryId ( $country )->setCity ( $city )->setPostcode ( $postcode )->setRegionId ( $regionId )->setRegion ( $region )->setCollectShippingRates ( true );
87
+ $this->_getQuote ()->save ();
88
+ $this->loadLayout ( false );
89
+ $this->renderLayout ();
90
+ }
91
+
92
+ // order summery
93
+ public function reviewAction() {
94
+ $this->loadLayout ( false );
95
+ $this->renderLayout ();
96
+ }
97
+
98
+ /**
99
+ * Shipping address save action
100
+ */
101
+ public function saveShippingAction() {
102
+ if ($this->getRequest ()->isPost ()) {
103
+ $preAddr = Mage::getSingleton ( 'customer/session' )->getPreaddress ();
104
+
105
+ if ($preAddr) {
106
+ $data = array ();
107
+ if (! empty ( $preAddr ['ShippingAddress'] [0] )) {
108
+ $preData = $preAddr ['ShippingAddress'];
109
+ } else {
110
+ $preData = $preAddr;
111
+ }
112
+ $dataId = $this->getRequest ()->getPost ( 'addressid' );
113
+
114
+ $mpData = Mage::getModel ( 'masterpass/masterpass' );
115
+ foreach ( $preData as $value ) {
116
+ if ($dataId == $value ['AddressId']) {
117
+ $reecipientName = $value ['RecipientName'];
118
+ $name = Mage::helper ( 'masterpass' )->getRecipienName ( $reecipientName );
119
+
120
+ if (! is_array ( $value ['Line2'] )) {
121
+ $lin2 = $value ['Line2'];
122
+ } else {
123
+ $lin2 = null;
124
+ }
125
+
126
+ if (! is_array ( $value ['Line3'] )) {
127
+ $lin3 = $value ['Line3'];
128
+ } else {
129
+ $lin3 = null;
130
+ }
131
+
132
+ $regionIdS = Mage::helper ( 'masterpass' )->checkMasterpassData ( $mpData->statesMapping ( $value ['CountrySubdivision'] ) );
133
+ $regionS = Mage::helper ( 'masterpass' )->checkMasterpassData ( $mpData->getMasterpassRegion ( $value ['CountrySubdivision'] ) );
134
+ $shippingPhone = $mpData->getRemoveDash ( Mage::helper ( 'masterpass' )->checkMasterpassData ( $value ['RecipientPhoneNumber'] ) );
135
+ $data = array (
136
+ 'firstname' => $name [0],
137
+ 'lastname' => $name [1],
138
+ 'street' => array (
139
+ 0 => $value ['Line1'],
140
+ 1 => $lin2,
141
+ 2 => $lin3
142
+ ),
143
+ 'city' => $value ['City'],
144
+ 'region_id' => $regionIdS,
145
+ 'region' => $regionS,
146
+ 'postcode' => $value ['PostalCode'],
147
+ 'country_id' => $value ['Country'],
148
+ 'telephone' => $shippingPhone
149
+ );
150
+ break;
151
+ }
152
+ }
153
+ $customerAddressId = $this->getRequest ()->getPost ( 'shipping_address_id', false );
154
+ $this->getOnepage ()->saveShipping ( $data, $customerAddressId );
155
+ }
156
+ }
157
+ $this->loadLayout ( false );
158
+ $this->renderLayout ();
159
+ }
160
+ public function saveShippingMethodAction() {
161
+ if ($this->getRequest ()->isPost ()) {
162
+ $data = $this->getRequest ()->getPost ( 'shippingmethod', '' );
163
+ $result = $this->getOnepage ()->saveShippingMethod ( $data );
164
+ // $result will contain error data if shipping method is empty
165
+
166
+ $this->getOnepage ()->getQuote ()->collectTotals ()->save ();
167
+ }
168
+ $this->loadLayout ( false );
169
+ $this->renderLayout ();
170
+ }
171
+ public function pairingcallbackAction() {
172
+ $pairing_token = $this->getRequest ()->getParam ( 'pairing_token' );
173
+ $pairing_verifier = $this->getRequest ()->getParam ( 'pairing_verifier' );
174
+ $preCheckoutData = null;
175
+ if (! $pairing_token || ! $pairing_verifier) {
176
+ Mage::helper ( 'masterpass' )->resetMasterData ();
177
+ // $generic_error_message = Mage::getStoreConfig('masterpass/config/checkouterrormessage');
178
+ // Mage::getSingleton('core/session')->addError($generic_error_message);
179
+ $this->_redirect ( 'masterpass/masterpasspairing/' );
180
+ return $this;
181
+ }
182
+ try {
183
+ $longAccessToken = Mage::helper ( 'masterpass' )->getAccessToken ( $pairing_token, $pairing_verifier );
184
+ if ($longAccessToken->accessToken) {
185
+ // save long access token
186
+ $customer = Mage::getSingleton ( 'customer/session' )->getCustomer ();
187
+ $customerData = Mage::getModel ( 'customer/customer' )->load ( $customer->getId () );
188
+ $customerData->setData ( 'longtoken', $longAccessToken->accessToken );
189
+ try {
190
+ $customerData->save ();
191
+ $this->_redirect ( 'masterpass/masterpasspairing/' );
192
+ } catch ( Exception $e ) {
193
+ Mage::getSingleton ( 'core/session' )->addError ( 'There is a problem please try again later.' );
194
+ $this->_redirect ( 'masterpass/masterpasspairing/' );
195
+ }
196
+ } else {
197
+ $this->_redirect ( 'masterpass/masterpasspairing/' );
198
+ }
199
+ } catch ( Exception $e ) {
200
+ Mage::helper ( 'masterpass' )->resetMasterData ();
201
+ $generic_error_message = Mage::getStoreConfig ( 'masterpass/config/checkouterrormessage' );
202
+ Mage::getSingleton ( 'core/session' )->addError ( $generic_error_message );
203
+ $this->_redirect ( 'masterpass/masterpasspairing/' );
204
+ }
205
+ }
206
+
207
+ /**
208
+ * Get checkout quote object.
209
+ *
210
+ * @return Mage_Sales_Model_Quote
211
+ */
212
+ protected function _getQuote() {
213
+ if ($this->_quote === null) {
214
+ $this->_quote = $this->_getCheckoutSession ()->getQuote ();
215
+ }
216
+ return $this->_quote;
217
+ }
218
+
219
+ /**
220
+ * Get checkout session object.
221
+ *
222
+ * @return Mage_Checkout_Model_Session
223
+ */
224
+ protected function _getCheckoutSession() {
225
+ if ($this->_checkoutSession === null) {
226
+ $this->_checkoutSession = Mage::getSingleton ( "checkout/session" );
227
+ }
228
+ return $this->_checkoutSession;
229
+ }
230
+ public function placeOrderAction() {
231
+ // check if private key path is empty
232
+ if ($this->_checkPk ()) {
233
+ $this->_redirect ( "checkout/cart" );
234
+ return $this;
235
+ }
236
+ if ($this->getRequest ()->isPost ()) {
237
+ $post = $this->getRequest ()->getPost ();
238
+ Mage::getSingleton ( 'customer/session' )->setExprsFormData ( $post );
239
+
240
+ $translate = Mage::getSingleton ( 'core/translate' );
241
+ /* @var $translate Mage_Core_Model_Translate */
242
+ $translate->setTranslateInline ( false );
243
+ try {
244
+ $quote = $this->getQuote ();
245
+ $postObject = new Varien_Object ();
246
+ $postObject->setData ( $post );
247
+
248
+ $error = false;
249
+
250
+ if (! Zend_Validate::is ( trim ( $post ['longaccesstoken'] ), 'NotEmpty' )) {
251
+ $error = true;
252
+ }
253
+ if (! Zend_Validate::is ( trim ( $post ['cards'] ), 'NotEmpty' )) {
254
+ $error = true;
255
+ }
256
+ if (! $quote->getIsVirtual ()) {
257
+
258
+ if (! Zend_Validate::is ( trim ( $post ['address'] ), 'NotEmpty' ) && ! $post ['shipping']) {
259
+ $error = true;
260
+ }
261
+ }
262
+
263
+ if ($error) {
264
+ throw new Exception ();
265
+ } else {
266
+ $precheckoutData = Mage::helper ( 'masterpass' )->postExpressCheckoutData ( $post );
267
+ $precheckoutData = json_decode ( json_encode ( ( array ) $precheckoutData ), 1 );
268
+ if (empty ( $precheckoutData )) {
269
+
270
+ // remove longaccesstoken
271
+ // save long access token
272
+ $customer = Mage::getSingleton ( 'customer/session' )->getCustomer ();
273
+ $customerData = Mage::getModel ( 'customer/customer' )->load ( $customer->getId () );
274
+ $longAccessToken = null;
275
+ $customerData->setData ( 'longtoken', $longAccessToken );
276
+
277
+ $customerData->save ();
278
+ Mage::getSingleton ( 'core/session' )->addError ( Mage::getStoreConfig ( 'masterpass/config/checkouterrormessage' ) );
279
+ $this->_redirect ( 'checkout/cart' );
280
+ return $this;
281
+ }
282
+ if (! empty ( $precheckoutData ['Checkout'] )) {
283
+ $this->savePrecheckoutData ( $precheckoutData );
284
+ } else {
285
+ $customer = Mage::getSingleton ( 'customer/session' )->getCustomer ();
286
+ $customerData = Mage::getModel ( 'customer/customer' )->load ( $customer->getId () );
287
+ $customerData->save ();
288
+
289
+ if (isset ( $precheckoutData ['Errors'] ['Error'] ['Source'] )) {
290
+ if ($precheckoutData ['Errors'] ['Error'] ['Source'] == "3DS Needed") {
291
+ throw new Mage_Core_Exception ( "3DS Needed" );
292
+ }
293
+ }
294
+ }
295
+ }
296
+ } catch ( Mage_Core_Exception $e ) {
297
+ if ($e->getMessage () == "3DS Needed") {
298
+ Mage::getSingleton ( 'core/session' )->setExpSecure ( true );
299
+ } else {
300
+ Mage::getSingleton ( 'core/session' )->setExpSecure ( false );
301
+ }
302
+
303
+ if (isset ( $postback_data )) {
304
+ $TransactionStatus = 'Failure';
305
+ Mage::helper ( 'masterpass' )->postTransaction ( $postback_data, $TransactionStatus, self::APPROVAL_CODE );
306
+ }
307
+
308
+ $this->_redirect ( 'masterpass/masterpasspairing/precheckout' );
309
+ }
310
+ } else {
311
+ $generic_error_message = Mage::getStoreConfig ( 'masterpass/config/checkouterrormessage' );
312
+ Mage::getSingleton ( 'core/session' )->addError ( $generic_error_message );
313
+ $this->_redirect ( 'masterpass/masterpasspairing/precheckout' );
314
+ }
315
+ }
316
+ public function placeOrderExpressAction() {
317
+ $expressDataValues = Mage::getSingleton ( "customer/session" )->getData ( "expressData" );
318
+ $mpstatus = $this->getRequest ()->getParam ( 'mpstatus' );
319
+
320
+ if ($mpstatus == "failure" || $mpstatus == "cancel") {
321
+ Mage::getSingleton ( 'core/session' )->setExpSecure ( false );
322
+ Mage::getSingleton ( 'core/session' )->addError ( "Authorization Failed. Please Try Again." );
323
+ $this->_redirect ( 'checkout/cart' );
324
+ } else {
325
+ $customer = Mage::getSingleton ( 'customer/session' )->getCustomer ();
326
+ $lonAccessToken = $customer->getData ( 'longtoken' );
327
+
328
+ $expressDataValues ['longaccesstoken'] = $lonAccessToken;
329
+ $expressCheckoutResponse = Mage::helper ( 'masterpass' )->postExpressCheckoutData ( $expressDataValues );
330
+ $precheckoutData = json_decode ( json_encode ( ( array ) $expressCheckoutResponse ), 1 );
331
+ if (! empty ( $precheckoutData ['Checkout'] )) {
332
+ $this->savePrecheckoutData ( $precheckoutData );
333
+ } else {
334
+ Mage::getSingleton ( 'core/session' )->setExpSecure ( false );
335
+ $generic_error_message = Mage::getStoreConfig ( 'masterpass/config/checkouterrormessage' );
336
+ Mage::getSingleton ( 'core/session' )->addError ( $generic_error_message );
337
+ $this->_redirect ( 'masterpass/masterpasspairing/precheckout' );
338
+ }
339
+ }
340
+ }
341
+ public function savePrecheckoutData($precheckoutData) {
342
+ Mage::getSingleton ( 'core/session' )->setExpSecure ( false );
343
+ $preData = $precheckoutData ['Checkout'];
344
+ // send transaction back to masterpass
345
+ $postback_data = array (
346
+ 'transaction_id' => $preData ['TransactionId'],
347
+ 'precheckout_id' => $preData ['PreCheckoutTransactionId']
348
+ );
349
+
350
+ Mage::getSingleton ( 'checkout/session' )->setPostBackExpressData ( $postback_data );
351
+ // get billing address and card
352
+ if (! is_array ( $preData ['Card'] ['BillingAddress'] ['Line2'] )) {
353
+ $line2 = $preData ['Card'] ['BillingAddress'] ['Line2'];
354
+ } else {
355
+ $line2 = '';
356
+ }
357
+
358
+ if (! is_array ( $preData ['Card'] ['BillingAddress'] ['Line3'] )) {
359
+ $line3 = $preData ['Card'] ['BillingAddress'] ['Line3'];
360
+ } else {
361
+ $line3 = '';
362
+ }
363
+
364
+ $mpData = Mage::getModel ( 'masterpass/masterpass' );
365
+ $regionIdb = Mage::helper ( 'masterpass' )->checkMasterpassData ( $mpData->statesMapping ( $preData ['Card'] ['BillingAddress'] ['CountrySubdivision'] ) );
366
+ $regionb = Mage::helper ( 'masterpass' )->checkMasterpassData ( $mpData->getMasterpassRegion ( $preData ['Card'] ['BillingAddress'] ['CountrySubdivision'] ) );
367
+ $bPhone = $mpData->getRemoveDash ( Mage::helper ( 'masterpass' )->checkMasterpassData ( $preData ['Contact'] ['PhoneNumber'] ) );
368
+
369
+ $bdata = array (
370
+ 'firstname' => $preData ['Contact'] ['FirstName'],
371
+ 'lastname' => $preData ['Contact'] ['FirstName'],
372
+ 'street' => array (
373
+ 0 => $preData ['Card'] ['BillingAddress'] ['Line1'],
374
+ 1 => $line2,
375
+ 2 => $line3
376
+ ),
377
+ 'city' => $preData ['Card'] ['BillingAddress'] ['City'],
378
+ 'region_id' => $regionIdb,
379
+ 'region' => $regionb,
380
+ 'postcode' => $preData ['Card'] ['BillingAddress'] ['PostalCode'],
381
+ 'country_id' => $preData ['Card'] ['BillingAddress'] ['Country'],
382
+ 'telephone' => $bPhone
383
+ );
384
+ // save billing address
385
+ try {
386
+ $customerAddressId = $this->getRequest ()->getPost ( 'billing_address_id', false );
387
+ $this->getOnepage ()->saveBilling ( $bdata, $customerAddressId );
388
+ } catch ( Exception $e ) {
389
+ Mage::getSingleton ( 'core/session' )->addError ( $e->getMessage () );
390
+ $this->_redirect ( 'masterpass/masterpasspairing/precheckout' );
391
+ }
392
+
393
+ $quote = $this->getQuote ();
394
+
395
+ $exprsPostedData = Mage::getSingleton ( 'customer/session' )->getExprsFormData ();
396
+ // if virtual product no shipping is required
397
+ if (! $quote->getIsVirtual ()) {
398
+ if ($exprsPostedData ['shipping']) {
399
+ $sdata = $exprsPostedData ['shipping'];
400
+ } else {
401
+ $reecipientName = $preData ['ShippingAddress'] ['RecipientName'];
402
+ $name = Mage::helper ( 'masterpass' )->getRecipienName ( $reecipientName );
403
+
404
+ if (! is_array ( $preData ['ShippingAddress'] ['Line2'] )) {
405
+ $slin2 = $preData ['ShippingAddress'] ['Line2'];
406
+ } else {
407
+ $slin2 = null;
408
+ }
409
+
410
+ if (! is_array ( $preData ['ShippingAddress'] ['Line3'] )) {
411
+ $slin3 = $preData ['ShippingAddress'] ['Line3'];
412
+ } else {
413
+ $slin3 = null;
414
+ }
415
+
416
+ $regionIdS = Mage::helper ( 'masterpass' )->checkMasterpassData ( $mpData->statesMapping ( $preData ['ShippingAddress'] ['CountrySubdivision'] ) );
417
+ $regionS = Mage::helper ( 'masterpass' )->checkMasterpassData ( $mpData->getMasterpassRegion ( $preData ['ShippingAddress'] ['CountrySubdivision'] ) );
418
+ $shippingPhone = $mpData->getRemoveDash ( Mage::helper ( 'masterpass' )->checkMasterpassData ( $preData ['ShippingAddress'] ['RecipientPhoneNumber'] ) );
419
+ $sdata = array (
420
+ 'firstname' => $name [0],
421
+ 'lastname' => $name [1],
422
+ 'street' => array (
423
+ 0 => $preData ['ShippingAddress'] ['Line1'],
424
+ 1 => $slin2,
425
+ 2 => $slin3
426
+ ),
427
+ 'city' => $preData ['ShippingAddress'] ['City'],
428
+ 'region_id' => $regionIdS,
429
+ 'region' => $regionS,
430
+ 'postcode' => $preData ['ShippingAddress'] ['PostalCode'],
431
+ 'country_id' => $preData ['ShippingAddress'] ['Country'],
432
+ 'telephone' => $shippingPhone
433
+ );
434
+ }
435
+
436
+ try {
437
+ $this->getOnepage ()->saveShipping ( $sdata, $customerAddressId );
438
+ } catch ( Exception $e ) {
439
+ Mage::getSingleton ( 'core/session' )->addError ( $e->getMessage () );
440
+ $this->_redirect ( 'masterpass/masterpasspairing/precheckout' );
441
+ }
442
+ }
443
+ // save payment
444
+ $cdata = Mage::helper ( 'masterpass' )->getCardData ( $preData ['Card'] );
445
+
446
+ try {
447
+ $this->getOnepage ()->savePayment ( $cdata );
448
+ } catch ( Mage_Core_Exception $e ) {
449
+ Mage::getSingleton ( 'core/session' )->addError ( $e->getMessage () );
450
+ $this->_redirect ( 'masterpass/masterpasspairing/precheckout' );
451
+ }
452
+
453
+ if ($cdata) {
454
+ $cdata ['checks'] = Mage_Payment_Model_Method_Abstract::CHECK_USE_CHECKOUT | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY | Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX | Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL;
455
+ $this->getOnepage ()->getQuote ()->getPayment ()->importData ( $cdata );
456
+ }
457
+
458
+ $this->getOnepage ()->saveOrder ();
459
+ $this->getOnepage ()->getQuote ()->save ();
460
+
461
+ $TransactionStatus = 'Success';
462
+
463
+ Mage::helper ( 'masterpass' )->postTransaction ( $postback_data, $TransactionStatus, self::APPROVAL_CODE );
464
+ $this->_redirect ( 'masterpass/index/success', array (
465
+ '_secure' => true
466
+ ) );
467
+ }
468
+
469
+ // connect checkout
470
+ public function connectedcheckoutAction() {
471
+ // check private key path is not empty
472
+ if ($this->_checkPk ()) {
473
+ $this->_redirect ( "checkout/cart" );
474
+ return $this;
475
+ }
476
+
477
+ $requestToken = $this->getRequest ()->getParam ( "oauth_token" );
478
+ $requestVerifier = $this->getRequest ()->getParam ( "oauth_verifier" );
479
+ $checkoutResourceUrl = $this->getRequest ()->getParam ( "checkout_resource_url" );
480
+ if (! $requestToken && ! $requestVerifier) {
481
+ $generic_error_message = Mage::getStoreConfig ( 'masterpass/config/checkouterrormessage' );
482
+ Mage::getSingleton ( 'core/session' )->addError ( str_replace ( ':', '', $generic_error_message ) );
483
+ return $this->_redirect ( "checkout/cart" );
484
+ return $this;
485
+ }
486
+
487
+ $quote = $this->getQuote ();
488
+ try {
489
+ $longAccessToken = Mage::helper ( 'masterpass' )->getAccessToken ( $requestToken, $requestVerifier );
490
+ if ($longAccessToken->accessToken) {
491
+
492
+ // get checkout data from masterpass
493
+ $checkoutData = Mage::helper ( 'masterpass' )->getCheckoutData ( $checkoutResourceUrl, $longAccessToken->accessToken );
494
+
495
+ $masterpassData = simplexml_load_string ( $checkoutData );
496
+ $precheckoutData = json_decode ( json_encode ( ( array ) $masterpassData ), 1 );
497
+
498
+ if (! empty ( $precheckoutData )) {
499
+ $preData = $precheckoutData;
500
+ // send transaction back to masterpass
501
+ $postback_data = array (
502
+ 'transaction_id' => $preData ['TransactionId'],
503
+ 'precheckout_id' => $preData ['PreCheckoutTransactionId']
504
+ );
505
+
506
+ // get billing address and card
507
+
508
+ $preData ['Card'] ['BillingAddress'];
509
+
510
+ if (! is_array ( $preData ['Card'] ['BillingAddress'] ['Line2'] )) {
511
+ $line2 = $preData ['Card'] ['BillingAddress'] ['Line2'];
512
+ } else {
513
+ $line2 = '';
514
+ }
515
+ $mpData = Mage::getModel ( 'masterpass/masterpass' );
516
+ $regionIdb = Mage::helper ( 'masterpass' )->checkMasterpassData ( $mpData->statesMapping ( $preData ['Card'] ['BillingAddress'] ['CountrySubdivision'] ) );
517
+ $regionb = Mage::helper ( 'masterpass' )->checkMasterpassData ( $mpData->getMasterpassRegion ( $preData ['Card'] ['BillingAddress'] ['CountrySubdivision'] ) );
518
+ $bPhone = $mpData->getRemoveDash ( Mage::helper ( 'masterpass' )->checkMasterpassData ( $preData ['Contact'] ['PhoneNumber'] ) );
519
+
520
+ $bdata = array (
521
+ 'firstname' => $preData ['Contact'] ['FirstName'],
522
+ 'lastname' => $preData ['Contact'] ['FirstName'],
523
+ 'street' => array (
524
+ 0 => $preData ['Card'] ['BillingAddress'] ['Line1'],
525
+ 1 => $line2
526
+ ),
527
+ 'city' => $preData ['Card'] ['BillingAddress'] ['City'],
528
+ 'region_id' => $regionIdb,
529
+ 'region' => $regionb,
530
+ 'postcode' => $preData ['Card'] ['BillingAddress'] ['PostalCode'],
531
+ 'country_id' => $preData ['Card'] ['BillingAddress'] ['Country'],
532
+ 'telephone' => $bPhone
533
+ );
534
+ // save billing address
535
+ try {
536
+ $customerAddressId = $this->getRequest ()->getPost ( 'billing_address_id', false );
537
+ $this->getOnepage ()->saveBilling ( $bdata, $customerAddressId );
538
+ } catch ( Exception $e ) {
539
+ Mage::getSingleton ( 'core/session' )->addError ( $e->getMessage () );
540
+ $this->_redirect ( 'masterpass/masterpasspairing/precheckout' );
541
+ }
542
+
543
+ // if virtual product no shipping is required
544
+
545
+ if (! $quote->getIsVirtual ()) {
546
+ $reecipientName = $preData ['ShippingAddress'] ['RecipientName'];
547
+
548
+ $name = Mage::helper ( 'masterpass' )->getRecipienName ( $reecipientName );
549
+
550
+ if (! is_array ( $preData ['ShippingAddress'] ['Line2'] )) {
551
+ $slin2 = $preData ['ShippingAddress'] ['Line2'];
552
+ } else {
553
+ $slin2 = null;
554
+ }
555
+ $regionIdS = Mage::helper ( 'masterpass' )->checkMasterpassData ( $mpData->statesMapping ( $preData ['ShippingAddress'] ['CountrySubdivision'] ) );
556
+ $regionS = Mage::helper ( 'masterpass' )->checkMasterpassData ( $mpData->getMasterpassRegion ( $preData ['ShippingAddress'] ['CountrySubdivision'] ) );
557
+ $shippingPhone = $mpData->getRemoveDash ( Mage::helper ( 'masterpass' )->checkMasterpassData ( $preData ['ShippingAddress'] ['RecipientPhoneNumber'] ) );
558
+ $sdata = array (
559
+ 'firstname' => $name [0],
560
+ 'lastname' => $name [1],
561
+ 'street' => array (
562
+ 0 => $preData ['ShippingAddress'] ['Line1'],
563
+ 1 => $slin2
564
+ ),
565
+ 'city' => $preData ['ShippingAddress'] ['City'],
566
+ 'region_id' => $regionIdS,
567
+ 'region' => $regionS,
568
+ 'postcode' => $preData ['ShippingAddress'] ['PostalCode'],
569
+ 'country_id' => $preData ['ShippingAddress'] ['Country'],
570
+ 'telephone' => $shippingPhone
571
+ );
572
+ try {
573
+ $customerAddressId = null;
574
+
575
+ $this->getOnepage ()->saveShipping ( $sdata, $customerAddressId );
576
+ } catch ( Exception $e ) {
577
+ Mage::getSingleton ( 'core/session' )->addError ( $e->getMessage () );
578
+ $this->_redirect ( 'masterpass/masterpasspairing/precheckout' );
579
+ }
580
+ // if connected checkout and address is not paired then auto select shipping method
581
+ if (! Mage::getStoreConfig ( 'masterpass/config/cfaddress' )) {
582
+ $address = $this->getOnepage ()->getQuote ()->getShippingAddress ();
583
+
584
+ $rates = $address->collectShippingRates ()->getGroupedAllShippingRates ();
585
+ asort ( $rates );
586
+ $i = 0;
587
+ $code = null;
588
+ foreach ( $rates as $carrier ) {
589
+ foreach ( $carrier as $rate ) {
590
+
591
+ if ($i < 1) {
592
+ $code = $rate->getData ( 'code' );
593
+ }
594
+ $i ++;
595
+ }
596
+ }
597
+
598
+ try {
599
+
600
+ $this->getOnepage ()->saveShippingMethod ( $code );
601
+ // $this->getOnepage()->getQuote()->collectTotals()->save();
602
+ } catch ( Exception $e ) {
603
+
604
+ Mage::getSingleton ( 'core/session' )->addError ( $e->getMessage () );
605
+ $this->_redirect ( 'masterpass/masterpasspairing/precheckout' );
606
+ }
607
+ }
608
+ // //
609
+ }
610
+
611
+ // save payment
612
+ $cdata = Mage::helper ( 'masterpass' )->getCardData ( $preData ['Card'] );
613
+
614
+ try {
615
+ $this->getOnepage ()->savePayment ( $cdata );
616
+ } catch ( Mage_Core_Exception $e ) {
617
+
618
+ Mage::getSingleton ( 'core/session' )->addError ( $e->getMessage () );
619
+ $this->_redirect ( 'masterpass/masterpasspairing/precheckout' );
620
+ }
621
+
622
+ if ($cdata) {
623
+ $cdata ['checks'] = Mage_Payment_Model_Method_Abstract::CHECK_USE_CHECKOUT | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY | Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX | Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL;
624
+ $this->getOnepage ()->getQuote ()->getPayment ()->importData ( $cdata );
625
+ }
626
+
627
+ $this->getOnepage ()->saveOrder ();
628
+
629
+ $this->getOnepage ()->getQuote ()->save ();
630
+
631
+ $TransactionStatus = 'Success';
632
+
633
+ Mage::helper ( 'masterpass' )->postTransaction ( $postback_data, $TransactionStatus, self::APPROVAL_CODE );
634
+ $this->_redirect ( 'masterpass/index/success', array (
635
+ '_secure' => true
636
+ ) );
637
+ } else {
638
+ $generic_error_message = Mage::getStoreConfig ( 'masterpass/config/checkouterrormessage' );
639
+ Mage::getSingleton ( 'core/session' )->addError ( $generic_error_message );
640
+ $this->_redirect ( 'masterpass/masterpasspairing/precheckout' );
641
+ }
642
+ } else {
643
+ Mage::getSingleton ( 'core/session' )->addError ( 'There is a problem please try again later.' );
644
+ $this->_redirect ( 'masterpass/masterpasspairing/precheckout' );
645
+ }
646
+ } catch ( Exception $ex ) {
647
+ if (isset ( $postback_data )) {
648
+ $TransactionStatus = 'Failure';
649
+
650
+ Mage::helper ( 'masterpass' )->postTransaction ( $postback_data, $TransactionStatus, self::APPROVAL_CODE );
651
+ }
652
+ $generic_error_message = Mage::getStoreConfig ( 'masterpass/config/checkouterrormessage' );
653
+ Mage::getSingleton ( 'core/session' )->addError ( $generic_error_message );
654
+ $this->_redirect ( 'masterpass/masterpasspairing/precheckout' );
655
+ }
656
+ }
657
+ public function getQuote() {
658
+ if ($this->_quote === null) {
659
+ $this->_quote = Mage::getSingleton ( "checkout/session" )->getQuote ();
660
+ }
661
+ return $this->_quote;
662
+ }
663
+ }
app/code/local/MasterCard/Masterpass/etc/adminhtml.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <acl>
4
+ <resources>
5
+ <all>
6
+ <title>Allow Everything</title>
7
+ </all>
8
+ <admin>
9
+ <children>
10
+ <system>
11
+ <children>
12
+ <config>
13
+ <children>
14
+ <masterpass translate="title">
15
+ <title>MasterPass Section</title>
16
+ <sort_order>100</sort_order>
17
+ </masterpass>
18
+ </children>
19
+ </config>
20
+ </children>
21
+ </system>
22
+ </children>
23
+ </admin>
24
+ </resources>
25
+ </acl>
26
+ </config>
app/code/local/MasterCard/Masterpass/etc/config.xml ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <MasterCard_Masterpass>
5
+ <version>0.1.0</version>
6
+ </MasterCard_Masterpass>
7
+ </modules>
8
+ <adminhtml>
9
+ <events>
10
+ <controller_action_predispatch>
11
+ <observers>
12
+ <opc_check_related>
13
+ <type>singleton</type>
14
+ <class>masterpass/observer</class>
15
+ <method>checkPrivateKey</method>
16
+ </opc_check_related>
17
+ </observers>
18
+ </controller_action_predispatch>
19
+ </events>
20
+ </adminhtml>
21
+ <global>
22
+ <models>
23
+ <masterpass>
24
+ <class>MasterCard_Masterpass_Model</class>
25
+ </masterpass>
26
+ </models>
27
+ <resources>
28
+ <mastercard_masterpass_setup>
29
+ <setup>
30
+ <module>MasterCard_Masterpass</module>
31
+ <class>Mage_Eav_Model_Entity_Setup</class>
32
+ </setup>
33
+ <connection>
34
+ <use>core_setup</use>
35
+ </connection>
36
+ </mastercard_masterpass_setup>
37
+ <mastercard_masterpass_write>
38
+ <connection>
39
+ <use>core_write</use>
40
+ </connection>
41
+ </mastercard_masterpass_write>
42
+ <mastercard_masterpass_read>
43
+ <connection>
44
+ <use>core_read</use>
45
+ </connection>
46
+ </mastercard_masterpass_read>
47
+ </resources>
48
+ <blocks>
49
+ <masterpass>
50
+ <class>MasterCard_Masterpass_Block</class>
51
+ </masterpass>
52
+ <checkout>
53
+ <rewrite>
54
+ <!-- uncommend this line if using default tamplate -->
55
+ <!-- <links>MasterCard_Masterpass_Block_Onepage_Links</links>-->
56
+ <cart_sidebar>MasterCard_Masterpass_Block_Onepage_Sidebar</cart_sidebar>
57
+ <onepage_link>MasterCard_Masterpass_Block_Onepage_Link</onepage_link>
58
+ </rewrite>
59
+ </checkout>
60
+ </blocks>
61
+ <helpers>
62
+ <masterpass>
63
+ <class>MasterCard_Masterpass_Helper</class>
64
+ </masterpass>
65
+ </helpers>
66
+ <events>
67
+ <controller_action_predispatch>
68
+ <observers>
69
+ <controller_action_before>
70
+ <class>masterpass/observer</class>
71
+ <method>mastterPassToControllerActionPostDispatch</method>
72
+ </controller_action_before>
73
+ </observers>
74
+ </controller_action_predispatch>
75
+ <checkout_cart_product_add_after>
76
+ <observers>
77
+ <controller_action_before>
78
+ <class>masterpass/observer</class>
79
+ <method>noPassKeyNotification</method>
80
+ </controller_action_before>
81
+ </observers>
82
+ </checkout_cart_product_add_after>
83
+ </events>
84
+ </global>
85
+ <frontend>
86
+ <routers>
87
+ <masterpass>
88
+ <use>standard</use>
89
+ <args>
90
+ <module>MasterCard_Masterpass</module>
91
+ <frontName>masterpass</frontName>
92
+ </args>
93
+ </masterpass>
94
+ </routers>
95
+ <layout>
96
+ <updates>
97
+ <button>
98
+ <file>masterpass/masterpass.xml</file>
99
+ </button>
100
+ </updates>
101
+ </layout>
102
+ </frontend>
103
+ <default>
104
+ <masterpass>
105
+ <config>
106
+ <enabled>0</enabled>
107
+ <buttonsize>147x034px</buttonsize>
108
+ <sbconsumerkey></sbconsumerkey>
109
+ <sbcheckoutidentifier></sbcheckoutidentifier>
110
+ <sbkeystorepassword></sbkeystorepassword>
111
+ <prconsumerkey></prconsumerkey>
112
+ <prcheckoutidentifier></prcheckoutidentifier>
113
+ <prkeystorepassword></prkeystorepassword>
114
+ <shippingsuppression>false</shippingsuppression>
115
+ <requestbasiccheckout>false</requestbasiccheckout>
116
+ <rewards>false</rewards>
117
+ <enabledlearnmore>1</enabledlearnmore>
118
+ <cfcard>1</cfcard>
119
+ <cfaddress>1</cfaddress>
120
+ <environment>sandbox</environment>
121
+ <acceptedcards>master,amex,visa</acceptedcards>
122
+ <acceptancemark>050px</acceptancemark>
123
+ <expresstextcolor>#FFFFFF</expresstextcolor>
124
+ <expressbuttoncolor>#a00000</expressbuttoncolor>
125
+ <checkouterrormessage>Masterpass is currently not available, try another payment method.</checkouterrormessage>
126
+ <learnmoremasterpasslink><![CDATA[<a " onclick="window.open('http://www.mastercard.com/mc_us/wallet/learnmore/en/','','scrollbars,width=700,height=690'); return false;" style="vertical-align: top;font-size: 13px;float:left;" href="javascript:void(0);">
127
+ Learn more
128
+ </a>]]></learnmoremasterpasslink>
129
+ </config>
130
+ </masterpass>
131
+ </default>
132
+
133
+ </config>
app/code/local/MasterCard/Masterpass/etc/system.xml ADDED
@@ -0,0 +1,492 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <masterpass translate="">
5
+ <label>MasterPass</label>
6
+ <tab>general</tab>
7
+ <frontend_type>text</frontend_type>
8
+ <sort_order>1000</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>1</show_in_store>
12
+ <groups>
13
+ <config translate="label">
14
+ <label>MasterPass</label>
15
+ <frontend_type>text</frontend_type>
16
+ <comment>
17
+ <![CDATA[<img src="https://www.mastercard.com/mc_us/wallet/img/en/US/mp_acc_076px_gif.gif" alt="Checkout with MasterPass Button Example"
18
+ /><br/><a href="https://masterpass.com/SP/Merchant/Home" target="_blank">Signup for MasterPass</a>]]>
19
+ </comment>
20
+ <expanded>1</expanded>
21
+ <sort_order>100</sort_order>
22
+ <show_in_default>1</show_in_default>
23
+ <show_in_website>1</show_in_website>
24
+ <show_in_store>1</show_in_store>
25
+ <fields>
26
+ <!-- New fields go here -->
27
+ <enabled translate="label comment">
28
+ <label>Enable MasterPass Wallet</label>
29
+ <comment>
30
+ <![CDATA[Enable or Disable option]]>
31
+ </comment>
32
+ <frontend_type>select</frontend_type>
33
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
34
+ <sort_order>10</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>1</show_in_store>
38
+ </enabled>
39
+ <notification_email translate="label comment tooltip">
40
+ <label>Notification Email Address</label>
41
+ <comment><![CDATA[If a private key execuatable path is not entered, a notification will be sent to the above email address.]]></comment>
42
+ <tooltip><![CDATA[If a private key execuatable path is not entered, a notification will be sent to the above email address.]]></tooltip>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ <sort_order>20</sort_order>
47
+ <validate>validate-email</validate>
48
+ <shared>1</shared>
49
+ <depends>
50
+ <enabled>1</enabled>
51
+ </depends>
52
+ </notification_email>
53
+ <buttonsize translate="label comment">
54
+ <label>MasterPass Button Size</label>
55
+ <comment></comment>
56
+ <frontend_type>select</frontend_type>
57
+ <source_model>masterpass/system_config_source_buttonsize</source_model>
58
+ <sort_order>40</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ <shared>1</shared>
63
+ <depends>
64
+ <enabled>1</enabled>
65
+ </depends>
66
+ </buttonsize>
67
+ <acceptancemark translate="label comment">
68
+ <label>Acceptance Marks</label>
69
+ <comment><![CDATA[MasterPass Acceptance Marks Image will be displayed on the order confirmation page]]></comment>
70
+ <frontend_type>select</frontend_type>
71
+ <source_model>masterpass/system_config_source_acceptancemarksize</source_model>
72
+ <sort_order>45</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ <shared>1</shared>
77
+ <depends>
78
+ <enabled>1</enabled>
79
+ </depends>
80
+ </acceptancemark>
81
+ <masterpassxml translate="label comment">
82
+ <label>MasterPass API Version</label>
83
+ <comment><![CDATA[XML Version]]></comment>
84
+ <frontend_type>select</frontend_type>
85
+ <source_model>masterpass/system_config_source_xmlversion</source_model>
86
+ <sort_order>50</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>1</show_in_store>
90
+ <shared>1</shared>
91
+ <depends>
92
+ <enabled>1</enabled>
93
+ </depends>
94
+ </masterpassxml>
95
+ <environment translate="label comment">
96
+ <label>Environment</label>
97
+ <comment><![CDATA[Sandbox/Production]]></comment>
98
+ <frontend_type>select</frontend_type>
99
+ <source_model>masterpass/system_config_source_environment</source_model>
100
+ <sort_order>50</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>1</show_in_store>
104
+ <shared>1</shared>
105
+ <depends>
106
+ <enabled>1</enabled>
107
+ </depends>
108
+ </environment>
109
+ <sbconsumerkey translate="label comment">
110
+ <label>Sandbox Consumer Key</label>
111
+ <comment><![CDATA[Retrieve from the Merchant Portal]]></comment>
112
+ <frontend_type>text</frontend_type>
113
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
114
+ <sort_order>110</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>1</show_in_store>
118
+ <shared>1</shared>
119
+ <depends>
120
+ <enabled>1</enabled>
121
+ <environment>sandbox</environment>
122
+ </depends>
123
+ </sbconsumerkey>
124
+ <sbcheckoutidentifier translate="label comment">
125
+ <label>Sandbox Checkout Identifier</label>
126
+ <comment><![CDATA[Retrieve from the Merchant Portal]]></comment>
127
+ <frontend_type>text</frontend_type>
128
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
129
+ <sort_order>120</sort_order>
130
+ <show_in_default>1</show_in_default>
131
+ <show_in_website>1</show_in_website>
132
+ <show_in_store>1</show_in_store>
133
+ <shared>1</shared>
134
+ <depends>
135
+ <enabled>1</enabled>
136
+ <environment>sandbox</environment>
137
+ </depends>
138
+ </sbcheckoutidentifier>
139
+ <sbkeystorepath translate="label">
140
+ <label>Sandbox Keystore File</label>
141
+ <comment><![CDATA[Keystore Certificate File saved in
142
+ {magento_root}/shell/certs]]>
143
+ </comment>
144
+ <frontend_type>file</frontend_type>
145
+ <backend_model>adminhtml/system_config_backend_file</backend_model>
146
+ <upload_dir>shell/certs</upload_dir>
147
+ <sort_order>125</sort_order>
148
+ <show_in_default>1</show_in_default>
149
+ <show_in_website>1</show_in_website>
150
+ <show_in_store>1</show_in_store>
151
+ <depends>
152
+ <enabled>1</enabled>
153
+ <environment>sandbox</environment>
154
+ </depends>
155
+ </sbkeystorepath>
156
+ <sbkeystorepassword translate="label comment">
157
+ <label>Sandbox Private Key Executable Path</label>
158
+ <comment><![CDATA[Example: /var/www/privatekey.sh]]></comment>
159
+ <frontend_type>text</frontend_type>
160
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
161
+ <sort_order>130</sort_order>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>1</show_in_store>
165
+ <shared>1</shared>
166
+ <depends>
167
+ <enabled>1</enabled>
168
+ <environment>sandbox</environment>
169
+ </depends>
170
+ </sbkeystorepassword>
171
+ <prconsumerkey translate="label comment">
172
+ <label>Production Consumer Key</label>
173
+ <comment>Retrieve from the Merchant Portal</comment>
174
+ <frontend_type>text</frontend_type>
175
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
176
+ <sort_order>110</sort_order>
177
+ <show_in_default>1</show_in_default>
178
+ <show_in_website>1</show_in_website>
179
+ <show_in_store>1</show_in_store>
180
+ <shared>1</shared>
181
+ <depends>
182
+ <enabled>1</enabled>
183
+ <environment>production</environment>
184
+ </depends>
185
+ </prconsumerkey>
186
+ <prcheckoutidentifier translate="label comment">
187
+ <label>Production Checkout Identifier</label>
188
+ <comment><![CDATA[Retrieve from the Merchant Portal]]></comment>
189
+ <frontend_type>text</frontend_type>
190
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
191
+ <sort_order>120</sort_order>
192
+ <show_in_default>1</show_in_default>
193
+ <show_in_website>1</show_in_website>
194
+ <show_in_store>1</show_in_store>
195
+ <shared>1</shared>
196
+ <depends>
197
+ <enabled>1</enabled>
198
+ <environment>production</environment>
199
+ </depends>
200
+ </prcheckoutidentifier>
201
+ <prkeystorepath translate="label">
202
+ <label>Production Keystore File</label>
203
+ <comment><![CDATA[Keystore Certificate File saved in
204
+ {magento_root}/shell/certs]]>
205
+ </comment>
206
+ <frontend_type>file</frontend_type>
207
+ <backend_model>adminhtml/system_config_backend_file</backend_model>
208
+ <upload_dir>shell/certs</upload_dir>
209
+ <sort_order>130</sort_order>
210
+ <show_in_default>1</show_in_default>
211
+ <show_in_website>1</show_in_website>
212
+ <show_in_store>1</show_in_store>
213
+ <depends>
214
+ <enabled>1</enabled>
215
+ <environment>production</environment>
216
+ </depends>
217
+ </prkeystorepath>
218
+ <prkeystorepassword translate="label comment">
219
+ <label>Production Private Key Executable Path</label>
220
+ <comment><![CDATA[Example: /var/www/privatekey.sh]]></comment>
221
+ <frontend_type>text</frontend_type>
222
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
223
+ <sort_order>135</sort_order>
224
+ <show_in_default>1</show_in_default>
225
+ <show_in_website>1</show_in_website>
226
+ <show_in_store>1</show_in_store>
227
+ <shared>1</shared>
228
+ <depends>
229
+ <enabled>1</enabled>
230
+ <environment>production</environment>
231
+ </depends>
232
+ </prkeystorepassword>
233
+
234
+
235
+ <callbackurl translate="label comment">
236
+ <label>Call Back Url</label>
237
+ <comment><![CDATA[Note: THIS FIELD IS FOR CUSTOM CALL BACK ONLY. To use default call back url this field must be blank. Example: http://yoursite.com/call back path]]></comment>
238
+ <frontend_type>text</frontend_type>
239
+ <sort_order>140</sort_order>
240
+ <show_in_default>1</show_in_default>
241
+ <show_in_website>1</show_in_website>
242
+ <show_in_store>1</show_in_store>
243
+ <shared>1</shared>
244
+ <depends>
245
+ <enabled>1</enabled>
246
+ </depends>
247
+ </callbackurl>
248
+ <paymentgateway translate="label">
249
+ <label>Payment Gateway</label>
250
+ <comment><![CDATA[The payment gateway used to process transactions using MasterPass Wallet. Must support the accepted cards chosen below, and must not require credit card validation.]]></comment>
251
+ <tooltip><![CDATA[If your payment gateway is not showing up, please check if it supports credit cards and that it is set to not require credit card validation.]]></tooltip>
252
+ <frontend_type>select</frontend_type>
253
+ <frontend_class>validate-select</frontend_class>
254
+ <source_model>masterpass/system_config_source_paymentGateways</source_model>
255
+ <sort_order>150</sort_order>
256
+ <show_in_default>1</show_in_default>
257
+ <show_in_website>1</show_in_website>
258
+ <show_in_store>1</show_in_store>
259
+ <depends>
260
+ <enabled>1</enabled>
261
+
262
+ </depends>
263
+ </paymentgateway>
264
+ <userflows translate="label comment tooltip">
265
+ <label>User Flows</label>
266
+ <comment></comment>
267
+ <tooltip><![CDATA[Select the Standard Checkout or Express Checkout to begin checkout with Masterpass.]]></tooltip>
268
+ <frontend_type>select</frontend_type>
269
+ <source_model>masterpass/system_config_source_userflows</source_model>
270
+ <sort_order>155</sort_order>
271
+ <show_in_default>1</show_in_default>
272
+ <show_in_website>1</show_in_website>
273
+ <show_in_store>1</show_in_store>
274
+ <shared>1</shared>
275
+ <depends>
276
+ <enabled>1</enabled>
277
+ </depends>
278
+ </userflows>
279
+ <expressrequirement translate="label comment">
280
+ <label></label>
281
+ <comment><![CDATA[Please note: To use Express Checkout, merchant must obtain approval from MasterCard. Express checkout will not be activated unless merchant satisfies MasterCard requirements for Express Checkout merchants. To get started, <a href="https://masterpass.com/express/form" target="_blank">Click Here!</a>]]></comment>
282
+ <frontend_type>hidden</frontend_type>
283
+ <sort_order>160</sort_order>
284
+ <show_in_default>1</show_in_default>
285
+ <show_in_website>1</show_in_website>
286
+ <show_in_store>1</show_in_store>
287
+ <shared>1</shared>
288
+ <depends>
289
+ <enabled>1</enabled>
290
+ <userflows>3</userflows>
291
+ </depends>
292
+ </expressrequirement>
293
+ <cfcard translate="label comment">
294
+ <label>Credit Card</label>
295
+ <comment><![CDATA[Credit Card]]></comment>
296
+ <frontend_type>select</frontend_type>
297
+ <source_model>adminhtml/system_config_source_yesno</source_model>
298
+ <sort_order>165</sort_order>
299
+ <show_in_default>1</show_in_default>
300
+ <show_in_website>1</show_in_website>
301
+ <show_in_store>1</show_in_store>
302
+ <shared>1</shared>
303
+ <depends>
304
+ <enabled>1</enabled>
305
+ <userflows separator=",">2,3</userflows>
306
+ </depends>
307
+ </cfcard>
308
+ <cfprofile translate="label comment">
309
+ <label>Profile</label>
310
+ <comment><![CDATA[Profile]]></comment>
311
+ <frontend_type>select</frontend_type>
312
+ <source_model>adminhtml/system_config_source_yesno</source_model>
313
+ <sort_order>170</sort_order>
314
+ <show_in_default>1</show_in_default>
315
+ <show_in_website>1</show_in_website>
316
+ <show_in_store>1</show_in_store>
317
+ <shared>1</shared>
318
+ <depends>
319
+ <enabled>1</enabled>
320
+ <userflows separator=",">2,3</userflows>
321
+ </depends>
322
+ </cfprofile>
323
+ <cfaddress translate="label comment">
324
+ <label>Address</label>
325
+ <comment><![CDATA[address]]></comment>
326
+ <frontend_type>select</frontend_type>
327
+ <source_model>adminhtml/system_config_source_yesno</source_model>
328
+ <sort_order>180</sort_order>
329
+ <show_in_default>1</show_in_default>
330
+ <show_in_website>1</show_in_website>
331
+ <show_in_store>1</show_in_store>
332
+ <shared>1</shared>
333
+ <depends>
334
+ <enabled>1</enabled>
335
+ <userflows separator=",">2,3</userflows>
336
+
337
+ </depends>
338
+ </cfaddress>
339
+
340
+ <!-- express checkout -->
341
+
342
+
343
+ <exreward translate="label comment">
344
+ <label>Reward</label>
345
+ <comment><![CDATA[Reward]]></comment>
346
+ <frontend_type>select</frontend_type>
347
+ <source_model>adminhtml/system_config_source_yesno</source_model>
348
+ <sort_order>240</sort_order>
349
+ <show_in_default>1</show_in_default>
350
+ <show_in_website>1</show_in_website>
351
+ <show_in_store>1</show_in_store>
352
+ <shared>1</shared>
353
+ <depends>
354
+ <enabled>1</enabled>
355
+ <userflows separator=",">2,3</userflows>
356
+ </depends>
357
+ </exreward>
358
+ <shippingsuppression translate="label comment">
359
+ <label>Shipping Suppression</label>
360
+ <comment></comment>
361
+ <frontend_type>select</frontend_type>
362
+ <source_model>masterpass/system_config_source_trueorfalse</source_model>
363
+ <sort_order>260</sort_order>
364
+ <show_in_default>1</show_in_default>
365
+ <show_in_website>1</show_in_website>
366
+ <show_in_store>1</show_in_store>
367
+ <shared>1</shared>
368
+ <depends>
369
+ <enabled>1</enabled>
370
+ </depends>
371
+ </shippingsuppression>
372
+ <rewards translate="label comment">
373
+ <label>Rewards Program</label>
374
+ <comment><![CDATA[By default it is "false".]]></comment>
375
+ <frontend_type>select</frontend_type>
376
+ <source_model>masterpass/system_config_source_trueorfalse</source_model>
377
+ <sort_order>270</sort_order>
378
+ <show_in_default>1</show_in_default>
379
+ <show_in_website>1</show_in_website>
380
+ <show_in_store>1</show_in_store>
381
+ <shared>1</shared>
382
+ <depends>
383
+ <enabled>1</enabled>
384
+ <userflows>1</userflows>
385
+ </depends>
386
+ </rewards>
387
+ <loyaltyprogram translate="label comment">
388
+ <label>Loyalty Program</label>
389
+ <comment><![CDATA[Please use comma to separate each program. EX: 12345,45678]]></comment>
390
+ <frontend_type>text</frontend_type>
391
+ <sort_order>280</sort_order>
392
+ <show_in_default>1</show_in_default>
393
+ <show_in_website>1</show_in_website>
394
+ <show_in_store>1</show_in_store>
395
+ <shared>1</shared>
396
+ <depends>
397
+ <enabled>1</enabled>
398
+ <rewards>true</rewards>
399
+ </depends>
400
+ </loyaltyprogram>
401
+ <requestbasiccheckout translate="label comment">
402
+ <label>Request Basic Checkout</label>
403
+ <comment></comment>
404
+ <frontend_type>select</frontend_type>
405
+ <source_model>masterpass/system_config_source_trueorfalse</source_model>
406
+ <sort_order>290</sort_order>
407
+ <show_in_default>1</show_in_default>
408
+ <show_in_website>1</show_in_website>
409
+ <show_in_store>1</show_in_store>
410
+ <shared>1</shared>
411
+ <depends>
412
+ <enabled>1</enabled>
413
+ <userflows>1</userflows>
414
+ </depends>
415
+ </requestbasiccheckout>
416
+ <acceptedcards translate="label comment">
417
+ <label>Accepted Credit Cards</label>
418
+ <comment></comment>
419
+ <frontend_type>multiselect</frontend_type>
420
+ <source_model>masterpass/system_config_source_acceptedcards</source_model>
421
+ <sort_order>300</sort_order>
422
+ <show_in_default>1</show_in_default>
423
+ <show_in_website>1</show_in_website>
424
+ <show_in_store>1</show_in_store>
425
+ <shared>1</shared>
426
+ <depends>
427
+ <enabled>1</enabled>
428
+ <userflows>1</userflows>
429
+ </depends>
430
+ </acceptedcards>
431
+ <privatelabel translate="label comment">
432
+ <label>Private Label Card</label>
433
+ <comment><![CDATA[Empty by default. NOTE: THE PRIVATE LABEL IS CASE SENSITIVE. THE VALUE IN THIS FIELD MUST MATCH THE VALUE COMING FROM MasterPass.]]></comment>
434
+ <frontend_type>text</frontend_type>
435
+ <sort_order>310</sort_order>
436
+ <show_in_default>1</show_in_default>
437
+ <show_in_website>1</show_in_website>
438
+ <show_in_store>1</show_in_store>
439
+ <shared>1</shared>
440
+ <depends>
441
+ <enabled>1</enabled>
442
+ <userflows>1</userflows>
443
+ </depends>
444
+ </privatelabel>
445
+ <checkouterrormessage translate="label comment">
446
+ <label>Generic Checkout Error Message</label>
447
+ <comment></comment>
448
+ <frontend_type>text</frontend_type>
449
+ <sort_order>320</sort_order>
450
+ <show_in_default>1</show_in_default>
451
+ <show_in_website>1</show_in_website>
452
+ <show_in_store>1</show_in_store>
453
+ <shared>1</shared>
454
+ <depends>
455
+ <enabled>1</enabled>
456
+ </depends>
457
+ </checkouterrormessage>
458
+ <enabledlearnmore translate="label comment">
459
+ <label>Enable Learn More Link</label>
460
+ <frontend_type>select</frontend_type>
461
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
462
+ <sort_order>330</sort_order>
463
+ <show_in_default>1</show_in_default>
464
+ <show_in_website>1</show_in_website>
465
+ <show_in_store>1</show_in_store>
466
+ <shared>1</shared>
467
+ <depends>
468
+ <enabled>1</enabled>
469
+ </depends>
470
+ </enabledlearnmore>
471
+ <learnmoremasterpasslink translate="label comment">
472
+ <label>Learn More Link</label>
473
+ <sort_order>340</sort_order>
474
+ <frontend_type>textarea</frontend_type>
475
+ <show_in_default>1</show_in_default>
476
+ <show_in_website>1</show_in_website>
477
+ <show_in_store>1</show_in_store>
478
+ <shared>1</shared>
479
+ <depends>
480
+ <enabled>1</enabled>
481
+ <enabledlearnmore>1</enabledlearnmore>
482
+ </depends>
483
+ <comment>
484
+ <![CDATA[This message will be displayed on the shopping cart page below the "Masterpass" button.]]>
485
+ </comment>
486
+ </learnmoremasterpasslink>
487
+ </fields>
488
+ </config>
489
+ </groups>
490
+ </masterpass>
491
+ </sections>
492
+ </config>
app/code/local/MasterCard/Masterpass/sql/mastercard_masterpass_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this license header, choose License Headers in Project Properties.
5
+ * To change this template file, choose Tools | Templates
6
+ * and open the template in the editor.
7
+ */
8
+
9
+ $installer = $this;
10
+
11
+ $installer->startSetup();
12
+
13
+
14
+ $installer->addAttribute("customer", "longtoken", array(
15
+ 'label' => 'MasterPass Long Access Token',
16
+ 'type' => 'varchar',
17
+ 'input' => 'text',
18
+ 'default' => '',
19
+ 'position' => 70,
20
+ 'visible' => true,
21
+ 'required' => false,
22
+ 'user_defined' => true,
23
+ 'searchable' => false,
24
+ 'filterable' => false,
25
+ 'comparable' => false,
26
+ 'visible_on_front' => false,
27
+ 'unique' => false
28
+ ));
29
+
30
+
31
+
32
+ $installer->endSetup();
app/design/frontend/rwd/default/layout/masterpass/masterpass.xml ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <checkout_cart_index>
4
+ <reference name="head">
5
+ <action method="addItem" ifconfig="masterpass/config/enabled">
6
+ <type>skin_css</type>
7
+ <name>css/masterpass/masterpassclient.css</name>
8
+ </action>
9
+ </reference>
10
+ <reference name="checkout.cart.top_methods">
11
+ <block type="masterpass/button" name="masterpass.checkout.button.top"
12
+ after="-" template="masterpass/cart/button.phtml">
13
+ </block>
14
+ </reference>
15
+
16
+ <reference name="checkout.cart.methods">
17
+ <block type="masterpass/button" name="masterpass.checkout.button"
18
+ after="checkout.cart.methods.onepage" template="masterpass/cart/buttonbottom.phtml">
19
+ </block>
20
+ </reference>
21
+
22
+ <update handle="SHORTCUT_popup" />
23
+ </checkout_cart_index>
24
+ <!-- customer account block -->
25
+ <customer_account>
26
+ <reference name="customer_account_navigation">
27
+ <block type="masterpass/customer_link" name="masterpass_customer_link">
28
+ <action method="addProfileLink"></action>
29
+ </block>
30
+ </reference>
31
+ </customer_account>
32
+
33
+ <masterpass_masterpasspairing_index>
34
+ <label>Pair With My MasterPass Wallet</label>
35
+ <update handle="customer_account" />
36
+
37
+ <!-- referencing content rather than my.account for compatibility back to 1.4. -->
38
+ <reference name="content">
39
+ <!-- The active payment method can inject itself into this wrapper with handle customer_paymentinfo_index_{method}. -->
40
+ <block type="masterpass/customer_wrapper" name="masterpass_customer_wrapper" template="masterpass/customer/wrapper.phtml" />
41
+
42
+ <block type="customer/account_dashboard" name="customer.account.link.back" template="customer/account/link/back.phtml" />
43
+ </reference>
44
+ </masterpass_masterpasspairing_index>
45
+ <masterpass_masterpasspairing_precheckout>
46
+ <reference name="root">
47
+ <action method="setTemplate">
48
+ <template>page/1column.phtml</template>
49
+ </action>
50
+ </reference>
51
+ <reference name="head">
52
+ <action method="addItem" ifconfig="masterpass/config/enabled">
53
+ <type>skin_css</type>
54
+ <name>css/masterpass/masterpassclient.css</name>
55
+ </action>
56
+ </reference>
57
+ <reference name="content">
58
+ <block type="masterpass/checkout_precheckout" name="precheckout.masterpass" template="masterpass/precheckout/precheckout.phtml">
59
+ <block type="masterpass/checkout_shipping" name="shipping-form" as="shippingform" template="masterpass/precheckout/shipping.phtml"/>
60
+ <block type="checkout/onepage_shipping_method_available" name="choose-shipping-method" as="mpshippingmethod" template="masterpass/precheckout/shipping_method.phtml"/>
61
+ <block type="checkout/onepage_shipping_method_additional" name="checkout.onepage.shipping_method.additional" as="additional" template="checkout/onepage/shipping_method/additional.phtml"/>
62
+ <block type="masterpass/checkout_review_details" name="masterpass.checkout.review.details" as="details" template="masterpass/review/details.phtml">
63
+ <action method="addItemRender">
64
+ <type>default</type>
65
+ <block>checkout/cart_item_renderer</block>
66
+ <template>checkout/onepage/review/item.phtml</template>
67
+ </action>
68
+ <action method="addItemRender">
69
+ <type>grouped</type>
70
+ <block>checkout/cart_item_renderer_grouped</block>
71
+ <template>checkout/onepage/review/item.phtml</template>
72
+ </action>
73
+ <action method="addItemRender">
74
+ <type>configurable</type>
75
+ <block>checkout/cart_item_renderer_configurable</block>
76
+ <template>checkout/onepage/review/item.phtml</template>
77
+ </action>
78
+ <block type="checkout/cart_totals" name="masterpass.checkout.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
79
+ </block>
80
+ </block>
81
+ </reference>
82
+ </masterpass_masterpasspairing_precheckout>
83
+ <checkout_onepage_index>
84
+ <reference name="content">
85
+ <block type="masterpass/button" name="masterpass.pairing"
86
+ before="-" template="masterpass/precheckout/pairWallet.phtml">
87
+ </block>
88
+ </reference>
89
+ </checkout_onepage_index>
90
+ <checkout_onepage_index>
91
+ <reference name="checkout.onepage.login">
92
+ <action method="setTemplate"><template>masterpass/onepage/login.phtml</template></action>
93
+ </reference>
94
+ </checkout_onepage_index>
95
+ <!-- standard checkout -->
96
+ <masterpass_index_checkout>
97
+ <reference name="head">
98
+ <action method="addItem" ifconfig="masterpass/config/enabled">
99
+ <type>skin_css</type>
100
+ <name>css/masterpass/masterpassclient.css</name>
101
+ </action>
102
+ </reference>
103
+ <reference name="root">
104
+ <action method="setTemplate">
105
+ <template>page/1column.phtml</template>
106
+ </action>
107
+ </reference>
108
+ <reference name="content">
109
+ <block type="masterpass/checkout_checkout" name="masterpass-checkout" template="masterpass/onepage/checkout.phtml">
110
+ <block type="masterpass/checkout_checkout" name="masterpass-shipping-form" as="standshippingform" template="masterpass/onepage/shipping_form.phtml"/>
111
+ <block type="checkout/onepage_shipping_method_available" name="choose-shipping-method" as="mpshippingmethod" template="masterpass/precheckout/shipping_method.phtml"/>
112
+ <block type="masterpass/checkout_review_details" name="masterpass.checkout.review.details" as="orderdetails" template="masterpass/review/details.phtml">
113
+ <action method="addItemRender">
114
+ <type>default</type>
115
+ <block>checkout/cart_item_renderer</block>
116
+ <template>checkout/onepage/review/item.phtml</template>
117
+ </action>
118
+ <action method="addItemRender">
119
+ <type>grouped</type>
120
+ <block>checkout/cart_item_renderer_grouped</block>
121
+ <template>checkout/onepage/review/item.phtml</template>
122
+ </action>
123
+ <action method="addItemRender">
124
+ <type>configurable</type>
125
+ <block>checkout/cart_item_renderer_configurable</block>
126
+ <template>checkout/onepage/review/item.phtml</template>
127
+ </action>
128
+ <block type="checkout/cart_totals" name="masterpass.checkout.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
129
+ </block>
130
+ </block>
131
+
132
+ </reference>
133
+ </masterpass_index_checkout>
134
+ <masterpass_index_review>
135
+ <block output="toHtml" type="masterpass/checkout_review_details" name="masterpass.checkout.review.details" as="details" template="masterpass/ajax/details.phtml">
136
+ <action method="addItemRender">
137
+ <type>default</type>
138
+ <block>checkout/cart_item_renderer</block>
139
+ <template>checkout/onepage/review/item.phtml</template>
140
+ </action>
141
+ <action method="addItemRender">
142
+ <type>grouped</type>
143
+ <block>checkout/cart_item_renderer_grouped</block>
144
+ <template>checkout/onepage/review/item.phtml</template>
145
+ </action>
146
+ <action method="addItemRender">
147
+ <type>configurable</type>
148
+ <block>checkout/cart_item_renderer_configurable</block>
149
+ <template>checkout/onepage/review/item.phtml</template>
150
+ </action>
151
+ <block type="checkout/cart_totals" name="masterpass.checkout.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
152
+ </block>
153
+ </masterpass_index_review>
154
+ <masterpass_index_saveshipping>
155
+ <block output="toHtml" type="checkout/onepage_shipping_method_available" name="choose-shipping-method" template="masterpass/ajax/shipping_method.phtml"/>
156
+ </masterpass_index_saveshipping>
157
+ <!-- Ajax Request -->
158
+ <masterpass_masterpasspairing_saveshipping>
159
+ <block output="toHtml" type="checkout/onepage_shipping_method_available" name="choose-shipping-method" template="masterpass/ajax/shipping_method.phtml"/>
160
+ </masterpass_masterpasspairing_saveshipping>
161
+ <masterpass_masterpasspairing_availableshipping>
162
+ <block output="toHtml" type="checkout/onepage_shipping_method_available" name="choose-shipping-method" template="masterpass/ajax/shipping_method.phtml"/>
163
+ </masterpass_masterpasspairing_availableshipping>
164
+ <masterpass_masterpasspairing_saveshippingmethod>
165
+ <block output="toHtml" type="checkout/onepage_shipping_method_available" name="choose-shipping-method" template="masterpass/ajax/shipping_method.phtml"/>
166
+ </masterpass_masterpasspairing_saveshippingmethod>
167
+ <masterpass_masterpasspairing_review>
168
+ <block output="toHtml" type="masterpass/checkout_review_details" name="masterpass.checkout.review.details" as="details" template="masterpass/ajax/details.phtml">
169
+ <action method="addItemRender">
170
+ <type>default</type>
171
+ <block>checkout/cart_item_renderer</block>
172
+ <template>checkout/onepage/review/item.phtml</template>
173
+ </action>
174
+ <action method="addItemRender">
175
+ <type>grouped</type>
176
+ <block>checkout/cart_item_renderer_grouped</block>
177
+ <template>checkout/onepage/review/item.phtml</template>
178
+ </action>
179
+ <action method="addItemRender">
180
+ <type>configurable</type>
181
+ <block>checkout/cart_item_renderer_configurable</block>
182
+ <template>checkout/onepage/review/item.phtml</template>
183
+ </action>
184
+ <block type="checkout/cart_totals" name="masterpass.checkout.review.details.totals" as="totals" template="checkout/onepage/review/totals.phtml"/>
185
+ </block>
186
+ </masterpass_masterpasspairing_review>
187
+ <!-- end Ajax -->
188
+
189
+ <customer_account_index translate="label">
190
+ <reference name="my.account.wrapper">
191
+ <block type="masterpass/customer_wrapper" name="masterpass.pairing"
192
+ before="customer_account_dashboard" template="masterpass/customer/pair_after_register.phtml">
193
+ </block>
194
+ </reference>
195
+ </customer_account_index>
196
+ <masterpass_index_success>
197
+ <label>One Page Checkout Success</label>
198
+ <reference name="head">
199
+ <action method="addItem" ifconfig="masterpass/config/enabled">
200
+ <type>skin_css</type>
201
+ <name>css/masterpass/masterpassclient.css</name>
202
+ </action>
203
+ </reference>
204
+ <reference name="root">
205
+ <action method="setTemplate"><template>page/1column.phtml</template></action>
206
+ </reference>
207
+ <reference name="content">
208
+ <block type="checkout/onepage_success" name="checkout.success" template="masterpass/onepage/success.phtml"/>
209
+ </reference>
210
+ </masterpass_index_success>
211
+ </layout>
app/design/frontend/rwd/default/template/masterpass/ajax/details.phtml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php
3
+
4
+ $taxHelper = Mage::helper("tax");
5
+ $displayBothPrices = $taxHelper->displayCartBothPrices();
6
+ if ($displayBothPrices) {
7
+ $colspan = 2;
8
+ $rowspan = 2;
9
+ } else {
10
+ $colspan = 1;
11
+ $rowspan = 1;
12
+ }
13
+ ?>
14
+
15
+ <h3 class="mp-title"><?php echo $this->__('Order Review') ?></h3>
16
+ <table id="details-table" class="data-table">
17
+ <col />
18
+ <col width="1" />
19
+ <col width="1" />
20
+ <col width="1" />
21
+ <?php if ($displayBothPrices): ?>
22
+ <col width="1" />
23
+ <col width="1" />
24
+ <?php endif; ?>
25
+ <thead>
26
+ <tr>
27
+ <th rowspan="<?php echo $rowspan ?>"><?php echo $this->__("Product Name") ?></th>
28
+ <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__("Price"); ?></th>
29
+ <th rowspan="<?php echo $rowspan ?>" class="a-center"><?php echo $this->__("Qty"); ?></th>
30
+ <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__("Subtotal"); ?></th>
31
+ </tr>
32
+ <?php if ($displayBothPrices): ?>
33
+ <tr>
34
+ <th class="a-right"><?php echo $taxHelper->getIncExcTaxLabel(false); ?></th>
35
+ <th><?php echo $taxHelper->getIncExcTaxLabel(true); ?></th>
36
+ <th class="a-right"><?php echo $taxHelper->getIncExcTaxLabel(false); ?></th>
37
+ <th><?php echo $taxHelper->getIncExcTaxLabel(true); ?></th>
38
+ </tr>
39
+ <?php endif; ?>
40
+ </thead>
41
+ <?php echo $this->getChildHtml("totals"); ?>
42
+ <tbody>
43
+ <?php foreach ($this->getItems() as $item): ?>
44
+ <?php echo $this->getItemHtml($item); ?>
45
+ <?php endforeach ?>
46
+ </tbody>
47
+ </table>
48
+
49
+ <script type="text/javascript">decorateTable("details-table");</script>
app/design/frontend/rwd/default/template/masterpass/ajax/shipping_method.phtml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
4
+ $subtotal = round($totals["subtotal"]->getValue()); //Subtotal value
5
+ ?>
6
+
7
+
8
+ <?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
9
+ <div class="box-title">
10
+ <h3 class="mp-title"><?php echo $this->__("Shipping Method"); ?></h3>
11
+ </div>
12
+ <strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong>
13
+ <?php else: ?>
14
+ <?php if (count($_shippingRateGroups) == '1' && Mage::getStoreConfig('onestepcheckout/general/hide_shipping_method')): ?>
15
+ <div class="box">
16
+ <div class="box-title">
17
+ <h3 class="mp-title"><?php echo $this->__("Shipping Method"); ?></h3>
18
+ </div>
19
+ <div id="required-shipping" class="validation-advice" style="display: none;">Please select a shipping method.</div>
20
+ </div>
21
+ <dl class="shipment-methods" style="display: none">
22
+ <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
23
+
24
+ <dd><?php echo $this->getCarrierName($code) ?></dd>
25
+ <?php foreach ($_rates as $_rate): ?>
26
+ <dt style="margin-bottom: 5px;">
27
+ <?php if ($_rate->getErrorMessage()): ?>
28
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
29
+ <?php else: ?>
30
+ <input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" onclick="updateShippingMethod('<?php echo $_rate->getCode() ?>')"/>
31
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><!--<b><?php echo $this->getCarrierName($code) ?>:</b>--> <?php echo $_rate->getMethodTitle() ?>
32
+ <strong>
33
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
34
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
35
+ <?php echo $_excl; ?>
36
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
37
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
38
+ <?php endif; ?>
39
+ </strong>
40
+ </label>
41
+ <?php endif ?>
42
+ </dt>
43
+
44
+ <?php endforeach; ?>
45
+
46
+ <?php endforeach; ?>
47
+ </dl>
48
+ <?php else: ?>
49
+ <dl class="shipment-methods">
50
+ <div class="box">
51
+ <div class="box-title">
52
+ <h3 class="mp-title"><?php echo $this->__("Shipping Method"); ?></h3>
53
+ </div>
54
+ <div id="required-shipping" class="validation-advice" style="display: none;">Please select a shipping method.</div>
55
+ </div>
56
+ <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
57
+ <dd><?php echo $this->getCarrierName($code) ?></dd>
58
+ <?php foreach ($_rates as $_rate): ?>
59
+ <dt style="margin-bottom: 5px;">
60
+
61
+ <?php if ($_rate->getErrorMessage()): ?>
62
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
63
+ <?php else: ?>
64
+ <input name="shipping_method" type="radio" class="validate-one-required-by-name" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if ($_rate->getCode() === $this->getAddressShippingMethod()) echo ' checked="checked"' ?> onclick="updateShippingMethod('<?php echo $_rate->getCode() ?>')"/>
65
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><!--<b><?php echo $this->getCarrierName($code) ?>:</b>--> <?php echo $_rate->getMethodTitle() ?>
66
+ <strong>
67
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
68
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
69
+
70
+ <?php echo $_excl; ?>
71
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
72
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
73
+ <?php endif; ?>
74
+ </strong>
75
+ </label>
76
+ <?php endif ?>
77
+ </dt>
78
+ <?php endforeach; ?>
79
+ <?php endforeach; ?>
80
+ </dl>
81
+ <?php endif; ?>
82
+ <?php endif; ?>
app/design/frontend/rwd/default/template/masterpass/cart/button.phtml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $isMasterpassEnabled = Mage::helper('masterpass')->isMasterpassEnabled(); ?>
2
+ <?php if ($isMasterpassEnabled && !$this->checkUserFlows()): ?>
3
+ <div>
4
+ <a href="#" onclick="handleBuyWithMasterPass()" title="Buy With MasterPass"><img src="https://static.masterpass.com/dyn/img/btn/en/US/mp_chk_btn_<?php echo Mage::getStoreConfig('masterpass/config/buttonsize'); ?>.png"/></a>
5
+ </div>
6
+
7
+ <?php if (Mage::getStoreConfig('masterpass/config/enabledlearnmore')): ?>
8
+ <?php echo Mage::getStoreConfig('masterpass/config/learnmoremasterpasslink'); ?>
9
+ <?php endif; ?>
10
+ <?php endif; ?>
11
+
12
+
app/design/frontend/rwd/default/template/masterpass/cart/buttonbottom.phtml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $isMasterpassEnabled = Mage::helper('masterpass')->isMasterpassEnabled(); ?>
2
+ <?php if ($isMasterpassEnabled): ?>
3
+ <?php if (!$this->checkUserFlows()): ?>
4
+
5
+ <?php
6
+ $prefix = '';
7
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
8
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment') . ".";
9
+ }
10
+ ?>
11
+
12
+
13
+ <script type="text/javascript" src="https://<?php echo $prefix; ?>masterpass.com/lightbox/Switch/integration/MasterPass.client.js"></script>
14
+
15
+ <div>
16
+ <a href="#" onclick="handleBuyWithMasterPass()" title="Buy With MasterPass"><img src="https://static.masterpass.com/dyn/img/btn/en/US/mp_chk_btn_<?php echo Mage::getStoreConfig('masterpass/config/buttonsize'); ?>.png"/></a>
17
+ </div>
18
+
19
+ <?php if (Mage::getStoreConfig('masterpass/config/enabledlearnmore')): ?>
20
+ <div style="padding-left: 22px;">
21
+ <?php echo Mage::getStoreConfig('masterpass/config/learnmoremasterpasslink'); ?>
22
+ </div>
23
+ <?php endif ?>
24
+
25
+
26
+ <script>
27
+
28
+ function handleBuyWithMasterPass() {
29
+ //check if privatekey path is not empty
30
+ var response;
31
+ new Ajax.Request('<?php echo $this->getUrl() . 'masterpass/index/validatePk'; ?>',
32
+ {
33
+ method:'get',
34
+ onSuccess: function(transport){
35
+ response = transport.responseText;
36
+ if (response != ''){
37
+ <?php $data = $this->helper('masterpass')->getMerchantSettings(); ?>
38
+ var token = "<?php print_r($this->helper('masterpass')->postShoppingCart()); ?>";
39
+ if (token != ''){
40
+ MasterPass.client.checkout({
41
+ "requestToken":token,
42
+ <?php if (Mage::getStoreConfig('masterpass/config/callbackurl') != '') { ?>
43
+ "callbackUrl":"<?php echo Mage::getStoreConfig('masterpass/config/callbackurl'); ?>",
44
+ <?php } else { ?>
45
+ "callbackUrl":"<?php echo $this->getUrl() . 'masterpass/index/callback'; ?>",
46
+ <?php } ?>
47
+ "merchantCheckoutId":"<?php echo $data['checkout_id']; ?>",
48
+ "allowedCardTypes":"<?php print_r($this->helper('masterpass')->acceptedCards()); ?>",
49
+ "cancelCallback" : "<?php echo $this->getUrl(); ?>",
50
+ "suppressShippingAddressEnable": "<?php echo $data['suppressShipping']; ?>",
51
+ "loyaltyEnabled" : "<?php echo $data['loyaltyEnabled']; ?>",
52
+ <?php if ($data['loyaltyEnabled'] == 'true') { ?>
53
+ "allowedLoyaltyPrograms" : "<?php echo $data['loyaltyProgram']; ?>",
54
+ <?php } ?>
55
+ "requestBasicCheckout" : "<?php echo $data['requestBasicCheckout']; ?>",
56
+ "version":"<?php echo $data['version']; ?>"
57
+ });
58
+ } else{
59
+ window.location.href = '<?php echo Mage::getUrl('', array('_secure' => true)); ?>masterpass/index/callback';
60
+ }
61
+ } else{
62
+ location.reload();
63
+ }
64
+ },
65
+ onFailure: function(){
66
+ location.reload();
67
+ }
68
+ });
69
+ }
70
+
71
+
72
+ </script>
73
+ <?php endif; ?>
74
+ <?php endif; ?>
75
+
app/design/frontend/rwd/default/template/masterpass/customer/pair_after_register.phtml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * To change this license header, choose License Headers in Project Properties.
4
+ * To change this template file, choose Tools | Templates
5
+ * and open the template in the editor.
6
+ */
7
+ ?>
8
+ <?php $isMasterpassEnabled = Mage::helper('masterpass')->isMasterpassEnabled(); ?>
9
+ <?php if ($isMasterpassEnabled): ?>
10
+ <?php if (Mage::helper('masterpass')->isExpressEnabled()): ?>
11
+ <?php if (!$this->isWalletPaired()): ?>
12
+ <div class="dashboard" style="overflow: hidden;">
13
+ <h3><?php echo $this->__('Pairing With MasterPass Wallet') ?></h3>
14
+ <ul class="messages">
15
+ <li class="erro-msg">
16
+ <ul>
17
+ <li>
18
+ <span style="color: red;">Connect your MasterPass wallet and checkout faster! Simply click on the Connect with MasterPass button below</span>
19
+ </li>
20
+ </ul>
21
+ </li>
22
+ </ul>
23
+
24
+
25
+ <?php $pairinData = $this->pairingData(); ?>
26
+
27
+ <?php if ($this->getPairingButton()): ?>
28
+ <a href="#" title="Connect With MasterPass" onclick="connectWithMasterPass()">
29
+ <img src="https://www.mastercard.com/mc_us/wallet/img/en/US/mp_connect_with_button_042px.png"/>
30
+ </a>
31
+ <?php if (Mage::getStoreConfig('masterpass/config/enabledlearnmore')): ?>
32
+ <div><?php echo Mage::getStoreConfig('masterpass/config/learnmoremasterpasslink'); ?></div>
33
+ <?php endif ?>
34
+ <?php
35
+ $prefix = '';
36
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
37
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment') . ".";
38
+ }
39
+ ?>
40
+ <script type="text/javascript" src="https://<?php echo $prefix; ?>masterpass.com/lightbox/Switch/integration/MasterPass.client.js"></script>
41
+ <script type="text/javascript">
42
+ //<![CDATA[
43
+ <?php $data = $this->helper('masterpass')->getMerchantSettings(); ?>
44
+ function connectWithMasterPass() {
45
+ var pairingToken = "<?php echo Mage::helper('masterpass')->postMerchantInitData(); ?>";
46
+ MasterPass.client.connect({
47
+ "callbackUrl": "<?php echo $this->pairingcallbackUrl(); ?>",
48
+ "pairingRequestToken": pairingToken,
49
+ "requestExpressCheckout": <?php echo Mage::helper('masterpass')->requestExpressCheckout(); ?>,
50
+ "requestedDataTypes": "<?php echo Mage::helper('masterpass')->pairingDataTypes(); ?>",
51
+ "merchantCheckoutId": "<?php echo $data['checkout_id']; ?>",
52
+ "allowedCardTypes": ["<?php print_r($this->helper('masterpass')->acceptedCards()); ?>"],
53
+ "suppressShippingAddressEnable": "<?php echo $data['suppressShipping']; ?>",
54
+ "requestPairing": true,
55
+ "version": "<?php echo $data['version']; ?>"
56
+ });
57
+ }
58
+ //]]>
59
+ </script>
60
+
61
+ </div>
62
+ <?php endif; ?>
63
+ <?php endif; ?>
64
+ <?php endif; ?>
65
+ <?php endif; ?>
app/design/frontend/rwd/default/template/masterpass/customer/wrapper.phtml ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * To change this license header, choose License Headers in Project Properties.
4
+ * To change this template file, choose Tools | Templates
5
+ * and open the template in the editor.
6
+ */
7
+ ?>
8
+ <?php $isMasterpassEnabled = Mage::helper('masterpass')->isMasterpassEnabled(); ?>
9
+ <?php if($isMasterpassEnabled): ?>
10
+ <?php if(Mage::helper('masterpass')->isExpressEnabled()): ?>
11
+ <h3><?php echo $this->__('Pairing With MasterPass Wallet') ?></h3>
12
+ <?php if ($this->isWalletPaired()): ?>
13
+ <ul class="messages">
14
+ <li class="success-msg">
15
+ <ul>
16
+ <li>
17
+ <span>Your account is now connected (paired) with your MasterPass wallet. If you want to disconnect from this merchant at any time, log into your MasterPass wallet and click Menu | My Account | Connections. Select the merchant name you wish to remove your connection with and click Disconnect</span>
18
+ </li>
19
+ </ul>
20
+ </li>
21
+ </ul>
22
+ <?php else: ?>
23
+ <ul class="messages">
24
+ <li class="erro-msg">
25
+ <ul>
26
+ <li>
27
+ <span>Wallet is not connected. Connect your MasterPass wallet and checkout faster! Simply click on the Connect with MasterPass button below.</span>
28
+ </li>
29
+ </ul>
30
+ </li>
31
+ </ul>
32
+ <?php endif; ?>
33
+
34
+ <?php $pairinData = $this->pairingData(); ?>
35
+
36
+ <?php if ($this->getPairingButton()): ?>
37
+ <a href="#" title="Connect With MasterPass" onclick="connectWithMasterPass()">
38
+ <img src="https://www.mastercard.com/mc_us/wallet/img/en/US/mp_connect_with_button_042px.png"/>
39
+ </a>
40
+ <?php if (Mage::getStoreConfig('masterpass/config/enabledlearnmore')): ?>
41
+ <?php echo Mage::getStoreConfig('masterpass/config/learnmoremasterpasslink'); ?>
42
+ <?php endif ?>
43
+ <?php
44
+ $prefix = '';
45
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
46
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment') . ".";
47
+ }
48
+ ?>
49
+ <script type="text/javascript" src="https://<?php echo $prefix; ?>masterpass.com/lightbox/Switch/integration/MasterPass.client.js"></script>
50
+ <script type="text/javascript">
51
+ //<![CDATA[
52
+ <?php $data = $this->helper('masterpass')->getMerchantSettings(); ?>
53
+ function connectWithMasterPass() {
54
+ var pairingToken = "<?php echo Mage::helper('masterpass')->postMerchantInitData(); ?>";
55
+ MasterPass.client.connect({
56
+ "callbackUrl": "<?php echo $this->pairingcallbackUrl(); ?>",
57
+ "pairingRequestToken": pairingToken,
58
+ "requestExpressCheckout": <?php echo Mage::helper('masterpass')->requestExpressCheckout(); ?>,
59
+ "requestedDataTypes": "<?php echo Mage::helper('masterpass')->pairingDataTypes(); ?>",
60
+ "merchantCheckoutId": "<?php echo $data['checkout_id']; ?>",
61
+ "allowedCardTypes": ["<?php print_r($this->helper('masterpass')->acceptedCards()); ?>"],
62
+ "suppressShippingAddressEnable": "<?php echo $data['suppressShipping']; ?>",
63
+ "requestPairing": true,
64
+ "version": "<?php echo $data['version']; ?>"
65
+ });
66
+ }
67
+ //]]>
68
+ </script>
69
+ <?php endif; ?>
70
+ <?php endif; ?>
71
+ <?php endif ?>
app/design/frontend/rwd/default/template/masterpass/onepage/checkout.phtml ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * To change this license header, choose License Headers in Project Properties.
4
+ * To change this template file, choose Tools | Templates
5
+ * and open the template in the editor.
6
+ */
7
+ ?>
8
+
9
+ <?php if (!$this->getQuote()->isVirtual()): ?>
10
+ <div class="mp-complete">
11
+ <h3 class="mp-title"><?php echo $this->__('Shipping Address') ?></h3>
12
+ <?php if($this->getShipping()->getFirstname()!=''){ ?>
13
+ <address><?php echo $this->getShipping()->format('html') ?></address>
14
+
15
+ <span class="changelink">
16
+ <a onclick="updateShipping();" href="#">Change</a>
17
+ </span>
18
+ <?php } ?>
19
+ <?php echo $this->getChildHtml("standshippingform"); ?>
20
+ </div>
21
+ <?php endif; ?>
22
+ <form id="mpForm" method="post" action="<?php echo $this->getMasterpasscheckoutUrl(); ?>">
23
+ <?php if (!$this->getQuote()->isVirtual()): ?>
24
+ <div class="mp-complete">
25
+ <?php echo $this->getChildHtml("mpshippingmethod"); ?>
26
+ </div>
27
+ <?php endif; ?>
28
+ <div class="mp-complete">
29
+ <h3 class="mp-title"><?php echo $this->__('Billing Address') ?></h3>
30
+ <address><?php echo $this->getBilling()->format('html') ?></address>
31
+ </div>
32
+ <div class="payment-info">
33
+ <h3 class="mp-title"><?php echo $this->__('Payment') ?></h3>
34
+ <img class="masterpass-logo" src="https://www.mastercard.com/mc_us/wallet/img/en/US/mp_mc_acc_<?php echo Mage::getStoreConfig('masterpass/config/acceptancemark') ?>_gif.gif" alt=" MasterPass Checkout"/>
35
+ <?php $card = Mage::getSingleton('checkout/session')->getCardMask(); ?>
36
+
37
+ <ul class="mp-complete">
38
+ <li><?php echo $this->__('Credit Card Type: ') ?><?php echo $card['cardType']; ?></li>
39
+ <li><?php echo $this->__('Credit Card Number: ') ?>xxxx-<?php echo $card['last4']; ?></li>
40
+ <?php if($card['expiryMonth'] && $card['expiryYear']){ ?>
41
+ <li><?php echo $this->__('Expiration Date: ') ?><?php echo $card['expiryMonth'] . '/' . $card['expiryYear']; ?></li>
42
+ <?php } ?>
43
+ <li><?php echo $this->__('Name on the Card: ') ?><?php echo $card['cardHolder']; ?></li>
44
+ <?php if($card['RewardProgram']){ ?>
45
+ <li><b><?php echo $this->__('Reward Card') ?></b></li>
46
+ <li><?php echo $this->__('Reward Name: ') ?><?php echo $card['RewardProgram']['RewardName']; ?></li>
47
+ <li><?php echo $this->__('Reward Number: ') ?><?php echo $card['RewardProgram']['RewardNumber']; ?></li>
48
+ <?php } ?>
49
+ </ul>
50
+ </div>
51
+ <?php echo $this->getChildHtml("orderdetails"); ?>
52
+ <ul class="masterpass-checkout-block">
53
+ <li>
54
+ <button id="masterpass-checkout" class="button mp-checkout-button" value="Update Total" name="do" title="submit order" type="submit">
55
+ <span>
56
+ <span>Submit Order</span>
57
+ </span>
58
+ </button>
59
+ <span class="please-wait" id="please-wait" style="display:none;">
60
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading...') ?>" title="<?php echo $this->__('Loading...') ?>" class="v-middle" /> <?php echo $this->__('Loading...') ?>
61
+ </span>
62
+ </li>
63
+ </ul>
64
+ </form>
65
+
66
+
67
+ <script type="text/javascript" language="Javascript">
68
+ //<![CDATA[
69
+ var mpForm = new VarienForm('mpForm', true);
70
+ //update shipping method
71
+ function updateShippingMethod(method) {
72
+ document.getElementById('masterpass-checkout').setAttribute("style", "display:none;");
73
+ document.getElementById('please-wait').setAttribute("style", "display:block;");
74
+ document.getElementById("items-review").innerHTML = '<img style="margin:auto;" src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>"/>';
75
+ var reloadurl = '<?php echo $this->getUrl('masterpass/index/saveshippingmethod') ?>';
76
+
77
+ new Ajax.Request(reloadurl, {
78
+ method: 'post',
79
+ parameters: {shippingmethod: method},
80
+ onSuccess: review
81
+ });
82
+ }
83
+
84
+ //reload review
85
+ function review() {
86
+ document.getElementById('masterpass-checkout').setAttribute("style", "display:block;");
87
+ document.getElementById('please-wait').setAttribute("style", "display:none;");
88
+ var reviewurl = '<?php echo $this->getUrl('masterpass/index/review') ?>';
89
+ new Ajax.Request(reviewurl, {
90
+ onSuccess: function (response) {
91
+ document.getElementById("items-review").innerHTML = response.responseText;
92
+ }
93
+ });
94
+ }
95
+ //]]>
96
+ </script>
app/design/frontend/rwd/default/template/masterpass/onepage/login.phtml ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magento.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magento.com for more information.
20
+ *
21
+ * @category design
22
+ * @package rwd_default
23
+ * @copyright Copyright (c) 2006-2014 X.commerce, Inc. (http://www.magento.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * Customer onepage checkout login form template
30
+ *
31
+ * @see app/design/frontend/base/default/template/checkout/onepage/login.phtml
32
+ */
33
+ /** @var $this Mage_Checkout_Block_Onepage_Login */
34
+ ?>
35
+ <?php echo $this->getChildHtml('login_before') ?>
36
+ <div class="col2-set<?php if (!$this->helper('customer')->isRegistrationAllowed() && !$this->getQuote()->isAllowedGuestCheckout()) echo ' login-only' ?>">
37
+ <div class="col-1">
38
+ <h3>
39
+ <?php if( $this->getQuote()->isAllowedGuestCheckout() && $this->helper('customer')->isRegistrationAllowed() ): ?>
40
+ <?php echo $this->__('Checkout as a Guest or Register') ?>
41
+ <?php elseif ( $this->getQuote()->isAllowedGuestCheckout() && !$this->helper('customer')->isRegistrationAllowed() ): ?>
42
+ <?php echo $this->__('Checkout as a Guest') ?>
43
+ <?php else: ?>
44
+ <?php echo $this->__('Register to Create an Account') ?>
45
+ <?php endif; ?>
46
+ </h3>
47
+ <?php if( !$this->getQuote()->isAllowedGuestCheckout() && $this->helper('customer')->isRegistrationAllowed() ): ?>
48
+ <p class="description"><?php echo $this->__('Register and save time!') ?></strong><br />
49
+ <?php echo $this->__('Register with us for future convenience:') ?></p>
50
+ <ul>
51
+ <li><?php echo $this->__('Fast and easy check out') ?></li>
52
+ <li><?php echo $this->__('Easy access to your order history and status') ?></li>
53
+ </ul>
54
+ <?php elseif( $this->getQuote()->isAllowedGuestCheckout() && $this->helper('customer')->isRegistrationAllowed() ): ?>
55
+ <p class="description"><?php echo $this->__('Register with us for future convenience:') ?></p>
56
+ <?php endif ?>
57
+ <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
58
+ <ul class="form-list">
59
+ <?php if( $this->getQuote()->isAllowedGuestCheckout() ): ?>
60
+ <li class="control">
61
+ <input type="radio" name="checkout_method" id="login:guest" value="guest"<?php if($this->getQuote()->getCheckoutMethod()!=Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER): ?> checked="checked"<?php endif; ?> class="radio" /><label for="login:guest"><?php echo $this->__('Checkout as Guest') ?></label>
62
+ </li>
63
+ <?php endif; ?>
64
+ <?php if( $this->helper('customer')->isRegistrationAllowed() ): ?>
65
+ <li class="control">
66
+ <input type="radio" name="checkout_method" id="login:register" value="register"<?php if($this->getQuote()->getCheckoutMethod()==Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER || !$this->getQuote()->isAllowedGuestCheckout()): ?> checked="checked"<?php endif ?> class="radio" />
67
+ <label for="login:register"><?php echo $this->__('Register and Checkout') ?></label>
68
+ </li>
69
+ <?php endif; ?>
70
+ </ul>
71
+ <?php else: ?>
72
+ <input type="hidden" name="checkout_method" id="login:register" value="register" checked="checked" />
73
+ <?php endif; ?>
74
+ <div class="buttons-set">
75
+ <p class="required">&nbsp;</p>
76
+ <?php if ($this->getQuote()->isAllowedGuestCheckout()): ?>
77
+ <button id="onepage-guest-register-button" type="button" class="button" onclick="checkout.setMethod();"><span><span><?php echo $this->__('Continue') ?></span></span></button>
78
+ <?php elseif ($this->helper('checkout')->isCustomerMustBeLogged()): ?>
79
+ <button id="onepage-guest-register-button" type="button" class="button" onclick="window.location='<?php echo $this->helper('checkout/url')->getRegistrationUrl();?>'"><span><span><?php echo $this->__('Register') ?></span></span></button>
80
+ <?php else: ?>
81
+ <?php if (Mage::getStoreConfig('masterpass/config/enabled') && Mage::getStoreConfig('masterpass/config/userflows') == '1') { ?>
82
+ <form action="<?php echo $this->getUrl('customer/account/create/'); ?>">
83
+ <button id="onepage-guest-register-button" type="submit" class="button"><span><span><?php echo $this->__('Register') ?></span></span></button>
84
+ </form>
85
+ <?php }else{ ?>
86
+ <form action="<?php echo $this->getUrl('persistent/index/saveMethod'); ?>">
87
+ <button id="onepage-guest-register-button" type="submit" class="button"><span><span><?php echo $this->__('Register') ?></span></span></button>
88
+ </form>
89
+ <?php } ?>
90
+ <?php endif; ?>
91
+ </div>
92
+ </div>
93
+ <div class="col-2">
94
+ <h3><?php echo $this->__('Returning Customers') ?></h3>
95
+ <?php echo $this->getMessagesBlock()->toHtml() ?>
96
+ <form id="login-form" action="<?php echo $this->getPostAction() ?>" method="post">
97
+ <div class="fieldset">
98
+ <?php echo $this->getBlockHtml('formkey'); ?>
99
+ <p class="description"><?php echo $this->__('Sign in to speed up your checkout process') ?></p>
100
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
101
+ <ul class="form-list">
102
+ <li>
103
+ <label for="login-email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
104
+ <div class="input-box">
105
+ <input type="email" autocapitalize="off" autocorrect="off" spellcheck="false" class="input-text required-entry validate-email" id="login-email" name="login[username]" value="<?php echo $this->escapeHtml($this->getUsername()) ?>" />
106
+ </div>
107
+ </li>
108
+ <li>
109
+ <label for="login-password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
110
+ <div class="input-box">
111
+ <input type="password" class="input-text validate-password required-entry" id="login-password" name="login[password]" autocomplete="off" />
112
+ </div>
113
+ </li>
114
+ <li>
115
+ <a href="<?php echo $this->getUrl('customer/account/forgotpassword') ?>" class="f-left"><?php echo $this->__('Forgot your password?') ?></a>
116
+ </li>
117
+ <?php echo $this->getChildHtml('form.additional.info'); ?>
118
+ <?php echo $this->getChildHtml('persistent.remember.me'); ?>
119
+ </ul>
120
+ <?php echo $this->getChildHtml('persistent.remember.me.tooltip'); ?>
121
+ <input name="context" type="hidden" value="checkout" />
122
+ </div>
123
+ </form>
124
+ <div class="buttons-set">
125
+ <button type="submit" class="button" onclick="onepageLogin(this)"><span><span><?php echo $this->__('Login') ?></span></span></button>
126
+ </div>
127
+ </div>
128
+ </div>
129
+
130
+ <script type="text/javascript">
131
+ //<![CDATA[
132
+ var loginForm = new VarienForm('login-form', true);
133
+ $('login-email').observe('keypress', bindLoginPost);
134
+ $('login-password').observe('keypress', bindLoginPost);
135
+ function bindLoginPost(evt){
136
+ if (evt.keyCode == Event.KEY_RETURN) {
137
+ loginForm.submit();
138
+ }
139
+ }
140
+ function onepageLogin(button)
141
+ {
142
+ if(loginForm.validator && loginForm.validator.validate()){
143
+ button.disabled = true;
144
+ loginForm.submit();
145
+ }
146
+ }
147
+ //]]>
148
+ </script>
149
+ <?php
150
+ $registerParam = $this->getRequest()->getParam('register');
151
+ if ($registerParam || $registerParam === ''):
152
+ ?>
153
+ <script type="text/javascript">
154
+ //<![CDATA[
155
+ document.observe("dom:loaded", function() {
156
+ if($('login:register')) {
157
+ $('login:register').checked = true;
158
+ checkout.setMethod();
159
+ }
160
+ })
161
+ //]]>
162
+ </script>
163
+ <?php endif; ?>
app/design/frontend/rwd/default/template/masterpass/onepage/shipping_form.phtml ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * To change this license header, choose License Headers in Project Properties.
4
+ * To change this template file, choose Tools | Templates
5
+ * and open the template in the editor.
6
+ */
7
+ ?>
8
+ <?php $data = $this->helper('masterpass')->getMerchantSettings(); ?>
9
+ <div id="standard-shipping-form" <?php if($data['suppressShipping']!='true' || $this->getAddress()->getFirstname()){ ?>style="display: none;" <?php } ?>>
10
+ <form class="mp-shipping-form" name="mp-shipping-form" id="mp-shipping-form" method="post">
11
+ <table>
12
+
13
+ <tr>
14
+ <td>
15
+ <label class="required" for="shipping:firstname">
16
+ <em>*</em>
17
+ First Name
18
+ </label>
19
+ <div class="input-box">
20
+ <input id="shipping:firstname" class="input-text required-entry mp-shipping-input" type="text" maxlength="255" title="First Name" value="<?php echo $this->getShipping()->getFirstname() ?>" name="shipping[firstname]">
21
+ </div>
22
+ </td>
23
+ <td>
24
+ <label class="required" for="shipping:lastname">
25
+ <em>*</em>
26
+ Last Name
27
+ </label>
28
+ <div class="input-box">
29
+ <input id="shipping:lastname" class="input-text required-entry mp-shipping-input" type="text" maxlength="255" title="Last Name" value="<?php echo $this->getShipping()->getLastname() ?>" name="shipping[lastname]">
30
+ </div>
31
+ </td>
32
+ </tr>
33
+ <tr>
34
+ <td colspan="2">
35
+ <label for="shipping:company">Company</label>
36
+ <div class="input-box">
37
+ <input id="shipping:company" class="input-text mp-shipping-input-wide" type="text" title="Company" value="" name="shipping[company]">
38
+ </div>
39
+ </td>
40
+ </tr>
41
+ <tr>
42
+ <td colspan="2">
43
+ <label class="required" for="shipping:street1">
44
+ <em>*</em>
45
+ Address
46
+ </label>
47
+ <div class="input-box">
48
+ <input id="shipping:street1" class="input-text required-entry shipping-address mp-shipping-input-wide" type="text" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>" name="shipping[street][]" title="Street Address">
49
+ </div>
50
+ </td>
51
+ </tr>
52
+ <tr>
53
+ <td colspan="2">
54
+ <div class="input-box">
55
+ <input id="shipping:street2" class="input-text shipping-address mp-shipping-input-wide" type="text" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(2)) ?>" name="shipping[street][]" title="Street Address 2">
56
+ </div>
57
+ </td>
58
+ </tr>
59
+ <tr>
60
+ <td colspan="2">
61
+ <label class="required" for="shipping:city">
62
+ <em>*</em>
63
+ City
64
+ </label>
65
+ <div class="input-box">
66
+ <input id="shipping:city" class="input-text required-entry mp-shipping-input-wide" type="text" value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>" name="shipping[city]" title="City">
67
+ </div>
68
+ </td>
69
+ </tr>
70
+ <tr>
71
+ <td colspan="2">
72
+ <label for="shipping:region" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
73
+ <div class="input-box">
74
+ <select id="shipping:region_id" name="shipping[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select mp-shipping-input-wide" style="display:none;">
75
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
76
+ </select>
77
+ <script type="text/javascript">
78
+ //<![CDATA[
79
+ $('shipping:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
80
+ //]]>
81
+ </script>
82
+ <input type="text" id="shipping:region" name="shipping[region]" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text mp-shipping-input-wide" style="display:none;" />
83
+ </div>
84
+ </td>
85
+ </tr>
86
+ <tr>
87
+ <td colspan="2">
88
+ <label class="required" for="shipping:postcode">
89
+ <em>*</em>
90
+ Zip/Postal Code
91
+ </label>
92
+ <div class="input-box">
93
+ <input id="shipping:postcode" class="input-text validate-zip-international required-entry mp-shipping-input-wide" type="text" value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>" name="shipping[postcode]" title="Zip/Postal Code">
94
+ </div>
95
+ </td>
96
+ </tr>
97
+ <tr>
98
+ <td colspan="2">
99
+ <label for="shipping:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
100
+ <div class="input-box" style="width: 264px !important;">
101
+ <?php echo $this->getCountryHtmlSelect('shipping') ?>
102
+ </div>
103
+ </td>
104
+ </tr>
105
+ <tr>
106
+ <td colspan="2">
107
+ <label class="required" for="shipping:telephone">
108
+ <em>*</em>
109
+ Telephone
110
+ </label>
111
+ <div class="input-box">
112
+ <input id="shipping:telephone" class="input-text required-entry mp-shipping-input-wide" type="text" title="Telephone" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" name="shipping[telephone]">
113
+ </div>
114
+ </td>
115
+ </tr>
116
+ <tr>
117
+ <td colspan="2">
118
+ <button id="masterpass-checkout" class="button mp-checkout-button" type="submit" title="Update Total" name="update" value="update">
119
+ <span>
120
+ <span>Update Shipping</span>
121
+ </span>
122
+ </button>
123
+ </td>
124
+ </tr>
125
+ </table>
126
+ </form>
127
+ </div>
128
+ <script type="text/javascript">
129
+ //<![CDATA[
130
+ document.getElementById('shipping:country_id').setAttribute("style", "width:264px !important;");
131
+ var shippingRegionUpdater = new RegionUpdater('shipping:country_id', 'shipping:region', 'shipping:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'shipping:postcode');
132
+
133
+ function updateShipping() {
134
+ document.getElementById('standard-shipping-form').setAttribute("style", "display:block;");
135
+ }
136
+
137
+ var formId = 'mp-shipping-form';
138
+ var myForm = new VarienForm(formId, true);
139
+ //]]>
140
+ </script>
app/design/frontend/rwd/default/template/masterpass/onepage/success.phtml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * To change this template, choose Tools | Templates
4
+ * and open the template in the editor.
5
+ */
6
+ ?>
7
+
8
+
9
+ <div class="page-title">
10
+ <h1><?php echo $this->__('Your order has been received.') ?></h1>
11
+ </div>
12
+ <?php echo $this->getMessagesBlock()->toHtml() ?>
13
+ <h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>
14
+
15
+ <?php if ($this->getOrderId()): ?>
16
+ <?php if ($this->getCanViewOrder()) : ?>
17
+ <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
18
+ <?php else : ?>
19
+ <p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
20
+ <?php endif; ?>
21
+ <p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
22
+ <?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) : ?>
23
+ <p>
24
+ <?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
25
+ <?php echo $this->getChildHtml() ?>
26
+ </p>
27
+ <?php endif; ?>
28
+ <?php endif; ?>
29
+
30
+ <?php if ($this->getAgreementRefId()): ?>
31
+ <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId()))) ?></p>
32
+ <?php endif; ?>
33
+
34
+ <?php if ($profiles = $this->getRecurringProfiles()): ?>
35
+ <p><?php echo $this->__('Your recurring payment profiles:'); ?></p>
36
+ <ul class="disc">
37
+ <?php foreach ($profiles as $profile): ?>
38
+ <?php $profileIdHtml = ($this->getCanViewProfiles() ? sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getProfileUrl($profile)), $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) : $this->escapeHtml($this->getObjectData($profile, 'reference_id'))); ?>
39
+ <li><?php echo $this->__('Payment profile # %s: "%s".', $profileIdHtml, $this->escapeHtml($this->getObjectData($profile, 'schedule_description'))) ?></li>
40
+ <?php endforeach; ?>
41
+ </ul>
42
+ <?php endif; ?>
43
+ <?php
44
+ $isMasterpassEnable = Mage::getStoreConfig('masterpass/config/enabled');
45
+ $isPostBack = Mage::helper('masterpass')->ifPostback();
46
+
47
+ if ($isMasterpassEnable && $isPostBack) {
48
+ ?>
49
+
50
+ <div class="buttons-set">
51
+ <p>Purchased with</p>
52
+ <div class="masterpass-logo-a acceptance-mark-image"><img src="https://www.mastercard.com/mc_us/wallet/img/en/US/mp_mc_acc_<?php echo Mage::getStoreConfig('masterpass/config/acceptancemark') ?>_gif.gif" alt=" MasterPass Checkout"/></div>
53
+ <?php if (Mage::getSingleton('core/session')->getPartnerLogo()): ?>
54
+ <div class="partner-logo-a"><img src="<?php echo Mage::getSingleton('core/session')->getPartnerLogo() ?>" height="<?php echo Mage::getStoreConfig('masterpass/config/acceptancemark') ?>" /></div>
55
+ <?php endif; ?>
56
+ </div>
57
+ <?php
58
+ Mage::getSingleton('core/session')->unsPartnerLogo();
59
+ }
60
+ ?>
61
+ <div class="buttons-set">
62
+ <button type="button" class="button" title="<?php echo Mage::helper('core')->quoteEscape($this->__('Continue Shopping')) ?>" onclick="window.location = '<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
63
+ </div>
app/design/frontend/rwd/default/template/masterpass/precheckout/pairWallet.phtml ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $isMasterpassEnabled = Mage::helper('masterpass')->isMasterpassEnabled(); ?>
2
+ <?php if ($isMasterpassEnabled): ?>
3
+ <?php
4
+ $prefix = '';
5
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
6
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment') . ".";
7
+ }
8
+ ?>
9
+
10
+ <script type="text/javascript" src="https://<?php echo $prefix; ?>masterpass.com/lightbox/Switch/integration/MasterPass.client.js"></script>
11
+ <?php if (!Mage::helper('masterpass')->isExpressEnabled()) { ?>
12
+ <div class="page-title">
13
+ <h2>FOR FASTER CHECKOUT</h2>
14
+ <a class="pair-mp-wallet" href="#" onclick="handleBuyWithMasterPass()" title="Buy With MasterPass"><img src="https://static.masterpass.com/dyn/img/btn/en/US/mp_chk_btn_<?php echo Mage::getStoreConfig('masterpass/config/buttonsize'); ?>.png"/></a>
15
+ </div>
16
+ <?php if (Mage::getStoreConfig('masterpass/config/enabledlearnmore')): ?>
17
+ <?php echo Mage::getStoreConfig('masterpass/config/learnmoremasterpasslink'); ?>
18
+ <?php endif ?>
19
+ <div style="margin: 25px 0 10px;">- OR -</div>
20
+ <script type="text/javascript">
21
+ //<![CDATA[
22
+ function handleBuyWithMasterPass() {
23
+ new Ajax.Request('<?php echo $this->getUrl() . 'masterpass/index/validatePk'; ?>',
24
+ {
25
+ method:'get',
26
+ onSuccess: function(transport){
27
+ var response = transport.responseText;
28
+ if (response != ''){
29
+ <?php $data = $this->helper('masterpass')->getMerchantSettings(); ?>
30
+ var token = "<?php print_r($this->helper('masterpass')->postShoppingCart()); ?>";
31
+ if (token != ''){
32
+ MasterPass.client.checkout({
33
+ "requestToken":token,
34
+ <?php if (Mage::getStoreConfig('masterpass/config/callbackurl') != '') { ?>
35
+ "callbackUrl":"<?php echo Mage::getStoreConfig('masterpass/config/callbackurl'); ?>",
36
+ <?php } else { ?>
37
+ "callbackUrl":"<?php echo $this->getUrl() . 'masterpass/index/callback'; ?>",
38
+ <?php } ?>
39
+ "merchantCheckoutId":"<?php echo $data['checkout_id']; ?>",
40
+ "allowedCardTypes":"<?php print_r($this->helper('masterpass')->acceptedCards()); ?>",
41
+ "cancelCallback" : "<?php echo $this->getUrl(); ?>",
42
+ "suppressShippingAddressEnable": "<?php echo $data['suppressShipping']; ?>",
43
+ "loyaltyEnabled" : "<?php echo $data['loyaltyEnabled']; ?>",
44
+ <?php if ($data['loyaltyEnabled'] == 'true') { ?>
45
+ "allowedLoyaltyPrograms" : "<?php echo $data['loyaltyProgram']; ?>",
46
+ <?php } ?>
47
+ "requestBasicCheckout" : "<?php echo $data['requestBasicCheckout']; ?>",
48
+ "version":"<?php echo $data['version']; ?>"
49
+ });
50
+ } else{
51
+ window.location.href = '<?php echo Mage::getUrl('', array('_secure' => true)); ?>masterpass/index/callback';
52
+ }
53
+
54
+ } else{
55
+ location.reload();
56
+ }
57
+ } });
58
+ }
59
+ //]]>
60
+ </script>
61
+
62
+ <?php } elseif (Mage::getSingleton('customer/session')->isLoggedIn()) { ?>
63
+ <div class="page-title">
64
+ <h2>FOR FASTER CHECKOUT</h2>
65
+ <a class="pair-mp-wallet" href="#" onclick="<?php if ($this->walletIsPaired()): ?> window.location = '<?php echo Mage::getUrl('', array('_secure' => true)) . "masterpass/masterpasspairing/precheckout"; ?>';<?php else: ?>pairWithMasterPass()<?php endif; ?>"><img src="https://static.masterpass.com/dyn/img/btn/en/US/mp_chk_btn_<?php echo Mage::getStoreConfig('masterpass/config/buttonsize'); ?>.png"/></a>
66
+ </div>
67
+ <?php if (Mage::getStoreConfig('masterpass/config/enabledlearnmore')): ?>
68
+ <?php echo Mage::getStoreConfig('masterpass/config/learnmoremasterpasslink'); ?>
69
+ <?php endif ?>
70
+ <div style="margin: 25px 0 10px;">- OR -</div>
71
+
72
+ <script type="text/javascript">
73
+ //<![CDATA[
74
+ function pairWithMasterPass() {
75
+ new Ajax.Request('<?php echo $this->getUrl() . 'masterpass/index/validatePk'; ?>',
76
+ {
77
+ method:'get',
78
+ onSuccess: function(transport){
79
+ var response = transport.responseText;
80
+ if (response != ''){
81
+ <?php $data = $this->helper('masterpass')->getMerchantSettings(); ?>
82
+ var token = "<?php print_r($this->helper('masterpass')->postShoppingCart()); ?>";
83
+ MasterPass.client.checkout({
84
+ "requestToken": token,
85
+ "callbackUrl": "<?php echo Mage::getUrl('', array('_secure' => true)) . "masterpass/index/callback"; ?>",
86
+ "pairingRequestToken": "<?php print_r($this->helper('masterpass')->postMerchantInitData()); ?>",
87
+ "requestExpressCheckout": <?php echo Mage::helper('masterpass')->requestExpressCheckout(); ?>,
88
+ "requestedDataTypes": "<?php echo Mage::helper('masterpass')->pairingDataTypes(); ?>",
89
+ "merchantCheckoutId": "<?php echo $data['checkout_id']; ?>",
90
+ "allowedCardTypes": "<?php print_r($this->helper('masterpass')->acceptedCards()); ?>",
91
+ "cancelCallback": "<?php echo $this->getUrl(); ?>",
92
+ "suppressShippingAddressEnable": "<?php echo $data['suppressShipping']; ?>",
93
+ "loyaltyEnabled": "<?php echo $data['loyaltyEnabled']; ?>",
94
+ "requestPairing": true,
95
+ "version": "<?php echo $data['version']; ?>"
96
+ });
97
+ } else{
98
+ location.reload();
99
+ }
100
+ } });
101
+ }
102
+ //]]>
103
+ </script>
104
+ <?php } ?>
105
+ <?php
106
+
107
+
108
+ endif ?>
app/design/frontend/rwd/default/template/masterpass/precheckout/precheckout.phtml ADDED
@@ -0,0 +1,514 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * To change this license header, choose License Headers in Project Properties.
4
+ * To change this template file, choose Tools | Templates
5
+ * and open the template in the editor.
6
+ */
7
+
8
+ if (Mage::getStoreConfig('masterpass/config/userflows') == '2' || Mage::getStoreConfig('masterpass/config/userflows') == '3') {
9
+ if(!Mage::getSingleton('core/session')->getExpSecure())
10
+ {
11
+ $preCheckout = $this->getPrecheckoutdata();
12
+ }
13
+ }
14
+
15
+ if ($preCheckout) {
16
+ ?>
17
+
18
+ <?php
19
+ $prefix = '';
20
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
21
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment') . ".";
22
+ }
23
+ ?>
24
+
25
+ <script type="text/javascript" src="https://<?php echo $prefix; ?>masterpass.com/lightbox/Switch/integration/MasterPass.client.js"></script>
26
+ <?php echo $this->getMessagesBlock()->toHtml() ?>
27
+ <h1><?php echo $this->__('Checkout With MasterPass') ?></h1>
28
+ <div class="preCheckou-main">
29
+ <!-- profile -->
30
+
31
+ <?php if (Mage::getStoreConfig('masterpass/config/userflows') == '3') { ?>
32
+ <div class="fieldset">
33
+ <form id="mpForm" class="scaffold-form" method="post" action="<?php echo $this->getPostexpresscheckout(); ?>" >
34
+ <input type="hidden" name="longaccesstoken" value="<?php echo $this->getLongToken(); ?>"/>
35
+ <input type="hidden" name="precheckoutid" value="<?php echo $this->getPreCheckoutTranId(); ?>"/>
36
+ <input type="hidden" name="walletid" value="<?php echo $this->getConWalletId(); ?>"/>
37
+ <?php } ?>
38
+ <div class="masterpass-form-left">
39
+ <ul class="form-list">
40
+ <?php $profile = $this->getPreProfile(); ?>
41
+ <?php if ($profile['FirstName']) { ?>
42
+ <li class="fields">
43
+ <h3 class="mp-title"><?php echo $this->__('Profile') ?></h3>
44
+ <div class="input-box"><?php echo $profile['FirstName'] . ' ' . $profile['LastName']; ?></div>
45
+ </li>
46
+ <?php } ?>
47
+ <!-- address -->
48
+ <?php if ($this->canbeShipped() && !Mage::getStoreConfig('masterpass/config/cfaddress')): ?>
49
+ <?php echo $this->getChildHtml("shippingform"); ?>
50
+ <?php endif; ?>
51
+ <?php $shippingAddresses = $this->getPreAddress(); ?>
52
+ <?php if ($shippingAddresses) { ?>
53
+ <li class="fields">
54
+ <div class="field">
55
+ <h3 class="mp-title"><?php echo $this->__('Shipping Address') ?></h3>
56
+ <div class="input-box">
57
+
58
+ <select id="addressSelect" name="address">
59
+ <?php if (is_array($shippingAddresses)) { ?>
60
+ <?php foreach ($shippingAddresses as $address) { ?>
61
+ <?php
62
+ //check address line2
63
+ if (!is_array($address['Line2'])) {
64
+ $lin2 = '<br/>' . $address['Line2'] . '<br/>';
65
+ } else {
66
+ $lin2 = '<br/>';
67
+ }
68
+
69
+ if (!is_array($address['Line3'])) {
70
+ $lin3 = $address['Line3'] . '<br/>';
71
+ } else {
72
+ $lin3 = '';
73
+ }
74
+
75
+ $state = Mage::getModel('masterpass/masterpass')->getRemoveDash($address['CountrySubdivision']);
76
+ ?>
77
+ <option <?php
78
+ if ($address['SelectedAsDefault'] == 'true') {
79
+ echo 'selected';
80
+ }
81
+ ?> detail="<?php echo $address['RecipientName'] . '<br/>' . $address['Line1'] . $lin2 .$lin3 . $address['City'] . ',' . $state . ' ' . $address['PostalCode'] . ', ' . $address['Country'] ?>" value="<?php echo $address['AddressId']; ?>"><?php echo $address['Country'] . ' : ' . $address['Line1']; ?></option>
82
+ <?php } ?>
83
+ <?php } else { ?>
84
+ <option value="<?php echo $shippingAddresses['AddressId']; ?>"><?php echo $shippingAddresses['Country'] . ' : ' . $shippingAddresses['Line1']; ?></option>
85
+ <?php } ?>
86
+ </select>
87
+ </div>
88
+ <div id="selected-address" class="pre-data"></div>
89
+ </div>
90
+ </li>
91
+ <?php } ?>
92
+ <!-- cards-->
93
+ <?php $cards = $this->getPreCards(); ?>
94
+
95
+ <?php if ($cards) { ?>
96
+ <li class="fields">
97
+ <div class="field">
98
+ <h3 class="mp-title"><?php echo $this->__('Payment') ?></h3>
99
+ <div class="input-box">
100
+ <div class="masterpass-logo"><img src="https://www.mastercard.com/mc_us/wallet/img/en/US/mp_mc_acc_<?php echo Mage::getStoreConfig('masterpass/config/acceptancemark') ?>_gif.gif" alt=" MasterPass Checkout"/></div>
101
+ <div class="partner-logo"><img src="<?php echo $this->partnerLogo() ?>" height="<?php echo Mage::getStoreConfig('masterpass/config/acceptancemark') ?>" /></div>
102
+ </div>
103
+ <div class="input-box">
104
+ <select id="cardSelect" name="cards">
105
+ <?php if (is_array($cards)) { ?>
106
+ <?php foreach ($cards as $card) { ?>
107
+ <?php if (empty($card['BrandName'])) $card['BrandName'] = 'undefined'; ?>
108
+ <option <?php
109
+ if ($card['SelectedAsDefault'] == 'true') {
110
+ echo 'selected';
111
+ }
112
+ ?> detail="Name: <?php
113
+ echo $card['CardHolderName'];
114
+ if ($card['ExpiryMonth']) {
115
+ echo '<br/>Exp: ' . $card['ExpiryMonth'] . '/' . $card['ExpiryYear'];
116
+ } echo '<br/>Card: XXXX-XXXX-XXXX-' . $card['LastFour'];
117
+ ?>" value="<?php echo $card['CardId']; ?>"><?php echo $card['BrandName'] . ' - ' . $card['LastFour']; ?></option>
118
+ <?php } ?>
119
+ <?php } else { ?>
120
+ <option detail="Name: <?php echo $card['CardHolderName'] . '<br/>Exp: ' . $card['ExpiryMonth'] . '/' . $card['ExpiryYear'] . '<br/>Card: XXXX-XXXX-XXXX-' . $card['LastFour']; ?>" value="<?php echo $cards['CardId']; ?>"><?php echo $cards['BrandName'] . ' - ' . $cards['LastFour']; ?></option>
121
+ <?php } ?>
122
+ </select>
123
+ </div>
124
+ <div id="selected-card" class="pre-data"></div>
125
+ </div>
126
+ </li>
127
+ <?php } ?>
128
+
129
+ <!-- Reward program -->
130
+ <?php $rewardPrograms = $this->getPreReward(); ?>
131
+ <?php if (!empty($rewardPrograms)) { ?>
132
+ <li class="fields">
133
+ <div class="field">
134
+ <h3 class="mp-title"><?php echo $this->__('Reward') ?></h3>
135
+ <div class="input-box">
136
+ <select id="rewardSelect" name="rewardprogram">
137
+ <?php foreach ($rewardPrograms as $reward) { ?>
138
+ <option detail="<?php echo 'Reward Name: ' . $reward['RewardName']; ?>" value="<?php echo $reward['RewardProgramId']; ?>"><?php echo $reward['RewardNumber']; ?></option>
139
+ <?php } ?>
140
+ </select>
141
+ </div>
142
+ <div id="selected-reward" class="pre-data"></div>
143
+ </div>
144
+ </li>
145
+ <?php } ?>
146
+
147
+ <!-- <li class="fields">Or</li>
148
+ <li class="fields">
149
+ <button class="button btn-proceed-checkout btn-checkout" onclick="window.location = '<?php echo $this->getUrl('checkout/onepage', array('_secure' => true)); ?>';" title="Proceed to Checkout" type="button">
150
+ <span>
151
+ <span>Proceed to Checkout</span>
152
+ </span>
153
+ </button>
154
+ </li>-->
155
+ </ul>
156
+ </div>
157
+ <div class="masterpass-form-right">
158
+ <?php if ($this->canbeShipped() && Mage::getStoreConfig('masterpass/config/userflows') == '3'): ?>
159
+ <?php echo $this->getChildHtml("mpshippingmethod"); ?>
160
+ <?php elseif ($this->canbeShipped() && Mage::getStoreConfig('masterpass/config/userflows') == '2'): ?>
161
+ <?php echo $this->getChildHtml("mpshippingmethod"); ?>
162
+ <?php endif; ?>
163
+ <?php echo $this->getChildHtml("details"); ?>
164
+ <ul class="masterpass-checkout-block">
165
+ <li>
166
+ <div id="buy-with-masterpass" class="input-box">
167
+ <?php if (Mage::getStoreConfig('masterpass/config/userflows') == '3') { ?>
168
+ <input id="expresscheckout" class="expresscheckout-button validation-passed" title="Buy With MasterPass" type="image" src="https://static.masterpass.com/dyn/img/btn/en/US/mp_chk_btn_<?php echo Mage::getStoreConfig('masterpass/config/buttonsize'); ?>.png"/>
169
+ <?php } else { ?>
170
+ <a href="#" onclick="handleCheckoutWithMasterpass()" title="Buy With MasterPass">
171
+ <img src="https://static.masterpass.com/dyn/img/btn/en/US/mp_chk_btn_<?php echo Mage::getStoreConfig('masterpass/config/buttonsize'); ?>.png"/>
172
+ </a>
173
+ <?php } ?>
174
+ </div>
175
+ </li>
176
+ <li>
177
+ <div class="input-box">
178
+ <?php if (Mage::getStoreConfig('masterpass/config/enabledlearnmore')): ?>
179
+ <label style="font-weight: 500;">
180
+ <?php echo Mage::getStoreConfig('masterpass/config/learnmoremasterpasslink'); ?>
181
+ </label>
182
+ <?php endif ?>
183
+ </div>
184
+ </li>
185
+ </ul>
186
+ </div>
187
+ <?php if (Mage::getStoreConfig('masterpass/config/userflows') == '3') { ?>
188
+ </form>
189
+
190
+ <script type="text/javascript" language="Javascript">
191
+ //<![CDATA[
192
+ var mpForm = new VarienForm('mpForm', true);
193
+
194
+ //]]>
195
+ </script>
196
+ </div>
197
+ <?php } ?>
198
+ </div>
199
+ <?php
200
+ if (Mage::getStoreConfig('masterpass/config/userflows') == '2') {
201
+ $prefix = '';
202
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
203
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment') . ".";
204
+ }
205
+ ?>
206
+ <script type="text/javascript" src="https://<?php echo $prefix; ?>masterpass.com/lightbox/Switch/integration/MasterPass.client.js"></script>
207
+ <?php } ?>
208
+ <?php if (Mage::getStoreConfig('masterpass/config/userflows') == '2' || Mage::getStoreConfig('masterpass/config/userflows') == '3') { ?>
209
+ <script type="text/javascript" language="Javascript">
210
+ //<![CDATA[
211
+
212
+ var c = document.getElementById("cardSelect");
213
+ var cardId = c.options[c.selectedIndex].getAttribute("detail");
214
+
215
+ document.getElementById("selected-card").innerHTML = cardId;
216
+ document.getElementById("cardSelect").onchange = function () {
217
+ var c = document.getElementById("cardSelect");
218
+ var cardId = c.options[c.selectedIndex].getAttribute("detail");
219
+ document.getElementById("selected-card").innerHTML = cardId;
220
+ }
221
+
222
+ <?php if ($shippingAddresses) { ?>
223
+ //address
224
+
225
+ var ad = document.getElementById("addressSelect");
226
+ var addressId = ad.options[ad.selectedIndex].getAttribute("detail");
227
+ window.onload = function () {
228
+ document.getElementById("shipping-method").innerHTML = '<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>"/>';
229
+
230
+ var ad = document.getElementById("addressSelect");
231
+ var address = ad.options[ad.selectedIndex].getAttribute("detail");
232
+ document.getElementById("selected-address").innerHTML = address;
233
+ var addressid = ad.options[ad.selectedIndex].value;
234
+ var reloadurl = '<?php echo $this->getUrl('masterpass/masterpasspairing/saveshipping') ?>';
235
+
236
+ new Ajax.Request(reloadurl, {
237
+ method: 'post',
238
+ parameters: {addressid: addressid},
239
+ onSuccess: successFunc
240
+ });
241
+ }
242
+ document.getElementById("selected-address").innerHTML = addressId;
243
+ document.getElementById("addressSelect").onchange = function () {
244
+ document.getElementById("shipping-method").innerHTML = '<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>"/>';
245
+ document.getElementById("items-review").innerHTML = '<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>"/>';
246
+ var ad = document.getElementById("addressSelect");
247
+ var address = ad.options[ad.selectedIndex].getAttribute("detail");
248
+ document.getElementById("selected-address").innerHTML = address;
249
+ var addressid = ad.options[ad.selectedIndex].value;
250
+ var reloadurl = '<?php echo $this->getUrl('masterpass/masterpasspairing/saveshipping') ?>';
251
+
252
+ new Ajax.Request(reloadurl, {
253
+ method: 'post',
254
+ parameters: {addressid: addressid},
255
+ onSuccess: successFunc
256
+ });
257
+
258
+ }
259
+ <?php } else { // if no address ?>
260
+ document.getElementById("shipping:country_id").onchange = function () {
261
+ getShippingMethods();
262
+ }
263
+ document.getElementById("shipping:postcode").onblur = function () {
264
+ getShippingMethods();
265
+ }
266
+ document.getElementById("shipping:city").onblur = function () {
267
+ getShippingMethods();
268
+ }
269
+ document.getElementById("shipping:region").onblur = function () {
270
+ getShippingMethods();
271
+ }
272
+ document.getElementById("shipping:region_id").onchange = function () {
273
+ getShippingMethods();
274
+ }
275
+ function getShippingMethods() {
276
+ document.getElementById("shipping-method").innerHTML = '<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>"/>';
277
+ var countryid = document.getElementById('shipping:country_id').value;
278
+ var zipcode = document.getElementById('shipping:postcode').value;
279
+ var city = document.getElementById('shipping:city').value;
280
+ var regionid = document.getElementById('shipping:region_id').value;
281
+ var region = document.getElementById('shipping:region').value;
282
+ var url = '<?php echo $this->getUrl('masterpass/masterpasspairing/availableshipping') ?>';
283
+
284
+ new Ajax.Request(url, {
285
+ method: 'post',
286
+ parameters: {country_id: countryid, postcode: zipcode, city: city, region_id: region, region: region},
287
+ onSuccess: successFunc
288
+ });
289
+ }
290
+
291
+ <?php } ?>
292
+ //reload shipping methods
293
+ function successFunc(response) {
294
+ document.getElementById("shipping-method").innerHTML = response.responseText;
295
+ review();
296
+ }
297
+ //reload review
298
+ function review() {
299
+ var reviewurl = '<?php echo $this->getUrl('masterpass/masterpasspairing/review') ?>';
300
+ new Ajax.Request(reviewurl, {
301
+ onSuccess: function (response) {
302
+ document.getElementById("items-review").innerHTML = response.responseText;
303
+ }
304
+ });
305
+ }
306
+ //update shipping method
307
+ function updateShippingMethod(method) {
308
+
309
+ document.getElementById("items-review").innerHTML = '<img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>"/>';
310
+ var reloadurl = '<?php echo $this->getUrl('masterpass/masterpasspairing/saveshippingmethod') ?>';
311
+
312
+ new Ajax.Request(reloadurl, {
313
+ method: 'post',
314
+ parameters: {shippingmethod: method},
315
+ onSuccess: reloadshippingmethod
316
+ });
317
+ }
318
+ function reloadshippingmethod(response) {
319
+
320
+ document.getElementById("shipping-method").innerHTML = response.responseText;
321
+ review();
322
+ }
323
+ //
324
+ //reward
325
+ <?php if (!empty($rewardPrograms)) { ?>
326
+ var rw = document.getElementById("rewardSelect");
327
+ var rewardId = rw.options[rw.selectedIndex].getAttribute("detail");
328
+ document.getElementById("selected-reward").innerHTML = rewardId;
329
+ document.getElementById("rewardSelect").onchange = function () {
330
+ var rw = document.getElementById("rewardSelect");
331
+ var rewardId = rw.options[rw.selectedIndex].getAttribute("detail");
332
+ document.getElementById("selected-reward").innerHTML = rewardId;
333
+ }
334
+ <?php } ?>
335
+ //hide buy with masterpass button after click
336
+ // if connected checkout is enabled also execut this function
337
+ function disableButton() {
338
+ document.getElementById('expresscheckout').setAttribute("style", "display:none;");
339
+ document.getElementById('please-wait').setAttribute("style", "display:block;");
340
+
341
+ }
342
+ <?php if (Mage::getStoreConfig('masterpass/config/userflows') == '2') { ?>
343
+
344
+ function handleCheckoutWithMasterpass() {
345
+ //check if shipping method is checked
346
+ var shippingMethod;
347
+ <?php if (Mage::getStoreConfig('masterpass/config/cfaddress') && $this->canbeShipped()) { ?>
348
+ shippingMethod = validateForm();
349
+ <?php } else { ?>
350
+ shippingMethod = true;
351
+ <?php } ?>
352
+ if (shippingMethod) {
353
+
354
+ <?php
355
+ $data = $this->helper('masterpass')->getMerchantSettings();
356
+ if (Mage::getStoreConfig('masterpass/config/cfaddress')) {
357
+ $shippingSup = 'false';
358
+ } else {
359
+ $shippingSup = 'true';
360
+ }
361
+ ?>
362
+ var token = "<?php echo $this->helper('masterpass')->postShoppingCart(); ?>";
363
+
364
+ <?php if ($cards != null) { ?>
365
+ var c = document.getElementById("cardSelect");
366
+ var cardId = c.options[c.selectedIndex].value;
367
+ <?php } else { ?>
368
+ var cardId = '';
369
+ <?php } if ($shippingAddresses != null) { ?>
370
+ var d = document.getElementById("addressSelect");
371
+ var addressId = d.options[d.selectedIndex].value;
372
+ <?php } else { ?>
373
+ var addressId = '';
374
+ <?php } if ($rewardPrograms != null) { ?>
375
+ var l = document.getElementById("rewardSelect");
376
+ var loltyprograms = l.options[l.selectedIndex].value;
377
+ <?php } else { ?>
378
+ var loltyprograms = '';
379
+ <?php } ?>
380
+
381
+ MasterPass.client.checkout({
382
+ "requestToken": token,
383
+ "callbackUrl": "<?php echo $this->connectedCallBackUrl(); ?>",
384
+ "merchantCheckoutId": "<?php echo $data['checkout_id']; ?>",
385
+ "allowedCardTypes": ["<?php print_r($this->helper('masterpass')->acceptedCards()); ?>"],
386
+ "cardId": cardId,
387
+ "shippingId": addressId,
388
+ "precheckoutTransactionId": "<?php echo $this->getPreCheckoutTranId(); ?>",
389
+ "walletName": "<?php echo $this->getWalletName(); ?>",
390
+ "consumerWalletId": "<?php echo $this->getConWalletId(); ?>",
391
+ "loyaltyEnabled": "<?php echo $data['loyaltyEnabled']; ?>",
392
+ "allowedLoyaltyPrograms": loltyprograms,
393
+ "version": "<?php echo $data['version']; ?>"
394
+
395
+ }
396
+ );
397
+ } else {
398
+ //if shipping is not checked
399
+ document.getElementById('required-shipping').setAttribute("style", "display:block;");
400
+ }
401
+ }
402
+
403
+ //validat shipping method
404
+ function validateForm() {
405
+ var radios = document.getElementsByName("shipping_method");
406
+ var formValid = false;
407
+
408
+ var i = 0;
409
+ while (!formValid && i < radios.length) {
410
+ if (radios[i].checked)
411
+ formValid = true;
412
+ i++;
413
+ }
414
+ return formValid;
415
+ }
416
+ <?php } //end if ?>
417
+
418
+
419
+ //]]>
420
+ </script>
421
+ <?php } ?>
422
+ <?php
423
+ } else if (Mage::getStoreConfig('masterpass/config/userflows') == '3' && Mage::getSingleton('core/session')->getExpSecure()) { ?>
424
+ <?php
425
+ $prefix = '';
426
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
427
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment');
428
+ }
429
+ ?>
430
+
431
+ <?php if($prefix=='sandbox') {?>
432
+ <script type="text/javascript" src="https://<?php echo $prefix; ?>masterpass.com/lightbox/Switch/integration/MasterPass.client.js"></script>
433
+ <?php } else if($prefix=='') { ?>
434
+ <script type="text/javascript" src="https://masterpass.com/lightbox/Switch/integration/MasterPass.client.js"></script>
435
+ <?php } ?>
436
+
437
+
438
+ <script type="text/javascript">
439
+
440
+ var securReq = <?php echo Mage::getSingleton('core/session')->getExpSecure(); ?>;
441
+ <?php $data = $this->helper('masterpass')->getMerchantSettings(); ?>
442
+
443
+ if(securReq)
444
+ {
445
+ console.log("SECURITY REQUIRED");
446
+ MasterPass.client.cardSecurity({
447
+ "requestToken": "<?php echo Mage::getSingleton('core/session')->getExpToken(); ?>",
448
+ "callbackUrl": "<?php echo Mage::getUrl('', array('_secure' => true)) . "masterpass/masterpasspairing/placeOrderExpress"; ?>",
449
+ "failureCallback":failureCall,
450
+ "cancelCallback":cancelCall,
451
+ "merchantCheckoutId":"<?php echo $data['checkout_id']; ?>",
452
+ "precheckoutTransactionId":"<?php echo Mage::getSingleton("core/session")->getpreTransId(); ?>"
453
+ });
454
+
455
+ <?php Mage::getSingleton('core/session')->setExpSecure(false); ?>
456
+ }
457
+
458
+ function cancelCall(data)
459
+ {
460
+ <?php Mage::getSingleton('core/session')->setExpSecure(false); ?>
461
+ window.location = "<?php echo Mage::getUrl('', array('_secure' => true)) . "masterpass/masterpasspairing/placeOrderExpress?mpstatus="; ?>"+ data.mpstatus;
462
+ }
463
+
464
+ function failureCall(data)
465
+ {
466
+ <?php Mage::getSingleton('core/session')->setExpSecure(false); ?>
467
+ window.location = "<?php echo Mage::getUrl('', array('_secure' => true)) . "masterpass/masterpasspairing/placeOrderExpress?mpstatus="; ?>"+ data.mpstatus;
468
+ }
469
+
470
+ </script>
471
+ <?php } else if(!$preCheckout) { // if longaccesstoken expired then repair masterpass wallet?>
472
+ <?php
473
+ $prefix = '';
474
+ if (Mage::getStoreConfig('masterpass/config/environment') === 'sandbox') {
475
+ $prefix .= Mage::getStoreConfig('masterpass/config/environment') . ".";
476
+ }
477
+ ?>
478
+ <h1><?php echo $this->__('Please repair your MasterPass Wallet') ?></h1>
479
+ <div class="preCheckou-main">
480
+ <a href="#" title="Connect With MasterPass" onclick="repairWallet()">
481
+ <img src="https://www.mastercard.com/mc_us/wallet/img/en/US/mp_connect_with_button_042px.png"/>
482
+ </a>
483
+ <?php if (Mage::getStoreConfig('masterpass/config/enabledlearnmore')): ?>
484
+ <?php echo Mage::getStoreConfig('masterpass/config/learnmoremasterpasslink'); ?>
485
+ <?php endif ?>
486
+ </div>
487
+ <script type="text/javascript" src="https://<?php echo $prefix; ?>masterpass.com/lightbox/Switch/integration/MasterPass.client.js"></script>
488
+ <script type="text/javascript">
489
+ //<![CDATA[
490
+ window.onload = function () {
491
+
492
+ var securReq = "<?php echo Mage::getSingleton('core/session')->getExpSecure(); ?>";
493
+ if(!secureReq){
494
+ repairWallet();
495
+ }
496
+ }
497
+ <?php $data = $this->helper('masterpass')->getMerchantSettings(); ?>
498
+ function repairWallet() {
499
+ var pairingToken = "<?php echo Mage::helper('masterpass')->postMerchantInitData(); ?>";
500
+ MasterPass.client.connect({
501
+ "callbackUrl": "<?php echo Mage::getUrl('', array('_secure' => true)) . "masterpass/index/expresscallback"; ?>",
502
+ "pairingRequestToken": pairingToken,
503
+ "requestExpressCheckout": <?php echo Mage::helper('masterpass')->requestExpressCheckout(); ?>,
504
+ "requestedDataTypes": "<?php echo Mage::helper('masterpass')->pairingDataTypes(); ?>",
505
+ "merchantCheckoutId": "<?php echo $data['checkout_id']; ?>",
506
+ "allowedCardTypes": ["<?php print_r($this->helper('masterpass')->acceptedCards()); ?>"],
507
+ "suppressShippingAddressEnable": "<?php echo $data['suppressShipping']; ?>",
508
+ "requestPairing": true,
509
+ "version": "<?php echo $data['version']; ?>"
510
+ });
511
+ }
512
+ //]]>
513
+ </script>
514
+ <?php } ?>
app/design/frontend/rwd/default/template/masterpass/precheckout/shipping.phtml ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div>
2
+ <h3 class="mp-title"><?php echo $this->__('Shipping Address') ?></h3>
3
+ <ul class="form-list">
4
+
5
+ <li id="shipping-new-address-form">
6
+ <fieldset>
7
+ <ul>
8
+ <li class="fields">
9
+ <div class="customer-name">
10
+ <div class="shipping-field name-firstname">
11
+ <label class="required" for="shipping:firstname">
12
+ <em>*</em>
13
+ First Name
14
+ </label>
15
+ <div class="input-box">
16
+ <input id="shipping:firstname" class="input-text required-entry" type="text" maxlength="255" title="First Name" value="" name="shipping[firstname]">
17
+ </div>
18
+ </div>
19
+ <div class="shipping-field name-lastname">
20
+ <label class="required" for="shipping:lastname">
21
+ <em>*</em>
22
+ Last Name
23
+ </label>
24
+ <div class="input-box">
25
+ <input id="shipping:lastname" class="input-text required-entry" type="text" maxlength="255" title="Last Name" value="" name="shipping[lastname]">
26
+ </div>
27
+ </div>
28
+ </div>
29
+ </li>
30
+ <li class="fields">
31
+ <div class="shipping-field">
32
+ <label for="shipping:company">Company</label>
33
+ <div class="input-box">
34
+ <input id="shipping:company" class="input-text " type="text" title="Company" value="" name="shipping[company]">
35
+ </div>
36
+ </div>
37
+ <div class="shipping-field">
38
+
39
+
40
+ </div>
41
+ </li>
42
+ <li class="shipping-wide">
43
+ <label class="required" for="shipping:street1">
44
+ <em>*</em>
45
+ Address
46
+ </label>
47
+ <div class="input-box">
48
+ <input id="shipping:street1" class="input-text required-entry shipping-address" type="text" value="" name="shipping[street][]" title="Street Address">
49
+ </div>
50
+ </li>
51
+ <li class="shipping-wide">
52
+ <div class="input-box">
53
+ <input id="shipping:street2" class="input-text shipping-address" type="text" value="" name="shipping[street][]" title="Street Address 2">
54
+ </div>
55
+ </li>
56
+
57
+ <li class="fields">
58
+ <div class="shipping-field">
59
+ <label class="required" for="shipping:city">
60
+ <em>*</em>
61
+ City
62
+ </label>
63
+ <div class="input-box">
64
+ <input id="shipping:city" class="input-text required-entry" type="text" value="" name="shipping[city]" title="City">
65
+ </div>
66
+ </div>
67
+ <div class="shipping-field select-shipping">
68
+ <label for="shipping:region" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
69
+ <div class="input-box">
70
+ <select id="shipping:region_id" name="shipping[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
71
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
72
+ </select>
73
+ <script type="text/javascript">
74
+ //<![CDATA[
75
+ $('shipping:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
76
+ //]]>
77
+ </script>
78
+ <input type="text" id="shipping:region" name="shipping[region]" value="" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
79
+ </div>
80
+ </div>
81
+ </li>
82
+ <li class="fields">
83
+ <div class="shipping-field">
84
+ <label class="required" for="shipping:postcode">
85
+ <em>*</em>
86
+ Zip/Postal Code
87
+ </label>
88
+ <div class="input-box">
89
+ <input id="shipping:postcode" class="input-text validate-zip-international required-entry" type="text" value="" name="shipping[postcode]" title="Zip/Postal Code">
90
+ </div>
91
+ </div>
92
+ <div class="shipping-field select-shipping">
93
+ <label for="shipping:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
94
+ <div class="input-box">
95
+ <?php echo $this->getCountryHtmlSelect('shipping') ?>
96
+ </div>
97
+ </div>
98
+ </li>
99
+ <li class="fields">
100
+ <div class="shipping-field">
101
+ <label class="required" for="shipping:telephone">
102
+ <em>*</em>
103
+ Telephone
104
+ </label>
105
+ <div class="input-box">
106
+ <input id="shipping:telephone" class="input-text required-entry" type="text" title="Telephone" value="" name="shipping[telephone]">
107
+ </div>
108
+ </div>
109
+ <div class="shipping-field">
110
+ <label for="shipping:fax">Fax</label>
111
+ <div class="input-box">
112
+ <input id="shipping:fax" class="input-text " type="text" title="Fax" value="" name="shipping[fax]">
113
+ </div>
114
+ </div>
115
+ </li>
116
+
117
+ </fieldset>
118
+ </li>
119
+
120
+ </ul>
121
+
122
+ <script type="text/javascript">
123
+ //<![CDATA[
124
+ var shippingRegionUpdater = new RegionUpdater('shipping:country_id', 'shipping:region', 'shipping:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'shipping:postcode');
125
+ //]]>
126
+ </script>
127
+ </div>
app/design/frontend/rwd/default/template/masterpass/precheckout/shipping_method.phtml ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category design_default
22
+ * @package Mage
23
+ * @copyright Copyright (c) 2008 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ $totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
27
+ $subtotal = round($totals["subtotal"]->getValue()); //Subtotal value
28
+ ?>
29
+ <div id="shipping-method">
30
+ <?php if (!($_shippingRateGroups = $this->getShippingRates())): ?>
31
+ <div class="box-title">
32
+ <h3 class="mp-title"><?php echo $this->__("Shipping Method"); ?></h3>
33
+ </div>
34
+ <strong><?php echo $this->__('Sorry, no quotes are available for this order at this time.') ?></strong>
35
+ <?php else: ?>
36
+ <?php if (count($_shippingRateGroups) == '1' && Mage::getStoreConfig('onestepcheckout/general/hide_shipping_method')): ?>
37
+
38
+ <dl class="shipment-methods" style="display: none">
39
+ <div class="box">
40
+ <div class="box-title">
41
+ <h3 class="mp-title"><?php echo $this->__("Shipping Method"); ?></h3>
42
+ </div>
43
+ <div id="required-shipping" class="validation-advice" style="display: none;">Please select a shipping method.</div>
44
+ </div>
45
+ <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
46
+
47
+ <dd><?php echo $this->getCarrierName($code) ?></dd>
48
+ <?php foreach ($_rates as $_rate): ?>
49
+ <dt style="margin-bottom: 5px;">
50
+ <?php if ($_rate->getErrorMessage()): ?>
51
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
52
+ <?php else: ?>
53
+ <input name="shipping_method" type="radio" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>" checked="checked" onclick="updateShippingMethod('<?php echo $_rate->getCode() ?>')"/>
54
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><!--<b><?php echo $this->getCarrierName($code) ?>:</b>--> <?php echo $_rate->getMethodTitle() ?>
55
+ <strong>
56
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
57
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
58
+ <?php echo $_excl; ?>
59
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
60
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
61
+ <?php endif; ?>
62
+ </strong>
63
+ </label>
64
+ <?php endif ?>
65
+ </dt>
66
+
67
+ <?php endforeach; ?>
68
+
69
+ <?php endforeach; ?>
70
+ </dl>
71
+ <?php else: ?>
72
+ <dl class="shipment-methods">
73
+ <div class="box">
74
+ <div class="box-title">
75
+ <h3 class="mp-title"><?php echo $this->__("Shipping Method"); ?></h3>
76
+ </div>
77
+ <div id="required-shipping" class="validation-advice" style="display: none;">Please select a shipping method.</div>
78
+ </div>
79
+ <?php foreach ($_shippingRateGroups as $code => $_rates): ?>
80
+ <dd><?php echo $this->getCarrierName($code) ?></dd>
81
+ <?php foreach ($_rates as $_rate): ?>
82
+ <dt style="margin-bottom: 5px;">
83
+
84
+ <?php if ($_rate->getErrorMessage()): ?>
85
+ <ul class="messages"><li class="error-msg"><ul><li><?php echo $_rate->getErrorMessage() ?></li></ul></li></ul>
86
+ <?php else: ?>
87
+ <input name="shipping_method" type="radio" class="validate-one-required-by-name" value="<?php echo $_rate->getCode() ?>" id="s_method_<?php echo $_rate->getCode() ?>"<?php if ($_rate->getCode() === $this->getAddressShippingMethod()) echo ' checked="checked"' ?> onclick="updateShippingMethod('<?php echo $_rate->getCode() ?>')"/>
88
+ <label for="s_method_<?php echo $_rate->getCode() ?>"><!--<b><?php echo $this->getCarrierName($code) ?>:</b>--> <?php echo $_rate->getMethodTitle() ?>
89
+ <strong>
90
+ <?php $_excl = $this->getShippingPrice($_rate->getPrice(), $this->helper('tax')->displayShippingPriceIncludingTax()); ?>
91
+ <?php $_incl = $this->getShippingPrice($_rate->getPrice(), true); ?>
92
+
93
+ <?php echo $_excl; ?>
94
+ <?php if ($this->helper('tax')->displayShippingBothPrices() && $_incl != $_excl): ?>
95
+ (<?php echo $this->__('Incl. Tax'); ?> <?php echo $_incl; ?>)
96
+ <?php endif; ?>
97
+ </strong>
98
+ </label>
99
+ <?php endif ?>
100
+ </dt>
101
+ <?php endforeach; ?>
102
+ <?php endforeach; ?>
103
+ </dl>
104
+ <?php endif; ?>
105
+ <?php endif; ?>
106
+ </div>
app/design/frontend/rwd/default/template/masterpass/review/details.phtml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <?php
3
+
4
+ $taxHelper = Mage::helper("tax");
5
+ $displayBothPrices = $taxHelper->displayCartBothPrices();
6
+ if ($displayBothPrices) {
7
+ $colspan = 2;
8
+ $rowspan = 2;
9
+ } else {
10
+ $colspan = 1;
11
+ $rowspan = 1;
12
+ }
13
+ ?>
14
+ <div id="items-review" class="precheckout-cart">
15
+ <h3 class="mp-title"><?php echo $this->__('Order Review') ?></h3>
16
+ <table id="details-table" class="data-table">
17
+ <col />
18
+ <col width="1" />
19
+ <col width="1" />
20
+ <col width="1" />
21
+ <?php if ($displayBothPrices): ?>
22
+ <col width="1" />
23
+ <col width="1" />
24
+ <?php endif; ?>
25
+ <thead>
26
+ <tr>
27
+ <th rowspan="<?php echo $rowspan ?>"><?php echo $this->__("Product Name") ?></th>
28
+ <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__("Price"); ?></th>
29
+ <th rowspan="<?php echo $rowspan ?>" class="a-center"><?php echo $this->__("Qty"); ?></th>
30
+ <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__("Subtotal"); ?></th>
31
+ </tr>
32
+ <?php if ($displayBothPrices): ?>
33
+ <tr>
34
+ <th class="a-right"><?php echo $taxHelper->getIncExcTaxLabel(false); ?></th>
35
+ <th><?php echo $taxHelper->getIncExcTaxLabel(true); ?></th>
36
+ <th class="a-right"><?php echo $taxHelper->getIncExcTaxLabel(false); ?></th>
37
+ <th><?php echo $taxHelper->getIncExcTaxLabel(true); ?></th>
38
+ </tr>
39
+ <?php endif; ?>
40
+ </thead>
41
+ <?php echo $this->getChildHtml("totals"); ?>
42
+ <tbody>
43
+ <?php foreach ($this->getItems() as $item): ?>
44
+ <?php echo $this->getItemHtml($item); ?>
45
+ <?php endforeach ?>
46
+ </tbody>
47
+ </table>
48
+ </div>
49
+ <script type="text/javascript">decorateTable("details-table");</script>
app/etc/modules/MasterCard_Countriesmapping.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <MasterCard_Countriesmapping>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </MasterCard_Countriesmapping>
8
+ </modules>
9
+ </config>
app/etc/modules/MasterCard_Masterpass.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <MasterCard_Masterpass>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </MasterCard_Masterpass>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>247119f646a9429826c2d9ee9eda603e</name>
4
+ <version>1.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>The Masterpass extension by Mastercard enables you to easily embed Masterpass checkout capability into your online shopping site, helping to streamline the payment process for your customers without changing the way you currently process payments.</summary>
10
+ <description>Overview:&#xD;
11
+ &#xD;
12
+ One checkout button. Many wallets.&#xD;
13
+ &#xD;
14
+ Masterpass&#x2122; gives your customers a quick, easy, and secure way to check out and gives you access to a world of digital wallets through a single button on your checkout page.&#xD;
15
+ &#xD;
16
+ Masterpass is a global digital platform that enables &#x201C;in context&#x201D; shopping experiences by powering a network of digital wallets that can all be accessed through the global Masterpass acceptance Network - Powered by the Buy with Masterpass button.&#xD;
17
+ &#xD;
18
+ Each digital wallet stores the cardholder&#x2019;s payment and shipping information, including certain private label and loyalty cards, in one convenient and secure place&#xD;
19
+ &#xD;
20
+ How You May Benefit:&#xD;
21
+ &#xD;
22
+ &#xBB;&#xBB; One button, many trusted wallets: behind the Masterpass button on the checkout page are many bank-issued wallets, connecting merchants to more&#xD;
23
+ consumer-trusted wallets compared to any other digital payment solution.&#xD;
24
+ &#xD;
25
+ &#xBB;&#xBB; Conversion: because it requires less typing and remembers consumer preferences, Masterpass makes checkout fast and simple for consumers, reducing the risk of cart abandonment and increasing conversion and repeat visits.&#xD;
26
+ &#xD;
27
+ &#xBB;&#xBB; Convenience: Masterpass is about giving customers more options and control over the way they shop and pay. Browser and in-app purchasing and, in&#xD;
28
+ the future, the ability for customers to check out in-store with a mobile device will mean expanded opportunities for purchasing and brand interaction.&#xD;
29
+ &#xD;
30
+ &#xBB;&#xBB; Trust: Masterpass keeps cardholder payment information secure in one place. It&#x2019;s designed to help customers feel confident when accessing their&#xD;
31
+ payment information at every checkout, thereby promoting repeat usage.&#xD;
32
+ &#xD;
33
+ &#xBB;&#xBB; Loyalty: Masterpass helps facilitate a consumer&#x2019;s participation in a merchant loyalty program by storing and automatically passing a consumer&#x2019;s&#xD;
34
+ loyalty card during checkout. In addition, customer information that you capture today can also be available to you with Masterpass.&#xD;
35
+ &#xD;
36
+ &#xBB;&#xBB; Speed to market: Unlike many other wallet solutions, Masterpass simply passes the card details to the merchant, so the merchant can process&#xD;
37
+ the transaction using its normal card-processing flows. So integration with merchant systems can be completed efficiently and cost-effectively.</description>
38
+ <notes>Magento 1.9.x - Masterpass Plugin&#xD;
39
+ &#xD;
40
+ Release Version : 1.0.1</notes>
41
+ <authors><author><name>Kanchan</name><user>Wadhwani</user><email>kanchan.wadhwani@mastercard.com</email></author></authors>
42
+ <date>2017-01-23</date>
43
+ <time>09:18:21</time>
44
+ <contents><target name="magelocal"><dir name="MasterCard"><dir name="Masterpass"><dir><dir name="Block"><file name="Button.php" hash="1a429c49c9dedb966191ff4f4c50ddc3"/><dir name="Checkout"><file name="Checkout.php" hash="6f9a462fe5d0187fd4751cca6c85f89a"/><file name="Precheckout.php" hash="a828f750d689f4d9b5222f4a1a2c6456"/><dir name="Review"><file name="Details.php" hash="790ced01b5addf9b9b24d9218fb0c33e"/></dir><file name="Shipping.php" hash="e9ea05153a63d1b4f9da9cad5d1db1f9"/></dir><dir name="Customer"><file name="Link.php" hash="e8ee7a1e3601664f8e8b8cdf44e71ef9"/><file name="Wrapper.php" hash="09dba0fcdeadceb52a90ee5441b90123"/></dir><dir name="Onepage"><file name="Link.php" hash="039f7b1ae7df8662ef227bab0549b2fb"/><file name="Links.php" hash="f3c01a14888e34603e6a57687efbdc36"/><file name="Sidebar.php" hash="ad16486774e3126a3374f99a605e8429"/></dir></dir><dir name="Helper"><file name="Data.php" hash="ffee4036ca7cbec3b2b226a3ad1169c9"/></dir><dir name="Model"><file name="Masterpass.php" hash="ad8097a4563a9b0aa1f3eff5ac84900f"/><dir name="Mpservice"><file name="Connector.php" hash="52af484e28882d4d31ea7ef5184804c6"/><file name="Masterpassservice.php" hash="ec3c7ba3ce63eb418c239cd884335952"/></dir><file name="Observer.php" hash="24d4a8acbf1c5868c5ea79d2dc34650e"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Acceptancemarksize.php" hash="8ec292ead3a713efe536c6c2ef9aca82"/><file name="Acceptedcards.php" hash="ebd77872c91758bf3ad2fe7adaa4adb5"/><file name="Buttonsize.php" hash="50ad6bd94312823e47f2ca818a8f7dd1"/><file name="Environment.php" hash="753ab7965b14c8377bf63db72032db0d"/><file name="PaymentGateways.php" hash="640d3d44c51af6e403a4b5f9df66e5b1"/><file name="Transactionurl.php" hash="74ea3cbbcde2e52a0f8f4ef305967034"/><file name="Trueorfalse.php" hash="ee4dcfae8ea6a46ff8da42a6fda18e70"/><file name="Userflows.php" hash="3a14414ce3d7b3d07df37b95400f5e0e"/><file name="Xmlversion.php" hash="a2cfb8fa9ee269f2515f30e9abcb23ef"/></dir></dir></dir></dir><dir name="controllers"><file name="IndexController.php" hash="a55646fae6c2c08f16fb44eef0ffd103"/><file name="MasterpasspairingController.php" hash="2a1c7376fa63811a349ef0c3d828ef5a"/></dir><dir name="etc"><file name="adminhtml.xml" hash="1d2115f5d5bb06de392ea3cf515b5ebd"/><file name="config.xml" hash="2612f2923859b04273b179d42fa70ce6"/><file name="system.xml" hash="f45b29f9c16a0a8de469a9e91bc1f312"/></dir><dir name="sql"><dir name="mastercard_masterpass_setup"><file name="mysql4-install-0.1.0.php" hash="38c331167583ae1d9cfa5d00ecebac20"/></dir></dir></dir></dir><dir name="Countriesmapping"><dir><dir name="etc"><file name="config.xml" hash="47f98b31a84df747c320718cce08cd45"/></dir><dir name="sql"><dir name="mastercard_countriesmapping_setup"><file name="directory_country_region.csv" hash="16be4ef9316eabd5604f5e596f81d740"/><file name="mysql4-install-0.1.0.php" hash="ec6fa1e1d0571378172a7de159bad3f3"/></dir></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="rwd"><dir name="default"><dir name="template"><dir name="masterpass"><dir><dir name="ajax"><file name="details.phtml" hash="2a172dab4e2b54cf5517de3820157881"/><file name="shipping_method.phtml" hash="220889e5a2e98fa0d159a511de146070"/></dir><dir name="cart"><file name="button.phtml" hash="1e68368321f680a609c6bce487e32b9b"/><file name="buttonbottom.phtml" hash="843a406af660d725bc47bba49de4ee26"/></dir><dir name="customer"><file name="pair_after_register.phtml" hash="3ed1b0865b4fa234350084c826094a7f"/><file name="wrapper.phtml" hash="fe50189f2dd952d3a3c6c5c59993144e"/></dir><dir name="onepage"><file name="checkout.phtml" hash="b875c0ed2dd5670c4cd5978e82964a11"/><file name="login.phtml" hash="d0b0ef5e915b6a1221401d939f7a2829"/><file name="shipping_form.phtml" hash="e51ccb958b7bc1bec75a297ee4c5e1d5"/><file name="success.phtml" hash="2fa71f9d848eabf5a7b1ab44be3a9b10"/></dir><dir name="precheckout"><file name="pairWallet.phtml" hash="37d39d153e71eaf253ae4068ea5f09d1"/><file name="precheckout.phtml" hash="1d2ca4ac7be11a4710a897bac34096c4"/><file name="shipping.phtml" hash="f53c61d624e335e16b384fca300089ab"/><file name="shipping_method.phtml" hash="e538eeda277d26b0a9bc709ed5921a0f"/></dir><dir name="review"><file name="details.phtml" hash="9333c9fd334824ce39e016bae27a0a8e"/></dir></dir></dir></dir><dir name="layout"><dir name="masterpass"><file name="masterpass.xml" hash="783f48695cd31fbbefef50680aced811"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="MasterCard_Masterpass.xml" hash="9c512f65a88ebaf147b31584cdfe314b"/><file name="MasterCard_Countriesmapping.xml" hash="c8527b091c87d9e2b541182f226dd69f"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="rwd"><dir name="default"><dir name="css"><dir name="masterpass"><file name="masterpassclient.css" hash="097a750d4de75735ee995c8ed68f1fa4"/></dir></dir></dir></dir></dir></target></contents>
45
+ <compatible/>
46
+ <dependencies><required><php><min>5.5.0</min><max>5.6.14</max></php></required></dependencies>
47
+ </package>
skin/frontend/rwd/default/css/masterpass/masterpassclient.css ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /**********************************/
3
+ /******** MasterPass Shell ********/
4
+ /**********************************/
5
+ .masterpass-index-success .col-main {text-align: center;}
6
+ .masterpass-index-success .buttons-set {
7
+ margin: 10px 0;
8
+ text-align: center;
9
+ }
10
+
11
+ .masterpass-index-success .buttons-set button {
12
+ float: none !important;
13
+ }
14
+ #MasterPass_overlay {
15
+ background: #000;
16
+ bottom: 0;
17
+ display: block;
18
+ left: 0;
19
+ opacity: .7;
20
+ position: fixed;
21
+ right: 0;
22
+ top: 0;
23
+ z-index: 1000000;
24
+ filter: alpha(opacity = 70);
25
+ zoom:1;
26
+ }
27
+
28
+ #MasterPass_container {
29
+ position: fixed;
30
+ width: 100%;
31
+ height: 100%;
32
+ top: 0;
33
+ left: 0;
34
+ z-index: 1000001;
35
+ overflow: auto;
36
+ -webkit-overflow-scrolling: touch;
37
+ }
38
+
39
+ /* #MasterPass_frame {
40
+ background: transparent;
41
+ display: block;
42
+ height: 740px;
43
+ left: 50%;
44
+ margin: -370px 0 0 -350px;
45
+ position: fixed;
46
+ top: 50%;
47
+ width: 700px;
48
+ z-index: 10000001;
49
+ border: none;
50
+ } */
51
+
52
+ #MasterPass_frame {
53
+ background: transparent;
54
+ display: block;
55
+ height: 740px;
56
+ left: 50%;
57
+ margin: 0 0 0 -350px;
58
+ position: absolute;
59
+ top: 5%;
60
+ width: 700px;
61
+ z-index: 10000001;
62
+ border: none;
63
+ }
64
+
65
+
66
+ /* Responsive styling for smaller screens */
67
+ /****************************************************************/
68
+
69
+
70
+ /*@media screen and (max-width:699px), screen and (max-height:739px) {
71
+
72
+
73
+ #MasterPass_frame {
74
+ background: transparent;
75
+ display: block;
76
+ height: 620px;
77
+ left: 50%;
78
+ margin: -310px 0 0 -350px;
79
+ position: fixed;
80
+ top: 50%;
81
+ width: 700px;
82
+ z-index: 10000001;
83
+ border: none;
84
+ }
85
+
86
+ } */
87
+ @media screen and (max-height: 800px) {
88
+
89
+ #MasterPass_frame {
90
+ height: 739px;
91
+ }
92
+
93
+ }
94
+
95
+ @media screen and (max-height: 700px){
96
+ #MasterPass_frame {
97
+ margin-top: -30px;
98
+ }
99
+
100
+ }
101
+
102
+ @media screen and (max-width:699px), screen and (max-height:613px) {
103
+ .masterpass-prechk-image {width: 80%;}
104
+ .masterpass-form-right, .masterpass-form-left {width: 100% !important;}
105
+ .pre-data {margin-left: 0px;}
106
+ /*body.MasterPass_modal-open {
107
+ position: fixed;
108
+ }*/
109
+
110
+ /* frame */
111
+ /*#MasterPass_frame {
112
+ width: 100%;
113
+ min-width: 320px;
114
+ height: 100%;
115
+ top: 0;
116
+ left: 0;
117
+ margin: 0;
118
+ }*/
119
+
120
+ #MasterPass_frame {
121
+ width: 100%;
122
+ min-width: 320px;
123
+ height: 100%;
124
+ top: 0;
125
+ left: 0;
126
+ margin: 0;
127
+ position: fixed;
128
+ }
129
+ }
130
+
131
+ body.MasterPass_modal-open {
132
+ position: fixed;
133
+ overflow: hidden;
134
+ top:0;
135
+ bottom:0;
136
+ left:0;
137
+ right:0;
138
+ margin:0;
139
+ }
140
+ .prechk-line {width: 75px;}
141
+ .acceptance-mark-image {margin: auto;}
142
+ .pre-data {margin-top: 10px;}
143
+ .precheckout-cart {width: 100%; float:left;}
144
+ .preCheckou-main {width: 100%; float:left; padding: 0px 40px 10px 40px;}
145
+ .mp-table {margin-left: 48px;}
146
+ .mp-table td {padding: 6px;}
147
+ .mp-table td label {font-weight: 600;}
148
+ .masterpass-form-right, .masterpass-form-left {width: 49%; float:left;}
149
+ .shipping-field
150
+ {
151
+ clear: none;
152
+ float: left;
153
+ width: 40%;
154
+ margin-right: 18px;
155
+ margin-bottom: 10px;
156
+ }
157
+ .shipping-wide {
158
+ width: 100%;
159
+ margin-bottom: 10px;
160
+ float: left;
161
+ }
162
+ .select-shipping {margin-bottom: 15px;}
163
+ .shipping-address {width: 84% !important;}
164
+ .expresscheckout-button {background: none !important;}
165
+ .masterpass-logo,.partner-logo {float:left; margin-right: 10px; margin-bottom: 10px;}
166
+ .masterpass-logo-a,.partner-logo-a {display: inline-block; margin-right: 10px; margin-bottom: 10px;}
167
+ .partner-logo,.partner-logo-a {border-left: 2px solid; padding-left: 10px;}
168
+ .mp-title {color: #3399cc;}
169
+ .mp-complete {width: 270px; float:left; margin-right: 10px;}
170
+ .payment-info {float: left;margin-right: 10px;width: 300px;}
171
+ .mp-checkout-button {margin-top: 15px;}
172
+ .mp-shipping-input {width: 127px !important; margin-right: 10px;}
173
+ .mp-shipping-input-wide{width: 264px !important;}
174
+
175
+ .masterpass-checkout-block {
176
+ float: right;
177
+ padding-top: 10px;
178
+ }