-
Notifications
You must be signed in to change notification settings - Fork 0
/
Abstract.php
1281 lines (1192 loc) · 70.3 KB
/
Abstract.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/** ____________ _ _ _ ________ ___ _ _ _______ ___ ___ _ _ _ ___
* \_ _/ \_ _/ \| | |_| \ \_ _/ \| _ || \ |/ \_ _/ / __\| _ |/ \| | | _ \
* | | | | | ' | |_ | | || | '_/| /| | '_/| | | |_ \| / | | | | __/
* |_|\_/|_|_|_|___| |_|_\_||_|\__/|_\_\|_\_|\__/|_| \___/|_\_\\_/|___|_|
*
* NOTICE OF LICENSE
*
* This source file is subject to the Creative Commons License.
* If you are unable to obtain it through the world-wide-web, please send an email
* to servicedesk@totalinternetgroup.nl so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade this module to newer
* versions in the future. If you wish to customize this module for your
* needs please contact servicedesk@totalinternetgroup.nl for more information.
*
* @copyright 2014 Total Internet Group B.V. (http://www.totalinternetgroup.nl)
* @license http://creativecommons.org/licenses/by-nc-nd/3.0/nl/deed.en_US
*/
class TIG_Buckaroo3Extended_Model_Abstract extends Mage_Payment_Model_Method_Abstract
{
const BUCKAROO_SUCCESS = 'BUCKAROO_SUCCESS';
const BUCKAROO_FAILED = 'BUCKAROO_FAILED';
const BUCKAROO_ERROR = 'BUCKAROO_ERROR';
const BUCKAROO_NEUTRAL = 'BUCKAROO_NEUTRAL';
const BUCKAROO_PENDING_PAYMENT = 'BUCKAROO_PENDING_PAYMENT';
const BUCKAROO_INCORRECT_PAYMENT = 'BUCKAROO_INCORRECT_PAYMENT';
const BUCKAROO_REJECTED = 'BUCKAROO_REJECTED';
/**
* @var Mage_Sales_Model_Order $_order
*/
protected $_order = '';
protected $_debugEmail;
protected $_billingInfo = '';
protected $_session = '';
protected $_storeId = '';
/**
* List of possible response codes sent by buckaroo.
* This is the list for the BPE 3.0 gateway.
*/
public $responseCodes = array(
190 => array(
'message' => 'Success',
'status' => self::BUCKAROO_SUCCESS,
),
490 => array(
'message' => 'Payment failure',
'status' => self::BUCKAROO_FAILED,
),
491 => array(
'message' => 'Validation error',
'status' => self::BUCKAROO_FAILED,
),
492 => array(
'message' => 'Technical error',
'status' => self::BUCKAROO_ERROR,
),
690 => array(
'message' => 'Payment rejected',
'status' => self::BUCKAROO_REJECTED,
),
790 => array(
'message' => 'Waiting for user input',
'status' => self::BUCKAROO_PENDING_PAYMENT,
),
791 => array(
'message' => 'Waiting for processor',
'status' => self::BUCKAROO_PENDING_PAYMENT,
),
792 => array(
'message' => 'Waiting on consumer action',
'status' => self::BUCKAROO_PENDING_PAYMENT,
),
793 => array(
'message' => 'Payment on hold',
'status' => self::BUCKAROO_PENDING_PAYMENT,
),
890 => array(
'message' => 'Cancelled by consumer',
'status' => self::BUCKAROO_FAILED,
),
891 => array(
'message' => 'Cancelled by merchant',
'status' => self::BUCKAROO_FAILED,
),
);
/**
* Retrieves instance of the last used order
*/
protected function _loadLastOrder()
{
if (!empty($this->_order)) {
return;
}
$session = Mage::getSingleton('checkout/session');
$orderId = $session->getLastRealOrderId();
if (!empty($orderId)) {
$this->_order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
}
return $this;
}
public function setOrder($order) {
$this->_order = $order;
return $this;
}
public function getOrder()
{
return $this->_order;
}
public function setLastOrder($order)
{
$this->_order = $order;
return $this;
}
public function getLastOrder()
{
return $this->_order;
}
public function setDebugEmail($debugEmail)
{
$this->_debugEmail = $debugEmail;
return $this;
}
public function getDebugEmail()
{
return $this->_debugEmail;
}
public function setBillingInfo($billingInfo)
{
$this->_billingInfo = $billingInfo;
return $this;
}
public function getBillingInfo()
{
return $this->_billingInfo;
}
public function setSession($session)
{
$this->_session = $session;
return $this;
}
public function getSession()
{
return $this->_session;
}
public function setStoreId($storeId)
{
$this->_storeId = $storeId;
return $this;
}
public function getStoreId()
{
return $this->_storeId;
}
public function __construct($debugEmail = false)
{
if (strpos(dirname(__FILE__), DS .'Model') !== false) {
$dir = str_replace(DS .'Model', DS .'certificate', dirname(__FILE__));
} else {
$dir = str_replace(
DS
.'includes'
. DS
. 'src',
DS
. 'app'
. DS
. 'code'
. DS
. 'community'
. DS
. 'TIG'
. DS
. 'Buckaroo3Extended'
. DS
. 'certificate',
dirname(__FILE__)
);
}
if (!defined('CERTIFICATE_DIR')) {
define('CERTIFICATE_DIR', $dir);
}
$this->_loadLastOrder();
if (!Mage::helper('buckaroo3extended')->isAdmin()) {
$this->setSession(Mage::getSingleton('checkout/session'));
} else {
$this->setSession(Mage::getSingleton('core/session'));
}
$this->_setOrderBillingInfo();
if ($debugEmail) {
$this->setDebugEmail($debugEmail);
} else {
$this->setDebugEmail('');
}
if (!Mage::helper('buckaroo3extended')->isAdmin() && !Mage::registry('buckaroo_push-error')) {
$this->_checkExpired();
}
if ($this->getOrder()) {
$this->setStoreId($this->getOrder()->getStoreId());
} else {
$this->setStoreId(Mage::app()->getStore()->getId());
}
}
/**
* Checks if the order object is still there. Prevents errors when session has expired.
*/
protected function _checkExpired()
{
if (empty($this->_order)) {
$returnUrl = Mage::getUrl(Mage::getStoreConfig('buckaroo/buckaroo3extended_advanced/failure_redirect', $this->getStoreId()));
header('location:' . $returnUrl);
}
}
public function setOrderBillingInfo() {
return $this->_setOrderBillingInfo();
}
/**
* retrieve billing information from order
*
*/
protected function _setOrderBillingInfo()
{
if (empty($this->_order)) {
return false;
}
$billingAddress = $this->_order->getBillingAddress();
$firstname = $billingAddress->getFirstname();
$lastname = $billingAddress->getLastname();
$city = $billingAddress->getCity();
$state = $billingAddress->getState();
$address = $billingAddress->getStreetFull();
$zip = $billingAddress->getPostcode();
$email = $this->_order->getCustomerEmail();
$telephone = $billingAddress->getTelephone();
$fax = $billingAddress->getFax();
$countryCode = $billingAddress->getCountry();
$billingInfo = array(
'firstname' => $firstname,
'lastname' => $lastname,
'city' => $city,
'state' => $state,
'address' => $address,
'zip' => $zip,
'email' => $email,
'telephone' => $telephone,
'fax' => $fax,
'countryCode' => $countryCode
);
$this->setBillingInfo($billingInfo);
return $this;
}
/**
* Restores a previously closed quote so that the cart stays filled after an unsuccessfull order
*/
public function restoreQuote()
{
$quoteId = $this->_order->getQuoteId();
$quote = Mage::getModel('sales/quote')
->load($quoteId)
->setIsActive(true)
->setReservedOrderId(null)
->save();
Mage::getSingleton('checkout/session')->replaceQuote($quote);
}
/**
* Empties the cart after a successfull order. To prevent the cart from staying filled when the user
* has a modified shop that doesn't automatically clear the cart when placing an order.
*/
public function emptyCart()
{
if (!Mage::getStoreConfig('buckaroo/buckaroo3extended_advanced/manual_empty_cart', $this->getStoreId())) {
return false;
}
$cartHelper = Mage::helper('checkout/cart');
$items = $cartHelper->getCart()->getItems();
foreach ($items as $item) {
$itemId = $item->getItemId();
$cartHelper->getCart()->removeItem($itemId)->save();
}
}
/**
* Determines the totalamount of the order and the currency to be used based on which currencies are available
* and which currency the customer has selected.
*
* Will default to base currency if the selected currency is unavailable.
*
* @return array
*/
protected function _determineAmountAndCurrency()
{
$code = $this->_order->getPayment()->getMethod();
// availability currency codes for this Payment Module
switch($code)
{
case 'buckaroo3extended_ideal':
case 'buckaroogiftcard':
case 'buckaroo2012giftcard':
case 'buckarooideal':
case 'buckaroo':
case 'buckaroo2012ideal': $paymentMethod = Mage::getModel('buckaroo3extended/paymentMethods_ideal_paymentMethod');
$currenciesAllowedConfig = Mage::getStoreConfig('buckaroo/buckaroo3extended_ideal/allowed_currencies', $this->getStoreId());
break;
case 'buckaroo3extended_visa':
case 'buckaroocc':
case 'buckaroo2012creditcard': $paymentMethod = Mage::getModel('buckaroo3extended/paymentMethods_visa_paymentMethod');
$currenciesAllowedConfig = Mage::getStoreConfig('buckaroo/buckaroo3extended_visa/allowed_currencies', $this->getStoreId());
break;
case 'buckaroo3extended_amex': $paymentMethod = Mage::getModel('buckaroo3extended/paymentMethods_amex_paymentMethod');
$currenciesAllowedConfig = Mage::getStoreConfig('buckaroo/buckaroo3extended_amex/allowed_currencies', $this->getStoreId());
break;
case 'buckaroo3extended_mastercard':
case 'mastercard': $paymentMethod = Mage::getModel('buckaroo3extended/paymentMethods_mastercard_paymentMethod');
$currenciesAllowedConfig = Mage::getStoreConfig('buckaroo/buckaroo3extended_mastercard/allowed_currencies', $this->getStoreId());
break;
case 'buckaroo3extended_directdebit':
case 'buckaroocollect':
case 'buckaroo2012machtiging': $paymentMethod = Mage::getModel('buckaroo3extended/paymentMethods_directdebit_paymentMethod');
$currenciesAllowedConfig = Mage::getStoreConfig('buckaroo/buckaroo3extended_directdebit/allowed_currencies', $this->getStoreId());
break;
case 'buckaroo3extended_paypal':
case 'buckaroopaypal':
case 'buckaroo2012paypal': $paymentMethod = Mage::getModel('buckaroo3extended/paymentMethods_paypal_paymentMethod');
$currenciesAllowedConfig = Mage::getStoreConfig('buckaroo/buckaroo3extended_paypal/allowed_currencies', $this->getStoreId());
break;
case 'buckaroo3extended_transfer':
case 'buckarootransfer':
case 'buckaroo2012overschrijving': $paymentMethod = Mage::getModel('buckaroo3extended/paymentMethods_transfer_paymentMethod');
$currenciesAllowedConfig = Mage::getStoreConfig('buckaroo/buckaroo3extended_transfer/allowed_currencies', $this->getStoreId());
break;
case 'buckaroo3extended_paymentguarantee':
case 'buckarootransfergarant':
case 'buckaroo2012betaalgarant': $paymentMethod = Mage::getModel('buckaroo3extended/paymentMethods_paymentguarantee_paymentMethod');
$currenciesAllowedConfig = Mage::getStoreConfig('buckaroo/buckaroo3extended_paymentguarantee/allowed_currencies', $this->getStoreId());
break;
case 'buckaroo3extended_giropay':
case 'buckaroogiropay':
case 'buckaroo2012giropay': $paymentMethod = Mage::getModel('buckaroo3extended/paymentMethods_giropay_paymentMethod');
$currenciesAllowedConfig = Mage::getStoreConfig('buckaroo/buckaroo3extended_giropay/allowed_currencies', $this->getStoreId());
break;
case 'buckaroo3extended_paysafecard':
case 'buckaroocashticket':
case 'buckaroopaysafecard':
case 'buckaroo2012cashticketpaysafecard': $paymentMethod = Mage::getModel('buckaroo3extended/paymentMethods_paysafecard_paymentMethod');
$currenciesAllowedConfig = Mage::getStoreConfig('buckaroo/buckaroo3extended_paysafecard/allowed_currencies', $this->getStoreId());
break;
case 'buckaroo3extended_payperemail':
case 'buckaroopayperemail':
case 'buckaroo2012payperemail': $paymentMethod = Mage::getModel('buckaroo3extended/paymentMethods_payperemail_paymentMethod');
$currenciesAllowedConfig = Mage::getStoreConfig('buckaroo/buckaroo3extended_payperemail/allowed_currencies', $this->getStoreId());
break;
case 'buckaroo3extended_sofortueberweisung': $paymentMethod = Mage::getModel('buckaroo3extended/paymentMethods_sofortueberweisung_paymentMethod');
$currenciesAllowedConfig = Mage::getStoreConfig('buckaroo/buckaroo3extended_sofortueberweisung/allowed_currencies', $this->getStoreId());
break;
default: $paymentMethod = null;
$currenciesAllowedConfig = 'EUR';
}
if (!is_null($paymentMethod)) {
$currenciesAllowed = $paymentMethod->allowedCurrencies;
} else {
$currenciesAllowed = array('EUR');
}
$currenciesAllowedConfig = explode(',', $currenciesAllowedConfig);
$currentCurrency = Mage::app()->getStore()->getCurrentCurrencyCode();
// currency is not available for this module
if (in_array($currentCurrency, $currenciesAllowed)
&& in_array($currentCurrency, $currenciesAllowedConfig))
{
$currency = $currentCurrency;
$totalAmount = $this->_order->getGrandTotal();
} else {
$totalAmount = $this->_order->getBaseGrandTotal();
$currency = $this->_order->getBaseCurrency()->getCode();
}
return array($currency, $totalAmount);
}
/**
* get locale based on country
* locale is formatted as language-LOCALE
*
* @return array
*/
protected function _getLocale()
{
$country = $this->_order->getBillingAddress()->getCountry();
$locale = Mage::getStoreConfig('general/locale/code', $this->_order->getStoreId());
$locale = str_replace('_', '-', $locale);
$lang = strtoupper(substr($locale, 0, 2));
return array($country, $locale, $lang);
}
/**
* Retrieves an array with information related to a recieved response code.
* This method will only be called when it's child cant find it itself. This list
* is a general list of known status codes. Its not as inclusive as the lists used\
* by its children. However, this list also contains general error codes not
* carried by its children.
*
* @return array $returnArray
*/
protected function _parseResponse()
{
$code = $this->_response->Status->Code->Code;
if (!isset($this->responseCodes[$code]))
{
return array(
'message' => 'Onbekende responsecode: ' . $code,
'status' => self::BUCKAROO_NEUTRAL
);
}
$returnArray = $this->responseCodes[$code];
if (is_object($this->_response)
&& isset($this->_response->Status->SubCode))
{
//the subcode is additional information sometimes returned by Buckaroo. Currently not used,
//but it may be of use when debugging.
$returnArray['subCode'] = array(
'message' => $this->_response->Status->SubCode->_,
'code' => $this->_response->Status->SubCode->Code,
);
}
$returnArray['code'] = $code;
return $returnArray;
}
/**
* Retrieves an array with information related to a received response code.
* This method will only be called when it's child cant find it itself. This list
* is a general list of known status codes. Its not as inclusive as the lists used\
* by its children. However, this list also contains general error codes not
*
* @param $code
* @return array|bool
*/
protected function _parsePostResponse($code)
{
$isCorrect = $this->_checkCorrectAmount();
if ($isCorrect !== true) {
return $isCorrect;
}
if (isset($this->responseCodes[$code]))
{
$returnArray = $this->responseCodes[$code];
if ($this->_response) {
$returnArray['code'] = $code;
}
return $returnArray;
} elseif (isset($this->oldResponseCodes[$code])) {
return array(
'message' => $this->oldResponseCodes[$code]['*']['omschrijving'],
'status' => $this->oldResponseCodes[$code]['*']['code'],
'code' => $code
);
} else {
return array(
'message' => 'Onbekende responsecode: ' . $code,
'status' => self::BUCKAROO_NEUTRAL,
'code' => $code,
);
}
}
/**
* Checks if the correct amount has been paid.
*/
protected function _checkCorrectAmount()
{
$amountPaid = $this->_postArray['brq_amount'];
$this->_debugEmail .= 'Currency used is '
. $this->_postArray['brq_currency']
. '. Order currency is '
. $this->_order->getOrderCurrencyCode()
. ".\n";
if ($this->_postArray['brq_currency'] == $this->_order->getOrderCurrencyCode()) {
$this->_debugEmail .= "Currency used is same as order currency \n";
$amountOrdered = $this->_order->getGrandTotal();
} else {
$this->_debugEmail .= "Currency used is different from order currency \n";
$amountOrdered = $this->_order->getBaseGrandTotal();
}
$this->_debugEmail .= "Amount paid: {$amountPaid}. Amount ordered: {$amountOrdered} \n";
if (($amountPaid - $amountOrdered) > 0.01 || ($amountPaid - $amountOrdered) < -0.01) {
return array(
'message' => 'Incorrect amount transfered',
'status' => self::BUCKAROO_INCORRECT_PAYMENT,
);
} else {
return true;
}
}
/**
* cleans all elements in the array per instructions from Buckaroo PSP
*
* @param array $array
* @return array $cleanArray
*/
public function _cleanArrayForSoap($array)
{
$cleanArray = array();
foreach ($array as $key => $value) {
$value = str_replace('\r', ' ', $value);
$value = str_replace('\n', ' ', $value);
$cleanArray[$key] = $value;
}
return $cleanArray;
}
/**
* function which converts special characters to html numeric equivalents
*/
public function htmlNumeric($string) {
preg_match_all('/[^\!-\~\s]/', $string, $specialChars);
if ($specialChars) {
foreach ($specialChars[0] as $char) {
$newChar = ord($char);
$numericChars[] = '&#'.$newChar.';';
$patterns[] = "/{$char}/";
}
if (isset($numericChars) && isset($patterns)) {
$string = preg_replace($patterns, $numericChars, $string);
}
}
return $string;
}
public function log($message, $force = false)
{
Mage::helper('buckaroo3extended')->log($message, $force);
}
public function logException($e)
{
Mage::helper('buckaroo3extended')->logException($e);
}
public function sendDebugEmail()
{
$debugEmailConfig = Mage::getStoreConfig('buckaroo/buckaroo3extended_advanced/debug_email', $this->getStoreId());
if (empty($debugEmailConfig))
{
return;
}
$mail = $this->_debugEmail;
$recipients = explode(',', Mage::getStoreConfig('buckaroo/buckaroo3extended_advanced/debug_email', $this->getStoreId()));
foreach($recipients as $recipient) {
mail(
trim($recipient),
'Buckaroo 3 Extended Debug Email',
$mail
);
}
}
public function buckarooSort($array)
{
$arrayToSort = array();
$origArray = array();
foreach ($array as $key => $value) {
$arrayToSort[strtolower($key)] = $value;
$origArray[strtolower($key)] = $key;
}
ksort($arrayToSort);
$sortedArray = array();
foreach($arrayToSort as $key => $value) {
$key = $origArray[$key];
$sortedArray[$key] = $value;
}
return $sortedArray;
}
protected function _updateRefundedOrderStatus($success = false)
{
$successString = $success ? 'success' : 'failed';
if (!is_object($this->_order)) {
return $this;
}
$state = $this->_order->getState();
if ($success) {
$comment = 'Buckaroo refund request was successfully processed.';
} else {
$comment = 'Unfortunately the Buckaroo refund request could not be processed succesfully.';
}
if ($this->_order->getBaseGrandTotal() != $this->_order->getBaseTotalRefunded()) {
$configField = "buckaroo/buckaroo3extended_refund/order_status_partial_{$state}_{$successString}";
$status = Mage::getStoreConfig($configField);
} else {
$status = null;
}
if (!empty($status)) {
$this->_order->setStatus($status)->save();
$this->_order->addStatusHistoryComment($comment, $status)
->save();
} else {
$this->_order->addStatusHistoryComment($comment)
->save();
}
}
/**
* Long list of response codes used by BPE 2.0 gateway. Added here for backwards compatibility. Added
* to the bottem of the page so it doesn't take up as much space
*/
public $oldResponseCodes = array(
0 => array( '*'=>array( "omschrijving" => "De credit card transactie is pending.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "creditcard")),
001 => array( '*'=>array( "omschrijving" => "De credit card transactie is pending. De MPI-status van de klant wordt gecheckt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "creditcard")),
070 => array( '*'=>array( "omschrijving" => "De refund is nog niet verwerkt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "creditcard")),
071 => array( '*'=>array( "omschrijving" => "De refund is succesvol verwerkt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "creditcard")),
072 => array( '*'=>array( "omschrijving" => "Er is een fout opgetreden bij het refunden.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "creditcard")),
073 => array( '*'=>array( "omschrijving" => "De refund is geannuleerd.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "creditcard")),
100 => array( '*'=>array( "omschrijving" => "De transactie is door de credit-maatschappij goedgekeurd.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "creditcard")),
101 => array( '*'=>array( "omschrijving" => "De transactie is door de credit-maatschappij afgekeurd.",
"code" => self::BUCKAROO_FAILED,
"type" => "creditcard")),
102 => array( '*'=>array( "omschrijving" => "De transactie is mislukt. Er is een fout opgetreden in de verwerking bij de creditmaatschappij.",
"code" => self::BUCKAROO_FAILED,
"type" => "creditcard")),
103 => array( '*'=>array( "omschrijving" => "Deze creditcardtransactie is niet binnen de maximale, toegestane tijd uitgevoerd.",
"code" => self::BUCKAROO_FAILED,
"type" => "creditcard")),
104 => array( '*'=>array( "omschrijving" => "De kaart is verlopen.",
"code" => self::BUCKAROO_FAILED,
"type" => "creditcard")),
120 => array( '*'=>array( "omschrijving" => "Deze PayPal transactie is nog niet volledig verwerkt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypal")),
121 => array( '*'=>array( "omschrijving" => "Transactiestatus: autorisatie geslaagd.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "paypal")),
122 => array( '*'=>array( "omschrijving" => "Deze PayPal-transactie is door de consument geannuleerd.",
"code" => self::BUCKAROO_FAILED,
"type" => "paypal")),
123 => array( '*'=>array( "omschrijving" => "Deze PayPal-transactie is niet binnen de maximale, toegestane tijd uitgevoerd.",
"code" => self::BUCKAROO_FAILED,
"type" => "paypal")),
124 => array( '*'=>array( "omschrijving" => "Deze PayPal-transactie is om onbekende reden bij PayPal mislukt.",
"code" => self::BUCKAROO_FAILED,
"type" => "paypal")),
125 => array( '*'=>array( "omschrijving" => "Deze PayPal-transactie is niet geaccepteerd.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypal")),
126 => array( '*'=>array( "omschrijving" => "Deze PayPal-transactie is in afwachting.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypal")),
135 => array( '*'=>array( "omschrijving" => "Deze PayPal-transactie is nog niet volledig verwerkt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypal")),
136 => array( '*'=>array( "omschrijving" => "Om technische reden kon de status van deze transactie nog niet bij PayPal worden achterhaald. De transactie is mogelijk nog niet afgerond",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypal")),
137 => array( '*'=>array( "omschrijving" => "De afschrijvingscode is ongeldig.",
"code" => self::BUCKAROO_FAILED,
"type" => "paypal")),
138 => array( '*'=>array( "omschrijving" => "Er is een systeemfout opgetreden.",
"code" => self::BUCKAROO_FAILED,
"type" => "paypal")),
139 => array( '*'=>array( "omschrijving" => "Het PayPal transactie-ID is ongeldig of niet beschikbaar.",
"code" => self::BUCKAROO_FAILED,
"type" => "paypal")),
140 => array( '*'=>array( "omschrijving" => "Er kon geen transactie worden gevonden.",
"code" => self::BUCKAROO_FAILED,
"type" => "paypal")),
150 => array( '*'=>array( "omschrijving" => "Deze Paysafecard-transactie is nog niet volledig verwerkt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypal")),
151 => array( '*'=>array( "omschrijving" => "Transactiestatus: authorisatie geslaagd.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "paypal")),
152 => array( '*'=>array( "omschrijving" => "Deze Paysafecard-transactie is door de consument geannuleerd.",
"code" => self::BUCKAROO_FAILED,
"type" => "paypal")),
153 => array( '*'=>array( "omschrijving" => "Deze Paysafecard-transactie is niet binnen de maximale, toegestane tijd uitgevoerd.",
"code" => self::BUCKAROO_FAILED,
"type" => "paypal")),
155 => array( '*'=>array( "omschrijving" => "Deze Paysafecard-transactie is niet geaccepteerd.",
"code" => self::BUCKAROO_FAILED,
"type" => "paypal")),
156 => array( '*'=>array( "omschrijving" => "Deze Paysafecard-transactie is nog niet volledig verwerkt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypal")),
157 => array( '*'=>array( "omschrijving" => "Om technische reden kon de status van deze transactie nog niet bij Paysafecard worden achterhaald. De transactie is mogelijk nog niet afgerond.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypal")),
158 => array( '*'=>array( "omschrijving" => "Er is een systeemfout opgetreden bij Paysafecard. Onze excuses voor het ongemak.",
"code" => self::BUCKAROO_FAILED,
"type" => "paypal")),
159 => array( '*'=>array( "omschrijving" => "Het Paysafecard transactie-id is ongeldig of niet beschikbaar.",
"code" => self::BUCKAROO_FAILED,
"type" => "paypal")),
170 => array( '*'=>array( "omschrijving" => "Deze Cash-Ticket transactie is nog niet volledig verwerkt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypal")),
171 => array( '*'=>array( "omschrijving" => "Transactiestatus: authorisatie geslaagd",
"code" => self::BUCKAROO_SUCCESS,
"type" => "creditcard")),
172 => array( '*'=>array( "omschrijving" => "Deze Cash-Ticket transactie is door de consument geannuleerd.",
"code" => self::BUCKAROO_FAILED,
"type" => "creditcard")),
173 => array( '*'=>array( "omschrijving" => "Deze Cash-Ticket transactie is niet binnen de maximale, toegestane tijd uitgevoerd.",
"code" => self::BUCKAROO_FAILED,
"type" => "creditcard")),
175 => array( '*'=>array( "omschrijving" => "Deze Cash-Ticket transactie is niet geaccepteerd.",
"code" => self::BUCKAROO_FAILED,
"type" => "creditcard")),
176 => array( '*'=>array( "omschrijving" => "Deze Cash-Ticket transactie is nog niet volledig verwerkt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "creditcard")),
177 => array( '*'=>array( "omschrijving" => "Om technische reden kon de status van deze transactie nog niet bij Cash-Ticket worden achterhaald. De transactie is mogelijk nog niet afgerond.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "creditcard")),
178 => array( '*'=>array( "omschrijving" => "Er is een systeemfout opgetreden bij Cash-Ticket. Onze excuses voor het ongemak.",
"code" => self::BUCKAROO_FAILED,
"type" => "creditcard")),
179 => array( '*'=>array( "omschrijving" => "Het Cash-Ticket transactie-id is ongeldig of niet beschikbaar.",
"code" => self::BUCKAROO_FAILED,
"type" => "creditcard")),
201 => array( '*'=>array( "omschrijving" => "Er is timeout opgetreden bij het verwerken van de transactie.Gebruik de TransactionKey om de verwerkingsstatus nogmaals te controleren.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "creditcard")),
203 => array( '*'=>array( "omschrijving" => "De transactie is geweigerd. Het creditcardnummer is geblokkeerd.",
"code" => self::BUCKAROO_FAILED,
"type" => "creditcard")),
204 => array( '*'=>array( "omschrijving" => "De transactie is geweigerd. Het ip-adres is geblokkeerd",
"code" => self::BUCKAROO_FAILED,
"type" => "creditcard")),
205 => array( '*'=>array( "omschrijving" => "De transactie is geweigerd. Het land van uitgifte van deze creditcard is geblokkeerd",
"code" => self::BUCKAROO_FAILED,
"type" => "creditcard")),
206 => array( '*'=>array( "omschrijving" => "De transactie is geweigerd. De faktuur [waarde] wordt momenteel of is reeds betaald.",
"code" => self::BUCKAROO_FAILED,
"type" => "creditcard")),
207 => array( '*'=>array( "omschrijving" => "De transactie is geweigerd. Het maximaal aantal betaalpogingen voor faktuur [waarde] is overschreden.",
"code" => self::BUCKAROO_FAILED,
"type" => "creditcard")),
242 => array( '*'=>array( "omschrijving" => "Provisie BetaalGarant succesvol verwerkt.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "garant")),
243 => array( '*'=>array( "omschrijving" => "Provisie incassobureau BetaalGarant succesvol verwerkt.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "garant")),
244 => array( '*'=>array( "omschrijving" => "Provisie Buckaroo BetaalGarant succesvol verwerkt.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "garant")),
245 => array( '*'=>array( "omschrijving" => "Toetskosten incassobureau BetaalGarant succesvol verwerkt.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "garant")),
246 => array( '*'=>array( "omschrijving" => "Btw incassobureau BetaalGarant succesvol verwerkt.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "garant")),
247 => array( '*'=>array( "omschrijving" => "Btw buckaroo BetaalGarant succesvol verwerkt.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "garant")),
252 => array( '*'=>array( "omschrijving" => "Kredietwaardigheidcontrole resultaat negatief.",
"code" => self::BUCKAROO_FAILED,
"type" => "garant")),
254 => array( '*'=>array( "omschrijving" => "Betaalgarant verzoek succesvol verwerkt.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "garant")),
260 => array( '*'=>array( "omschrijving" => "Kredietwaardigheidcontrole abonnement niet actief.",
"code" => self::BUCKAROO_FAILED,
"type" => "garant")),
261 => array( '*'=>array( "omschrijving" => "Technische fout opgetreden tijdens kredietwaardigheidcontrole.",
"code" => self::BUCKAROO_FAILED,
"type" => "garant")),
262 => array( '*'=>array( "omschrijving" => "Verplichte velden voor kredietwaardigheidcontrole ontbreken of zijn onjuist",
"code" => self::BUCKAROO_FAILED,
"type" => "garant")),
300 => array( '*'=>array("omschrijving" => "Betaling voor deze overschrijving wordt nog verwacht.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "transfer"),
'buckarootransfergarant'=>array("omschrijving" => "Uw bestelling is geaccepteerd.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "transfer")),
301 => array( '*'=>array( "omschrijving" => "De overschrijving is ontvangen.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "transfer")),
302 => array( '*'=>array( "omschrijving" => "De transactie is geweigerd of afgewezen.",
"code" => self::BUCKAROO_FAILED,
"type" => "transfer")),
303 => array( '*'=>array( "omschrijving" => "De uiterste betaaldatum voor deze overschrijving is verstreken.",
"code" => self::BUCKAROO_FAILED,
"type" => "transfer")),
304 => array( '*'=>array( "omschrijving" => "De datum voor ingebrekestelling is verstreken.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "transfer")),
305 => array( '*'=>array( "omschrijving" => "Het ontvangen bedrag voor de overschrijving is lager dan het bedrag van de transactie.",
"code" => 'BUCKAROO_INCORRECT_AMOUNT',
"type" => "transfer")),
306 => array( '*'=>array( "omschrijving" => "Het ontvangen bedrag voor de overschrijving is groter dan het bedrag van de transactie.",
"code" => 'BUCKAROO_INCORRECT_AMOUNT',
"type" => "transfer")),
309 => array( '*'=>array( "omschrijving" => "De overschrijving is geannuleerd.",
"code" => self::BUCKAROO_FAILED,
"type" => "transfer")),
345 => array( '*'=>array( "omschrijving" => "Oorspronkelijk transactie-bedrag gedeeld.",
"code" => self::BUCKAROO_FAILED,
"type" => "transfer")),
371 => array( '*'=>array( "omschrijving" => "De refund voor deze overschrijving is verwerkt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "creditcard")),
372 => array( '*'=>array( "omschrijving" => "De refund voor deze overschrijving is verwerkt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "transfer")),
373 => array( '*'=>array( "omschrijving" => "De refund voor deze overschrijving is verwerkt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "transfer")),
381 => array( '*'=>array( "omschrijving" => "De refund voor deze overschrijving is mislukt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "transfer")),
382 => array( '*'=>array( "omschrijving" => "De refund voor deze overschrijving is mislukt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "transfer")),
383 => array( '*'=>array( "omschrijving" => "De refund voor deze overschrijving is mislukt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "transfer")),
390 => array( '*'=>array( "omschrijving" => "De transactie is buiten Buckaroo om met de klant afgehandeld.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "transfer")),
392 => array( '*'=>array( "omschrijving" => "Anders betaald.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "transfer")),
400 => array( '*'=>array( "omschrijving" => "De kadokaart-transactie is nog in behandeling",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "giftcard")),
401 => array( '*'=>array( "omschrijving" => "De betaling middels kado-kaart is geslaagd.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "giftcard")),
402 => array( '*'=>array( "omschrijving" => "Betaling middels de kadokaart is afgewezen.",
"code" => self::BUCKAROO_FAILED,
"type" => "giftcard")),
409 => array( '*'=>array( "omschrijving" => "Betaling middels de kadokaart is geannuleerd.",
"code" => self::BUCKAROO_FAILED,
"type" => "giftcard")),
403 => array( '*'=>array( "omschrijving" => "Deze Giftcard transactie is niet binnen de maximale, toegestane tijd uitgevoerd.",
"code" => self::BUCKAROO_FAILED,
"type" => "giftcard")),
404 => array( '*'=>array( "omschrijving" => "Deze Giftcard transactie is om onbekende reden bij de kaartuitgever mislukt.",
"code" => self::BUCKAROO_FAILED,
"type" => "giftcard")),
409 => array( '*'=>array( "omschrijving" => "Betaling middels de kadokaart is geannuleerd.",
"code" => self::BUCKAROO_FAILED,
"type" => "giftcard")),
410 => array( '*'=>array( "omschrijving" => "De Merchant Account Code is ongeldig",
"code" => self::BUCKAROO_FAILED,
"type" => "giftcard")),
411 => array( '*'=>array( "omschrijving" => "De betaling middels kadokaart is voorlopig geaccepteerd.",
"code" => 'BUCKAROO_PENDINGPAYMENT',
"type" => "giftcard")),
414 => array( '*'=>array( "omschrijving" => "Er is een systeem-fout opgetreden.",
"code" => self::BUCKAROO_FAILED,
"type" => "giftcard")),
421 => array( '*'=>array( "omschrijving" => "Er is een onbekende Issuer voor de kado-kaart opgegeven.",
"code" => self::BUCKAROO_FAILED,
"type" => "giftcard")),
422 => array( '*'=>array( "omschrijving" => "Er is een fout opgetreden bij de Issuer. De betaling is mislukt. [waarde].",
"code" => self::BUCKAROO_FAILED,
"type" => "giftcard")),
425 => array( '*'=>array( "omschrijving" => "Niet genoeg saldo om deze transactie uit te voeren.",
"code" => self::BUCKAROO_FAILED,
"type" => "giftcard")),
461 => array( '*'=>array( "omschrijving" => "Transactie voltooid.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "giftcard")),
462 => array( '*'=>array( "omschrijving" => "Transactie voltooid.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "giftcard")),
463 => array( '*'=>array( "omschrijving" => "Transactie voltooid.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "giftcard")),
464 => array( '*'=>array( "omschrijving" => "Transactie voltooid.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "giftcard")),
468 => array( '*'=>array( "omschrijving" => "Originele factuur voor deze vordering niet gevonden.",
"code" => self::BUCKAROO_FAILED,
"type" => "giftcard")),
471 => array( '*'=>array( "omschrijving" => "De refund voor deze giftcardbetaling is verwerkt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "giftcard")),
472 => array( '*'=>array( "omschrijving" => "De refund voor deze giftcardbetaling is mislukt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "giftcard")),
500 => array( '*'=>array( "omschrijving" => "Paypermail: transactie pending",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypermail")),
541 => array( '*'=>array( "omschrijving" => "Transactiekosten zijn verrekend met saldo.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypermail")),
550 => array( '*'=>array( "omschrijving" => "De uitbetaling is nog niet verwerkt.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypermail")),
551 => array( '*'=>array( "omschrijving" => "De uitbetaling is succesvol verwerkt.",
"code" => self::BUCKAROO_SUCCESS,
"type" => "paypermail")),
552 => array( '*'=>array( "omschrijving" => "Transactiekosten zijn verrekend met saldo.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypermail")),
553 => array( '*'=>array( "omschrijving" => "Transactiekosten zijn verrekend met saldo.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypermail")),
560 => array( '*'=>array( "omschrijving" => "Correctiebetaling uitgevoerd door Buckaroo.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypermail")),
581 => array( '*'=>array( "omschrijving" => "Overschrijving van of naar ander Buckaroo-account.",
"code" => self::BUCKAROO_NEUTRAL,
"type" => "paypermail")),
600 => array( '*'=>array( "omschrijving" => "Eenmalige machtiging is nog niet verwerkt.",
"code" => self::BUCKAROO_NEUTRAL,