@@ -24,7 +24,7 @@ public function __construct()
2424 $ this ->appKey = MODULE_PAYMENT_PAYLIKE_TRANSACTION_MODE == 'Test ' ? MODULE_PAYMENT_PAYLIKE_TEST_APP_KEY : MODULE_PAYMENT_PAYLIKE_APP_KEY ;
2525 $ this ->formTitle = $ _SESSION ['PAYLIKE_TITLE ' ] = MODULE_PAYMENT_PAYLIKE_TITLE ;
2626 $ this ->paymentType = MODULE_PAYMENT_PAYLIKE_PAYMENT_TYPE ;
27-
27+
2828 if (strpos ($ _SERVER ['REQUEST_URI ' ], 'action=edit ' )) {
2929 echo '<script type="text/javascript" src="includes/modules/payment/paylike/paylike_admin.js"></script> ' ;
3030 echo '<link rel="stylesheet" type="text/css" href="includes/modules/payment/paylike/paylike_admin.css"/> ' ;
@@ -92,7 +92,7 @@ public function before_process()
9292 /* After order is processed */
9393 public function after_process ()
9494 {
95- global $ insert_id , $ order, $ order_totals ;
95+ global $ insert_id , $ order ;
9696 /* If 'Instant' payment, capture transaction via Paylike API */
9797 if ($ this ->paymentType === 'Instant ' ) {
9898 /* If transaction succeed */
@@ -101,9 +101,8 @@ public function after_process()
101101 $ descriptor = "Order # $ insert_id " ;
102102 /* Init Paylike API */
103103 require ('includes/classes/paylike/init.php ' );
104-
105104 $ paylike = new \Paylike \Paylike ($ this ->appKey );
106- $ amount = end ($ order_totals );
105+ $ amount = end ($ this -> getOrderTotalsSummary () );
107106 $ apps = $ paylike ->transactions ();
108107 $ apps ->capture ($ transactionId , [
109108 'amount ' => (float )number_format ($ amount ['value ' ] * $ order ->info ['currency_value ' ], 2 , '. ' , '' ) * 100 ,
@@ -115,6 +114,28 @@ public function after_process()
115114 return false ;
116115 }
117116
117+ function getOrderTotalsSummary () {
118+ $ order_totals = [];
119+ foreach (($ GLOBALS ['order_total_modules ' ]->modules ?? []) as $ value ) {
120+ $ class = pathinfo ($ value , PATHINFO_FILENAME );
121+ if ($ GLOBALS [$ class ]->enabled ) {
122+ foreach ($ GLOBALS [$ class ]->output as $ module ) {
123+ if (tep_not_null ($ module ['title ' ]) && tep_not_null ($ module ['text ' ])) {
124+ $ order_totals [] = [
125+ 'code ' => $ GLOBALS [$ class ]->code ,
126+ 'title ' => $ module ['title ' ],
127+ 'text ' => $ module ['text ' ],
128+ 'value ' => $ module ['value ' ],
129+ 'sort_order ' => $ GLOBALS [$ class ]->sort_order ,
130+ ];
131+ }
132+ }
133+ }
134+ }
135+
136+ return $ order_totals ;
137+ }
138+
118139 /* Define module admin fields */
119140 protected function get_parameters ()
120141 {
0 commit comments