PluginProbe
MakeCommerce for WooCommerce / 2.5.1
MakeCommerce for WooCommerce v2.5.1
4.1.0 4.0.8 trunk 1.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 2.0.0 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.2 All 96 releases
← All changes | makecommerce-payment.php +146 -43 2.1.32.5.1 View file →
@@ -16,15 +16,15 @@
16 16 const MC_REFUNDED = 'REFUNDED';
17 17
18 18 const module_name = 'MakeCommerce';
19 19
20 - const billing_descriptor_dba = '';
20 + const billing_descriptor_dba = '';
21 21 const currencies_allowed = 'EUR';
22 22 const module_homepage_url = 'https://maksekeskus.ee/en/integration-modules/makecommerce-woocommerce-payment-plugin/';
23 23 const testenv_homepage_url = 'http://maksekeskus.ee/en/for-developers/test-environment/';
24 24
25 25 public $id = 'makecommerce';
26 - public $version = '2.1.3';
26 + public $version = '2.5.0';
27 27
28 28 public $payment_return_url;
29 29 public $payment_return_url_m2m;
30 30 public $payment_return_url_cancel;
@@ -37,19 +37,23 @@
37 37 protected $_banklinks = array();
38 38 protected $_banklinks_grouped;
39 39 protected $_cards = array();
40 40
41 - protected $MK;
41 + protected $MK;
42 42 protected $_init;
43 43
44 44
45 - public function __construct($init = false) {
45 + public function __construct($init = false) {
46 46 $this->_init = $init;
47 -
48 - $this->payment_return_url = site_url('/?makecommerce_return=1');
49 - $this->payment_return_url_m2m = site_url('/?makecommerce_return=1&ajax_content=1');
50 - $this->payment_return_url_cancel = site_url('/?makecommerce_return=1');
51 -
47 + if (defined('ICL_LANGUAGE_CODE')) {
48 + $this->payment_return_url = site_url('/'.ICL_LANGUAGE_CODE.'/?makecommerce_return=1');
49 + $this->payment_return_url_m2m = site_url('/'.ICL_LANGUAGE_CODE.'/?makecommerce_return=1&ajax_content=1');
50 + $this->payment_return_url_cancel = site_url('/'.ICL_LANGUAGE_CODE.'/?makecommerce_return=1');
51 + } else {
52 + $this->payment_return_url = site_url('/?makecommerce_return=1');
53 + $this->payment_return_url_m2m = site_url('/?makecommerce_return=1&ajax_content=1');
54 + $this->payment_return_url_cancel = site_url('/?makecommerce_return=1');
55 + }
52 56 // Load the form fields.
53 57 $this->init_form_fields();
54 58
55 59 // Load the settings.
@@ -56,15 +60,21 @@
56 60 $this->init_settings();
57 61
58 62 $this->initBanklinks();
59 63
60 - $this->title = $this->settings['ui_widget_title'];
61 64 if (defined('ICL_LANGUAGE_CODE') && !empty($this->settings['ui_widget_title_'.ICL_LANGUAGE_CODE])) {
62 65 $this->title = $this->settings['ui_widget_title_'.ICL_LANGUAGE_CODE];
66 + } else if (!empty($this->settings['ui_widget_title'])) {
67 + $this->title = $this->settings['ui_widget_title'];
68 + } else {
69 + $this->title = '';
63 70 }
71 +
64 72 $this->method_title = 'MakeCommerce';
65 73 $this->description = true;
66 74
75 + $this->enabled = $this->settings['active'];
76 +
67 77 $this->MK = mk_get_api();
68 78 if (!$this->MK && $this->_init) {
69 79 add_action( 'admin_notices', array(&$this, 'makecommerce_api_info_missing') );
70 80 }
@@ -69,14 +79,23 @@
69 79 add_action( 'admin_notices', array(&$this, 'makecommerce_api_info_missing') );
70 80 }
71 81
72 82 $this->supports = array(
83 + 'subscriptions',
84 + 'subscription_cancellation',
85 + 'subscription_suspension',
86 + 'subscription_reactivation',
87 + 'subscription_amount_changes',
88 + 'subscription_date_changes',
89 + 'subscription_payment_method_change',
73 90 'products',
74 - 'refunds',
91 + 'refunds'
75 92 );
76 93
77 94 add_filter('query_vars', array(&$this, 'makecommerce_return_trigger'));
78 95 add_action('template_redirect', array(&$this, 'makecommerce_return_trigger_check'));
96 + add_action('woocommerce_scheduled_subscription_payment_' . $this->id, array($this, 'process_subscripion_payment_start'), 10, 2);
97 + add_action('scheduled_subscription_payment_' . $this->id, array($this, 'process_subscripion_payment_start'), 10, 2);
79 98
80 99 if($this->_init == false) {
81 100 add_action('woocommerce_update_options_payment_gateways', array(&$this, 'process_admin_options'));
82 101 add_action('woocommerce_update_options_payment_gateways_' . $this->id, array(&$this, 'process_admin_options'));
@@ -88,8 +107,9 @@
88 107 wp_enqueue_style('makecommerce', plugins_url('/css/makecommerce.css', __FILE__), array(), $this->version);
89 108 }
90 109 if (is_admin()) {
91 110 add_action( 'wp_ajax_mc_banklinks_reload', array(&$this, 'mc_banklinks_reload') );
111 +
92 112 require_once(ABSPATH.'wp-admin/includes/plugin.php');
93 113 $wc_version = get_plugin_data(__DIR__.'/../woocommerce/woocommerce.php');
94 114 if ((double)$wc_version['Version'] < 2.6) {
95 115 function sample_admin_notice__error() {
@@ -118,11 +138,12 @@
118 138 return true;
119 139 }
120 140
121 141 public function is_available() {
122 - if ($this->settings['active'] == "yes" && mk_is_api_set()) {
123 - return true;
142 + if (!($this->settings['active'] == "yes" && mk_is_api_set())) {
143 + return false;
124 144 }
145 + return parent::is_available();
125 146 }
126 147
127 148 private function initBanklinks() {
128 149 global $wpdb;
@@ -127,8 +148,9 @@
127 148 private function initBanklinks() {
128 149 global $wpdb;
129 150 global $mkDbTable;
130 151 $this->_banklinks = array();
152 + $has_subscriptions = class_exists('WC_Subscriptions_Cart') && WC_Subscriptions_Cart::cart_contains_subscription();
131 153
132 154 $tableName = $wpdb->prefix . $mkDbTable;
133 155 $methods = $wpdb->get_results('SELECT * FROM '.$tableName);
134 156
@@ -141,9 +163,11 @@
141 163 $banklinks_grouped = array();
142 164 $cards = array();
143 165 foreach($methods as $method) {
144 166 if($method->type == 'banklink') {
145 - $banklinks[] = $banklinks_grouped[$method->country][] = $method;
167 + if (!$has_subscriptions) {
168 + $banklinks[] = $banklinks_grouped[$method->country][] = $method;
169 + }
146 170 } elseif($method->type == 'card') {
147 171 $cards[] = $method;
148 172 }
149 173 }
@@ -184,9 +208,13 @@
184 208 ?>
185 209 <div class="notice notice-error is-dismissible">
186 210 <p>
187 211 <?php echo __('You have not entered the Shop ID and keys for the MakeCommerce payment module. The module will not work without them.', 'wc_makecommerce_domain'); ?>
212 + <?php if (mk_wc_version("3.4.0")) { ?>
213 + <a href="<?php echo admin_url('admin.php?page=wc-settings&tab=advanced&section=mk_api'); ?>"><?php echo __('Click here to enter them', 'wc_makecommerce_domain'); ?></a>
214 + <?php } else { ?>
188 215 <a href="<?php echo admin_url('admin.php?page=wc-settings&tab=api&section=mk_api'); ?>"><?php echo __('Click here to enter them', 'wc_makecommerce_domain'); ?></a>
216 + <?php } ?>
189 217 </p>
190 218 </div>
191 219 <?php
192 220 }
@@ -235,11 +263,12 @@
235 263 'type' => 'checkbox',
236 264 'label' => __('Enable MakeCommerce payments', 'wc_makecommerce_domain'),
237 265 'default' => 'no'
238 266 );
267 + if (mk_wc_version("3.4.0")) $a = admin_url('admin.php?page=wc-settings&tab=advanced&section=mk_api'); else $a = admin_url('admin.php?page=wc-settings&tab=api&section=mk_api');
239 268 $this->form_fields['api_title'] = array(
240 269 'title' => __('MakeCommerce API', 'wc_makecommerce_domain'),
241 - 'description' => sprintf(__('Go to <a href="%s">API settings</a> to fill in the credentials', 'wc_makecommerce_domain'), admin_url('admin.php?page=wc-settings&tab=api&section=mk_api')),
270 + 'description' => sprintf(__('Go to <a href="%s">API settings</a> to fill in the credentials', 'wc_makecommerce_domain'), $a),
242 271 'type' => 'title',
243 272 );
244 273 $this->form_fields['ui_title'] = array(
245 274 'title' => '<br>'.__('User Interface', 'wc_makecommerce_domain'),
@@ -480,13 +509,19 @@
480 509 return false;
481 510 }
482 511
483 512 $tableName = $wpdb->prefix . $mkDbTable;
513 + $sql = "select count(*) as isLogoUrlSet from information_schema.columns where table_name='".$tableName."' and column_name='logo_url'";
514 + $methodstruct = $wpdb->get_results( $sql );
515 + if ($methodstruct[0]->isLogoUrlSet == 0) {
516 + $wpdb->query('ALTER TABLE '.$tableName.' ADD COLUMN logo_url varchar(250)');
517 + }
518 +
484 519 $wpdb->query('TRUNCATE TABLE '.$tableName);
485 520
486 521 if(isset($methods->banklinks)) {
487 522 foreach($methods->banklinks as $method) {
488 - $wpdb->insert($tableName, array('type' => 'banklink', 'country' => $method->country, 'name' => $method->name, 'url' => $method->url));
523 + $wpdb->insert($tableName, array('type' => 'banklink', 'country' => $method->country, 'name' => $method->name, 'url' => $method->url, 'logo_url' => $method->logo_url));
489 524 }
490 525 $updated = true;
491 526 }
492 527
@@ -491,9 +526,9 @@
491 526 }
492 527
493 528 if(isset($methods->cards)) {
494 529 foreach($methods->cards as $method) {
495 - $wpdb->insert($tableName, array('type' => 'card', 'name' => $method->name));
530 + $wpdb->insert($tableName, array('type' => 'card', 'name' => $method->name, 'logo_url' => $method->logo_url));
496 531 }
497 532 $updated = true;
498 533 }
499 534
@@ -520,8 +555,64 @@
520 555 }
521 556 die();
522 557 }
523 558
559 +
560 + public function process_subscripion_payment_start($amount_to_charge, $renewal_order, $product_id = '') {
561 + $result = $this->process_subscription_payment($renewal_order, $amount_to_charge);
562 + if ( is_wp_error( $result ) ) {
563 + WC_Subscriptions_Manager::process_subscription_payment_failure_on_order($renewal_order, $product_id);
564 + } else {
565 + WC_Subscriptions_Manager::process_subscription_payments_on_order($renewal_order);
566 + }
567 + }
568 +
569 + public function process_subscription_payment($order, $amount = 0) {
570 + if (0 === $amount) {
571 + $order->payment_complete();
572 + return true;
573 + } // if ('processing' === $order->get_status() || 'completed' === $order->get_status()){ // ('processing' === $order->get_status())
574 + if ('processing' === $order->get_status() || 'completed' === $order->get_status()){
575 + return true;
576 + }
577 + $oorder_id = @WC_Subscriptions_Renewal_Order::get_parent_order_id($order);
578 + $payment_token = get_post_meta($oorder_id, '_makecommerce_payment_token', true);
579 + $payment_token_valid_until = get_post_meta($oorder_id, '_makecommerce_payment_token_valid_until', true);
580 + error_log($payment_token.'=>'. $payment_token_valid_until.'=>'. $order->get_status());
581 + $body = array(
582 + 'transaction' => array(
583 + 'amount' => (string)sprintf("%.2f", $amount),
584 + 'currency' => method_exists($order, 'get_currency') ? $order->get_currency() : $order->currency,
585 + 'reference' => $order->get_order_number(),
586 + ),
587 + 'customer' => array(
588 + 'email' => $order->get_billing_email(),
589 + 'ip' => $order->get_customer_ip_address(),
590 + 'country' => strtolower($order->get_billing_country()),
591 + 'locale' => strtolower(substr(get_locale(), 0, 2)),
592 + )
593 + );
594 + $transaction = $this->MK->createTransaction($body);
595 + $paymentRequest = array(
596 + 'amount' => (string)sprintf("%.2f", $transaction->amount),
597 + 'currency' => $transaction->currency,
598 + 'token' => $payment_token
599 + );
600 + try {
601 + $payment = $this->MK->createPayment($transaction->id, $paymentRequest);
602 + } catch (Exception $e) {
603 + error_log('Payment failed ['.$e->getMessage().']');
604 + $order->add_order_note(__('Unable to renew subscription', 'wc_makecommerce_domain')."\r\n".$e->getMessage());
605 + return new WP_Error('makecommerce_payment_declined', __( 'Renewal payment was declined', 'wc_makecommerce_domain' ) );
606 + }
607 + $orderNote = array();
608 + $orderNote[] = __('Transaction ID', 'wc_makecommerce_domain') . ': <a target=_blank href="'.$this->MK->getEnvUrls()->merchantUrl.'/merchant/shop/deals/detail.html?id='. $transaction->id .'">'.$transaction->id.'</a>';
609 + $orderNote[] = __('Payment option', 'wc_makecommerce_domain') . ': ' . get_post_meta($order->get_order_number(), '_makecommerce_preselected_method', true);
610 + $order->add_order_note(implode("\r\n", $orderNote));
611 + $order->payment_complete($transaction->id);
612 + return true;
613 + }
614 +
524 615 public function admin_order_page($order) {
525 616 //
526 617 }
527 618
@@ -529,10 +620,14 @@
529 620 if ($this->MK) {
530 621 try {
531 622 $order = new WC_Order($order_id);
532 623 $transactionId = $order->get_transaction_id();
624 +
625 + if ( empty($transactionId) ) {
626 + $transactionId = get_post_meta( $order_id, '_makecommerce_transaction_id', true);
627 + }
533 628
534 - if($response = $this->MK->createRefund($transactionId, array('amount' => $amount, 'comment' => ($comment ? : 'refund')))) {
629 + if($response = $this->MK->createRefund($transactionId, array('amount' => sprintf("%.2f", $amount), 'comment' => ($comment ? : 'refund')))) {
535 630 if($status = (string)$response->transaction->status) {
536 631 switch($status) {
537 632 case self::MC_REFUNDED:
538 633 $order->add_order_note(sprintf(__('Refund completed for amount %s', 'wc_makecommerce_domain'), $amount));
@@ -619,8 +714,9 @@
619 714 <?php
620 715 }
621 716
622 717 public function payment_fields() {
718 +
623 719
624 720 if($this->settings['ui_mode'] == 'inline') {
625 721
626 722 ?>
@@ -630,9 +726,9 @@
630 726 <input type="radio" id="makecommerce_method_picker_<?php echo $method->country.'_'.$method->name; ?>" name="PRESELECTED_METHOD_<?php echo $this->id; ?>" value="<?php echo $method->country.'_'.$method->name; ?>"/>
631 727 <label for="makecommerce_method_picker_<?php echo $method->country.'_'.$method->name; ?>">
632 728 <span class="makecommerce-method-title"><?php if(in_array($this->settings['ui_inline_uselogo'], array('text', 'text_logo'))) { echo ucfirst($method->name); if(count($this->_banklinks_grouped) > 1) { echo ' ('.$this->getCountryName($method->country).')'; } } ?></span>
633 729 <?php if(in_array($this->settings['ui_inline_uselogo'], array('logo', 'text_logo'))) : ?>
634 - <div><img src="<?php echo $this->getImageUrl($method->name); ?>" title="<?php echo ucfirst($method->name); ?>" /></div>
730 + <div><img src="<?php echo $method->logo_url; ?>" title="<?php echo ucfirst($method->name); ?>" /></div>
635 731 <?php endif; ?>
636 732 </label>
637 733 </li>
638 734 <?php endforeach; ?>
@@ -641,9 +737,9 @@
641 737 <input type="radio" id="makecommerce_method_picker_<?php echo 'card_'.$method->name; ?>" name="PRESELECTED_METHOD_<?php echo $this->id; ?>" value="<?php echo 'card_'.$method->name; ?>"/>
642 738 <label for="makecommerce_method_picker_<?php echo 'card_'.$method->name; ?>">
643 739 <span class="makecommerce-method-title"><?php if(in_array($this->settings['ui_inline_uselogo'], array('text', 'text_logo'))) { echo ucfirst($method->name); } ?></span>
644 740 <?php if(in_array($this->settings['ui_inline_uselogo'], array('logo', 'text_logo'))) : ?>
645 - <div><img src="<?php echo $this->getImageUrl($method->name); ?>" title="<?php echo ucfirst($method->name); ?>" /></div>
741 + <div><img src="<?php echo $method->logo_url; ?>" title="<?php echo ucfirst($method->name); ?>" /></div>
646 742 <?php endif; ?>
647 743 </label>
648 744 </li>
649 745 <?php endforeach; ?>
@@ -693,9 +789,9 @@
693 789 <?php endif; ?>
694 790 <div class="makecommerce_country_picker_methods" id="makecommerce_country_picker_methods_<?php echo $country; ?>">
695 791 <?php foreach($methods as $method): ?>
696 792 <div class="makecommerce-banklink-picker" banklink_id="<?php echo $method->country.'_'.$method->name; ?>">
697 - <img src="<?php echo $this->getImageUrl($method->name); ?>" title="<?php echo ucfirst($method->name); ?>" />
793 + <img src="<?php echo $method->logo_url; ?>" title="<?php echo ucfirst($method->name); ?>" />
698 794 </div>
699 795 <?php endforeach; ?>
700 796 <?php if($this->_cards && $this->settings['ui_widget_groupcc'] == 'no') : ?>
701 797 <div class="breaker"></div>
@@ -700,9 +796,9 @@
700 796 <?php if($this->_cards && $this->settings['ui_widget_groupcc'] == 'no') : ?>
701 797 <div class="breaker"></div>
702 798 <?php foreach($this->_cards as $method): ?>
703 799 <div class="makecommerce-banklink-picker" banklink_id="card_<?php echo $method->name; ?>">
704 - <img src="<?php echo $this->getImageUrl($method->name); ?>" title="<?php echo ucfirst($method->name); ?>" />
800 + <img src="<?php echo $method->logo_url; ?>" title="<?php echo ucfirst($method->name); ?>" />
705 801 </div>
706 802 <?php endforeach; ?>
707 803 <?php elseif($country == 'other') :?>
708 804 <p class="no-methods"><?php _e('No payment methods for selected country' ,'wc_makecommerce_domain');?></p>
@@ -715,9 +811,9 @@
715 811 <input type="radio" id="makecommerce_country_picker_card" name="makecommerce_country_picker" value="card"/><label for="makecommerce_country_picker_card"><?php echo $this->settings['ui_widget_groupcc_title']; ?></label>
716 812 <div class="makecommerce_country_picker_methods" id="makecommerce_country_picker_methods_card">
717 813 <?php foreach($this->_cards as $method): ?>
718 814 <div class="makecommerce-banklink-picker" banklink_id="card_<?php echo $method->name; ?>">
719 - <img src="<?php echo $this->getImageUrl($method->name); ?>" title="<?php echo ucfirst($method->name); ?>" />
815 + <img src="<?php echo $method->logo_url; ?>" title="<?php echo ucfirst($method->name); ?>" />
720 816 </div>
721 817 <?php endforeach; ?>
722 818 </div>
723 819 </li>
@@ -741,16 +837,18 @@
741 837 <?php else: ?>
742 838 makecommercePick();
743 839
744 840 jQuery('body').on('change', 'select[name=makecommerce_country_picker_select]', function() {
745 - selectedCountry = jQuery(this).val();
746 - jQuery('input[name=makecommerce_country_picker]').removeAttr('checked');
747 - makecommercePick();
841 + selectedCountry = jQuery(this).val();
842 + jQuery('input[name=makecommerce_country_picker]').removeAttr('checked');
843 + makecommercePick();
748 844 });
749 845 jQuery('body').on('change', 'input[name=makecommerce_country_picker]', function() {
846 + if(jQuery(this).is(":checked")) {
750 847 selectedCountry = jQuery(this).val();
751 848 jQuery('select[name=makecommerce_country_picker_select]').val(selectedCountry);
752 849 makecommercePick();
850 + }
753 851 });
754 852
755 853 function makecommercePick() {
756 854 jQuery('select#'+makecommerceId).val('');
@@ -820,9 +918,9 @@
820 918 return key($this->_banklinks_grouped);
821 919 }
822 920
823 921
824 - protected function getImageUrl($methodName) {
922 + protected function getImageUrl($methodName) { // remove it
825 923 //$imageUrlPath = 'https://static.maksekeskus.ee/img/channel/lnd/';
826 924 $imageUrlPath = $this->MK->getEnvUrls()->staticsUrl.'img/channel/lnd/';
827 925 return $imageUrlPath.$methodName.'.png';
828 926 }
@@ -848,15 +946,15 @@
848 946 $selected = isset($_POST['PRESELECTED_METHOD_' . $this->id]) ? sanitize_text_field($_POST['PRESELECTED_METHOD_' . $this->id]) : false;
849 947
850 948 if (!empty($selected)) {
851 949
852 - update_post_meta($order->id, '_makecommerce_preselected_method', $selected);
950 + update_post_meta($order->get_order_number(), '_makecommerce_preselected_method', $selected);
853 951
854 952 $request_body = array(
855 953 'transaction' => array(
856 - 'amount' => round($order->order_total, 2),
857 - 'currency' => $order->get_order_currency(),
858 - 'reference' => $order->id,
954 + 'amount' => (string)sprintf("%.2f", $order->get_total()),
955 + 'currency' => method_exists($order, 'get_currency') ? $order->get_currency() : $order->currency,
956 + 'reference' => $order->get_order_number(),
859 957 'transaction_url' => array(
860 958 'return_url' => array(
861 959 'url' => $this->payment_return_url,
862 960 'method' => 'POST',
@@ -872,9 +970,9 @@
872 970 ),
873 971 ),
874 972 'customer' => array(
875 973 'ip' => $_SERVER['REMOTE_ADDR'],
876 - 'country' => strtolower($order->billing_country),
974 + 'country' => strtolower($order->get_billing_country()),
877 975 'locale' => strtolower(substr(get_locale(), 0, 2)),
878 976 ),
879 977 );
880 978 $transaction = $this->MK->createTransaction($request_body);
@@ -879,9 +977,9 @@
879 977 );
880 978 $transaction = $this->MK->createTransaction($request_body);
881 979
882 980 if(isset($transaction->id)) {
883 - update_post_meta($order->id, '_makecommerce_transaction_id', $transaction->id);
981 + update_post_meta($order->get_order_number(), '_makecommerce_transaction_id', $transaction->id);
884 982 if (substr($selected, 0, 5) == 'card_') {
885 983 $redirect_url = $order->get_checkout_payment_url( true );
886 984 } else {
887 985 $redirect_url = false;
@@ -929,13 +1027,13 @@
929 1027 $lang = strtolower(substr(get_locale(), 0, 2));
930 1028 }
931 1029 $url = add_query_arg( array(
932 1030 'makecommerce_card_pay' => '1',
933 - 'order_id' => $order->id,
1031 + 'order_id' => $order->get_order_number(),
934 1032 'lang' => $lang,
935 1033 ), $baseUrl);
936 1034
937 - // $url = site_url('?makecommerce_card_pay=1&order_id='.$order->id.'&lang='.(defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : strtolower(substr(get_locale(), 0, 2))));
1035 + // $url = site_url('?makecommerce_card_pay=1&order_id='.$order->get_order_number().'&lang='.(defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : strtolower(substr(get_locale(), 0, 2))));
938 1036 return $url;
939 1037 }
940 1038
941 1039 */
@@ -950,20 +1048,21 @@
950 1048
951 1049
952 1050 public function generateCardForm($orderId) {
953 1051 $order = new WC_Order($orderId);
1052 + $has_subscription = function_exists('wcs_order_contains_subscription') && wcs_order_contains_subscription($order);
954 1053 $scriptSrc = htmlspecialchars($this->MK->getEnvUrls()->checkoutjsUrl.'checkout.js');
955 - $transactionId = get_post_meta($order->id, '_makecommerce_transaction_id', true);
956 - $idReference = $order->id;
1054 + $transactionId = get_post_meta($order->get_order_number(), '_makecommerce_transaction_id', true);
1055 + $idReference = $order->get_order_number();
957 1056 $jsParams = array(
958 1057 'key' => $this->MK->getPublishableKey(),
959 1058 'transaction' => $transactionId,
960 1059 'selector' => '#submit_banklinkmakecommerce_payment_form',
961 - 'amount' => round($order->order_total, 2),
1060 + 'amount' => sprintf("%.2f", $order->get_total()),
962 1061 'locale' => !empty($_GET['lang']) ? $_GET['lang'] : (defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : strtolower(substr(get_locale(), 0, 2))),
963 1062 'open-on-load' => 'true',
964 - 'client-name' => ($this->settings['cc_pass_cust_data'] == 'yes' ? (string) ($order->billing_first_name . ' ' . $order->billing_last_name) : ''),
965 - 'email' => ($this->settings['cc_pass_cust_data'] == 'yes' ? (string) $order->billing_email : ''),
1063 + 'client-name' => ($this->settings['cc_pass_cust_data'] == 'yes' ? (string) ((method_exists($order, 'get_billing_first_name') ? $order->get_billing_first_name() : $order->billing_first_name) . ' ' . (method_exists($order, 'get_billing_last_name') ? $order->get_billing_last_name() : $order->billing_last_name)) : ''),
1064 + 'email' => ($this->settings['cc_pass_cust_data'] == 'yes' ? (string) (method_exists($order, 'get_billing_email') ? $order->get_billing_email() : $order->billing_email) : ''),
966 1065 'name' => get_option('mc_shop_name', ''),
967 1066 'description' => __('Order', 'woocommerce') . '&nbsp;' . (string) $idReference,
968 1067 'completed' => 'makecommerce_cc_complete',
969 1068 'currency' => 'EUR',
@@ -968,8 +1067,14 @@
968 1067 'completed' => 'makecommerce_cc_complete',
969 1068 'currency' => 'EUR',
970 1069 'backdrop-close' => 'false',
971 1070 );
1071 + if ($has_subscription) {
1072 + $jsParams['recurring-required'] = 'true';
1073 + $jsParams['recurring-title'] = __('Pay for subscription', 'wc_makecommerce_domain');
1074 + $jsParams['recurring-description'] = __('This order contains subscriptions', 'wc_makecommerce_domain');
1075 + $jsParams['recurring-confirmation'] = __('I agree that my card will be recurringly billed by this store', 'wc_makecommerce_domain');
1076 + }
972 1077 ?>
973 1078 <script type="text/javascript">
974 1079 function makecommerce_cc_complete(data) {
975 1080 if(data.paymentToken) {
@@ -1025,9 +1130,9 @@
1025 1130
1026 1131 New woocommerce_makecommerce(true);
1027 1132
1028 1133 // Woocommerce Multilingual overrides
1029 - if ( in_array( 'woocommerce-multilingual/wpml-woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) {
1134 + if (is_plugin_active('woocommerce-multilingual/wpml-woocommerce.php')) {
1030 1135 add_filter( 'get_post_metadata', 'mc_override_payment_method_string', 5, 4 );
1031 1136 }
1032 1137
1033 1138 } // init ends here
@@ -1042,15 +1147,13 @@
1042 1147
1043 1148 add_action('plugins_loaded', 'woocommerce_payment_makecommerce_init');
1044 1149 add_action('woocommerce_payment_gateways', 'woocommerce_payment_makecommerce_add');
1045 1150
1046 -
1047 1151 // Banklinks update wrapper for action
1048 1152 function update_mc_banklinks() {
1049 1153 $obj = new woocommerce_makecommerce(true);
1050 1154 $obj->mc_banklinks_reload(true);
1051 1155 }
1052 -
1053 1156
1054 1157 function mc_override_payment_method_string( $check, $object_id, $meta_key, $single ){
1055 1158 if($meta_key == '_payment_method_title') {
1056 1159 $payment_method = get_post_meta( $object_id, '_payment_method', true );