zapper_scantocheckout - Version 1.0.0

Version Notes

Initial Release

Download this release

Release Info

Developer Branden
Extension zapper_scantocheckout
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

app/code/community/Zapper/ScanToCheckout/Block/Onepage.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Zapper_ScanToCheckout_Block_Onepage extends Mage_Checkout_Block_Onepage
4
+ {
5
+ public function getSteps()
6
+ {
7
+ $steps = array();
8
+ $enabled = intval(Mage::getStoreConfig('payment/scantocheckout/active', Mage::app()->getStore()));
9
+ if($enabled == '1' )
10
+ {
11
+ $stepCodes = array('scantocheckout', 'login', 'billing', 'shipping_method', 'payment', 'review');
12
+ }
13
+ else
14
+ {
15
+ $stepCodes = array('login', 'billing', 'shipping', 'shipping_method', 'payment', 'review');
16
+ }
17
+
18
+ if ($this->isCustomerLoggedIn()) {
19
+ $stepCodes = array_diff($stepCodes, array('login'));
20
+ }
21
+
22
+ foreach ($stepCodes as $step) {
23
+ $steps[$step] = $this->getCheckout()->getStepData($step);
24
+ }
25
+
26
+ return $steps;
27
+ }
28
+ public function getActiveStep()
29
+ {
30
+ $enabled = intval(Mage::getStoreConfig('payment/scantocheckout/active', Mage::app()->getStore()));
31
+ if($enabled == '1' )
32
+ {
33
+ return 'scantocheckout';
34
+ }
35
+ else {
36
+ return $this->isCustomerLoggedIn() ? 'billing' : 'login';
37
+ }
38
+
39
+ }
40
+ }
app/code/community/Zapper/ScanToCheckout/Block/Onepage/Scantocheckout.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Zapper_ScanToCheckout_Block_Onepage_Scantocheckout Extends Mage_Checkout_Block_Onepage_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $enabled = intval(Mage::getStoreConfig('payment/scantocheckout/active', Mage::app()->getStore()));
8
+ if($enabled == '1' )
9
+ {
10
+ $this->getCheckout()->setStepData('scantocheckout', array(
11
+ 'label' => Mage::helper('checkout')->__('Scan-to-Checkout'),
12
+ 'is_show' => $this->isShow()
13
+ ));
14
+ if ($this->isCustomerLoggedIn()) {
15
+ $this->getCheckout()->setStepData('scantocheckout', 'allow', true);
16
+ $this->getCheckout()->setStepData('billing', 'allow', false);
17
+ }
18
+ if (!$this->isCustomerLoggedIn()) {
19
+ $this->getCheckout()->setStepData('scantocheckout', 'allow', true);
20
+ $this->getCheckout()->setStepData('login', 'allow', false);
21
+ }
22
+ }
23
+ else
24
+ {
25
+ $this->getCheckout()->setStepData('billing', array(
26
+ 'label' => Mage::helper('checkout')->__('Billing Information'),
27
+ 'is_show' => $this->isShow()
28
+ ));
29
+ if (!$this->isCustomerLoggedIn()) {
30
+ $this->getCheckout()->setStepData('login', 'allow', true);
31
+ }
32
+
33
+ }
34
+ parent::_construct();
35
+ }
36
+ }
app/code/community/Zapper/ScanToCheckout/Block/checkout/ScanToCheckout.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Zapper_ScanToCheckout_Block_Onepage_ScanToCheckout extends Mage_Checkout_Block_Onepage_Abstract
5
+ {
6
+
7
+ protected function _construct()
8
+ {
9
+ $enabled = intval(Mage::getStoreConfig('payment/scantocheckout/active', Mage::app()->getStore()));
10
+ if($enabled == '1' )
11
+ {
12
+ $this->getCheckout()->setStepData('scantocheckout', array(
13
+ 'label' => Mage::helper('checkout')->__('Scan-to-Checkout'),
14
+ 'is_show' => $this->isShow()
15
+ ));
16
+ $this->getCheckout()->setStepData('scantocheckout', 'allow', true);
17
+ }
18
+ else
19
+ {
20
+ $this->getCheckout()->setStepData('billing', array(
21
+ 'label' => Mage::helper('checkout')->__('Billing '),
22
+ 'is_show' => $this->isShow()
23
+ ));
24
+
25
+ if ($this->isCustomerLoggedIn()) {
26
+ $this->getCheckout()->setStepData('billing', 'allow', true);
27
+ }
28
+ }
29
+ parent::_construct();
30
+ }
31
+
32
+
33
+
34
+
35
+ }
app/code/community/Zapper/ScanToCheckout/Helper/Data.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Zapper_ScanToCheckout_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+ function checkout()
5
+ {
6
+ $selfRegistrationAllowed = true;
7
+ $demoMode = false;
8
+
9
+ $baseUrl = Mage::getBaseUrl() . 'scantologin';
10
+
11
+ $api_url = Mage::getStoreConfig('zapper/config/location', Mage::app()->getStore());
12
+ $api_url = $api_url ? $api_url : 'https://zapapi.zapzap.mobi/zappertech';
13
+ //$api_url='https://zzqa.zapzapadmin.com/staging-zappertech';
14
+
15
+ if (Mage::getStoreConfig('payment/scantocheckout/sandbox') == "1")
16
+ {
17
+ $merchantId = '2127';
18
+ $siteId = '2490';
19
+ }
20
+ else {
21
+ $merchantId = Mage::getStoreConfig('zapper/config/merchant_id', Mage::app()->getStore());
22
+ $siteId = Mage::getStoreConfig('zapper/scan_to_login/site_id', Mage::app()->getStore());
23
+ }
24
+ $qrSize = Mage::getStoreConfig('zapper/config/qrsize', Mage::app()->getStore());
25
+ $timeout = Mage::getStoreConfig('zapper/config/timeout', Mage::app()->getStore());
26
+
27
+ $enable_scan = intval(Mage::getStoreConfig('payment/scantocheckout/active', Mage::app()->getStore()));
28
+ $selector = Mage::getStoreConfig('payment/scantocheckout/selector', Mage::app()->getStore());
29
+ $selector = $selector ? $selector : 'scan_to_checkout';
30
+
31
+ $additionalParameters = Mage::getStoreConfig('payment/scantocheckout/additionalparameters', Mage::app()->getStore());
32
+
33
+ $session = Mage::getSingleton('checkout/session');
34
+ $quote_id = $session->getQuoteId();
35
+ $quote = Mage::getModel('sales/quote')->load($quote_id);
36
+
37
+ if($enable_scan == 1) { ?>
38
+ <script>
39
+ jQuery(function($){
40
+
41
+ var paymentSelector = $('<div id="scantologinpurchase-container"><div id="logo-container" class="zapperLogo"><div class="scantologin-qrcode-placeholder"></div></div><div id="scantocheckout-end-container"><span id="scantocheckout-available-for"></span><a href="http://www.zapper.com/" target="_blank" id="scantologin-zapper-link">www.zapper.com</a></div></div>');
42
+
43
+ var qrPaymentCode = new ZapperTechCheckout.QrCode({
44
+ merchantId: <?php echo intval($merchantId) ?>,
45
+ siteId: <?php echo intval($siteId) ?>,
46
+ qrSize: <?php echo $qrSize ? intval($qrSize) : 4 ?>,
47
+ timeout: <?php echo $timeout ? intval($timeout) : 5000 ?>,
48
+ selector: paymentSelector,
49
+ baseUrl: "<?php echo $api_url?>",
50
+ additionalParameters: ['<?php echo strip_tags(Mage::helper('core')->currency(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal(),true,false)) ?>']
51
+ });
52
+
53
+ //$('#').append('<p>Scan the purchase code for amount '+amount+' to begin</p>');
54
+ $('#<?php print $selector ?>').html(paymentSelector);
55
+
56
+ var payment = function(data) {
57
+
58
+ // set up some placeholders for our incoming data
59
+ var existingAddresses = new Array();
60
+ var shippingLineOne, shippingLineTwo, shippingCity, shippingPostalCode, shippingCountry;
61
+ var billingLineOne, billingLineTwo, billingCity, billingPostalCode, billingCountry,cellNumber;
62
+
63
+ // iterate through the data and grab all the purchase specific data such as card info, addresses etc.
64
+ // you can print out data.Answers to see everything coming through
65
+
66
+
67
+ $(data.Answers).each(function(i, answer) {
68
+ if (answer.QuestionId == 12) {
69
+ if ($.inArray(answer.QuestionId, existingAddresses) < 0) {
70
+ shippingLineOne = answer.AnswerValue;
71
+ existingAddresses.push(answer.QuestionId);
72
+ } else {
73
+ billingLineOne = answer.AnswerValue;
74
+ }
75
+ }
76
+ if (answer.QuestionId == 13) {
77
+ if ($.inArray(answer.QuestionId, existingAddresses) < 0) {
78
+ shippingLineTwo = answer.AnswerValue;
79
+ existingAddresses.push(answer.QuestionId);
80
+ } else {
81
+ billingLineTwo = answer.AnswerValue;
82
+ }
83
+ }
84
+ if (answer.QuestionId == 14) {
85
+ if ($.inArray(answer.QuestionId, existingAddresses) < 0) {
86
+ shippingCity = answer.AnswerValue;
87
+ existingAddresses.push(answer.QuestionId);
88
+ } else {
89
+ billingCity = answer.AnswerValue;
90
+ }
91
+ }
92
+ if (answer.QuestionId == 16) {
93
+ if ($.inArray(answer.QuestionId, existingAddresses) < 0) {
94
+ shippingPostalCode = answer.AnswerValue;
95
+ existingAddresses.push(answer.QuestionId);
96
+ } else {
97
+ billingPostalCode = answer.AnswerValue;
98
+ }
99
+ }
100
+ if (answer.QuestionId == 17) {
101
+ if ($.inArray(answer.QuestionId, existingAddresses) < 0) {
102
+ shippingCountry = answer.AnswerValue;
103
+ existingAddresses.push(answer.QuestionId);
104
+ } else {
105
+ billingCountry = answer.AnswerValue;
106
+ }
107
+ }
108
+
109
+ if (answer.QuestionId == 2) {
110
+ firstname = answer.AnswerValue;
111
+ }
112
+ if (answer.QuestionId == 3) {
113
+ lastname = answer.AnswerValue;
114
+ }
115
+ if (answer.QuestionId == 1) {
116
+ email = answer.AnswerValue;
117
+ }
118
+ if (answer.QuestionId == 8) {
119
+ cellNumber = answer.AnswerValue;
120
+ }
121
+
122
+ });
123
+
124
+ var MyCardType = new Array();
125
+ MyCardType['American Express'] = "AE";
126
+ MyCardType['Visa'] = "VI";
127
+ MyCardType['MasterCard'] = "MC";
128
+ MyCardType['Discover'] = "DI";
129
+
130
+ var cardNumber = qrPaymentCode.getAnswer(data.Answers, 19)
131
+ , cardType = MyCardType[qrPaymentCode.getAnswer(data.Answers, 18)]
132
+ , cardName = qrPaymentCode.getAnswer(data.Answers, 20)
133
+ , cardCVC = qrPaymentCode.getAnswer(data.Answers, 26)
134
+ , cardExpiryMonth = qrPaymentCode.getAnswer(data.Answers, 24)
135
+ , cardExpiryYear = qrPaymentCode.getAnswer(data.Answers, 25);
136
+
137
+ cardExpiryMonth = cardExpiryMonth ? cardExpiryMonth : 1;
138
+ cardExpiryYear = cardExpiryYear ? cardExpiryYear : 2015;
139
+
140
+ $.post('<?php print Mage::getBaseUrl(); ?>scantocheckout/index/processOrder',
141
+ {
142
+ street1 : billingLineOne,
143
+ street2 : billingLineTwo,
144
+ city : billingCity,
145
+ postalcode : billingPostalCode,
146
+ country : billingCountry,
147
+ celnum : cellNumber,
148
+ ccnum : cardNumber,
149
+ ctype : MyCardType[qrPaymentCode.getAnswer(data.Answers, 18)],
150
+ ccvc : cardCVC,
151
+ cexpy : cardExpiryYear,
152
+ cexpm : cardExpiryMonth,
153
+ firstname : firstname,
154
+ lastname : lastname,
155
+ email : email
156
+ }, function(data,status)
157
+ {
158
+ if (data == 'success')
159
+ {
160
+ window.location = String('<?php echo Mage::getBaseUrl() ?>checkout/onepage/success');
161
+ }
162
+ else if (data == 'failed')
163
+ {
164
+ window.location = String('<?php echo Mage::getBaseUrl() ?>checkout/onepage/failure');
165
+ }
166
+ });
167
+ }
168
+
169
+ // pass the payment function as a callback to the payment request
170
+ qrPaymentCode.paymentRequest(payment);
171
+ // start the purchase polling for a response
172
+ qrPaymentCode.start();
173
+ });
174
+ </script>
175
+ <?php
176
+ }
177
+ }
178
+
179
+ function json_encoded($data)
180
+ {
181
+ @header('Cache-Control: no-cache, must-revalidate');
182
+ @header('Expires: Mon, 26 July 1997 05:00:00 GMT');
183
+ @header('Content-type: application/json');
184
+ echo json_encode($data);
185
+ }
186
+
187
+ function render($type = 1)
188
+ {
189
+ if ($type == 1)
190
+ {
191
+ $this->checkout();
192
+ }
193
+ }
194
+ }
app/code/community/Zapper/ScanToCheckout/Model/Create.php ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Zapper_ScanToCheckout_Model_Create extends Mage_Core_Model_Abstract
3
+ {
4
+ public function updateQuoteAddress($firstName,$lastName,$email,$street1,$street2,$city,$postcode,$country,$celNum )
5
+ {
6
+ $session = Mage::getSingleton('checkout/session');
7
+ if (Mage::getSingleton('customer/session')->isLoggedIn() )
8
+ {
9
+ $customer = mage::getModel('customer/customer')->load(Mage::getSingleton('customer/session')->getCustomer()->getId());
10
+ $passwd = '';
11
+ }
12
+ else
13
+ {
14
+ if ($email == 'undefined')
15
+ {
16
+
17
+ $customersearch = mage::getModel('customer/customer')->getCollection()
18
+ ->addAttributeToSelect('*')
19
+ ->addAttributeToFilter('firstname', array('like' => "$firstName"))
20
+ ->addAttributeToFilter('lastname', array('like' => "$lastName"));
21
+ if (count($customersearch)==1)
22
+ {
23
+ foreach($customersearch as $result)
24
+ {
25
+ $customer=mage::getModel('customer/customer')->load($result->getId());
26
+ }
27
+ $email = $customer->getEmail();
28
+ }
29
+ else {
30
+ //return error unable to verify email. please update zapper with a valid email address and try again????
31
+ echo 'Email verification';
32
+ die;
33
+ }
34
+ }
35
+ else
36
+ {
37
+
38
+ $customersearch = mage::getModel('customer/customer')->getCollection()
39
+ ->addAttributeToSelect('*')
40
+ ->addAttributeToFilter('email', array('like' => "$email"));
41
+ if (count($customersearch)==1)
42
+ {
43
+ $customer = Mage::getModel('customer/customer');
44
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
45
+ $customer->loadByEmail($email);
46
+ if ($customer->getId())
47
+ Mage::getSingleton('customer/session')->loginById($customer->getId());
48
+ }
49
+ else {
50
+
51
+ $passwd = $this->randomPassword();
52
+
53
+ //create Customer
54
+
55
+ $customer = Mage::getModel('customer/customer');
56
+ $password = $passwd;
57
+ $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
58
+ $customer->loadByEmail($email);
59
+ //Zend_Debug::dump($customer->debug()); exit;
60
+ if(!$customer->getId()) {
61
+ $customer->setEmail($email);
62
+ $customer->setFirstname($firstName);
63
+ $customer->setLastname($lastName);
64
+ $customer->setPassword($password);
65
+ }
66
+
67
+ try {
68
+ $customer->save();
69
+ $customer->setConfirmation(null);
70
+ $customer->save();
71
+ //Make a "login" of new customer
72
+ Mage::getSingleton('customer/session')->loginById($customer->getId());
73
+ }
74
+ catch (Exception $ex) {
75
+ //Zend_Debug::dump($ex->getMessage());
76
+ }
77
+
78
+ $_custom_address = array (
79
+ 'firstname' =>$firstName,
80
+ 'lastname' =>$lastName,
81
+ 'company' => '',
82
+ 'email' => $email,
83
+ 'street' => array(
84
+ '0' => $street1,
85
+ '1' => $street2
86
+ ),
87
+ 'city' => $city,
88
+ 'region_id' => '',
89
+ 'region' => '',
90
+ 'postcode' => $postcode,
91
+ 'country_id' => $country,
92
+ 'telephone' => $celNum,
93
+
94
+ );
95
+ $customAddress = Mage::getModel('customer/address');
96
+ //$customAddress = new Mage_Customer_Model_Address();
97
+ $customAddress->setData($_custom_address)
98
+ ->setCustomerId($customer->getId())
99
+ ->setIsDefaultBilling('1')
100
+ ->setIsDefaultShipping('1')
101
+ ->setSaveInAddressBook('1');
102
+ try {
103
+ $customAddress->save();
104
+ }
105
+ catch (Exception $ex) {
106
+ mage::log($ex->getMessage());
107
+ }
108
+ }
109
+ }
110
+
111
+ }
112
+
113
+ $quote_id = $session->getQuoteId();
114
+ $quote = Mage::getModel('sales/quote')->load($quote_id);
115
+ $billingAddress = array(
116
+ 'firstname' =>$firstName,
117
+ 'lastname' =>$lastName,
118
+ 'company' => '',
119
+ 'email' => $email,
120
+ 'street' => $street1.",".$street2,
121
+ 'city' => $city,
122
+ 'region_id' => '',
123
+ 'region' => '',
124
+ 'postcode' => $postcode,
125
+ 'country_id' => $country,
126
+ 'telephone' => $celNum,
127
+ 'fax' => '',
128
+ 'customer_password' => $passwd,
129
+ 'confirm_password' => $passwd,
130
+ 'save_in_address_book' => '0',
131
+ 'use_for_shipping' => '1',
132
+ );
133
+
134
+ $quote->getBillingAddress()
135
+ ->addData($billingAddress);
136
+
137
+ $quote->getShippingAddress()
138
+ ->addData($billingAddress)
139
+ ->setShippingMethod('freeshipping_freeshipping')
140
+ ->setPaymentMethod('ccsave') //set payment gateway module here
141
+ ->setCollectShippingRates(true)
142
+ ->collectTotals();
143
+ $quote->save();
144
+ }
145
+
146
+ public function updateQuotePayment($firstName,$lastName,$crCardNumber,$cardType,$cardExpiryYear,$cardExpiryMonth,$cardCVC)
147
+ {
148
+ $session = Mage::getSingleton('checkout/session');
149
+ $quote_id = $session->getQuoteId();
150
+ $quote = Mage::getModel('sales/quote')->load($quote_id);
151
+ $quote->getPayment()->importData(array(
152
+ 'method' => 'ccsave',
153
+ 'cc_owner' => $firstName.' '.$lastName,
154
+ 'cc_number' => $crCardNumber,
155
+ 'cc_last4' =>substr($crCardNumber,-4),
156
+ 'cc_type' => $cardType,
157
+ 'cc_exp_year' => $cardExpiryYear,
158
+ 'cc_exp_month' =>$cardExpiryMonth,
159
+ 'cc_cid' => $cardCVC));
160
+ $quote->save();
161
+ }
162
+
163
+ public function createOrder()
164
+ {
165
+ try
166
+ {
167
+ $session = Mage::getSingleton('checkout/session');
168
+
169
+ $quote_id = $session->getQuoteId();
170
+ $quote = Mage::getModel('sales/quote')->load($quote_id);
171
+
172
+ $itemQtys = array();
173
+ $items = $quote->getAllItems();
174
+ $convertQuoteObj = Mage::getSingleton('sales/convert_quote');
175
+ $order = $convertQuoteObj->addressToOrder($quote->getShippingAddress());
176
+ $order->setCustomerId(Mage::getSingleton('customer/session')->getCustomer()->getId());
177
+ $orderPaymentObj = $convertQuoteObj->paymentToOrderPayment($quote->getPayment());
178
+ $order->setBillingAddress($convertQuoteObj->addressToOrderAddress($quote->getBillingAddress()));
179
+ $order->setShippingAddress($convertQuoteObj->addressToOrderAddress($quote->getShippingAddress()))
180
+ ->setShipping_method('ccsave');
181
+ $order->setPayment($convertQuoteObj->paymentToOrderPayment($quote->getPayment()));
182
+
183
+ foreach ($items as $item) {
184
+ $orderItem = $convertQuoteObj->itemToOrderItem($item);
185
+ if ($item->getParentItem()) {
186
+ $orderItem->setParentItem($order->getItemByQuoteItemId($item->getParentItem()->getId()));
187
+ }
188
+ $order->addItem($orderItem);
189
+ }
190
+
191
+ $totalDue = $order->getTotalDue();
192
+
193
+
194
+ $order->getPayment()
195
+ ->setBaseAmountPaid($totalDue)
196
+ ->setAmountPaid($totalDue)
197
+ ->setAmount($totalDue);
198
+ $order->save();
199
+
200
+ $order->sendNewOrderEmail();
201
+ $session->setLastSuccessQuoteId($quote_id);
202
+ $session->setLastQuoteId($quote_id);
203
+ $session->setQuoteId($quote_id);
204
+ $session->setLastSuccessQuoteId($quote_id);
205
+
206
+ $invoice = $order->prepareInvoice();
207
+ $invoice->register()->pay();
208
+ $invoice->getOrder()->setIsInProcess(true);
209
+ $order->addRelatedObject($invoice);
210
+ $order->addStatusToHistory(Mage_Sales_Model_Order::STATE_PROCESSING,'Payment Success'."<br /> Transaction Date :".date('Y-m-d hh:mm:ss').
211
+ "<br /> Transaction Amount :".$quote->getGrandTotal());
212
+
213
+ $transaction = Mage::getModel('sales/order_payment_transaction');
214
+ $transaction->setOrderPaymentObject($order->getPayment())
215
+ ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT)
216
+ ->setTxnId('1')
217
+ ->setLast_trans_id('Payment trans ID')
218
+ ->save();
219
+
220
+ Mage::getModel('core/resource_transaction')
221
+ ->addObject($invoice)
222
+ ->addObject($order)
223
+ ->save();
224
+
225
+ $transaction = Mage::getModel('sales/order_payment');
226
+
227
+ $session->setLastOrderId($order->getId())
228
+ ->setRedirectUrl('')
229
+ ->setLastRealOrderId($quote->getReservedOrderId);
230
+ $session->getQuote()->setIsActive(false)->save();
231
+ return true;
232
+ }
233
+ catch (Exception $e)
234
+ {
235
+ mage::log($e);
236
+ return false;
237
+ }
238
+
239
+ }
240
+
241
+ function randomPassword() {
242
+ $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789";
243
+ for ($i = 0; $i < 8; $i++) {
244
+ $n = rand(0, count($alphabet)-1);
245
+ $pass[$i] = $alphabet[$n];
246
+ }
247
+ return $pass;
248
+ }
249
+ }
app/code/community/Zapper/ScanToCheckout/Model/Type/Onepage.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Zapper_ScanToCheckout_Model_Checkout_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
3
+ {
4
+ public function saveScanToCheckout($data){
5
+ $this->getCheckout()
6
+ ->setStepData('scantocheckout', 'allow', true)
7
+ ->setStepData('scantocheckout', 'complete', true)
8
+ ->setStepData('login', 'allow', true);
9
+ return array();
10
+ }
11
+ }
app/code/community/Zapper/ScanToCheckout/controllers/IndexController.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Zapper_ScanToCheckout_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function processOrderAction()
5
+ {
6
+ $street1 = $_POST['street1'];
7
+ if (isset($_POST['street2']))
8
+ {
9
+ $street2 = $_POST['street2'];
10
+ }
11
+ else {
12
+ $street2 = null;
13
+ }
14
+ $country = $_POST['country'];
15
+ $city = $_POST['city'];
16
+ $postcode = $_POST['postalcode'];
17
+ if (isset($_POST['celnum']))
18
+ {
19
+ $celNum = $_POST['celnum'];
20
+ }
21
+ else
22
+ {
23
+ $celNum = '000 000 0000';
24
+ }
25
+
26
+ $crCardNumber = $_POST['ccnum'];
27
+ $cardType = $_POST['ctype'];
28
+ $cardCVC = $_POST['ccvc'];
29
+ $cardExpiryYear = $_POST['cexpy'];
30
+ $cardExpiryMonth = $_POST['cexpm'];
31
+ $firstName = $_POST['firstname'];
32
+ $lastName = $_POST['lastname'];
33
+ $email = $_POST['email'];
34
+
35
+ mage::getModel('scantocheckout/create')->updateQuoteAddress($firstName,$lastName,$email,$street1,$street2,$city,$postcode,$country,$celNum);
36
+
37
+ //payment gateway integration called here,
38
+ //default set to use savecc
39
+ mage::getModel('scantocheckout/create')->updateQuotePayment($firstName,$lastName,$crCardNumber,$cardType,$cardExpiryYear,$cardExpiryMonth,$cardCVC);
40
+
41
+
42
+ if (mage::getModel('scantocheckout/create')->createOrder())
43
+ {
44
+ $data='success';
45
+ }
46
+ else {
47
+ $data='failure';
48
+ }
49
+ echo $data;
50
+ }
51
+ }
52
+
app/code/community/Zapper/ScanToCheckout/controllers/OnepageController.php ADDED
@@ -0,0 +1,313 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once 'Mage/Checkout/controllers/OnepageController.php';
4
+
5
+ class Zapper_ScanToCheckout_OnepageController extends Mage_Checkout_OnepageController
6
+ {
7
+
8
+
9
+ public function indexAction()
10
+ {
11
+ //show zapper
12
+ if (!Mage::helper('checkout')->canOnepageCheckout()) {
13
+ Mage::getSingleton('checkout/session')->addError($this->__('The onepage checkout is disabled.'));
14
+ $this->_redirect('checkout/cart');
15
+ return;
16
+ }
17
+ $quote = $this->getOnepage()->getQuote();
18
+ if (!$quote->hasItems() || $quote->getHasError()) {
19
+ $this->_redirect('checkout/cart');
20
+ return;
21
+ }
22
+
23
+ if (!$quote->validateMinimumAmount()) {
24
+ $error = Mage::getStoreConfig('sales/minimum_order/error_message') ?
25
+ Mage::getStoreConfig('sales/minimum_order/error_message') :
26
+ Mage::helper('checkout')->__('Subtotal must exceed minimum order amount');
27
+
28
+ Mage::getSingleton('checkout/session')->addError($error);
29
+ $this->_redirect('checkout/cart');
30
+ return;
31
+ }
32
+
33
+ Mage::getSingleton('checkout/session')->setCartWasUpdated(false);
34
+ Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::getUrl('*/*/*', array('_secure' => true)));
35
+ $this->getOnepage()->initCheckout();
36
+ $this->loadLayout();
37
+ $this->_initLayoutMessages('customer/session');
38
+ $this->getLayout()->getBlock('head')->setTitle($this->__('Checkout'));
39
+ $this->renderLayout();
40
+
41
+ }
42
+
43
+
44
+ protected function _getPaymentMethodsHtml()
45
+ {
46
+ $layout = $this->getLayout();
47
+ $update = $layout->getUpdate();
48
+ $update->load('checkout_onepage_paymentmethod');
49
+ $layout->generateXml();
50
+ $layout->generateBlocks();
51
+ $output = $layout->getOutput();
52
+ return $output;
53
+ }
54
+
55
+ public function saveScanToLoginAction()
56
+ {
57
+ if ($this->_expireAjax()) {
58
+ return;
59
+ }
60
+
61
+ $result['goto_section'] = 'billing';
62
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
63
+ }
64
+
65
+ public function saveScanToCheckoutAction()
66
+ {
67
+ if ($this->_expireAjax()) {
68
+ return;
69
+ }
70
+ if (Mage::getSingleton('customer/session')->isLoggedIn() )
71
+ {
72
+ $result['goto_section'] = 'billing';
73
+ }
74
+ else {
75
+ $result['goto_section'] = 'login';
76
+ }
77
+
78
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
79
+ }
80
+
81
+
82
+ public function saveBillingAction()
83
+ {
84
+ if ($this->_expireAjax()) {
85
+ return;
86
+ }
87
+ if ($this->getRequest()->isPost()) {
88
+ $data = $this->getRequest()->getPost('billing', array());
89
+ $customerAddressId = $this->getRequest()->getPost('billing_address_id', false);
90
+
91
+ if (isset($data['email'])) {
92
+ $data['email'] = trim($data['email']);
93
+ }
94
+
95
+ $result = $this->getOnepage()->saveShipping($data, $customerAddressId);
96
+ $result = $this->getOnepage()->saveBilling($data, $customerAddressId);
97
+ if (!isset($result['error'])) {
98
+ $methods = Mage::getSingleton('shipping/config')->getActiveCarriers();
99
+ if ($this->getOnepage()->getQuote()->isVirtual()) {
100
+ if (count($methods) > '2' ){
101
+ //$method = freeshipping_freeshipping;
102
+ //$result = $this->getOnepage()->saveShippingMethod($method);
103
+ //Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()->setShippingMethod($method)->save();
104
+ }
105
+ if (!isset($result['error'])) {
106
+ $result['goto_section'] = 'payment';
107
+ $result['update_section'] = array(
108
+ 'name' => 'payment-method',
109
+ 'html' => $this->_getPaymentMethodsHtml()
110
+ );
111
+ }
112
+
113
+ /** $result['goto_section'] = 'payment';
114
+ $result['update_section'] = array(
115
+ 'name' => 'payment-method',
116
+ 'html' => $this->_getPaymentMethodsHtml()
117
+ );
118
+ */
119
+ }
120
+ else {
121
+
122
+ $method = 'freeshipping_freeshipping';
123
+ $result = $this->getOnepage()->saveShippingMethod($method);
124
+ Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()->setShippingMethod($method)->save();
125
+
126
+ if (!isset($result['error'])) {
127
+ $result['goto_section'] = 'payment';
128
+ $result['update_section'] = array(
129
+ 'name' => 'payment-method',
130
+ 'html' => $this->_getPaymentMethodsHtml()
131
+ );
132
+
133
+
134
+ }
135
+ }
136
+
137
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
138
+ }
139
+ }
140
+ }
141
+
142
+ public function updateCheckoutAction()
143
+ {
144
+ if ($this->_expireAjax() || !$this->getRequest()->isPost()) {
145
+ return;
146
+ }
147
+
148
+
149
+
150
+ /*********** DISCOUNT CODES **********/
151
+
152
+ $quote = $this->getOnepage()->getQuote();
153
+ $couponData = $this->getRequest()->getPost('coupon', array());
154
+ $processCoupon = $this->getRequest()->getPost('process_coupon', false);
155
+
156
+ $couponChanged = false;
157
+ if ($couponData && $processCoupon) {
158
+ if (!empty($couponData['remove'])) {
159
+ $couponData['code'] = '';
160
+
161
+ }
162
+ $oldCouponCode = $quote->getCouponCode();
163
+ if ($oldCouponCode != $couponData['code']) {
164
+ try {
165
+ $quote->setCouponCode(
166
+ strlen($couponData['code']) ? $couponData['code'] : ''
167
+ );
168
+ $this->getRequest()->setPost('payment-method', true);
169
+ $this->getRequest()->setPost('shipping-method', true);
170
+ if ($couponData['code']) {
171
+ $couponChanged = true;
172
+ } else {
173
+ $couponChanged = true;
174
+ Mage::getSingleton('checkout/session')->addSuccess(Mage::helper('onepagecheckout')->__('Coupon code was canceled.'));
175
+ }
176
+ } catch (Mage_Core_Exception $e) {
177
+ $couponChanged = true;
178
+ Mage::getSingleton('checkout/session')->addError($e->getMessage());
179
+ } catch (Exception $e) {
180
+ $couponChanged = true;
181
+ Mage::getSingleton('checkout/session')->addError(Mage::helper('onepagecheckout')->__('Cannot apply the coupon code.'));
182
+ }
183
+
184
+ }
185
+ }
186
+
187
+ /***********************************/
188
+
189
+ $bill_data = $this->getRequest()->getPost('billing', array());
190
+ $bill_data = $this->_filterPostData($bill_data);
191
+ $bill_addr_id = $this->getRequest()->getPost('billing_address_id', false);
192
+ $result = array();
193
+ $ship_updated = false;
194
+
195
+ if ($this->_checkChangedAddress($bill_data, 'Billing', $bill_addr_id) || $this->getRequest()->getPost('payment-method', false))
196
+ {
197
+ if (isset($bill_data['email']))
198
+ {
199
+ $bill_data['email'] = trim($bill_data['email']);
200
+ }
201
+
202
+ $bill_result = $this->getOnepage()->saveBilling($bill_data, $bill_addr_id, false);
203
+
204
+ if (!isset($bill_result['error']))
205
+ {
206
+ $pmnt_data = $this->getRequest()->getPost('payment', array());
207
+ $this->getOnepage()->usePayment(isset($pmnt_data['method']) ? $pmnt_data['method'] : null);
208
+
209
+ $result['update_section']['payment-method'] = $this->_getPaymentMethodsHtml();
210
+
211
+ if (isset($bill_data['use_for_shipping']) && $bill_data['use_for_shipping'] == 1 && !$this->getOnepage()->getQuote()->isVirtual())
212
+ {
213
+ $result['update_section']['shipping-method'] = $this->_getShippingMethodsHtml();
214
+ $result['duplicateBillingInfo'] = 'true';
215
+
216
+ $ship_updated = true;
217
+ }
218
+ }
219
+ else
220
+ {
221
+ $result['error_messages'] = $bill_result['message'];
222
+ }
223
+ }
224
+
225
+ $ship_data = $this->getRequest()->getPost('shipping', array());
226
+ $ship_addr_id = $this->getRequest()->getPost('shipping_address_id', false);
227
+ $ship_method = $this->getRequest()->getPost('shipping_method', false);
228
+
229
+ if (!$ship_updated && !$this->getOnepage()->getQuote()->isVirtual())
230
+ {
231
+ if ($this->_checkChangedAddress($ship_data, 'Shipping', $ship_addr_id) || $ship_method)
232
+ {
233
+ $ship_result = $this->getOnepage()->saveShipping($ship_data, $ship_addr_id, false);
234
+
235
+ if (!isset($ship_result['error']))
236
+ {
237
+ $result['update_section']['shipping-method'] = $this->_getShippingMethodsHtml();
238
+ }
239
+ }
240
+
241
+
242
+ if(!isset($result['update_section']['shipping-method']) && $this->getRequest()->getPost('shipping-method', false))
243
+ {
244
+ $result['update_section']['shipping-method'] = $this->_getShippingMethodsHtml();
245
+ }
246
+
247
+ }
248
+
249
+ $check_shipping_diff = false;
250
+
251
+ // check how many shipping methods exist
252
+ $rates = Mage::getModel('sales/quote_address_rate')->getCollection()->setAddressFilter($this->getOnepage()->getQuote()->getShippingAddress()->getId())->toArray();
253
+ if(count($rates['items'])==1)
254
+ {
255
+ if($rates['items'][0]['code']!=$ship_method)
256
+ {
257
+ $check_shipping_diff = true;
258
+
259
+ $result['reload_totals'] = 'true';
260
+ }
261
+ }
262
+ else
263
+ $check_shipping_diff = true;
264
+
265
+ // get prev shipping method
266
+ if($check_shipping_diff){
267
+ $shipping = $this->getOnepage()->getQuote()->getShippingAddress();
268
+ $shippingMethod_before = $shipping->getShippingMethod();
269
+ }
270
+
271
+ $this->getOnepage()->useShipping($ship_method);
272
+
273
+ $this->getOnepage()->getQuote()->collectTotals()->save();
274
+
275
+ if($check_shipping_diff){
276
+ $shipping = $this->getOnepage()->getQuote()->getShippingAddress();
277
+ $shippingMethod_after = $shipping->getShippingMethod();
278
+
279
+ if($shippingMethod_before != $shippingMethod_after)
280
+ {
281
+ $result['update_section']['shipping-method'] = $this->_getShippingMethodsHtml();
282
+ $result['reload_totals'] = 'true';
283
+ }
284
+ else
285
+ unset($result['reload_totals']);
286
+ }
287
+
288
+ $result['update_section']['review'] = $this->_getReviewHtml();
289
+
290
+
291
+ /*********** DISCOUNT CODES **********/
292
+ if ($couponChanged) {
293
+ if ($couponData['code'] == $quote->getCouponCode()) {
294
+ Mage::getSingleton('checkout/session')->addSuccess(
295
+ Mage::helper('onepagecheckout')->__('Coupon code "%s" was applied.', Mage::helper('core')->htmlEscape($couponData['code']))
296
+ );
297
+ } else {
298
+ Mage::getSingleton('checkout/session')->addError(
299
+ Mage::helper('onepagecheckout')->__('Coupon code "%s" is not valid.', Mage::helper('core')->htmlEscape($couponData['code']))
300
+ );
301
+ }
302
+ $method = str_replace(' ', '', ucwords(str_replace('-', ' ', 'coupon-discount')));
303
+ $result['update_section']['coupon-discount'] = $this->{'_get' . $method . 'Html'}();
304
+
305
+ }
306
+ /************************************/
307
+
308
+
309
+
310
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
311
+ }
312
+
313
+ }
app/code/community/Zapper/ScanToCheckout/etc/config.xml ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Zapper_ScanToCheckout>
5
+ <version>1.0.0</version>
6
+ </Zapper_ScanToCheckout>
7
+ </modules>
8
+
9
+ <frontend>
10
+ <routers>
11
+ <scantocheckout>
12
+ <use>standard</use>
13
+ <args>
14
+ <module>Zapper_ScanToCheckout</module>
15
+ <frontName>scantocheckout</frontName>
16
+ <modules>
17
+ <Zapper_ScanToCheckout before="Mage_Checkout">Zapper_ScanToCheckout</Zapper_ScanToCheckout>
18
+ </modules>
19
+ </args>
20
+ </scantocheckout>
21
+ </routers>
22
+ <layout>
23
+ <updates>
24
+ <scantocheckout>
25
+ <file>scantocheckout.xml</file>
26
+ </scantocheckout>
27
+ </updates>
28
+ </layout>
29
+ </frontend>
30
+
31
+ <global>
32
+ <rewrite>
33
+ <zapper_scantopay_onepage>
34
+ <from><![CDATA[#^/checkout/onepage/#]]></from>
35
+ <to>/scantocheckout/onepage/</to>
36
+ </zapper_scantopay_onepage>
37
+ </rewrite>
38
+ <blocks>
39
+ <scantocheckout>
40
+ <class>Zapper_ScanToCheckout_Block</class>
41
+ </scantocheckout>
42
+ <checkout>
43
+ <rewrite>
44
+ <onepage>Zapper_ScanToCheckout_Block_Onepage</onepage>
45
+ </rewrite>
46
+ </checkout>
47
+ </blocks>
48
+
49
+ <models>
50
+ <scantocheckout>
51
+ <class>Zapper_ScanToCheckout_Model</class>
52
+ </scantocheckout>
53
+ <rewrite>
54
+ <type_onepage>Zapper_ScanToCheckout_Model_Type_Onepage</type_onepage>
55
+ </rewrite>
56
+ </models>
57
+ <helpers>
58
+ <scantocheckout>
59
+ <class>Zapper_ScanToCheckout_Helper</class>
60
+ </scantocheckout>
61
+ </helpers>
62
+ <resources>
63
+
64
+
65
+ <scantocheckout_setup>
66
+ <setup>
67
+ <module>Zapper_ScanToCheckout</module>
68
+ </setup>
69
+ <connection>
70
+ <use>core_setup</use>
71
+ </connection>
72
+ </scantocheckout_setup>
73
+ <scantocheckout_write>
74
+ <connection>
75
+ <use>core_write</use>
76
+ </connection>
77
+ </scantocheckout_write>
78
+ <scantocheckout_read>
79
+ <connection>
80
+ <use>core_read</use>
81
+ </connection>
82
+ </scantocheckout_read>
83
+ </resources>
84
+ </global>
85
+
86
+ <default>
87
+ <payment>
88
+ <scantocheckout>
89
+ <active>0</active>
90
+ <model>scantocheckout/paymentMethod</model>
91
+ <order_status>pending</order_status>
92
+ <title>Zapper Scan To Pay</title>
93
+
94
+ <cctypes>AE,VI,MC,DI</cctypes>
95
+ <payment_action>authorize</payment_action>
96
+ <secret></secret>
97
+ <allowspecific>0</allowspecific>
98
+ </scantocheckout>
99
+ </payment>
100
+ </default>
101
+ </config>
app/code/community/Zapper/ScanToCheckout/etc/system.xml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <scantocheckout translate="label" module="scantocheckout">
7
+ <label>Zapper for eCommerce</label>
8
+ <sort_order>670</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>0</show_in_store>
12
+ <fields>
13
+ <active translate="label">
14
+ <label>Enabled</label>
15
+ <frontend_type>select</frontend_type>
16
+ <source_model>adminhtml/system_config_source_yesno</source_model>
17
+ <sort_order>1</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>0</show_in_store>
21
+ <comment>Select No to disable the Scan to Checkout functionality on your magento site</comment>
22
+ </active>
23
+ <sandbox translate="label">
24
+ <label>Sandbox</label>
25
+ <frontend_type>select</frontend_type>
26
+ <source_model>adminhtml/system_config_source_yesno</source_model>
27
+ <sort_order>1</sort_order>
28
+ <show_in_default>1</show_in_default>
29
+ <show_in_website>1</show_in_website>
30
+ <show_in_store>0</show_in_store>
31
+ <comment>Put the system in Sandbox Mode.</comment>
32
+ </sandbox>
33
+ <title translate="label">
34
+ <label>Title</label>
35
+ <frontend_type>text</frontend_type>
36
+ <sort_order>2</sort_order>
37
+ <show_in_default>1</show_in_default>
38
+ <show_in_website>1</show_in_website>
39
+ <show_in_store>0</show_in_store>
40
+ <comment>Title – What will be displayed in Frontend under "Payment Information".</comment>
41
+ </title>
42
+ <static_block translate="label">
43
+ <label>Static Block</label>
44
+ <frontend_type>text</frontend_type>
45
+ <sort_order>3</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ <comment>Identify of static blog show on help link.</comment>
50
+ </static_block>
51
+
52
+ </fields>
53
+ </scantocheckout>
54
+ </groups>
55
+ </payment>
56
+ </sections>
57
+ </config>
app/design/frontend/base/default/layout/scantocheckout.xml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <layout version="0.1.0">
4
+ <customer_logged_out>
5
+ <reference name="head">
6
+ <!-- <action method="addItem"><type>skin_js</type><name>js/zapper/jquery.js</name></action> -->
7
+ <action method="addItem"><type>skin_js</type><name>js/zapper/jquery-migrate.min.js</name></action>
8
+ <action method="addItem"><type>skin_js</type><name>js/zapper/zappertech.js</name></action>
9
+ <action method="addItem"><type>skin_js</type><name>js/zapper/zappercheckout.js</name></action>
10
+ <action method="addItem"><type>skin_css</type><name>css/zapper/zappertech.css</name></action>
11
+ </reference>
12
+ </customer_logged_out>
13
+
14
+ <customer_logged_in>
15
+ <reference name="head">
16
+ <action method="removeItem"><type>skin_js</type><name>../skin/frontend/base/default/js/zappertech.js</name></action>
17
+ <!-- <action method="addItem"><type>skin_js</type><name>js/zapper/jquery.js</name></action> -->
18
+ <action method="addItem"><type>skin_js</type><name>js/zapper/jquery-migrate.min.js</name></action>
19
+ <action method="addItem"><type>skin_js</type><name>js/zapper/zappercheckout.js</name></action>
20
+ <action method="addItem"><type>skin_css</type><name>css/zapper/zappertech.css</name></action>
21
+ </reference>
22
+ </customer_logged_in>
23
+
24
+ <checkout_onepage_index>
25
+ <reference name="head">
26
+ <action method="addItem"><type>skin_js</type><name>js/zapper/scantocheckout.js</name></action>
27
+ </reference>
28
+ <reference name="checkout.progress">
29
+ <block type="checkout/onepage_progress" name="scantocheckout.progress" template="checkout/onepage/progress/scantocheckout.phtml"></block>
30
+ </reference>
31
+
32
+ <reference name="checkout.onepage">
33
+ <!-- Extra step added to OnePage Checkout -->
34
+ <block type="scantocheckout/onepage_scantocheckout" name="checkout.onepage.scantocheckout" as="scantocheckout" after="-" template="checkout/onepage/scantocheckout.phtml"/>
35
+ </reference>
36
+
37
+ </checkout_onepage_index>
38
+
39
+ <checkout_cart_index>
40
+ <reference name="head">
41
+ <action method="removeItem"><type>skin_js</type><name>../skin/frontend/base/default/js/zappertech.js</name></action>
42
+ <action method="addItem"><type>skin_js</type><name>js/zapper/jquery-migrate.min.js</name></action>
43
+ <action method="addItem"><type>skin_js</type><name>js/zapper/zappercheckout.js</name></action>
44
+ <action method="addItem"><type>skin_css</type><name>css/zapper/zappertech.css</name></action>
45
+ </reference>
46
+ </checkout_cart_index>
47
+
48
+ </layout>
app/design/frontend/base/default/template/checkout/onepage/scantocheckout.phtml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php // if enabled then show else exit ?>
2
+
3
+ <form action="<?php echo $this->getUrl('checkout/onepage/saveScantocheckout') ?>" method="post" id="co-scantocheckout-form">
4
+ <fieldset>
5
+ <div class="block-content" id="scan_to_checkout" style="text-align: center;"><?php Mage::helper('scantocheckout')->render(1); ?></div>
6
+ <?php if($this->getLayout()->createBlock('cms/block')->setBlockId('scantocheckout_help')->toHtml() !== '' ) : ?>
7
+ <div class="scantocheckout-help">
8
+ <?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('scantocheckout_help')->toHtml(); ?>
9
+ </div>
10
+ <?php endif; ?>
11
+ </fieldset>
12
+ </form>
13
+
14
+ <div class="row-fluid form-buttons btn-only" id="scantocheckout-buttons-container">
15
+ <button type="button" class="button" onclick="scantocheckout.save()"><?php echo $this->__('Or Click Here To Checkout The Slow Way') ?></button>
16
+ <span id="scantocheckout-please-wait" class="please-wait" style="display:none;">
17
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
18
+ </span>
19
+ </div>
20
+
21
+ <script type="text/javascript">
22
+ //<![CDATA[
23
+ var scantocheckout = new Scantocheckout('co-scantocheckout-form', '<?php echo $this->getUrl('checkout/onepage/saveScantocheckout') ?>');
24
+ var scantocheckoutForm = new VarienForm('co-scantocheckout-form');
25
+ //]]>
26
+ </script>
app/etc/modules/Zapper_ScanToCheckout.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <config>
2
+ <modules>
3
+ <Zapper_ScanToCheckout>
4
+ <active>true</active>
5
+ <codePool>community</codePool>
6
+ <depends>
7
+ <Mage_Payment />
8
+ <Zapper_ScanToLogin />
9
+ </depends>
10
+ </Zapper_ScanToCheckout>
11
+ </modules>
12
+ </config>
package.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>zapper_scantocheckout</name>
4
+ <version>1.0.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/gpl-license.php">GNU General Public License (GPL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Zapper for eCommerce checkout integration.&#xD;
10
+ Frictionless checkout framework via mobile device.</summary>
11
+ <description>Zapper for eCommerce&#x2122; checkout is a friction-less user checkout mechanism framework for the Magento site. This allows the visitors of the site, who use the Zapper&#x2122; mobile application, to securely and instantly checkout on the Magento site, through a mobile device. User information are securely stored on the mobile device. &#xD;
12
+ &#xD;
13
+ Scan, confirm card and shipping details on the mobile device and checkout.&#xD;
14
+ &#xD;
15
+ This is geared for developers who will integrate with other payment gateways. Zapper for eCommerce Checkout currently uses Save CC only.&#xD;
16
+ &#xD;
17
+ Important!&#xD;
18
+ Zapper for eCommerce checkout requires Zapper for eCommerce Login and Register to be installed prior to installing checkout.</description>
19
+ <notes>Initial Release</notes>
20
+ <authors><author><name>Branden</name><user>Magento_OTA</user><email>branden.paine@ota.co.za</email></author></authors>
21
+ <date>2014-05-09</date>
22
+ <time>11:21:20</time>
23
+ <contents><target name="mageetc"><dir name="modules"><file name="Zapper_ScanToCheckout.xml" hash="f40ae7dfb3501e445ca19c5297ce477c"/></dir></target><target name="magecommunity"><dir name="Zapper"><dir name="ScanToCheckout"><dir name="Block"><dir name="Onepage"><file name="Scantocheckout.php" hash="11ce240a4a30431bc58c77331eb16ad4"/></dir><file name="Onepage.php" hash="7416fb1dd8103385fe565a3cd442d906"/><dir name="checkout"><file name="ScanToCheckout.php" hash="171b5b70f46c44eb5f54a891498f523d"/></dir></dir><dir name="Helper"><file name="Data.php" hash="4c1175f18a2d1ac782892092b50f9310"/></dir><dir name="Model"><file name="Create.php" hash="950268b8beb542ef40eca78c492ade36"/><dir name="Type"><file name="Onepage.php" hash="b9cf22e1d863e4a53ba8c782e112e78b"/></dir></dir><dir name="controllers"><file name="IndexController.php" hash="603ca45bb3193065090a2bd219396cc1"/><file name="OnepageController.php" hash="212a8d6da1a0457cc6535dccba54c403"/></dir><dir name="etc"><file name="config.xml" hash="02a8fa7e859e5f4633a41ba254a0ddcb"/><file name="system.xml" hash="95232cf4c663ade1ca60b31e775e2efd"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="checkout"><dir name="onepage"><file name="scantocheckout.phtml" hash="1d019b0e49dff784f1a04684ca92628f"/></dir></dir></dir><dir name="layout"><file name="scantocheckout.xml" hash="f10f24b0d221e665e16d1cbc3e7351e9"/></dir></dir></dir></dir></target></contents>
24
+ <compatible/>
25
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Zapper_Scantologin</name><channel>community</channel><min>1.0.0</min><max>1.0.1</max></package></required></dependencies>
26
+ </package>