Plugin Directory

Changeset 2813931


Ignore:
Timestamp:
11/08/2022 02:21:49 AM (3 years ago)
Author:
mobipaid
Message:

Add release v1.0.8

Location:
mobipaid/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • mobipaid/trunk/changelog.txt

    r2699880 r2813931  
    2929= 1.0.7 - 2022-03-26 =
    3030* fix order status for gift card product
     31
     32= 1.0.8 - 2022-11-05 =
     33* add sandbox development mode
     34* add auto create default pos link if not available
     35* support compatibility wordpress 6.1 and woocommerce 7.0.1.
  • mobipaid/trunk/includes/class-mobipaid-api.php

    r2553115 r2813931  
    100100 }
    101101
     102  /**
     103  * Get pos link detail with the API.
     104  *
     105  * @param string $payment_id Payment ID.
     106  *
     107  * @return array
     108  */
     109  public static function get_pos_link()
     110  {
     111   $url = self::get_api_url() . '/pos';
     112   return self::send_request($url);
     113  }
     114
     115  /**
     116  * Create default pos link
     117  *
     118  * @param array $currency Currency.
     119  *
     120  * @return array
     121  */
     122  public static function create_default_pos_link(){
     123    $body = array();
     124
     125    $body['currency'] = ['ZAR', 'USD', 'EUR'];
     126    $body['auto_generate_ref_number'] = 0;
     127    $body['ref_number_suffix'] = 1;
     128    $body['ref_number_prefix'] = 'MP';
     129    $body['tip_enabled'] = false;
     130    $body['moto_enabled'] = false;
     131    $body['share_button_enabled'] = false;
     132
     133    $url = self::get_api_url() . '/pos';
     134
     135    return self::send_request($url, $body, 'POST');
     136  }
     137
    102138 /**
    103139  * Get payment detail with the API.
  • mobipaid/trunk/includes/class-mobipaid.php

    r2699874 r2813931  
    8282  $this->access_key     = $this->get_option('access_key');
    8383  $this->enable_logging = 'yes' === $this->get_option('enable_logging');
    84   $this->is_test_mode   = 'mp_live' !== substr($this->access_key, 0, 7);
     84  $this->is_test_mode   = 'yes' === $this->get_option('sandbox');
    8585  $this->init_api();
    8686 }
     
    9797    'title'   => __('Enable/Disable', 'mobipaid'),
    9898    'label'   => __('Enable Mobipaid', 'mobipaid'),
     99    'type'    => 'checkbox',
     100    'default' => 'no',
     101   ),
     102   'sandbox'        => array(
     103    'title'   => __('Sandbox', 'mobipaid'),
     104    'label'   => __('Enable Development Mode', 'mobipaid'),
    99105    'type'    => 'checkbox',
    100106    'default' => 'no',
     
    117123    'title'       => __('Access Key', 'mobipaid'),
    118124    'type'        => 'password',
    119     'description' => __('* This is the access key, received from Mobipaid developer portal. ( required )', 'mobipaid'),
     125    'description' => __('* This is the access key, received from Mobipaid developer portal. ( required )<br><br>* Access key for development mode have the prefix mp_test_<br>* Access key for production mode have the prefix mp_live_', 'mobipaid'),
    120126    'default'     => '',
    121127   ),
     
    136142  $post_data  = $this->get_post_data();
    137143  $access_key = $this->get_field_value('access_key', $this->form_fields, $post_data);
     144  $is_test_mode = !empty($this->get_field_value('sandbox', $this->form_fields, $post_data));
     145 
    138146  if (empty($access_key)) {
    139147   WC_Admin_Settings::add_error(__('Please enter an access key!', 'mobipaid'));
     148  }
     149
     150  $this->validate_pos_link($access_key, $is_test_mode);
     151 }
     152
     153 /**
     154  * Check if pos link is already created
     155  * if not exist, create new default pos link
     156  */
     157 public function validate_pos_link($access_key, $is_test_mode){
     158
     159  Mobipaid_API::$access_key   = $access_key;
     160  Mobipaid_API::$is_test_mode = $is_test_mode;
     161
     162  $this->log('Mobipaid - access_key: ' . Mobipaid_API::$access_key);
     163  $this->log('Mobipaid - is_test_mode: ' . Mobipaid_API::$is_test_mode);
     164
     165  $check = Mobipaid_API::get_pos_link();
     166  $this->log('get_pos_link - results: ' . wp_json_encode($check));
     167
     168  if (200 !== $check['response']['code']) {
     169
     170    $result = Mobipaid_API::create_default_pos_link();
     171    $this->log('create_default_pos_link - result: ' . wp_json_encode($result));
     172
     173    $response = $result['response']['code'];
     174   
     175    if(!isset($result['body']['message'])){
     176      $error_message = 'Failed when saving changes. Please contact admin or developer';
     177    }else{
     178      $error_message = 'Failed when saving changes : '.$result['body']['message'];
     179    }
     180   
     181    if($response !== 200){
     182      WC_Admin_Settings::add_error(__($error_message, 'mobipaid'));
     183    }
     184
    140185  }
    141186 }
  • mobipaid/trunk/readme.txt

    r2738072 r2813931  
    44Tags: credit card, mobipaid, google pay, apple pay, nedbank, payment method, payment gateway
    55Requires at least: 5.0
    6 Tested up to: 6.0
     6Tested up to: 6.1
    77Requires PHP: 7.0
    8 Stable tag: 1.0.7
     8Stable tag: 1.0.8
    99License: GPLv3
    1010License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    126126= 1.0.7 - 2022-03-26 =
    127127* fix order status for gift card product
     128
     129= 1.0.8 - 2022-11-05 =
     130* add sandbox development mode
     131* add auto create default pos link if not available
     132* support compatibility wordpress 6.1 and woocommerce 7.0.1.
Note: See TracChangeset for help on using the changeset viewer.