Changeset 2813931
- Timestamp:
- 11/08/2022 02:21:49 AM (3 years ago)
- Location:
- mobipaid/trunk
- Files:
-
- 4 edited
-
changelog.txt (modified) (1 diff)
-
includes/class-mobipaid-api.php (modified) (1 diff)
-
includes/class-mobipaid.php (modified) (4 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mobipaid/trunk/changelog.txt
r2699880 r2813931 29 29 = 1.0.7 - 2022-03-26 = 30 30 * 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 100 100 } 101 101 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 102 138 /** 103 139 * Get payment detail with the API. -
mobipaid/trunk/includes/class-mobipaid.php
r2699874 r2813931 82 82 $this->access_key = $this->get_option('access_key'); 83 83 $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'); 85 85 $this->init_api(); 86 86 } … … 97 97 'title' => __('Enable/Disable', 'mobipaid'), 98 98 'label' => __('Enable Mobipaid', 'mobipaid'), 99 'type' => 'checkbox', 100 'default' => 'no', 101 ), 102 'sandbox' => array( 103 'title' => __('Sandbox', 'mobipaid'), 104 'label' => __('Enable Development Mode', 'mobipaid'), 99 105 'type' => 'checkbox', 100 106 'default' => 'no', … … 117 123 'title' => __('Access Key', 'mobipaid'), 118 124 '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'), 120 126 'default' => '', 121 127 ), … … 136 142 $post_data = $this->get_post_data(); 137 143 $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 138 146 if (empty($access_key)) { 139 147 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 140 185 } 141 186 } -
mobipaid/trunk/readme.txt
r2738072 r2813931 4 4 Tags: credit card, mobipaid, google pay, apple pay, nedbank, payment method, payment gateway 5 5 Requires at least: 5.0 6 Tested up to: 6. 06 Tested up to: 6.1 7 7 Requires PHP: 7.0 8 Stable tag: 1.0. 78 Stable tag: 1.0.8 9 9 License: GPLv3 10 10 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 126 126 = 1.0.7 - 2022-03-26 = 127 127 * 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.