Version Notes
Version 1.0.14 of the Onescan Payment Extension.
Changelog
---------------
1.0.14
Now supports:
- Magento promotions and discounting.
- Onescan one-touch support for mobile devices
- Various tweaks and improvements
1.0.13
Check Magento admin settings to determine whether prices sent to the Onescanner's device should include tax.
Improved efficiency of extension code.
Modified shipping tax calculation to round down so that the amount displayed on the Onescanner's device matches the amount calculated by Magento.
1.0.12
Check Magento database to determine whether country of delivery requires state/region to be present.
Added a new field to the configuration menu that allows the Magento store administrator to specify the message that is sent to the Onescanner's device if the state/region is not recognised.
In some circumstances, the wrong delivery method was being stored in the Magento database
1.0.11
Potential installation issue with some Magento instances fixed.
1.0.10
Purchase failure where delivery is to a country in which Magento requires state/region information to be present - fixed.
Configurable error message added if the Magento store cannot deliver the Onescanner's order to the address supplied by Onescan.
The incorrect URL was being used for the redirect after a successful order in some Magento store configurations - fixed.
1.0.9
Under certain circumstances, shipping charges were being added twice - fixed.
1.0.8
Incorrect country code used in some Magento installations - fixed.
Compatibility issue reported when installing into latest version of Magento - fixed.
1.0.7
Prevented jQuery conflict for older versions of Magento
1.0.6
Potential installation issue with some Magento instances fixed.
1.0.5
Allows merchant to specify the image that will be displayed on the device during a purchase.
Under certain circumstances the tax calculation was rounding incorrectly making a £0.01 difference between the actual payment and what was recorded in Magento - fixed.
1.0.4
Incorrect compatibility information shown on Magento Connect - fixed.
1.0.3
Corrected error in layout file preventing Onescan logo from being shown on the admin pages.
1.0.2
Incorrect postage applied where minimum order value applies. Fixed.
Tax missing from individual items in admin sales/orders list. Fixed.
Orders not marked as paid and invoice not created in admin. Fixed.
Onescan was being listed as payment method option on the standard checkout page, resulting in orders potentially being placed with no payment being taken. If a customer uses Onescan to pay, they never get to that part of the checkout process so it makes no sense to have Onescan listed as a payment method there. This has been removed so now the only way for Onescan to be selected as a payment method is for the padlock to be scanned as intended.
1.0.1
Fixed potential installation problem.
1.0.0
Initial version.
Release Info
Developer | Ensygnia |
Extension | Ensygnia_Onescan |
Version | 1.0.14 |
Comparing to | |
See all releases |
Code changes from version 1.0.13 to 1.0.14
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/*
|
3 |
Ensygnia Onescan extension
|
4 |
-
Copyright (C)
|
5 |
|
6 |
This program is free software: you can redistribute it and/or modify
|
7 |
it under the terms of the GNU General Public License as published by
|
@@ -17,32 +17,31 @@
|
|
17 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18 |
*/
|
19 |
require_once(Mage::getBaseDir('lib') . "/Onescan/login/LocalDataFactory.php");
|
20 |
-
|
21 |
class Ensygnia_Onescan_Model_Callback_Purchase extends Ensygnia_Onescan_Model_Callback_Abstract {
|
22 |
public function getConfigReference() {
|
23 |
return 'onescan/config_purchase';
|
24 |
}
|
25 |
-
|
26 |
//Callback entry point
|
27 |
public function handle() {
|
28 |
$settings = $this->getConfig()->getSettings();
|
29 |
if (isset($_GET['basket'])) {
|
30 |
$settings->OnescanCallbackURL .= '?basket=' . $_GET['basket'];
|
31 |
}
|
32 |
-
|
33 |
$onescanMessage = Onescan::ReadMessage($settings);
|
34 |
//Mage::log('Message: ' . print_r($onescanMessage,true));
|
35 |
|
36 |
$purchaseProcess = new OnescanPurchaseProcess();
|
37 |
$nextAction = $purchaseProcess->DecodePurchaseMessage($onescanMessage);
|
38 |
$sessionState = $purchaseProcess->SessionState();
|
39 |
-
|
40 |
switch ($nextAction)
|
41 |
{
|
42 |
case PurchaseAction::StartPayment:
|
43 |
//Mage::log('Start Payment');
|
44 |
-
$
|
45 |
-
$purchaseProcess->ProcessStartPurchase($purchasePayload);
|
46 |
break;
|
47 |
case PurchaseAction::AdditionalCharges:
|
48 |
//Mage::log('Additional Charges');
|
@@ -64,14 +63,122 @@
|
|
64 |
//Mage::log('Payment Cancelled');
|
65 |
$purchaseProcess->ProcessPaymentCancelled();
|
66 |
break;
|
67 |
-
}
|
68 |
$responseMessage = $purchaseProcess->EncodeOutcome();
|
69 |
//Mage::log('Response: ' . print_r($responseMessage,true));
|
70 |
-
|
71 |
Onescan::SendMessage($responseMessage,$settings);
|
72 |
return parent::handle();
|
73 |
}
|
74 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
/// <summary>
|
76 |
/// Build some extra information about further charges.
|
77 |
/// </summary>
|
@@ -79,25 +186,55 @@
|
|
79 |
$additionalChargesContext = $process->AdditionalChargesContext;
|
80 |
$requires=$process->PurchaseInfo->Requires;
|
81 |
$purchaseCharges = new AdditionalChargesPayload();
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
if ($requires->DeliveryOptions && !empty($additionalChargesContext->DeliveryAddress)){
|
84 |
-
$
|
85 |
-
if($deliveryChargesResponse!==true){
|
86 |
-
$purchaseCharges->AddressNotSupported=1;
|
87 |
-
$purchaseCharges->AddressNotSupportedReason=$deliveryChargesResponse;
|
88 |
-
}
|
89 |
}
|
90 |
-
|
91 |
//Surcharges not yet supported
|
92 |
/*if ($requires->Surcharges && !empty($additionalChargesContext->PaymentMethod)){
|
93 |
if(!$this->AddPaymentMethodCharges($additionalChargesContext->PaymentMethod,$purchaseCharges,$process)){
|
94 |
//REPORT SURCHARGES ERROR TO DEVICE;
|
95 |
}
|
96 |
}*/
|
97 |
-
|
98 |
return $purchaseCharges;
|
99 |
}
|
100 |
|
|
|
101 |
/// <summary>
|
102 |
/// Add charges for the specified payment method.
|
103 |
/// </summary>
|
@@ -120,10 +257,10 @@
|
|
120 |
private function HandlePlayCardCharges($paymentMethod,$purchaseCharges,$process) {
|
121 |
//Surcharges not yet supported, this sample function never gets called
|
122 |
$cardDetails = $paymentMethod->CardInformation;
|
123 |
-
|
124 |
$purchaseCharges->PaymentMethodCharge = new PaymentMethodCharge();
|
125 |
$purchaseCharges->PaymentMethodCharge->Code = "PLAY";
|
126 |
-
$purchaseCharges->PaymentMethodCharge->Description = "The onescan play card attracts a
|
127 |
$purchaseCharges->PaymentMethodCharge->Charge = new Charge();
|
128 |
$purchaseCharges->PaymentMethodCharge->Charge->BaseAmount = 1.00;
|
129 |
$purchaseCharges->PaymentMethodCharge->Charge->Tax = 0;
|
@@ -136,11 +273,11 @@
|
|
136 |
private function HandleCreditCardCharges($paymentMethod,$purchaseCharges,$process) {
|
137 |
//Surcharges not yet supported, this sample function never gets called
|
138 |
$cardDetails = $paymentMethod->CardInformation;
|
139 |
-
|
140 |
if ($cardDetails->PaymentSystemCode == "VISA") {
|
141 |
-
|
142 |
$surcharge = round($process->PurchaseInfo->PaymentAmount * 0.01, 2);
|
143 |
-
|
144 |
$purchaseCharges->PaymentMethodCharge = new PaymentMethodCharge();
|
145 |
$purchaseCharges->PaymentMethodCharge->Code = "VISA";
|
146 |
$purchaseCharges->PaymentMethodCharge->Description = "Paying with a credit card attracts a 1% charge";
|
@@ -150,6 +287,7 @@
|
|
150 |
$purchaseCharges->PaymentMethodCharge->Charge->TotalAmount = $surcharge;
|
151 |
}
|
152 |
}
|
|
|
153 |
|
154 |
/// <summary>
|
155 |
/// Add delivery charges for the specified address.
|
@@ -159,13 +297,15 @@
|
|
159 |
$quote=$this->MagentoRetrieveQuote($process->SessionState()->SessionID);
|
160 |
|
161 |
//Retrieve allowed shipping rates.
|
162 |
-
$
|
163 |
-
|
164 |
-
|
165 |
//If retrieval of shipping rates was unsuccessful, return the error.
|
166 |
-
if($
|
167 |
-
|
|
|
|
|
168 |
}
|
|
|
169 |
|
170 |
//Get shipping tax rate
|
171 |
$taxCalculation = Mage::getModel('tax/calculation');
|
@@ -178,8 +318,8 @@
|
|
178 |
foreach ($allowedRates as $rate) {
|
179 |
$amount=$rate->getPrice();
|
180 |
if(is_numeric($amount)){
|
181 |
-
$option=new DeliveryOption();
|
182 |
-
$option->Code = $rate->getCode();
|
183 |
$option->Description = $rate->getMethodDescription();
|
184 |
//Setting default option is not yet supported in the Onescan extension
|
185 |
/*if($option->Code==$defaultCode){
|
@@ -204,12 +344,14 @@
|
|
204 |
|
205 |
if(count($purchaseCharges->DeliveryOptions)==0){
|
206 |
//No shipping rates available for this order, return an error
|
207 |
-
|
|
|
|
|
208 |
}
|
209 |
-
|
210 |
//Retreive Onescan data from database
|
211 |
$sessionID = $process->SessionState()->SessionID;
|
212 |
-
|
213 |
$onescanData = Mage::getModel('onescan/sessiondata')->getCollection();
|
214 |
$onescanData->addFieldToFilter('sessionid', array('like' => $sessionID));
|
215 |
$onescanData->load();
|
@@ -226,67 +368,126 @@
|
|
226 |
return true;
|
227 |
}
|
228 |
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
}
|
262 |
-
$payload->PaymentAmount = $totals['subtotal']->getValue();
|
263 |
-
$payload->Currency = Mage::app()->getStore($storeid)->getCurrentCurrencyCode();
|
264 |
-
|
265 |
-
$payload->Requires = new PaymentOptIns();
|
266 |
|
267 |
-
$
|
268 |
-
$payload->Requires->DeliveryOptions=true;
|
269 |
|
270 |
-
$
|
271 |
-
|
272 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
273 |
}
|
274 |
-
|
275 |
/// <summary>
|
276 |
/// Build order accepted payload.
|
277 |
/// </summary>
|
278 |
private function BuildOrderAccepted($process) {
|
279 |
//Retreive Onescan data from database
|
280 |
$sessionID = $process->SessionState()->SessionID;
|
281 |
-
|
282 |
$onescanData = Mage::getModel('onescan/sessiondata')->getCollection();
|
283 |
$onescanData->addFieldToFilter('sessionid', array('like' => $sessionID));
|
284 |
$onescanData->load();
|
285 |
$sessionData=$onescanData->getData();
|
286 |
-
|
287 |
$quoteid=$sessionData[0]['quoteid'];
|
288 |
$customerid=$sessionData[0]['customerid'];
|
289 |
-
|
290 |
//If FirstName or LastName are blank, Magento can't proceed with order
|
291 |
if ($process->PaymentConfirmation->FirstName=="") {
|
292 |
$process->PaymentConfirmation->FirstName="First";
|
@@ -313,15 +514,15 @@
|
|
313 |
private function randomPassword() {
|
314 |
$alphabet = "abcdefghijkmnopqrstuwxyzABCDEFGHJKLMNPQRSTUWXYZ23456789";
|
315 |
$pass='';
|
316 |
-
|
317 |
for ($i = 0; $i < 8; $i++) {
|
318 |
$n = rand(0, strlen($alphabet)-1);
|
319 |
$pass .= $alphabet[$n];
|
320 |
}
|
321 |
-
|
322 |
return $pass;
|
323 |
}
|
324 |
-
|
325 |
private function MagentoRetrieveQuote($sessionID){
|
326 |
//Retrieve quote from database
|
327 |
$onescanData = Mage::getModel('onescan/sessiondata')->getCollection();
|
@@ -329,14 +530,14 @@
|
|
329 |
$onescanData->load();
|
330 |
$sessionData=$onescanData->getData();
|
331 |
$quoteid=$sessionData[0]['quoteid'];
|
332 |
-
|
333 |
//Retreive quote
|
334 |
$cart=Mage::getModel('checkout/cart')->getCheckoutSession();
|
335 |
$cart->setQuoteId($quoteid);
|
336 |
-
|
337 |
return $cart->getQuote();
|
338 |
}
|
339 |
-
|
340 |
protected function MagentoLogin($customerid,$quoteid,$process){
|
341 |
//Retreive quote from database
|
342 |
$cart=Mage::getModel('checkout/cart')->getCheckoutSession();
|
@@ -359,7 +560,7 @@
|
|
359 |
if (empty($details)) {
|
360 |
//We do not recognise the user token, so we create an account and log in
|
361 |
$customer->loadByEmail($process->PaymentConfirmation->UserEmail);
|
362 |
-
|
363 |
if(!$customer->getId()) {
|
364 |
//New customer registration
|
365 |
$customer->setEmail($process->PaymentConfirmation->UserEmail);
|
@@ -386,20 +587,20 @@
|
|
386 |
);
|
387 |
$confirmMessage=true;
|
388 |
}
|
389 |
-
|
390 |
//Store the Onescan user token in the database and associate it with the Magento account
|
391 |
$newToken=Mage::getModel('onescan/logintokens');
|
392 |
$newToken->setOnescantoken($process->UserToken);
|
393 |
$newToken->setMagentouserid($customer->getId());
|
394 |
$newToken->save();
|
395 |
-
|
396 |
$message=Mage::getStoreConfig('onescantab/general/onescan_register-success-message');
|
397 |
-
|
398 |
if ($confirmMessage) {
|
399 |
$value=Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
|
400 |
$message = Mage::helper('customer')->__(Mage::getStoreConfig('onescantab/general/onescan_email-not-confirmed-message'),$value);
|
401 |
}
|
402 |
-
|
403 |
LocalDataFactory::storeObject($sessionID,$customer->getId());
|
404 |
LocalDataFactory::storeObject($sessionID . '-message',$message);
|
405 |
}
|
@@ -408,7 +609,7 @@
|
|
408 |
}
|
409 |
} else {
|
410 |
//Email address recognised so redirect to login page
|
411 |
-
LocalDataFactory::storeObject($sessionID . '-message',Mage::getStoreConfig('onescantab/general/onescan_email-exists-message'));
|
412 |
}
|
413 |
} else {
|
414 |
//We recognise the user token, so we can log in
|
@@ -419,13 +620,13 @@
|
|
419 |
$quote->assignCustomer($customer);
|
420 |
}
|
421 |
}
|
422 |
-
|
423 |
protected function MagentoPlaceOrder($process,$quoteid){
|
424 |
//Retreive quote from database
|
425 |
$cart=Mage::getModel('checkout/cart')->getCheckoutSession();
|
426 |
$cart->setQuoteId($quoteid);
|
427 |
$quote=$cart->getQuote();
|
428 |
-
|
429 |
//Add customer name to the quote, along with billing address and shipping address.
|
430 |
$quote->setcustomerfirstname($process->PaymentConfirmation->FirstName);
|
431 |
$quote->setcustomerlastname($process->PaymentConfirmation->LastName);
|
@@ -464,99 +665,8 @@
|
|
464 |
//Delete quote
|
465 |
$quote->setIsActive(false);
|
466 |
$quote->delete();
|
467 |
-
|
468 |
-
return $order->getIncrementId();
|
469 |
-
}
|
470 |
-
|
471 |
-
protected function MagentoGetShippingRates($quote,$shippingError,$address){
|
472 |
-
//Coupons not yet supported, sample code for reference
|
473 |
-
/*if ($quote->getCouponCode() != '') {
|
474 |
-
$c = Mage::getResourceModel('salesrule/rule_collection');
|
475 |
-
$c->getSelect()->where("code=?", $quote->getCouponCode());
|
476 |
-
foreach ($c->getItems() as $item) {
|
477 |
-
$coupon = $item;
|
478 |
-
}
|
479 |
-
if ($coupon->getSimpleFreeShipping() > 0) {
|
480 |
-
$quote->getShippingAddress()->setShippingMethod($this->_shippingCode)->save();
|
481 |
-
return true;
|
482 |
-
}
|
483 |
-
}*/
|
484 |
-
|
485 |
-
//Add address to quote
|
486 |
-
try {
|
487 |
-
$addressData = array(
|
488 |
-
'street' => $address->AddressLine1 . ', ' . $address->AddressLine2,
|
489 |
-
'city' => $address->Town,
|
490 |
-
'postcode' => $address->Postcode,
|
491 |
-
'telephone' => '0',
|
492 |
-
'country_id' => $address->CountryCode,
|
493 |
-
);
|
494 |
|
495 |
-
|
496 |
-
$requiredStates=explode(',',Mage::getStoreConfig('general/region/state_required', Mage::app()->getStore()));
|
497 |
-
if(in_array($address->CountryCode,$requiredStates)){
|
498 |
-
$regions=Mage::getModel('directory/region')
|
499 |
-
->getResourceCollection()
|
500 |
-
->addCountryFilter($address->CountryCode)
|
501 |
-
->load();
|
502 |
-
|
503 |
-
//Ensure we have a valid region/state as either the full name or two letter abbreviation
|
504 |
-
$regionMatch=false;
|
505 |
-
//Check if supplied county text appears within full region name
|
506 |
-
foreach($regions as $region){
|
507 |
-
if(stripos($region->default_name,$address->County)!==false
|
508 |
-
//Use first region if county is empty to allow testing with early version of Onscan app
|
509 |
-
|| $address->County==''){
|
510 |
-
$addressData['region']=$region->default_name;
|
511 |
-
$addressData['region_id']=$region->region_id;
|
512 |
-
$regionMatch=true;
|
513 |
-
break;
|
514 |
-
}
|
515 |
-
}
|
516 |
-
//If supplied county is two characters long, check if we match the two letter region abbreviation
|
517 |
-
if(strlen($address->County)==2){
|
518 |
-
foreach($regions as $region){
|
519 |
-
if(strcasecmp($address->County,$region->code)==0){
|
520 |
-
$addressData['region']=$region->default_name;
|
521 |
-
$addressData['region_id']=$region->region_id;
|
522 |
-
$regionMatch=true;
|
523 |
-
break;
|
524 |
-
}
|
525 |
-
}
|
526 |
-
}
|
527 |
-
if(!$regionMatch){
|
528 |
-
//Region not found, return an error
|
529 |
-
return Mage::getStoreConfig('onescantab/general/onescan_unknown-region-message');
|
530 |
-
}
|
531 |
-
}
|
532 |
-
|
533 |
-
$billingAddress = $quote->getBillingAddress()->addData($addressData);
|
534 |
-
$shippingAddress = $quote->getShippingAddress()->addData($addressData);
|
535 |
-
|
536 |
-
//Get valid shipping rates for this address
|
537 |
-
$quote->getShippingAddress()->collectTotals();
|
538 |
-
$quote->getShippingAddress()->setCollectShippingRates(true);
|
539 |
-
$quote->getShippingAddress()->collectShippingRates();
|
540 |
-
$rates = $quote->getShippingAddress()->getShippingRatesCollection();
|
541 |
-
}
|
542 |
-
catch (Mage_Core_Exception $e) {
|
543 |
-
Mage::getSingleton('checkout/session')->addError($e->getMessage());
|
544 |
-
}
|
545 |
-
catch (Exception $e) {
|
546 |
-
Mage::getSingleton('checkout/session')->addException($e, Mage::helper('checkout')->__('Load customer quote error'));
|
547 |
-
}
|
548 |
-
|
549 |
-
$quote->save();
|
550 |
-
|
551 |
-
$allowedRates=array();
|
552 |
-
foreach ($rates as $rate){
|
553 |
-
$rateCode=$rate->getCode();
|
554 |
-
if($quote->getShippingAddress()->collectShippingRates()->getShippingRateByCode($rateCode)){
|
555 |
-
$allowedRates[$rateCode]=$rate; //Using $rateCode as key removes duplicates
|
556 |
-
}
|
557 |
-
}
|
558 |
-
|
559 |
-
return $allowedRates;
|
560 |
}
|
561 |
}
|
562 |
-
?>
|
1 |
<?php
|
2 |
/*
|
3 |
Ensygnia Onescan extension
|
4 |
+
Copyright (C) 2016 Ensygnia Ltd
|
5 |
|
6 |
This program is free software: you can redistribute it and/or modify
|
7 |
it under the terms of the GNU General Public License as published by
|
17 |
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18 |
*/
|
19 |
require_once(Mage::getBaseDir('lib') . "/Onescan/login/LocalDataFactory.php");
|
20 |
+
|
21 |
class Ensygnia_Onescan_Model_Callback_Purchase extends Ensygnia_Onescan_Model_Callback_Abstract {
|
22 |
public function getConfigReference() {
|
23 |
return 'onescan/config_purchase';
|
24 |
}
|
25 |
+
|
26 |
//Callback entry point
|
27 |
public function handle() {
|
28 |
$settings = $this->getConfig()->getSettings();
|
29 |
if (isset($_GET['basket'])) {
|
30 |
$settings->OnescanCallbackURL .= '?basket=' . $_GET['basket'];
|
31 |
}
|
32 |
+
|
33 |
$onescanMessage = Onescan::ReadMessage($settings);
|
34 |
//Mage::log('Message: ' . print_r($onescanMessage,true));
|
35 |
|
36 |
$purchaseProcess = new OnescanPurchaseProcess();
|
37 |
$nextAction = $purchaseProcess->DecodePurchaseMessage($onescanMessage);
|
38 |
$sessionState = $purchaseProcess->SessionState();
|
39 |
+
|
40 |
switch ($nextAction)
|
41 |
{
|
42 |
case PurchaseAction::StartPayment:
|
43 |
//Mage::log('Start Payment');
|
44 |
+
$this->BuildPurchasePayload($sessionState->SessionID,$purchaseProcess);
|
|
|
45 |
break;
|
46 |
case PurchaseAction::AdditionalCharges:
|
47 |
//Mage::log('Additional Charges');
|
63 |
//Mage::log('Payment Cancelled');
|
64 |
$purchaseProcess->ProcessPaymentCancelled();
|
65 |
break;
|
66 |
+
}
|
67 |
$responseMessage = $purchaseProcess->EncodeOutcome();
|
68 |
//Mage::log('Response: ' . print_r($responseMessage,true));
|
69 |
+
|
70 |
Onescan::SendMessage($responseMessage,$settings);
|
71 |
return parent::handle();
|
72 |
}
|
73 |
|
74 |
+
/// <summary>
|
75 |
+
/// Build purchase payload.
|
76 |
+
/// </summary>
|
77 |
+
private function BuildPurchasePayload($sessionID,$purchaseProcess) {
|
78 |
+
//Retreive quote from database and reserve order id
|
79 |
+
$quote=$this->MagentoRetrieveQuote($sessionID);
|
80 |
+
$quote->reserveOrderId();
|
81 |
+
$quote->save();
|
82 |
+
|
83 |
+
// Temporarily set the payment method to Onescan to pick up any specific discounts
|
84 |
+
$quote->getPayment()->importData(array('method' => 'onescan'));
|
85 |
+
|
86 |
+
//Retreive prices from quote
|
87 |
+
$storeid=$quote->getStoreId();
|
88 |
+
$totals=$quote->getTotals();
|
89 |
+
//Build Onescan payload from quote data
|
90 |
+
$payload = new PurchasePayload();
|
91 |
+
$payload->RequiresDeliveryAddress = true;
|
92 |
+
$payload->MerchantName = Mage::app()->getStore()->getFrontendName();
|
93 |
+
$payload->MerchantTransactionID = GUID();
|
94 |
+
$payload->PurchaseDescription = Mage::getStoreConfig('onescantab/general/onescan_basket-name');
|
95 |
+
|
96 |
+
if(isset($totals['tax']) && $totals['tax']->getValue()) {
|
97 |
+
$payload->Tax = $totals['tax']->getValue();
|
98 |
+
} else {
|
99 |
+
$payload->Tax = 0;
|
100 |
+
}
|
101 |
+
|
102 |
+
$payload->PaymentAmount = $totals['grand_total']->getValue();
|
103 |
+
$payload->ProductAmount = $payload->PaymentAmount-$payload->Tax;
|
104 |
+
$payload->Currency = Mage::app()->getStore($storeid)->getCurrentCurrencyCode();
|
105 |
+
$payload->Requires = new PaymentOptIns();
|
106 |
+
$payload->Requires->Surcharges = false;
|
107 |
+
$payload->Requires->DeliveryOptions=true;
|
108 |
+
|
109 |
+
$payload->ImageData = Mage::getStoreConfig('onescantab/general/onescan_basket-logo-url');
|
110 |
+
|
111 |
+
$discount = 0;
|
112 |
+
// Check for a discount
|
113 |
+
if(isset($totals['discount']) && $totals['discount']->getValue()) {
|
114 |
+
$discount = (float)$totals['discount']->getValue();
|
115 |
+
}
|
116 |
+
|
117 |
+
// Check we're above the minimum_order/amount
|
118 |
+
$minamountflag = 0;
|
119 |
+
if (Mage::getStoreConfig('sales/minimum_order/active', Mage::app()->getStore()) == 1) {
|
120 |
+
$minamount = Mage::getStoreConfig('sales/minimum_order/amount', Mage::app()->getStore());
|
121 |
+
$minamountflag = ($minamount > $payload->PaymentAmount ? 1 : 0);
|
122 |
+
|
123 |
+
// Need to hold onto this discount and using it in the surcharge callback
|
124 |
+
$onescanData = Mage::getModel('onescan/sessiondata')->getCollection();
|
125 |
+
$onescanData->addFieldToFilter('sessionid', array('like' => $sessionID));
|
126 |
+
$onescanData->load();
|
127 |
+
$sessionData=$onescanData->getData();
|
128 |
+
|
129 |
+
//Save details to Onescan database tables for later retrieval
|
130 |
+
$onescanModel=Mage::getModel('onescan/sessiondata');
|
131 |
+
$onescanModel->setId($sessionData[0]['sessiondata_id']);
|
132 |
+
$onescanModel->setSessionid($sessionID);
|
133 |
+
$onescanModel->setQuoteid($quote->getId());
|
134 |
+
$onescanModel->setCustomerid($sessionData[0]['customerid']);
|
135 |
+
// TODO: Create a new field for storing min amount flag rather than using shipping tax
|
136 |
+
$onescanModel->setShippingtax($minamountflag);
|
137 |
+
$onescanModel->save();
|
138 |
+
}
|
139 |
+
|
140 |
+
// Add the payload to the process
|
141 |
+
$purchaseProcess->ProcessStartPurchase($payload);
|
142 |
+
|
143 |
+
// Add discount details only when minamountflag not set
|
144 |
+
if ($minamountflag == 0 && $discount <> 0) {
|
145 |
+
$this->AddDiscountPayload($quote, $purchaseProcess->EncodeOutcome(), $discount);
|
146 |
+
}
|
147 |
+
|
148 |
+
}
|
149 |
+
|
150 |
+
/// Add discount as a MerchantFieldGroup
|
151 |
+
private function AddDiscountPayload($quote, $responseMessage, $discount) {
|
152 |
+
$fieldGroup = new MerchantFieldGroup();
|
153 |
+
$fieldGroup->GroupHeading = "Discount";
|
154 |
+
$fieldGroup->IsMandatory = true;
|
155 |
+
$fieldGroup->Code = "DISCOUNT";
|
156 |
+
$fieldGroup->GroupType = "Informational";
|
157 |
+
//$fieldGroup->AppliesToEachItem = false;
|
158 |
+
$fieldGroup->IconUrl = "ion-alert";
|
159 |
+
|
160 |
+
$appliedRuleIds = $quote->getAppliedRuleIds();
|
161 |
+
$appliedRuleIds = explode(',', $appliedRuleIds);
|
162 |
+
$rules = Mage::getModel('salesrule/rule')->getCollection()->addFieldToFilter('rule_id' , array('in' => $appliedRuleIds));
|
163 |
+
$fieldGroup->Fields = array();
|
164 |
+
foreach ($rules as $rule) {
|
165 |
+
$field = new MerchantField();
|
166 |
+
$field->Label = $rule['description'];
|
167 |
+
array_push($fieldGroup->Fields, $field);
|
168 |
+
}
|
169 |
+
$field = new MerchantField();
|
170 |
+
$currency = Mage::helper('core')->currency( abs($discount) );
|
171 |
+
$field->Label = "This is a saving of " . $currency;
|
172 |
+
array_push($fieldGroup->Fields, $field);
|
173 |
+
|
174 |
+
$merchantFieldsPayload = new MerchantFieldsPayload();
|
175 |
+
$merchantFieldsPayload->FieldGroups[0] = $fieldGroup;
|
176 |
+
// Add payload to responseMessage
|
177 |
+
$payload = $responseMessage->AddNewPayloadItem();
|
178 |
+
$payload->JsonPayload = json_encode($merchantFieldsPayload);
|
179 |
+
$payload->PayloadName = MerchantFieldsPayload::Name;
|
180 |
+
}
|
181 |
+
|
182 |
/// <summary>
|
183 |
/// Build some extra information about further charges.
|
184 |
/// </summary>
|
186 |
$additionalChargesContext = $process->AdditionalChargesContext;
|
187 |
$requires=$process->PurchaseInfo->Requires;
|
188 |
$purchaseCharges = new AdditionalChargesPayload();
|
189 |
+
|
190 |
+
// Temporarily setting the payment method to Onescan doesnt give us any onescan specific discounts here
|
191 |
+
// so we are retrieving them from session store ...
|
192 |
+
//$quote=$this->MagentoRetrieveQuote($process->SessionState()->SessionID);
|
193 |
+
//$quote->getPayment()->importData(array('method' => 'onescan'));
|
194 |
+
|
195 |
+
// So we are relying on storing amount and retrieving here.
|
196 |
+
$onescanData = Mage::getModel('onescan/sessiondata')->getCollection();
|
197 |
+
$onescanData->addFieldToFilter('sessionid', array('like' => $process->SessionState()->SessionID));
|
198 |
+
$onescanData->load();
|
199 |
+
$sessionData=$onescanData->getData();
|
200 |
+
// TODO: Move to a dedicated field to store discount.
|
201 |
+
$discount = $sessionData[0]['shippingamount'];
|
202 |
+
$minamountflag = $sessionData[0]['shippingtax'];
|
203 |
+
|
204 |
+
if ($minamountflag == 1) {
|
205 |
+
$purchaseCharges->AddressNotSupported=1;
|
206 |
+
$purchaseCharges->AddressNotSupportedReason = Mage::getStoreConfig('sales/minimum_order/description', Mage::app()->getStore());
|
207 |
+
return $purchaseCharges;
|
208 |
+
}
|
209 |
+
|
210 |
+
/*
|
211 |
+
if ($requires->Surcharges) {
|
212 |
+
$purchaseCharges->PaymentMethodCharge = new PaymentMethodCharge();
|
213 |
+
$purchaseCharges->PaymentMethodCharge->Code = "DISCOUNT";
|
214 |
+
// TODO: Move description to config option
|
215 |
+
$purchaseCharges->PaymentMethodCharge->Description = "This order has a discount";
|
216 |
+
$purchaseCharges->PaymentMethodCharge->Charge = new Charge();
|
217 |
+
$purchaseCharges->PaymentMethodCharge->Charge->BaseAmount = $discount;
|
218 |
+
$purchaseCharges->PaymentMethodCharge->Charge->Tax = 0;
|
219 |
+
$purchaseCharges->PaymentMethodCharge->Charge->TotalAmount = $discount;
|
220 |
+
}
|
221 |
+
*/
|
222 |
+
// Now set delivery options/charges
|
223 |
if ($requires->DeliveryOptions && !empty($additionalChargesContext->DeliveryAddress)){
|
224 |
+
$this->AddDeliveryCharges($additionalChargesContext->DeliveryAddress,$purchaseCharges,$process);
|
|
|
|
|
|
|
|
|
225 |
}
|
226 |
+
|
227 |
//Surcharges not yet supported
|
228 |
/*if ($requires->Surcharges && !empty($additionalChargesContext->PaymentMethod)){
|
229 |
if(!$this->AddPaymentMethodCharges($additionalChargesContext->PaymentMethod,$purchaseCharges,$process)){
|
230 |
//REPORT SURCHARGES ERROR TO DEVICE;
|
231 |
}
|
232 |
}*/
|
233 |
+
|
234 |
return $purchaseCharges;
|
235 |
}
|
236 |
|
237 |
+
/*
|
238 |
/// <summary>
|
239 |
/// Add charges for the specified payment method.
|
240 |
/// </summary>
|
257 |
private function HandlePlayCardCharges($paymentMethod,$purchaseCharges,$process) {
|
258 |
//Surcharges not yet supported, this sample function never gets called
|
259 |
$cardDetails = $paymentMethod->CardInformation;
|
260 |
+
|
261 |
$purchaseCharges->PaymentMethodCharge = new PaymentMethodCharge();
|
262 |
$purchaseCharges->PaymentMethodCharge->Code = "PLAY";
|
263 |
+
$purchaseCharges->PaymentMethodCharge->Description = "The onescan play card attracts a ?1 surcharge";
|
264 |
$purchaseCharges->PaymentMethodCharge->Charge = new Charge();
|
265 |
$purchaseCharges->PaymentMethodCharge->Charge->BaseAmount = 1.00;
|
266 |
$purchaseCharges->PaymentMethodCharge->Charge->Tax = 0;
|
273 |
private function HandleCreditCardCharges($paymentMethod,$purchaseCharges,$process) {
|
274 |
//Surcharges not yet supported, this sample function never gets called
|
275 |
$cardDetails = $paymentMethod->CardInformation;
|
276 |
+
|
277 |
if ($cardDetails->PaymentSystemCode == "VISA") {
|
278 |
+
|
279 |
$surcharge = round($process->PurchaseInfo->PaymentAmount * 0.01, 2);
|
280 |
+
|
281 |
$purchaseCharges->PaymentMethodCharge = new PaymentMethodCharge();
|
282 |
$purchaseCharges->PaymentMethodCharge->Code = "VISA";
|
283 |
$purchaseCharges->PaymentMethodCharge->Description = "Paying with a credit card attracts a 1% charge";
|
287 |
$purchaseCharges->PaymentMethodCharge->Charge->TotalAmount = $surcharge;
|
288 |
}
|
289 |
}
|
290 |
+
*/
|
291 |
|
292 |
/// <summary>
|
293 |
/// Add delivery charges for the specified address.
|
297 |
$quote=$this->MagentoRetrieveQuote($process->SessionState()->SessionID);
|
298 |
|
299 |
//Retrieve allowed shipping rates.
|
300 |
+
$result=$this->MagentoGetShippingRates($quote,$address);
|
301 |
+
|
|
|
302 |
//If retrieval of shipping rates was unsuccessful, return the error.
|
303 |
+
if(gettype($result)=='string'){
|
304 |
+
$purchaseCharges->AddressNotSupported=1;
|
305 |
+
$purchaseCharges->AddressNotSupportedReason=$result;
|
306 |
+
return false;
|
307 |
}
|
308 |
+
$allowedRates = $result;
|
309 |
|
310 |
//Get shipping tax rate
|
311 |
$taxCalculation = Mage::getModel('tax/calculation');
|
318 |
foreach ($allowedRates as $rate) {
|
319 |
$amount=$rate->getPrice();
|
320 |
if(is_numeric($amount)){
|
321 |
+
$option=new DeliveryOption();
|
322 |
+
$option->Code = $rate->getCode();
|
323 |
$option->Description = $rate->getMethodDescription();
|
324 |
//Setting default option is not yet supported in the Onescan extension
|
325 |
/*if($option->Code==$defaultCode){
|
344 |
|
345 |
if(count($purchaseCharges->DeliveryOptions)==0){
|
346 |
//No shipping rates available for this order, return an error
|
347 |
+
$purchaseCharges->AddressNotSupported=1;
|
348 |
+
$purchaseCharges->AddressNotSupportedReason=Mage::getStoreConfig('onescantab/general/onescan_cannot-deliver-message');
|
349 |
+
return false;
|
350 |
}
|
351 |
+
|
352 |
//Retreive Onescan data from database
|
353 |
$sessionID = $process->SessionState()->SessionID;
|
354 |
+
|
355 |
$onescanData = Mage::getModel('onescan/sessiondata')->getCollection();
|
356 |
$onescanData->addFieldToFilter('sessionid', array('like' => $sessionID));
|
357 |
$onescanData->load();
|
368 |
return true;
|
369 |
}
|
370 |
|
371 |
+
protected function MagentoGetShippingRates($quote,$address){
|
372 |
+
//Coupons not yet supported, sample code for reference
|
373 |
+
/*if ($quote->getCouponCode() != '') {
|
374 |
+
$c = Mage::getResourceModel('salesrule/rule_collection');
|
375 |
+
$c->getSelect()->where("code=?", $quote->getCouponCode());
|
376 |
+
foreach ($c->getItems() as $item) {
|
377 |
+
$coupon = $item;
|
378 |
+
}
|
379 |
+
if ($coupon->getSimpleFreeShipping() > 0) {
|
380 |
+
$quote->getShippingAddress()->setShippingMethod($this->_shippingCode)->save();
|
381 |
+
return true;
|
382 |
+
}
|
383 |
+
}*/
|
384 |
+
|
385 |
+
//Add address to quote
|
386 |
+
try {
|
387 |
+
$addressData = array(
|
388 |
+
'street' => $address->AddressLine1 . ( property_exists($address,'AddressLine2') ? ', ' . $address->AddressLine2 : ''),
|
389 |
+
'city' => $address->Town,
|
390 |
+
'postcode' => $address->Postcode,
|
391 |
+
'telephone' => '0',
|
392 |
+
'country_id' => $address->CountryCode,
|
393 |
+
);
|
394 |
+
|
395 |
+
// Check that this is an allowed country first.
|
396 |
+
$validCountry = false;
|
397 |
+
$countryList = Mage::getModel('directory/country')->getResourceCollection()->loadByStore()->toOptionArray(true);
|
398 |
+
foreach($countryList as $country){
|
399 |
+
if ($address->CountryCode == $country['value']) {
|
400 |
+
$validCountry = true;
|
401 |
+
break;
|
402 |
+
}
|
403 |
+
}
|
404 |
+
if (!$validCountry) {
|
405 |
+
//Country not allowed
|
406 |
+
return Mage::getStoreConfig('onescantab/general/onescan_cannot-deliver-message');
|
407 |
+
}
|
408 |
+
|
409 |
+
//Check to see if region/state is required for the delivery country
|
410 |
+
$requiredStates=explode(',',Mage::getStoreConfig('general/region/state_required', Mage::app()->getStore()));
|
411 |
+
if(in_array($address->CountryCode,$requiredStates)){
|
412 |
+
$regions=Mage::getModel('directory/region')
|
413 |
+
->getResourceCollection()
|
414 |
+
->addCountryFilter($address->CountryCode)
|
415 |
+
->load();
|
416 |
+
|
417 |
+
//Ensure we have a valid region/state as either the full name or two letter abbreviation
|
418 |
+
$regionMatch=false;
|
419 |
+
//Check if supplied county text appears within full region name
|
420 |
+
foreach($regions as $region){
|
421 |
+
if(stripos($region->default_name,$address->County)!==false
|
422 |
+
//Use first region if county is empty to allow testing with early version of Onscan app
|
423 |
+
|| $address->County==''){
|
424 |
+
$addressData['region']=$region->default_name;
|
425 |
+
$addressData['region_id']=$region->region_id;
|
426 |
+
$regionMatch=true;
|
427 |
+
break;
|
428 |
+
}
|
429 |
+
}
|
430 |
+
//If supplied county is two characters long, check if we match the two letter region abbreviation
|
431 |
+
if(!$regionMatch && strlen($address->County)==2){
|
432 |
+
foreach($regions as $region){
|
433 |
+
if(strcasecmp($address->County,$region->code)==0){
|
434 |
+
$addressData['region']=$region->default_name;
|
435 |
+
$addressData['region_id']=$region->region_id;
|
436 |
+
$regionMatch=true;
|
437 |
+
break;
|
438 |
+
}
|
439 |
+
}
|
440 |
+
}
|
441 |
+
if(!$regionMatch){
|
442 |
+
//Region not found, return an error
|
443 |
+
return Mage::getStoreConfig('onescantab/general/onescan_unknown-region-message');
|
444 |
+
}
|
445 |
+
}
|
446 |
|
447 |
+
$billingAddress = $quote->getBillingAddress()->addData($addressData);
|
448 |
+
$shippingAddress = $quote->getShippingAddress()->addData($addressData);
|
449 |
+
|
450 |
+
//Get valid shipping rates for this address
|
451 |
+
$quote->getShippingAddress()->collectTotals();
|
452 |
+
$quote->getShippingAddress()->setCollectShippingRates(true);
|
453 |
+
$quote->getShippingAddress()->collectShippingRates();
|
454 |
+
$rates = $quote->getShippingAddress()->getShippingRatesCollection();
|
455 |
+
}
|
456 |
+
catch (Mage_Core_Exception $e) {
|
457 |
+
Mage::getSingleton('checkout/session')->addError($e->getMessage());
|
458 |
+
}
|
459 |
+
catch (Exception $e) {
|
460 |
+
Mage::getSingleton('checkout/session')->addException($e, Mage::helper('checkout')->__('Load customer quote error'));
|
461 |
}
|
|
|
|
|
|
|
|
|
462 |
|
463 |
+
$quote->save();
|
|
|
464 |
|
465 |
+
$allowedRates=array();
|
466 |
+
foreach ($rates as $rate){
|
467 |
+
$rateCode=$rate->getCode();
|
468 |
+
if($quote->getShippingAddress()->collectShippingRates()->getShippingRateByCode($rateCode)){
|
469 |
+
$allowedRates[$rateCode]=$rate; //Using $rateCode as key removes duplicates
|
470 |
+
}
|
471 |
+
}
|
472 |
+
|
473 |
+
return $allowedRates;
|
474 |
}
|
475 |
+
|
476 |
/// <summary>
|
477 |
/// Build order accepted payload.
|
478 |
/// </summary>
|
479 |
private function BuildOrderAccepted($process) {
|
480 |
//Retreive Onescan data from database
|
481 |
$sessionID = $process->SessionState()->SessionID;
|
482 |
+
|
483 |
$onescanData = Mage::getModel('onescan/sessiondata')->getCollection();
|
484 |
$onescanData->addFieldToFilter('sessionid', array('like' => $sessionID));
|
485 |
$onescanData->load();
|
486 |
$sessionData=$onescanData->getData();
|
487 |
+
|
488 |
$quoteid=$sessionData[0]['quoteid'];
|
489 |
$customerid=$sessionData[0]['customerid'];
|
490 |
+
|
491 |
//If FirstName or LastName are blank, Magento can't proceed with order
|
492 |
if ($process->PaymentConfirmation->FirstName=="") {
|
493 |
$process->PaymentConfirmation->FirstName="First";
|
514 |
private function randomPassword() {
|
515 |
$alphabet = "abcdefghijkmnopqrstuwxyzABCDEFGHJKLMNPQRSTUWXYZ23456789";
|
516 |
$pass='';
|
517 |
+
|
518 |
for ($i = 0; $i < 8; $i++) {
|
519 |
$n = rand(0, strlen($alphabet)-1);
|
520 |
$pass .= $alphabet[$n];
|
521 |
}
|
522 |
+
|
523 |
return $pass;
|
524 |
}
|
525 |
+
|
526 |
private function MagentoRetrieveQuote($sessionID){
|
527 |
//Retrieve quote from database
|
528 |
$onescanData = Mage::getModel('onescan/sessiondata')->getCollection();
|
530 |
$onescanData->load();
|
531 |
$sessionData=$onescanData->getData();
|
532 |
$quoteid=$sessionData[0]['quoteid'];
|
533 |
+
|
534 |
//Retreive quote
|
535 |
$cart=Mage::getModel('checkout/cart')->getCheckoutSession();
|
536 |
$cart->setQuoteId($quoteid);
|
537 |
+
|
538 |
return $cart->getQuote();
|
539 |
}
|
540 |
+
|
541 |
protected function MagentoLogin($customerid,$quoteid,$process){
|
542 |
//Retreive quote from database
|
543 |
$cart=Mage::getModel('checkout/cart')->getCheckoutSession();
|
560 |
if (empty($details)) {
|
561 |
//We do not recognise the user token, so we create an account and log in
|
562 |
$customer->loadByEmail($process->PaymentConfirmation->UserEmail);
|
563 |
+
|
564 |
if(!$customer->getId()) {
|
565 |
//New customer registration
|
566 |
$customer->setEmail($process->PaymentConfirmation->UserEmail);
|
587 |
);
|
588 |
$confirmMessage=true;
|
589 |
}
|
590 |
+
|
591 |
//Store the Onescan user token in the database and associate it with the Magento account
|
592 |
$newToken=Mage::getModel('onescan/logintokens');
|
593 |
$newToken->setOnescantoken($process->UserToken);
|
594 |
$newToken->setMagentouserid($customer->getId());
|
595 |
$newToken->save();
|
596 |
+
|
597 |
$message=Mage::getStoreConfig('onescantab/general/onescan_register-success-message');
|
598 |
+
|
599 |
if ($confirmMessage) {
|
600 |
$value=Mage::helper('customer')->getEmailConfirmationUrl($customer->getEmail());
|
601 |
$message = Mage::helper('customer')->__(Mage::getStoreConfig('onescantab/general/onescan_email-not-confirmed-message'),$value);
|
602 |
}
|
603 |
+
|
604 |
LocalDataFactory::storeObject($sessionID,$customer->getId());
|
605 |
LocalDataFactory::storeObject($sessionID . '-message',$message);
|
606 |
}
|
609 |
}
|
610 |
} else {
|
611 |
//Email address recognised so redirect to login page
|
612 |
+
LocalDataFactory::storeObject($sessionID . '-message',Mage::getStoreConfig('onescantab/general/onescan_email-exists-message'));
|
613 |
}
|
614 |
} else {
|
615 |
//We recognise the user token, so we can log in
|
620 |
$quote->assignCustomer($customer);
|
621 |
}
|
622 |
}
|
623 |
+
|
624 |
protected function MagentoPlaceOrder($process,$quoteid){
|
625 |
//Retreive quote from database
|
626 |
$cart=Mage::getModel('checkout/cart')->getCheckoutSession();
|
627 |
$cart->setQuoteId($quoteid);
|
628 |
$quote=$cart->getQuote();
|
629 |
+
|
630 |
//Add customer name to the quote, along with billing address and shipping address.
|
631 |
$quote->setcustomerfirstname($process->PaymentConfirmation->FirstName);
|
632 |
$quote->setcustomerlastname($process->PaymentConfirmation->LastName);
|
665 |
//Delete quote
|
666 |
$quote->setIsActive(false);
|
667 |
$quote->delete();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
668 |
|
669 |
+
return $order->getIncrementId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
670 |
}
|
671 |
}
|
672 |
+
?>
|
@@ -31,12 +31,16 @@
|
|
31 |
|
32 |
<div class="block-content">
|
33 |
<?php if ($this->hasItems()) { ?>
|
34 |
-
<div id="onescanPadlock_basket<?php echo $basketPadlockCount; ?>"
|
|
|
35 |
data-sessionurl="<?php echo $this->getOnescanHelper()->getSessionFromBasketUrl() . '?basket=' . $basketPadlockCount; ?>"
|
36 |
-
data-postconfirm="postConfirm(<?php echo $basketPadlockCount; ?>);"
|
37 |
-
data-
|
|
|
|
|
|
|
38 |
</div>
|
39 |
<?php } ?>
|
40 |
</div>
|
41 |
</div>
|
42 |
-
<?php endif; ?>
|
31 |
|
32 |
<div class="block-content">
|
33 |
<?php if ($this->hasItems()) { ?>
|
34 |
+
<div id="onescanPadlock_basket<?php echo $basketPadlockCount; ?>"
|
35 |
+
class="onescanPadlock_basket onescanpadlock"
|
36 |
data-sessionurl="<?php echo $this->getOnescanHelper()->getSessionFromBasketUrl() . '?basket=' . $basketPadlockCount; ?>"
|
37 |
+
data-postconfirm="postConfirm(<?php echo $basketPadlockCount; ?>);"
|
38 |
+
data-postfailed="postFailed();"
|
39 |
+
data-polltarget="<?php echo $this->getOnescanHelper()->getSessionPollUrl(); ?>"
|
40 |
+
data-buttononly="true"
|
41 |
+
data-nonescan="true">
|
42 |
</div>
|
43 |
<?php } ?>
|
44 |
</div>
|
45 |
</div>
|
46 |
+
<?php endif; ?>
|
@@ -31,10 +31,14 @@
|
|
31 |
<strong><span>Onescan Login</span></strong>
|
32 |
</div>
|
33 |
<div class="block-content">
|
34 |
-
<div id="onescanPadlock_login"
|
35 |
-
|
|
|
|
|
|
|
|
|
36 |
</div>
|
37 |
</div>
|
38 |
</div>
|
39 |
<?php endif; ?>
|
40 |
-
<?php endif; ?>
|
31 |
<strong><span>Onescan Login</span></strong>
|
32 |
</div>
|
33 |
<div class="block-content">
|
34 |
+
<div id="onescanPadlock_login"
|
35 |
+
class="onescanpadlock"
|
36 |
+
data-sessionurl="<?php echo $this->getOnescanHelper()->getLoginSessionUrl(); ?>"
|
37 |
+
data-polltarget="<?php echo $this->getOnescanHelper()->getSessionPollUrl(); ?>"
|
38 |
+
data-buttononly="true"
|
39 |
+
data-nonescan="true">
|
40 |
</div>
|
41 |
</div>
|
42 |
</div>
|
43 |
<?php endif; ?>
|
44 |
+
<?php endif; ?>
|
@@ -31,10 +31,14 @@
|
|
31 |
<strong><span>Onescan Register</span></strong>
|
32 |
</div>
|
33 |
<div class="block-content">
|
34 |
-
<div id="onescanPadlock_register"
|
35 |
-
|
|
|
|
|
|
|
|
|
36 |
</div>
|
37 |
</div>
|
38 |
</div>
|
39 |
<?php endif; ?>
|
40 |
-
<?php endif; ?>
|
31 |
<strong><span>Onescan Register</span></strong>
|
32 |
</div>
|
33 |
<div class="block-content">
|
34 |
+
<div id="onescanPadlock_register"
|
35 |
+
class="onescanpadlock"
|
36 |
+
data-sessionurl="<?php echo $this->getOnescanHelper()->getRegistrationSessionUrl(); ?>"
|
37 |
+
data-polltarget="<?php echo $this->getOnescanHelper()->getSessionPollUrl(); ?>"
|
38 |
+
data-buttononly="true"
|
39 |
+
data-nonescan="true">
|
40 |
</div>
|
41 |
</div>
|
42 |
</div>
|
43 |
<?php endif; ?>
|
44 |
+
<?php endif; ?>
|
@@ -1,8 +1,8 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Ensygnia_Onescan</name>
|
4 |
-
<version>1.0.
|
5 |
-
<stability>
|
6 |
<license uri="https://www.gnu.org/licenses/gpl.html">GPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
@@ -14,10 +14,15 @@ No usernames and passwords to remember, no security checks to pass, or tiresome
|
|
14 |
All while improving the security of your site. And the burden of dealing with sensitive financial information is lifted. Payments are confirmed by a tokenised system: at no point do the details need to be shared.
|
15 |

|
16 |
Thanks to Onescan, mobile phones become a secure proof of identity. Online, all customers have to do to login, register or even purchase an item is complete one simple scan. We take all the hassle out of online shopping and tear down the barriers between you and your customers.</description>
|
17 |
-
<notes>Version 1.0.
|
18 |

|
19 |
Changelog
|
20 |
---------------
|
|
|
|
|
|
|
|
|
|
|
21 |

|
22 |
1.0.13
|
23 |
Check Magento admin settings to determine whether prices sent to the Onescanner's device should include tax.
|
@@ -83,9 +88,9 @@ Fixed potential installation problem.
|
|
83 |
1.0.0
|
84 |
Initial version.</notes>
|
85 |
<authors><author><name>Ensygnia</name><user>MAG002660123</user><email>paul.newson@ensygnia.com</email></author></authors>
|
86 |
-
<date>
|
87 |
-
<time>
|
88 |
-
<contents><target name="magelocal"><dir name="Ensygnia"><dir name="Onescan"><dir name="Block"><file name="Abstract.php" hash="4488b86743ac3cd970d52a4dc857c4d6"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Cta.php" hash="433c964de85d708af211461033f7a5fc"/></dir></dir></dir><file name="Basket.php" hash="438f95ad093d4b5cde252eb4a8661035"/><file name="Login.php" hash="099ce7a3c3b483e0e509357949d0056d"/><file name="Logo.php" hash="fd58bed8012207372450577b137781ea"/><file name="Register.php" hash="a3ce5e2b5d4cb627f23a6d52dc3f5db9"/><dir name="Widget"><file name="Basket.php" hash="95fad0d733885b0c4651d7e41bc0039c"/><file name="Login.php" hash="225660cace8fc351da454b49d887e124"/><file name="Register.php" hash="89a1492f818fc787cdde4f1adc29702b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="6bf2bcc51f0639615a150835c182b014"/></dir><dir name="Model"><dir name="Callback"><file name="Abstract.php" hash="31b73999f34ffd0f7e539d9ed6499cce"/><file name="Login.php" hash="94f1d610a7c56a95e10694b58e84de31"/><file name="Purchase.php" hash="
|
89 |
<compatible/>
|
90 |
<dependencies><required><php><min>5.2.13</min><max>5.6.1</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7.0.0</min><max></max></package></required></dependencies>
|
91 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Ensygnia_Onescan</name>
|
4 |
+
<version>1.0.14</version>
|
5 |
+
<stability>beta</stability>
|
6 |
<license uri="https://www.gnu.org/licenses/gpl.html">GPL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
14 |
All while improving the security of your site. And the burden of dealing with sensitive financial information is lifted. Payments are confirmed by a tokenised system: at no point do the details need to be shared.
|
15 |

|
16 |
Thanks to Onescan, mobile phones become a secure proof of identity. Online, all customers have to do to login, register or even purchase an item is complete one simple scan. We take all the hassle out of online shopping and tear down the barriers between you and your customers.</description>
|
17 |
+
<notes>Version 1.0.14 of the Onescan Payment Extension.
|
18 |

|
19 |
Changelog
|
20 |
---------------
|
21 |
+
1.0.14 
|
22 |
+
Now supports:
|
23 |
+
- Magento promotions and discounting.
|
24 |
+
- Onescan one-touch support for mobile devices
|
25 |
+
- Various tweaks and improvements
|
26 |

|
27 |
1.0.13
|
28 |
Check Magento admin settings to determine whether prices sent to the Onescanner's device should include tax.
|
88 |
1.0.0
|
89 |
Initial version.</notes>
|
90 |
<authors><author><name>Ensygnia</name><user>MAG002660123</user><email>paul.newson@ensygnia.com</email></author></authors>
|
91 |
+
<date>2016-04-19</date>
|
92 |
+
<time>15:30:54</time>
|
93 |
+
<contents><target name="magelocal"><dir name="Ensygnia"><dir name="Onescan"><dir name="Block"><file name="Abstract.php" hash="4488b86743ac3cd970d52a4dc857c4d6"/><dir name="Adminhtml"><dir name="System"><dir name="Config"><file name="Cta.php" hash="433c964de85d708af211461033f7a5fc"/></dir></dir></dir><file name="Basket.php" hash="438f95ad093d4b5cde252eb4a8661035"/><file name="Login.php" hash="099ce7a3c3b483e0e509357949d0056d"/><file name="Logo.php" hash="fd58bed8012207372450577b137781ea"/><file name="Register.php" hash="a3ce5e2b5d4cb627f23a6d52dc3f5db9"/><dir name="Widget"><file name="Basket.php" hash="95fad0d733885b0c4651d7e41bc0039c"/><file name="Login.php" hash="225660cace8fc351da454b49d887e124"/><file name="Register.php" hash="89a1492f818fc787cdde4f1adc29702b"/></dir></dir><dir name="Helper"><file name="Data.php" hash="6bf2bcc51f0639615a150835c182b014"/></dir><dir name="Model"><dir name="Callback"><file name="Abstract.php" hash="31b73999f34ffd0f7e539d9ed6499cce"/><file name="Login.php" hash="94f1d610a7c56a95e10694b58e84de31"/><file name="Purchase.php" hash="c31074d0fdbda40df71e20bde9a30adf"/><file name="Registration.php" hash="7cf4b0cdd39e84e392cecaa38a35bd50"/></dir><dir name="Config"><file name="Abstract.php" hash="9e407f490c53651e5fe6b19c92cb5c1a"/><file name="Login.php" hash="6fbec423b7b3c6d72fa6e3b519163cd8"/><file name="Purchase.php" hash="0bd21ab4d83b48a31aa9003b473ed6db"/><file name="Registration.php" hash="4c39c0ee7690abc16c0519d3c950c5cb"/></dir><file name="Logintokens.php" hash="1a61be2e17f8ef9562cc205d525a473c"/><dir name="Method"><file name="Onescan.php" hash="9700daf18892390d3c6c73d1ad9349a9"/></dir><dir name="Resource"><dir name="Logintokens"><file name="Collection.php" hash="3767dcf1cbe12088186664ef7d1be309"/></dir><file name="Logintokens.php" hash="4f0fd6b83ee508a382a442641a357e31"/><dir name="Sessiondata"><file name="Collection.php" hash="0b62795cd0f7f7b6dba3ecf07599a9f6"/></dir><file name="Sessiondata.php" hash="48c60528f7accbf52da25030a7681fc0"/><file name="Setup.php" hash="e09e39a39405ebd80af368fefa013839"/></dir><file name="Sessiondata.php" hash="f5f6c2f7ea7fc3c6f033d5a5ff3b1666"/></dir><dir name="controllers"><file name="CallbackController.php" hash="dbbaebed3d7f7aa4e1431d22e2f6a541"/><file name="IndexController.php" hash="37d200f846305bed89a853d41e8f2c55"/></dir><dir name="etc"><file name="adminhtml.xml" hash="42e02288cfa5329abafb1ea0a98ef387"/><file name="config.xml" hash="54ad76a6b3ec05ab636f5704d3ae6393"/><file name="system.xml" hash="92cb2fbfe0086273b664f181cabb2241"/><file name="widget.xml" hash="2a9946cbc623b75b95eaf6d851d73c52"/></dir><file name="license.txt" hash="f075d971a6aa12e3ae52489ef961a7f5"/><dir name="sql"><dir name="onescan_setup"><file name="install-1.0.0.php" hash="08887eb2180ac838dcacd73b5cd2ab8b"/><file name="upgrade-1.0.4-1.0.5.php" hash="c55d900031db2717429a2e575ed4aa59"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="onescan.xml" hash="419c0333c31ba849f2ed2a8ea57cb823"/></dir><dir name="template"><dir name="onescan"><dir name="system"><dir name="config"><file name="cta.phtml" hash="c99b3ce3333dbff286f2156a031f5401"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="onescan.xml" hash="3f702507b0dfc4ffd7e6c3e3647ee831"/></dir><dir name="template"><dir name="onescan"><file name="basket.phtml" hash="1b34dc8be9d8df5b47be678c56d0433b"/><file name="login.phtml" hash="fdcd301789f8d977a9e362739421d0c0"/><file name="logo.phtml" hash="29e5cb387d8e2aaf676040a2c25b9596"/><file name="register.phtml" hash="bb298228247c169cab91baa18e77b5ae"/><file name="scripts.phtml" hash="e2c4469065c629b34a9280879f9da71e"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ensygnia_Onescan.xml" hash="d0d96d5e505006873bdb9c1b4f4c591f"/></dir></target><target name="magelib"><dir name="Onescan"><dir name="core"><file name="onescan-Exceptions.php" hash="1733a8f40cdc6fbb7a2c77890f0fd197"/><file name="onescan-GUID.php" hash="732799426a921038f30f1485f5cd7264"/><file name="onescan-HMAC.php" hash="797d68c8879ee9574dcb06770947d19b"/><file name="onescan-HTTPClient.php" hash="59eee1d07c3796ad24126c0c85b35086"/><file name="onescan-Login.php" hash="deaf58a3c6c9bc30a0acc4f10d64ade0"/><file name="onescan-Message.php" hash="f978243be9032897fcf1a288a23ce837"/><file name="onescan-Onescan.php" hash="93120300b4add29f3cd44709d8cc32d6"/><file name="onescan-Process.php" hash="86d8ccd62a5261d86ae7c35a099b5c1f"/><file name="onescan-Session.php" hash="a365d6c0fc9d41f603e88384b0c15fea"/><file name="onescan-SessionState.php" hash="a0b3b8d6d8d433551340ede175d094cc"/><file name="onescan-Settings.php" hash="2c62dcbb810b2d1d02f5773db9184408"/></dir><dir name="login"><file name="LocalDataFactory.php" hash="99605095507fb98c2de5dcf57e34411e"/><file name="onescan-LoginProcess.php" hash="c3552a34b51e879c535d7b67d541e0fd"/></dir><dir name="purchase"><file name="onescan-AdditionalChargesPayload.php" hash="cb1f2d49d560e1b46b866dffda932111"/><file name="onescan-CardInformation.php" hash="6c2fd7227533dfe986d93bd8bfeb4c1e"/><file name="onescan-CardType.php" hash="8e7765420c6a0de517949393b7360818"/><file name="onescan-Charge.php" hash="285cc0b1f0708f3a3dbc503447b7c0bd"/><file name="onescan-ConfirmPaymentPayload.php" hash="7eda3538cd471c41976732d462a2d84e"/><file name="onescan-CorePurchaseInfo.php" hash="08d943667c901189edaf8dc22406b7d8"/><file name="onescan-DeliveryOption.php" hash="8580b35f993b668c153b6488a9572bd4"/><file name="onescan-OrderAcceptedPayload.php" hash="c007ac8a0a78e51f516f9456d47c0129"/><file name="onescan-OrderDeclinedPayload.php" hash="1cfd9499b9cb167435a33766a5822909"/><file name="onescan-PaymentMethodCharge.php" hash="35f576d4ba1965a5ffc1155d28ba2ceb"/><file name="onescan-PaymentMethodInformation.php" hash="9c332bf6aa9395ec484a13a771101f94"/><file name="onescan-PaymentMethodType.php" hash="df5296173d5a34e55a425810072192dd"/><file name="onescan-PaymentOptins.php" hash="da07521ee0d52657a776ea8ecb705ac0"/><file name="onescan-PurchaseAction.php" hash="ca494c86fe5548b93ba2876a4e3b7aad"/><file name="onescan-PurchaseCharges.php" hash="1b67b353045ea1f93a7b18d2c1940b94"/><file name="onescan-PurchaseContextPayload.php" hash="0bdf109a37bd5104660d13ee3ea42d42"/><file name="onescan-PurchaseInclude.php" hash="a52385a7ceb5f056367a40eaff2a2d32"/><file name="onescan-PurchasePayload.php" hash="0970da6cfc0907c268218501d24f08d1"/><file name="onescan-PurchaseProcess.php" hash="e5108485d920ef899003d402f7bd5efd"/><file name="onescan-PurchaseSettings.php" hash="f3c3d6776d5da8a616eb417a9728fe61"/><file name="onescan-UserAddress.php" hash="4e1ec23d74d6f192a1edb31f3e3c9c8e"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="onescan"><dir name="css"><file name="onescan.css" hash="1f758b313e54a8782fcc96e34423caf5"/></dir><dir name="images"><file name="logo-sml.png" hash="af6d80c8d752b68ffff5d2cedd60319f"/><file name="logo.png" hash="ad10933575eaa2f9e379c0aad2ac038e"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><file name="onescan.css" hash="c649f4ebbe1ccb865f3582e04b842c34"/></dir><dir name="images"><file name="logo.png" hash="658a845e0e5d71fb94c072680a42c74b"/></dir><dir name="js"><file name="onescan.js" hash="22e614add95533cbb8415d030cccfe2e"/></dir></dir></dir></dir></target></contents>
|
94 |
<compatible/>
|
95 |
<dependencies><required><php><min>5.2.13</min><max>5.6.1</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.7.0.0</min><max></max></package></required></dependencies>
|
96 |
</package>
|