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 +141 -42 2.2.12.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.2.0';
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
@@ -534,9 +625,9 @@
534 625 if ( empty($transactionId) ) {
535 626 $transactionId = get_post_meta( $order_id, '_makecommerce_transaction_id', true);
536 627 }
537 628
538 - 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')))) {
539 630 if($status = (string)$response->transaction->status) {
540 631 switch($status) {
541 632 case self::MC_REFUNDED:
542 633 $order->add_order_note(sprintf(__('Refund completed for amount %s', 'wc_makecommerce_domain'), $amount));
@@ -623,8 +714,9 @@
623 714 <?php
624 715 }
625 716
626 717 public function payment_fields() {
718 +
627 719
628 720 if($this->settings['ui_mode'] == 'inline') {
629 721
630 722 ?>
@@ -634,9 +726,9 @@
634 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; ?>"/>
635 727 <label for="makecommerce_method_picker_<?php echo $method->country.'_'.$method->name; ?>">
636 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>
637 729 <?php if(in_array($this->settings['ui_inline_uselogo'], array('logo', 'text_logo'))) : ?>
638 - <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>
639 731 <?php endif; ?>
640 732 </label>
641 733 </li>
642 734 <?php endforeach; ?>
@@ -645,9 +737,9 @@
645 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; ?>"/>
646 738 <label for="makecommerce_method_picker_<?php echo 'card_'.$method->name; ?>">
647 739 <span class="makecommerce-method-title"><?php if(in_array($this->settings['ui_inline_uselogo'], array('text', 'text_logo'))) { echo ucfirst($method->name); } ?></span>
648 740 <?php if(in_array($this->settings['ui_inline_uselogo'], array('logo', 'text_logo'))) : ?>
649 - <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>
650 742 <?php endif; ?>
651 743 </label>
652 744 </li>
653 745 <?php endforeach; ?>
@@ -697,9 +789,9 @@
697 789 <?php endif; ?>
698 790 <div class="makecommerce_country_picker_methods" id="makecommerce_country_picker_methods_<?php echo $country; ?>">
699 791 <?php foreach($methods as $method): ?>
700 792 <div class="makecommerce-banklink-picker" banklink_id="<?php echo $method->country.'_'.$method->name; ?>">
701 - <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); ?>" />
702 794 </div>
703 795 <?php endforeach; ?>
704 796 <?php if($this->_cards && $this->settings['ui_widget_groupcc'] == 'no') : ?>
705 797 <div class="breaker"></div>
@@ -704,9 +796,9 @@
704 796 <?php if($this->_cards && $this->settings['ui_widget_groupcc'] == 'no') : ?>
705 797 <div class="breaker"></div>
706 798 <?php foreach($this->_cards as $method): ?>
707 799 <div class="makecommerce-banklink-picker" banklink_id="card_<?php echo $method->name; ?>">
708 - <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); ?>" />
709 801 </div>
710 802 <?php endforeach; ?>
711 803 <?php elseif($country == 'other') :?>
712 804 <p class="no-methods"><?php _e('No payment methods for selected country' ,'wc_makecommerce_domain');?></p>
@@ -719,9 +811,9 @@
719 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>
720 812 <div class="makecommerce_country_picker_methods" id="makecommerce_country_picker_methods_card">
721 813 <?php foreach($this->_cards as $method): ?>
722 814 <div class="makecommerce-banklink-picker" banklink_id="card_<?php echo $method->name; ?>">
723 - <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); ?>" />
724 816 </div>
725 817 <?php endforeach; ?>
726 818 </div>
727 819 </li>
@@ -745,16 +837,18 @@
745 837 <?php else: ?>
746 838 makecommercePick();
747 839
748 840 jQuery('body').on('change', 'select[name=makecommerce_country_picker_select]', function() {
749 - selectedCountry = jQuery(this).val();
750 - jQuery('input[name=makecommerce_country_picker]').removeAttr('checked');
751 - makecommercePick();
841 + selectedCountry = jQuery(this).val();
842 + jQuery('input[name=makecommerce_country_picker]').removeAttr('checked');
843 + makecommercePick();
752 844 });
753 845 jQuery('body').on('change', 'input[name=makecommerce_country_picker]', function() {
846 + if(jQuery(this).is(":checked")) {
754 847 selectedCountry = jQuery(this).val();
755 848 jQuery('select[name=makecommerce_country_picker_select]').val(selectedCountry);
756 849 makecommercePick();
850 + }
757 851 });
758 852
759 853 function makecommercePick() {
760 854 jQuery('select#'+makecommerceId).val('');
@@ -824,9 +918,9 @@
824 918 return key($this->_banklinks_grouped);
825 919 }
826 920
827 921
828 - protected function getImageUrl($methodName) {
922 + protected function getImageUrl($methodName) { // remove it
829 923 //$imageUrlPath = 'https://static.maksekeskus.ee/img/channel/lnd/';
830 924 $imageUrlPath = $this->MK->getEnvUrls()->staticsUrl.'img/channel/lnd/';
831 925 return $imageUrlPath.$methodName.'.png';
832 926 }
@@ -852,15 +946,15 @@
852 946 $selected = isset($_POST['PRESELECTED_METHOD_' . $this->id]) ? sanitize_text_field($_POST['PRESELECTED_METHOD_' . $this->id]) : false;
853 947
854 948 if (!empty($selected)) {
855 949
856 - update_post_meta($order->id, '_makecommerce_preselected_method', $selected);
950 + update_post_meta($order->get_order_number(), '_makecommerce_preselected_method', $selected);
857 951
858 952 $request_body = array(
859 953 'transaction' => array(
860 - 'amount' => round($order->order_total, 2),
861 - 'currency' => $order->get_order_currency(),
862 - '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(),
863 957 'transaction_url' => array(
864 958 'return_url' => array(
865 959 'url' => $this->payment_return_url,
866 960 'method' => 'POST',
@@ -876,9 +970,9 @@
876 970 ),
877 971 ),
878 972 'customer' => array(
879 973 'ip' => $_SERVER['REMOTE_ADDR'],
880 - 'country' => strtolower($order->billing_country),
974 + 'country' => strtolower($order->get_billing_country()),
881 975 'locale' => strtolower(substr(get_locale(), 0, 2)),
882 976 ),
883 977 );
884 978 $transaction = $this->MK->createTransaction($request_body);
@@ -883,9 +977,9 @@
883 977 );
884 978 $transaction = $this->MK->createTransaction($request_body);
885 979
886 980 if(isset($transaction->id)) {
887 - update_post_meta($order->id, '_makecommerce_transaction_id', $transaction->id);
981 + update_post_meta($order->get_order_number(), '_makecommerce_transaction_id', $transaction->id);
888 982 if (substr($selected, 0, 5) == 'card_') {
889 983 $redirect_url = $order->get_checkout_payment_url( true );
890 984 } else {
891 985 $redirect_url = false;
@@ -933,13 +1027,13 @@
933 1027 $lang = strtolower(substr(get_locale(), 0, 2));
934 1028 }
935 1029 $url = add_query_arg( array(
936 1030 'makecommerce_card_pay' => '1',
937 - 'order_id' => $order->id,
1031 + 'order_id' => $order->get_order_number(),
938 1032 'lang' => $lang,
939 1033 ), $baseUrl);
940 1034
941 - // $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))));
942 1036 return $url;
943 1037 }
944 1038
945 1039 */
@@ -954,20 +1048,21 @@
954 1048
955 1049
956 1050 public function generateCardForm($orderId) {
957 1051 $order = new WC_Order($orderId);
1052 + $has_subscription = function_exists('wcs_order_contains_subscription') && wcs_order_contains_subscription($order);
958 1053 $scriptSrc = htmlspecialchars($this->MK->getEnvUrls()->checkoutjsUrl.'checkout.js');
959 - $transactionId = get_post_meta($order->id, '_makecommerce_transaction_id', true);
960 - $idReference = $order->id;
1054 + $transactionId = get_post_meta($order->get_order_number(), '_makecommerce_transaction_id', true);
1055 + $idReference = $order->get_order_number();
961 1056 $jsParams = array(
962 1057 'key' => $this->MK->getPublishableKey(),
963 1058 'transaction' => $transactionId,
964 1059 'selector' => '#submit_banklinkmakecommerce_payment_form',
965 - 'amount' => round($order->order_total, 2),
1060 + 'amount' => sprintf("%.2f", $order->get_total()),
966 1061 'locale' => !empty($_GET['lang']) ? $_GET['lang'] : (defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : strtolower(substr(get_locale(), 0, 2))),
967 1062 'open-on-load' => 'true',
968 - 'client-name' => ($this->settings['cc_pass_cust_data'] == 'yes' ? (string) ($order->billing_first_name . ' ' . $order->billing_last_name) : ''),
969 - '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) : ''),
970 1065 'name' => get_option('mc_shop_name', ''),
971 1066 'description' => __('Order', 'woocommerce') . '&nbsp;' . (string) $idReference,
972 1067 'completed' => 'makecommerce_cc_complete',
973 1068 'currency' => 'EUR',
@@ -972,8 +1067,14 @@
972 1067 'completed' => 'makecommerce_cc_complete',
973 1068 'currency' => 'EUR',
974 1069 'backdrop-close' => 'false',
975 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 + }
976 1077 ?>
977 1078 <script type="text/javascript">
978 1079 function makecommerce_cc_complete(data) {
979 1080 if(data.paymentToken) {
@@ -1046,15 +1147,13 @@
1046 1147
1047 1148 add_action('plugins_loaded', 'woocommerce_payment_makecommerce_init');
1048 1149 add_action('woocommerce_payment_gateways', 'woocommerce_payment_makecommerce_add');
1049 1150
1050 -
1051 1151 // Banklinks update wrapper for action
1052 1152 function update_mc_banklinks() {
1053 1153 $obj = new woocommerce_makecommerce(true);
1054 1154 $obj->mc_banklinks_reload(true);
1055 1155 }
1056 -
1057 1156
1058 1157 function mc_override_payment_method_string( $check, $object_id, $meta_key, $single ){
1059 1158 if($meta_key == '_payment_method_title') {
1060 1159 $payment_method = get_post_meta( $object_id, '_payment_method', true );