-
Notifications
You must be signed in to change notification settings - Fork 9
/
midtranspay.php
1958 lines (1779 loc) · 71.2 KB
/
midtranspay.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
if (!defined('_PS_VERSION_'))
exit;
// TODO refactor code, get rid of installment etc.
// TODO refactor backend config fields, getrid of enabled payments etc.
// TODO uncomment these, use the real snap php library class (make sure to do this on other file too)
require_once ('library/veritrans/Veritrans.php');
require_once ('library/veritrans/Veritrans/Notification.php');
require_once ('library/veritrans/Veritrans/Transaction.php');
// TODO remove theese
// require_once(dirname(__FILE__).'/../veritranspay/library/veritrans/Veritrans.php');
// require_once(dirname(__FILE__).'/../veritranspay/library/veritrans/Veritrans/Notification.php');
// require_once(dirname(__FILE__).'/../veritranspay/library/veritrans/Veritrans/Transaction.php');
class MidtransPay extends PaymentModule
{
private $_html = '';
private $_postErrors = array();
public $midtrans_merchant_id;
public $midtrans_merchant_hash;
public $midtrans_kurs;
public $midtrans_convenience_fee;
public $midtrans_client_key;
public $midtrans_server_key;
public $midtrans_api_version;
public $midtrans_installments;
public $midtrans_3d_secure;
public $midtrans_payment_type;
public $midtrans_payment_success_status_mapping;
public $midtrans_payment_failure_status_mapping;
public $midtrans_payment_challenge_status_mapping;
public $midtrans_environment;
public $config_keys;
public $hooks = array('payment','header','backOfficeHeader','orderConfirmation','paymentReturn','paymentOptions');
public function __construct()
{
$this->name = 'midtranspay';
$this->tab = 'payments_gateways';
$this->version = '2.8.1';
$this->author = 'Midtrans';
$this->bootstrap = true;
$this->currencies = true;
$this->currencies_mode = 'checkbox';
$this->midtrans_convenience_fee = 0;
// key length must be between 0-32 chars to maintain compatibility with <= 1.5
$this->config_keys = array(
'MT_DISPLAY_TITLE',
'MT_DISPLAY_DESCRIPTION',
'MT_MERCHANT_ID',
'MT_CLIENT_KEY',
'MT_SERVER_KEY',
'MT_API_VERSION',
'MT_PAYMENT_TYPE',
'MT_3D_SECURE',
'MT_KURS',
'MT_CONVENIENCE_FEE',
'MT_PAYMENT_SUCCESS_STATUS_MAP',
'MT_PAYMENT_FAILURE_STATUS_MAP',
'MT_PAYMENT_CHALLENGE_STATUS_MAP',
'MT_ENVIRONMENT',
'MT_MINAMOUNT',
// Additional feature vars
'MT_ENABLED_ADV',
'MT_ENABLED_MIGS_BTN',
'MT_TITLE_MIGS_BTN',
'MT_BINS_MIGS_BTN',
'MT_ACQ_MIGS_BTN',
'MT_DISABLE_NON_MIGS_BTN',
'MT_ENABLED_INSTALLMENTMIGS_BTN',
'MT_TITLE_INSTALLMENTMIGS_BTN',
'MT_BINS_INSTALLMENTMIGS_BTN',
'MT_ACQ_INSTALLMENTMIGS_BTN',
'MT_ENABLED_INSTALLMENTOFF_BTN',
'MT_TITLE_INSTALLMENTOFF_BTN',
'MT_BINS_INSTALLMENTOFF_BTN',
'MT_TERM_INSTALLMENTOFF_BTN',
'MT_ENABLED_INSTALLMENTON_BTN',
'MT_TITLE_INSTALLMENTON_BTN',
'MT_BINS_INSTALLMENTON_BTN',
'MT_ENABLED_PROMO_BTN',
'MT_TITLE_PROMO_BTN',
'MT_METHOD_PROMO_BTN',
'MT_BINS_PROMO_BTN',
'MT_PROMO_CODE',
'MT_PROMO_CUSTOM_FIELDS',
'MT_MINAMOUNT_PROMO',
'MT_ENABLED_EXPIRY',
'MT_EXPIRY_DURATION',
'MT_EXPIRY_UNIT',
'MT_ENABLED_SAVECARD',
'MT_ENABLED_FIELDS',
'MT_FILEDS',
'MT_ENABLED_CUSTOMVA_BTN',
'MT_LIST_CUSTOMVA',
'MT_ENABLED_IGNORE_DENY',
'MT_ENABLED_REDIRECT',
'MT_ENABLED_MAP_FINISH_URL',
);
$config = Configuration::getMultiple($this->config_keys);
foreach ($this->config_keys as $key) {
if (isset($config[$key]))
$this->{strtolower($key)} = $config[$key];
}
if (isset($config['MT_KURS']))
$this->midtrans_kurs = $config['MT_KURS'];
else
Configuration::set('MT_KURS', 10000);
Configuration::set('MT_API_VERSION', 2);
Configuration::set('MT_PAYMENT_TYPE','vtweb');
if (!isset($config['MT_DISPLAY_TITLE']))
Configuration::set('MT_DISPLAY_TITLE', "Online Payment via Midtrans");
if (!isset($config['MT_DISPLAY_DESCRIPTION']))
Configuration::set('MT_DISPLAY_DESCRIPTION', "Payment will be displayed on the next step");
if (!isset($config['MT_3D_SECURE']))
Configuration::set('MT_3D_SECURE', 1);
if (!isset($config['MT_PAYMENT_SUCCESS_STATUS_MAP']))
Configuration::set('MT_PAYMENT_SUCCESS_STATUS_MAP', 2); //id for "payment accepted"
if (!isset($config['MT_PAYMENT_FAILURE_STATUS_MAP']))
Configuration::set('MT_PAYMENT_FAILURE_STATUS_MAP', 8); //id for "payment error"
if (!isset($config['MT_MINAMOUNT']))
Configuration::set('MT_MINAMOUNT', 500000);
// Additional feature vars
if (!isset($config['MT_ENABLED_ADV']))
Configuration::set('MT_ENABLED_ADV', 0);
if (!isset($config['MT_ENABLED_MIGS_BTN']))
Configuration::set('MT_ENABLED_MIGS_BTN', 0);
if (!isset($config['MT_TITLE_MIGS_BTN']))
Configuration::set('MT_TITLE_MIGS_BTN', "Online Payment via Midtrans - MIGS channel");
if (!isset($config['MT_BINS_MIGS_BTN']))
Configuration::set('MT_BINS_MIGS_BTN', "");
if (!isset($config['MT_ACQ_MIGS_BTN']))
Configuration::set('MT_ACQ_MIGS_BTN', "");
if (!isset($config['MT_ENABLED_INSTALLMENTMIGS_BTN']))
Configuration::set('MT_ENABLED_INSTALLMENTMIGS_BTN', 0);
if (!isset($config['MT_DISABLE_NON_MIGS_BTN']))
Configuration::set('MT_DISABLE_NON_MIGS_BTN', 0);
if (!isset($config['MT_ENABLED_INSTALLMENTMIGS_BTN']))
Configuration::set('MT_ENABLED_INSTALLMENTMIGS_BTN', 0);
if (!isset($config['MT_TITLE_INSTALLMENTMIGS_BTN']))
Configuration::set('MT_TITLE_INSTALLMENTMIGS_BTN', "Credit Card Installment Payment via Midtrans - MIGS channel");
if (!isset($config['MT_BINS_INSTALLMENTMIGS_BTN']))
Configuration::set('MT_BINS_INSTALLMENTMIGS_BTN', "");
if (!isset($config['MT_ACQ_INSTALLMENTMIGS_BTN']))
Configuration::set('MT_ACQ_INSTALLMENTMIGS_BTN', "");
if (!isset($config['MT_ENABLED_INSTALLMENTOFF_BTN']))
Configuration::set('MT_ENABLED_INSTALLMENTOFF_BTN', 0);
if (!isset($config['MT_TITLE_INSTALLMENTOFF_BTN']))
Configuration::set('MT_TITLE_INSTALLMENTOFF_BTN', "Credit Card Installment for other bank via Midtrans");
if (!isset($config['MT_BINS_INSTALLMENTOFF_BTN']))
Configuration::set('MT_BINS_INSTALLMENTOFF_BTN', "");
if (!isset($config['MT_TERM_INSTALLMENTOFF_BTN']))
Configuration::set('MT_TERM_INSTALLMENTOFF_BTN', "");
if (!isset($config['MT_ENABLED_INSTALLMENTON_BTN']))
Configuration::set('MT_ENABLED_INSTALLMENTON_BTN', 0);
if (!isset($config['MT_TITLE_INSTALLMENTON_BTN']))
Configuration::set('MT_TITLE_INSTALLMENTON_BTN', "Credit Card Installment via Midtrans");
if (!isset($config['MT_BINS_INSTALLMENTON_BTN']))
Configuration::set('MT_BINS_INSTALLMENTON_BTN', "");
if (!isset($config['MT_ENABLED_PROMO_BTN']))
Configuration::set('MT_ENABLED_PROMO_BTN', 0);
if (!isset($config['MT_TITLE_PROMO_BTN']))
Configuration::set('MT_TITLE_PROMO_BTN', "Online Payment Promo via Midtrans");
if (!isset($config['MT_METHOD_PROMO_BTN']))
Configuration::set('MT_METHOD_PROMO_BTN', "");
if (!isset($config['MT_BINS_PROMO_BTN']))
Configuration::set('MT_BINS_PROMO_BTN', "");
if (!isset($config['MT_PROMO_CODE']))
Configuration::set('MT_PROMO_CODE', "");
if (!isset($config['MT_PROMO_CUSTOM_FIELDS']))
Configuration::set('MT_PROMO_CUSTOM_FIELDS', "");
if (!isset($config['MT_MINAMOUNT_PROMO']))
Configuration::set('MT_MINAMOUNT_PROMO', 10000);
if (!isset($config['MT_ENABLED_EXPIRY']))
Configuration::set('MT_ENABLED_EXPIRY', 0);
if (!isset($config['MT_EXPIRY_DURATION']))
Configuration::set('MT_EXPIRY_DURATION', 24);
if (!isset($config['MT_EXPIRY_UNIT']))
Configuration::set('MT_EXPIRY_UNIT', "hours");
if (!isset($config['MT_ENABLED_SAVECARD']))
Configuration::set('MT_ENABLED_SAVECARD', 0);
if (!isset($config['MT_ENABLED_FIELDS']))
Configuration::set('MT_ENABLED_FIELDS', 0);
if (!isset($config['MT_FILEDS']))
Configuration::set('MT_FILEDS', "");
if (!isset($config['MT_ENABLED_CUSTOMVA_BTN']))
Configuration::set('MT_ENABLED_CUSTOMVA_BTN', 0);
if (!isset($config['MT_LIST_CUSTOMVA']))
Configuration::set('MT_LIST_CUSTOMVA', "bca,mandiri,permata,other_va");
if (!isset($config['MT_ENABLED_IGNORE_DENY']))
Configuration::set('MT_ENABLED_IGNORE_DENY', 0);
if (!isset($config['MT_ENABLED_REDIRECT']))
Configuration::set('MT_ENABLED_REDIRECT', 0);
if (!isset($config['MT_ENABLED_MAP_FINISH_URL']))
Configuration::set('MT_ENABLED_MAP_FINISH_URL', 0);
parent::__construct();
$this->displayName = $this->l('Midtrans Pay');
$this->description = $this->l('Accept payments for your products via Midtrans payment gateway.');
$this->confirmUninstall = $this->l('Are you sure about uninstalling Midtrans pay?');
if (!count(Currency::checkPaymentCurrencies($this->id)))
$this->warning = $this->l('No currency has been set for this module.');
// Retrocompatibility
$this->initContext();
}
public function isOldPrestashop()
{
return version_compare(Configuration::get('PS_VERSION_DB'), '1.5') == -1;
}
public function install()
{
// create a new order state for Midtrans, since Prestashop won't assign order ID unless it is validated,
// and no default order states matches the state we want. Assigning order_id with uniqid() will confuse
// users in the future
$mt_order_state = new OrderStateCore();
$mt_order_state->name = array((int)Configuration::get('PS_LANG_DEFAULT') => 'Awaiting Midtrans payment');;
$mt_order_state->module_name = 'midtranspay';
if ($this->isOldPrestashop()) {
$mt_order_state->color = '#0000FF';
} else
{
$mt_order_state->color = 'RoyalBlue';
}
$mt_order_state->unremovable = false;
$mt_order_state->add();
Configuration::updateValue('MT_ORDER_STATE_ID', $mt_order_state->id);
Configuration::updateValue('MT_API_VERSION', 2);
if (!parent::install() ||
!$this->registerHook('payment') ||
!$this->registerHook('header') ||
!$this->registerHook('backOfficeHeader') ||
!$this->registerHook('orderConfirmation') ||
!$this->registerHook('paymentReturn') ||
!$this->registerHook('paymentOptions')
)
return false;
// Set default config values
Configuration::updateGlobalValue('MT_DISPLAY_TITLE', "Online Payment via Midtrans");
Configuration::updateGlobalValue('MT_DISPLAY_DESCRIPTION', "Payment will be displayed on the next step");
Configuration::updateGlobalValue('MT_3D_SECURE', 1);
Configuration::updateGlobalValue('MT_PAYMENT_SUCCESS_STATUS_MAP', 2); //id for "payment accepted"
Configuration::updateGlobalValue('MT_PAYMENT_FAILURE_STATUS_MAP', 8); //id for "payment error"
Configuration::updateGlobalValue('MT_PAYMENT_CHALLENGE_STATUS_MAP', $mt_order_state->id); //id for newly created midtrans custom awaiting status
Configuration::updateGlobalValue('MT_MINAMOUNT', 500000);
Configuration::updateGlobalValue('MT_ENABLED_ADV', 0);
Configuration::updateGlobalValue('MT_ENABLED_MIGS_BTN', 0);
Configuration::updateGlobalValue('MT_TITLE_MIGS_BTN', "Online Payment via Midtrans - MIGS channel");
Configuration::updateGlobalValue('MT_BINS_MIGS_BTN', "");
Configuration::updateGlobalValue('MT_ACQ_MIGS_BTN', "");
Configuration::updateGlobalValue('MT_ENABLED_INSTALLMENTMIGS_BTN', 0);
Configuration::updateGlobalValue('MT_DISABLE_NON_MIGS_BTN', 0);
Configuration::updateGlobalValue('MT_ENABLED_INSTALLMENTMIGS_BTN', 0);
Configuration::updateGlobalValue('MT_TITLE_INSTALLMENTMIGS_BTN', "Credit Card Installment Payment via Midtrans - MIGS channel");
Configuration::updateGlobalValue('MT_BINS_INSTALLMENTMIGS_BTN', "");
Configuration::updateGlobalValue('MT_ACQ_INSTALLMENTMIGS_BTN', "");
Configuration::updateGlobalValue('MT_ENABLED_INSTALLMENTOFF_BTN', 0);
Configuration::updateGlobalValue('MT_TITLE_INSTALLMENTOFF_BTN', "Credit Card Installment for other bank via Midtrans");
Configuration::updateGlobalValue('MT_BINS_INSTALLMENTOFF_BTN', "");
Configuration::updateGlobalValue('MT_TERM_INSTALLMENTOFF_BTN', "6,12");
Configuration::updateGlobalValue('MT_ENABLED_INSTALLMENTON_BTN', 0);
Configuration::updateGlobalValue('MT_TITLE_INSTALLMENTON_BTN', "Credit Card Installment via Midtrans");
Configuration::updateGlobalValue('MT_BINS_INSTALLMENTON_BTN', "");
Configuration::updateGlobalValue('MT_ENABLED_PROMO_BTN', 0);
Configuration::updateGlobalValue('MT_TITLE_PROMO_BTN', "Online Payment Promo via Midtrans");
Configuration::updateGlobalValue('MT_METHOD_PROMO_BTN', "");
Configuration::updateGlobalValue('MT_BINS_PROMO_BTN', "");
Configuration::updateGlobalValue('MT_PROMO_CODE', "");
Configuration::updateGlobalValue('MT_PROMO_CUSTOM_FIELDS', "");
Configuration::updateGlobalValue('MT_MINAMOUNT_PROMO', 10000);
Configuration::updateGlobalValue('MT_ENABLED_EXPIRY', 0);
Configuration::updateGlobalValue('MT_EXPIRY_DURATION', 24);
Configuration::updateGlobalValue('MT_EXPIRY_UNIT', "hours");
Configuration::updateGlobalValue('MT_ENABLED_SAVECARD', 0);
Configuration::updateGlobalValue('MT_ENABLED_FIELDS', 0);
Configuration::updateGlobalValue('MT_FILEDS', "");
Configuration::updateGlobalValue('MT_ENABLED_CUSTOMVA_BTN', 0);
Configuration::updateGlobalValue('MT_LIST_CUSTOMVA', "");
Configuration::updateGlobalValue('MT_ENABLED_IGNORE_DENY', 0);
Configuration::updateGlobalValue('MT_ENABLED_REDIRECT', 0);
Configuration::updateGlobalValue('MT_ENABLED_MAP_FINISH_URL', 0);
return true;
}
public function uninstall()
{
$status = true;
foreach ($this->hooks as $hook) {
$this->unregisterHook($hook);
}
$midtrans_payment_waiting_order_state_id = Configuration::get('MT_ORDER_STATE_ID');
if ($midtrans_payment_waiting_order_state_id)
{
$order_state = new OrderStateCore($midtrans_payment_waiting_order_state_id);
$order_state->delete();
}
foreach ($this->config_keys as $key) {
Configuration::deleteByName($key);
}
if (!parent::uninstall())
$status = false;
return $status;
}
private function _postValidation()
{
if (Tools::isSubmit('btnSubmit'))
{
if (Tools::getValue('MT_API_VERSION') == 2)
{
if (!Tools::getValue('MT_CLIENT_KEY'))
$this->_postErrors[] = $this->l('Client Key is required.');
if (!Tools::getValue('MT_SERVER_KEY'))
$this->_postErrors[] = $this->l('Server Key is required.');
}
// validate conversion rate existence
if (!Currency::exists('IDR', null) && !Tools::getValue('MT_KURS'))
{
$this->_postErrors[] = $this->l('Currency conversion rate must be filled when IDR is not installed in the system.');
}
}
}
private function _postProcess()
{
if (Tools::isSubmit('btnSubmit'))
{
foreach ($this->config_keys as $key) {
Configuration::updateValue($key, Tools::getValue($key));
}
}
$this->_html .= '<div class="alert alert-success conf confirm"> '.$this->l('Settings updated').'</div>';
}
private function _displayMidtransPay()
{
if (version_compare(Configuration::get('PS_VERSION_DB'), '1.5') == -1)
{
$output = $this->context->smarty->fetch(__DIR__ . '/views/templates/hook/infos.tpl');
$this->_html .= $output;
} else
{
$this->_html .= $this->display(__FILE__, 'infos.tpl');
}
}
private function _displayMidtransPayOld()
{
$this->_html .= '<img src="../modules/midtranspay/Midtrans.png" style="float:left; margin-right:15px;"><b>'.$this->l('This module allows payment via midtrans.').'</b><br/><br/>
'.$this->l('Payment via midtrans.').'<br /><br /><br />';
}
private function _displayForm()
{
if (version_compare(Configuration::get('PS_VERSION_DB'), '1.5') == -1) {
// retrocompatibility with Prestashop 1.4
$this->_displayFormOld();
} else
{
$this->_displayFormNew();
}
}
public function getConfigFieldsValues()
{
$result = array();
foreach ($this->config_keys as $key) {
$result[$key] = Tools::getValue($key, Configuration::get($key));
}
//error_log('message fields_value'); // debug
//error_log(print_r($result,true)); // debug
return $result;
}
private function _displayFormNew()
{
$order_states = array();
foreach (OrderState::getOrderStates($this->context->language->id) as $state) {
array_push($order_states, array(
'id_option' => $state['id_order_state'],
'name' => $state['name']
)
);
}
$installments_options = array();
foreach (array('BNI', 'MANDIRI') as $bank) {
$installments_options[$bank] = array();
foreach (array(3, 6, 12) as $months) {
array_push($installments_options[$bank], array(
'id_option' => $bank . '_' . $months,
'name' => $months . ' Months'
));
}
}
$environments = array(
array(
'id_option' => 'development',
'name' => 'Development'
),
array(
'id_option' => 'production',
'name' => 'Production'
)
);
$installment_type = array(
array(
'id_option' => 'off',
'name' => 'Off'
),
array(
'id_option' => 'all_product',
'name' => 'All Products'
),
array(
'id_option' => 'certain_product',
'name' => 'Certain Product'
)
);
$fields_form = array(
'form' => array(
'legend' => array(
'title' => 'Basic Information',
'icon' => 'icon-cogs'
),
'input' => array(
array(
'type' => 'text',
'label' => 'Payment Option Display Text',
'name' => 'MT_DISPLAY_TITLE',
'required' => true,
'desc' => 'Customize payment option title that will be displayed to your customer when they checkout. e.g: Credit Card Payment, Online Payment etc.'
),
array(
'type' => 'text',
'label' => 'Payment Option Description Text',
'name' => 'MT_DISPLAY_DESCRIPTION',
'required' => false,
'desc' => 'Customize payment option description'
),
array(
'type' => 'select',
'label' => 'Environment',
'name' => 'MT_ENVIRONMENT',
'required' => true,
'options' => array(
'query' => $environments,
'id' => 'id_option',
'name' => 'name'
),
'class' => 'v2_settings sensitive'
),
array(
'type' => 'text',
'label' => 'Merchant ID',
'name' => 'MT_MERCHANT_ID',
'required' => true,
'desc' => 'Refer to Merchant Administration Portal (Menu: Settings > Access Key) to get your Merchant ID (e.g M012345).',
'class' => 'v1_vtdirect_settings v2_settings sensitive'
),
array(
'type' => 'text',
'label' => 'Client Key',
'name' => 'MT_CLIENT_KEY',
'required' => true,
'desc' => 'Refer to Merchant Administration Portal (Menu: Settings > Access Key) to get your Client Key.',
'class' => 'v1_vtdirect_settings v2_settings sensitive'
),
array(
'type' => 'text',
'label' => 'Server Key',
'name' => 'MT_SERVER_KEY',
'required' => true,
'desc' => 'Refer to Merchant Administration Portal (Menu: Settings > Access Key) to get your Server Key.',
'class' => 'v1_vtdirect_settings v2_settings sensitive'
),
array(
'type' => (version_compare(Configuration::get('PS_VERSION_DB'), '1.6') == -1)?'radio':'switch',
'label' => 'Enable 3D Secure?',
'name' => 'MT_3D_SECURE',
'required' => true,
'is_bool' => true,
'values' => array(
array(
'id' => '3d_secure_yes',
'value' => 1,
'label' => 'Yes'
),
array(
'id' => '3d_secure_no',
'value' => 0,
'label' => 'No'
)
),
'desc' => 'You must enable 3D Secure. Please contact us if you wish to disable this feature in the Production environment.'
//'class' => ''
),
array(
'type' => 'select',
'label' => 'Map payment SUCCESS status to:',
'name' => 'MT_PAYMENT_SUCCESS_STATUS_MAP',
'required' => true,
'options' => array(
'query' => $order_states,
'id' => 'id_option',
'name' => 'name'
),
//'class' => ''
),
array(
'type' => 'select',
'label' => 'Map payment FAILURE status to:',
'name' => 'MT_PAYMENT_FAILURE_STATUS_MAP',
'required' => true,
'options' => array(
'query' => $order_states,
'id' => 'id_option',
'name' => 'name'
),
//'class' => ''
),
array(
'type' => 'select',
'label' => 'Map payment PENDING/CHALLENGE status to:',
'name' => 'MT_PAYMENT_CHALLENGE_STATUS_MAP',
'required' => true,
'options' => array(
'query' => $order_states,
'id' => 'id_option',
'name' => 'name'
),
//'class' => ''
),
array(
'type' => 'text',
'label' => 'IDR Conversion Rate',
'name' => 'MT_KURS',
'desc' => 'Midtrans will use this rate to convert prices to IDR when there are no default conversion system.'
),
array(
'type' => 'text',
'label' => 'Installment Minimum Amount',
'name' => 'MT_MINAMOUNT',
'desc' => 'Minimum amount to allow payment using installment.',
'class' => 'advanced-insamount'
),
array(
'type' => (version_compare(Configuration::get('PS_VERSION_DB'), '1.6') == -1)?'radio':'switch',
'label' => '<strong>Show Advanced Features</strong>',
'name' => 'MT_ENABLED_ADV',
'required' => false,
'is_bool' => true,
'values' => array(
array(
'id' => 'advanced_feature_yes',
'value' => 1,
'label' => 'Yes'
),
array(
'id' => 'advanced_feature_no',
'value' => 0,
'label' => 'No'
)
),
'desc' => ''
),
// Installment Online
array(
'type' => (version_compare(Configuration::get('PS_VERSION_DB'), '1.6') == -1)?'radio':'switch',
'label' => '<strong>Enable Online Installment?</strong>',
'name' => 'MT_ENABLED_INSTALLMENTON_BTN',
'required' => false,
'is_bool' => true,
'values' => array(
array(
'id' => 'installmenton_btn_yes',
'value' => 1,
'label' => 'Yes'
),
array(
'id' => 'installmenton_btn_no',
'value' => 0,
'label' => 'No'
)
),
// 'desc' => 'Enable online installment payment support, please makesure you have complete the business requirements.',
'class' => 'advanced-on'
),
array(
'type' => 'text',
'label' => 'Payment Button Online Installment Display Text',
'name' => 'MT_TITLE_INSTALLMENTON_BTN',
'required' => false,
'desc' => 'Customize payment button title that will be displayed to your customer when they checkout using Online Installment. e.g: Credit Card Installment Payment etc.',
'class' => 'advanced-on'
),
array(
'type' => 'text',
'label' => 'Allowed CC BINs for Online Installment',
'name' => 'MT_BINS_INSTALLMENTON_BTN',
'desc' => 'Allowed Credit Card BINs for Online Installment payment, separate payment method code with coma. e.g: 5,4811,bni. Leave blank if you are not sure.',
'class' => 'advanced-on'
),
// Installment Offline
array(
'type' => (version_compare(Configuration::get('PS_VERSION_DB'), '1.6') == -1)?'radio':'switch',
'label' => '<strong>Enable Offline Installment?</strong>',
'name' => 'MT_ENABLED_INSTALLMENTOFF_BTN',
'required' => false,
'is_bool' => true,
'values' => array(
array(
'id' => 'installmentoff_btn_yes',
'value' => 1,
'label' => 'Yes'
),
array(
'id' => 'installmentoff_btn_no',
'value' => 0,
'label' => 'No'
)
),
// 'desc' => 'Enable offline installment payment support, please makesure you have complete the business requirements.',
'class' => 'advanced-off'
//'class' => ''
),
array(
'type' => 'text',
'label' => 'Payment Button Offline Installment Display Text',
'name' => 'MT_TITLE_INSTALLMENTOFF_BTN',
'required' => false,
'desc' => 'Customize payment button title that will be displayed to your customer when they checkout using Offline Installment. e.g: Credit Card Installment Payment etc.',
'class' => 'advanced-off'
),
array(
'type' => 'text',
'label' => 'Allowed CC BINs for Offline Installment',
'name' => 'MT_BINS_INSTALLMENTOFF_BTN',
'desc' => 'Allowed Credit Card BINs for Offline Installment payment. Leave blank if you are not sure.',
'class' => 'advanced-off'
),
array(
'type' => 'text',
'label' => 'Offline Installment Terms',
'name' => 'MT_TERM_INSTALLMENTOFF_BTN',
'desc' => 'Allowed Offline Installment terms. Separate terms with coma. e.g: 6,12.',
'class' => 'advanced-off'
),
// MIGS
array(
'type' => (version_compare(Configuration::get('PS_VERSION_DB'), '1.6') == -1)?'radio':'switch',
'label' => '<strong>Enable MIGS Channel Acquiring?</strong>',
'name' => 'MT_ENABLED_MIGS_BTN',
'required' => false,
'is_bool' => true,
'values' => array(
array(
'id' => 'migs_btn_yes',
'value' => 1,
'label' => 'Yes'
),
array(
'id' => 'migs_btn_no',
'value' => 0,
'label' => 'No'
)
),
// 'desc' => 'Enable additional button for Credit Card with MIGS channel as acquirer',
'class' => 'advanced-migs'
//'class' => ''
),
array(
'type' => 'text',
'label' => 'Payment Button CC MIGS fullpayment Display Text',
'name' => 'MT_TITLE_MIGS_BTN',
'required' => false,
'desc' => 'Customize payment button title that will be displayed to your customer when they checkout for CC MIGS fullpayment. e.g: BCA Credit Card, Maybank Credit Card, etc.',
'class' => 'advanced-migs'
),
array(
'type' => 'text',
'label' => 'Allowed CC BINs for CC MIGS fullpayment',
'name' => 'MT_BINS_MIGS_BTN',
'desc' => 'Allowed Credit Card BINs for MIGS Credit Card payment. Leave blank if you are not sure.',
'class' => 'advanced-migs'
),
array(
'type' => 'text',
'label' => 'Acquiring Bank CC MIGS fullpayment',
'name' => 'MT_ACQ_MIGS_BTN',
'desc' => 'Specify your acquiring bank for MIGS Credit Card Payment. Leave blank if you are not sure',
'class' => 'advanced-migs'
),
array(
'type' => (version_compare(Configuration::get('PS_VERSION_DB'), '1.6') == -1)?'radio':'switch',
'label' => '<strong>Disable Non MIGS Channel Acquiring button?</strong>',
'desc' => 'Select yes if you only have MIGS channel acquiring',
'name' => 'MT_DISABLE_NON_MIGS_BTN',
'required' => false,
'is_bool' => true,
'values' => array(
array(
'id' => 'disable_non_migs_btn_yes',
'value' => 1,
'label' => 'Yes'
),
array(
'id' => 'disable_non_migs_btn_no',
'value' => 0,
'label' => 'No'
)
),
// 'desc' => 'Enable additional button for Credit Card with MIGS channel as acquirer',
'class' => 'advanced-migs'
//'class' => ''
),
// Installment MIGS
array(
'type' => (version_compare(Configuration::get('PS_VERSION_DB'), '1.6') == -1)?'radio':'switch',
'label' => '<strong>Enable Online Installment MIGS Channel?</strong>',
'name' => 'MT_ENABLED_INSTALLMENTMIGS_BTN',
'required' => false,
'is_bool' => true,
'values' => array(
array(
'id' => 'installmentmigs_btn_yes',
'value' => 1,
'label' => 'Yes'
),
array(
'id' => 'installmentmigs_btn_no',
'value' => 0,
'label' => 'No'
)
),
// 'desc' => 'Enable online installment (MIGS channel) payment support, please makesure you have complete the business requirements.',
'class' => 'advanced-insmigs'
//'class' => ''
),
array(
'type' => 'text',
'label' => 'Payment Button CC Online Installment MIGS fullpayment Display Text',
'name' => 'MT_TITLE_INSTALLMENTMIGS_BTN',
'required' => false,
'desc' => 'Customize payment button title that will be displayed to your customer when they checkout for CC MIGS online installment. e.g: Installment BCA Credit Card, Maybank Installment, etc.',
'class' => 'advanced-insmigs'
),
array(
'type' => 'text',
'label' => 'Allowed CC BINs for CC Online Installment MIGS',
'name' => 'MT_BINS_INSTALLMENTMIGS_BTN',
'desc' => 'Allowed Credit Card BINs for MIGS online installment payment. Leave blank if you are not sure.',
'class' => 'advanced-insmigs'
),
array(
'type' => 'text',
'label' => 'Acquiring Bank CC Online Installment MIGS',
'name' => 'MT_ACQ_INSTALLMENTMIGS_BTN',
'desc' => 'Specify your acquiring bank for MIGS Online Installment. Leave blank if you are not sure.',
'class' => 'advanced-insmigs'
),
// Promo payment
array(
'type' => (version_compare(Configuration::get('PS_VERSION_DB'), '1.6') == -1)?'radio':'switch',
'label' => '<strong>Enable Bank Promotion Payment?</strong>',
'name' => 'MT_ENABLED_PROMO_BTN',
'required' => false,
'is_bool' => true,
'values' => array(
array(
'id' => 'promo_btn_yes',
'value' => 1,
'label' => 'Yes'
),
array(
'id' => 'promo_btn_no',
'value' => 0,
'label' => 'No'
)
),
// 'desc' => 'Enable additional button for promo/discount, please makesure you have promo agreement with us.',
'class' => 'advanced-promo'
//'class' => ''
),
array(
'type' => 'text',
'label' => 'Promo Button Display Text',
'name' => 'MT_TITLE_PROMO_BTN',
'required' => false,
'desc' => 'Customize payment button title that will be displayed to your customer when they checkout using Promo Button. e.g: Credit Card Promo etc.',
'class' => 'advanced-promo'
),
array(
'type' => 'text',
'label' => 'Allowed CC BINs for Promo',
'name' => 'MT_BINS_PROMO_BTN',
'desc' => 'Allowed Credit Card BINs for Promo payment, separate payment method code with coma. e.g: 5,4811,bni. Leave blank if you are not sure.',
'class' => 'advanced-promo'
),
array(
'type' => 'text',
'label' => 'Allowed Payment Method for Promo',
'name' => 'MT_METHOD_PROMO_BTN',
'desc' => 'Customize allowed payment method, separate payment method code with coma. e.g: bank_transfer,credit_card. Leave blank if you are not sure.',
'class' => 'advanced-promo'
),
array(
'type' => 'text',
'label' => 'Promo Code',
'name' => 'MT_PROMO_CODE',
'desc' => 'Promo Code that would be used for discount. Leave blank if you are not sure, default code will be used.',
'class' => 'advanced-promo'
),
array(
'type' => 'text',
'label' => 'Custom Fields for Promo',
'name' => 'MT_PROMO_CUSTOM_FIELDS',
'required' => false,
'desc' => 'Custom fields to be sent to merchant Up to 3 custom fields separated by coma (,). e.g: promogopay1',
'class' => 'advanced-promo'
),
array(
'type' => 'text',
'label' => 'Promo Minimum Amount',
'name' => 'MT_MINAMOUNT_PROMO',
'desc' => 'Minimum amount to allow payment using promo.',
'class' => 'advanced-promosamount'
),
// SaveCard
array(
'type' => (version_compare(Configuration::get('PS_VERSION_DB'), '1.6') == -1)?'radio':'switch',
'label' => '<strong>Enable Save Card?</strong>',
'name' => 'MT_ENABLED_SAVECARD',
'required' => false,
'is_bool' => true,
'values' => array(
array(
'id' => 'savecard_btn_yes',
'value' => 1,
'label' => 'Yes'
),
array(
'id' => 'savecard_btn_no',
'value' => 0,
'label' => 'No'
)
),
'class' => 'advanced-savecard'
//'class' => ''
),
// Enable Snap Redirection instead of popup
array(
'type' => (version_compare(Configuration::get('PS_VERSION_DB'), '1.6') == -1)?'radio':'switch',
'label' => 'Payment page redirect to Midtrans instead of popup?',
'name' => 'MT_ENABLED_REDIRECT',
'required' => false,
'is_bool' => true,
'values' => array(
array(
'id' => 'redirect_btn_yes',
'value' => 1,
'label' => 'Yes'
),
array(
'id' => 'redirect_btn_no',
'value' => 0,
'label' => 'No'
)
),
'class' => 'advanced-redirect'
//'class' => ''
),
// Enable use of Dashboard Finish URL instead of finish url hardcoded by module
array(
'type' => (version_compare(Configuration::get('PS_VERSION_DB'), '1.6') == -1)?'radio':'switch',
'label' => 'Use Dashboard configured finish url instead of auto configured url?',
'name' => 'MT_ENABLED_MAP_FINISH_URL',
'required' => false,
'is_bool' => true,
'values' => array(
array(
'id' => 'map_finish_url_btn_yes',
'value' => 1,
'label' => 'Yes'
),
array(
'id' => 'map_finish_url_btn_no',
'value' => 0,
'label' => 'No'
)
),
'class' => 'advanced-mapfinishurl'
//'class' => ''
),
// Custom VA button
array(
'type' => (version_compare(Configuration::get('PS_VERSION_DB'), '1.6') == -1)?'radio':'switch',
'label' => '<strong>Enable Separated Bank Transfer Button?</strong>',
'name' => 'MT_ENABLED_CUSTOMVA_BTN',
'required' => false,
'is_bool' => true,
'values' => array(
array(
'id' => 'customva_btn_yes',
'value' => 1,
'label' => 'Yes'
),
array(
'id' => 'customva_btn_no',
'value' => 0,
'label' => 'No'
)
),
'class' => 'advanced-fields'
//'class' => ''
),
array(
'type' => 'text',
'label' => 'Displayed Banks',
'name' => 'MT_LIST_CUSTOMVA',
'required' => true,
'desc' => 'bank names separated by coma (,). e.g: permata,mandiri,bca,other_va',
'class' => 'advanced-customva'
),
// Custom Expiry
array(
'type' => (version_compare(Configuration::get('PS_VERSION_DB'), '1.6') == -1)?'radio':'switch',
'label' => '<strong>Enable Custom Expiry Feature?</strong>',
'name' => 'MT_ENABLED_EXPIRY',
'required' => false,
'is_bool' => true,
'values' => array(
array(
'id' => 'expiry_btn_yes',
'value' => 1,
'label' => 'Yes'
),
array(
'id' => 'expiry_btn_no',
'value' => 0,
'label' => 'No'
)
),
'class' => 'advanced-expiry'
//'class' => ''
),
array(
'type' => 'text',
'label' => 'Duration',
'name' => 'MT_EXPIRY_DURATION',
'required' => false,
'desc' => 'Duration in number. e.g: 30.',
'class' => 'advanced-expiry'
),
array(
'type' => 'text',
'label' => 'Time Unit',
'name' => 'MT_EXPIRY_UNIT',