@@ -237,7 +237,7 @@ public function pay()
237237 $ cancel_timer = (int )$ metaData ['cryptapi_order_timestamp ' ] + (int )$ this ->config ->get ('payment_cryptapi_order_cancelation_timeout ' ) - time ();
238238
239239 $ params = [
240- 'module_path ' => \ Opencart \ Extension \ CryptAPI \ System \ Library \CryptAPIHelper:: base_url () . '/extension/cryptapi/catalog/view/image/ ' ,
240+ 'module_path ' => HTTP_SERVER . '/extension/cryptapi/catalog/view/image/ ' ,
241241 'header ' => $ this ->load ->controller ('common/header ' ),
242242 'footer ' => $ this ->load ->controller ('common/footer ' ),
243243 'currency_symbol_left ' => $ currencySymbolLeft ,
@@ -251,7 +251,7 @@ public function pay()
251251 'qr_code ' => $ metaData ['cryptapi_qrcode ' ],
252252 'qr_code_value ' => $ metaData ['cryptapi_qrcode_value ' ],
253253 'show_branding ' => $ this ->config ->get ('payment_cryptapi_branding ' ),
254- 'branding_logo ' => \ Opencart \ Extension \ CryptAPI \ System \ Library \CryptAPIHelper:: base_url () . '/extension/cryptapi/catalog/view/image/payment.png ' ,
254+ 'branding_logo ' => HTTP_SERVER . '/extension/cryptapi/catalog/view/image/payment.png ' ,
255255 'qr_code_setting ' => $ this ->config ->get ('payment_cryptapi_qrcode ' ),
256256 'order_timestamp ' => $ order ['total ' ],
257257 'order_cancelation_timeout ' => $ this ->config ->get ('payment_cryptapi_order_cancelation_timeout ' ),
@@ -292,30 +292,37 @@ public function after_purchase(&$route, &$data, &$output)
292292
293293 $ nonce = $ metaData ['cryptapi_nonce ' ];
294294
295- // Send the E-mail with the order URL
296- $ mail = new \Opencart \System \Library \Mail ($ this ->config ->get ('config_mail_engine ' ));
297- $ mail ->parameter = $ this ->config ->get ('config_mail_parameter ' );
298- $ mail ->smtp_hostname = $ this ->config ->get ('config_mail_smtp_hostname ' );
299- $ mail ->smtp_username = $ this ->config ->get ('config_mail_smtp_username ' );
300- $ mail ->smtp_password = html_entity_decode ($ this ->config ->get ('config_mail_smtp_password ' ), ENT_QUOTES , 'UTF-8 ' );
301- $ mail ->smtp_port = $ this ->config ->get ('config_mail_smtp_port ' );
302- $ mail ->smtp_timeout = $ this ->config ->get ('config_mail_smtp_timeout ' );
303-
304- $ subject = sprintf ($ this ->language ->get ('order_subject ' ), $ order ['order_id ' ], strtoupper ($ metaData ['cryptapi_currency ' ]));
305-
306- $ data ['order_greeting ' ] = sprintf ($ this ->language ->get ('order_greeting ' ), $ order ['order_id ' ], strtoupper ($ metaData ['cryptapi_currency ' ]));
307- $ data ['order_url ' ] = $ metaData ['cryptapi_payment_url ' ];
308- $ data ['store ' ] = html_entity_decode ($ order ['store_name ' ], ENT_QUOTES , 'UTF-8 ' );
309- $ data ['store_url ' ] = $ order ['store_url ' ];
310-
311- $ html = $ this ->load ->view ('extension/cryptapi/payment/cryptapi_email ' , $ data );
312-
313- $ mail ->setTo ($ order ['email ' ]);
314- $ mail ->setFrom ($ this ->config ->get ('config_email ' ));
315- $ mail ->setSender (html_entity_decode ($ order ['store_name ' ], ENT_QUOTES , 'UTF-8 ' ));
316- $ mail ->setSubject (html_entity_decode ($ subject , ENT_QUOTES , 'UTF-8 ' ));
317- $ mail ->setHtml ($ html );
318- $ mail ->send ();
295+ /**
296+ * Tries sending an e-mail. Will fail if configuration is not set but won't throw an error.
297+ */
298+ try {
299+ // Send the E-mail with the order URL
300+ $ mail = new \Opencart \System \Library \Mail ($ this ->config ->get ('config_mail_engine ' ));
301+ $ mail ->parameter = $ this ->config ->get ('config_mail_parameter ' );
302+ $ mail ->smtp_hostname = $ this ->config ->get ('config_mail_smtp_hostname ' );
303+ $ mail ->smtp_username = $ this ->config ->get ('config_mail_smtp_username ' );
304+ $ mail ->smtp_password = html_entity_decode ($ this ->config ->get ('config_mail_smtp_password ' ), ENT_QUOTES , 'UTF-8 ' );
305+ $ mail ->smtp_port = $ this ->config ->get ('config_mail_smtp_port ' );
306+ $ mail ->smtp_timeout = $ this ->config ->get ('config_mail_smtp_timeout ' );
307+
308+ $ subject = sprintf ($ this ->language ->get ('order_subject ' ), $ order ['order_id ' ], strtoupper ($ metaData ['cryptapi_currency ' ]));
309+
310+ $ data ['order_greeting ' ] = sprintf ($ this ->language ->get ('order_greeting ' ), $ order ['order_id ' ], strtoupper ($ metaData ['cryptapi_currency ' ]));
311+ $ data ['order_url ' ] = $ metaData ['cryptapi_payment_url ' ];
312+ $ data ['store ' ] = html_entity_decode ($ order ['store_name ' ], ENT_QUOTES , 'UTF-8 ' );
313+ $ data ['store_url ' ] = $ order ['store_url ' ];
314+
315+ $ html = $ this ->load ->view ('extension/cryptapi/payment/cryptapi_email ' , $ data );
316+
317+ $ mail ->setTo ($ order ['email ' ]);
318+ $ mail ->setFrom ($ this ->config ->get ('config_email ' ));
319+ $ mail ->setSender (html_entity_decode ($ order ['store_name ' ], ENT_QUOTES , 'UTF-8 ' ));
320+ $ mail ->setSubject (html_entity_decode ($ subject , ENT_QUOTES , 'UTF-8 ' ));
321+ $ mail ->setHtml ($ html );
322+ $ mail ->send ();
323+ } catch (\Exception $ exception ) {
324+ # don't do anything
325+ }
319326
320327 return $ this ->response ->redirect ($ this ->url ->link ('extension/cryptapi/payment/cryptapi|pay ' , 'order_id= ' . $ order ['order_id ' ] . 'nonce= ' . $ nonce , true ));
321328 }
@@ -418,9 +425,9 @@ public function cron($load_class = true)
418425 $ this ->load ->model ('extension/cryptapi/payment/cryptapi ' );
419426 $ this ->response ->addHeader ('Content-Type: application/json ' );
420427
421- $ order_timeout = intval ( $ this ->config ->get ('payment_cryptapi_order_cancelation_timeout ' ) );
422- $ value_refresh = intval ( $ this ->config ->get ('payment_cryptapi_refresh_values ' ) );
423- $ qrcode_size = intval ( $ this ->config ->get ('payment_cryptapi_qrcode_size ' ) );
428+ $ order_timeout = ( int ) $ this ->config ->get ('payment_cryptapi_order_cancelation_timeout ' );
429+ $ value_refresh = ( int ) $ this ->config ->get ('payment_cryptapi_refresh_values ' );
430+ $ qrcode_size = ( int ) $ this ->config ->get ('payment_cryptapi_qrcode_size ' );
424431
425432 $ response = $ this ->response ->setOutput (json_encode (['status ' => 'ok ' ]));
426433
@@ -447,15 +454,15 @@ public function cron($load_class = true)
447454
448455 $ history = json_decode ($ metaData ['cryptapi_history ' ], true );
449456
450- $ min_tx = floatval ( $ metaData ['cryptapi_min ' ]) ;
457+ $ min_tx = ( float ) $ metaData ['cryptapi_min ' ];
451458
452459 $ calc = \Opencart \Extension \CryptAPI \System \Library \CryptAPIHelper::calc_order ($ history , $ metaData ['cryptapi_total ' ], floatval ($ metaData ['cryptapi_total_fiat ' ]));
453460
454461 $ remaining = $ calc ['remaining ' ];
455462 $ remaining_pending = $ calc ['remaining_pending ' ];
456463 $ already_paid = $ calc ['already_paid ' ];
457464
458- if ($ value_refresh !== 0 && $ last_price_update + $ value_refresh <= time ()) {
465+ if ($ value_refresh !== 0 && ( $ last_price_update + $ value_refresh <= time () )) {
459466 if ($ remaining === $ remaining_pending ) {
460467 $ cryptapi_coin = $ metaData ['cryptapi_currency ' ];
461468
@@ -479,7 +486,7 @@ public function cron($load_class = true)
479486 $ this ->model_extension_cryptapi_payment_cryptapi ->updatePaymentData ($ order_id , 'cryptapi_last_price_update ' , time ());
480487 }
481488
482- if ($ order_timeout !== 0 && (strtotime ($ order ['date_added ' ]) + $ order_timeout ) <= time () && $ already_paid <= 0 && ( int ) $ metaData [ ' cryptapi_cancelled ' ] === 0 ) {
489+ if ($ order_timeout !== 0 && (strtotime ($ order ['date_added ' ]) + $ order_timeout ) <= time () && $ already_paid <= 0 ) {
483490 $ this ->model_checkout_order ->addHistory ($ order ['order_id ' ], 7 );
484491 $ this ->model_extension_cryptapi_payment_cryptapi ->updatePaymentData ($ order_id , 'cryptapi_cancelled ' , '1 ' );
485492 }
0 commit comments