Changeset 2678231
- Timestamp:
- 02/14/2022 06:54:27 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
leyka/trunk/gateways/mixplat/leyka-class-mixplat-gateway.php
r2678084 r2678231 13 13 14 14 $this->_id = 'mixplat'; 15 $this->_title = __('MIXPLAT - SMS', 'leyka');15 $this->_title = __('MIXPLAT', 'leyka'); 16 16 17 17 $this->_description = apply_filters( … … 24 24 $this->_registration_link = '//mixplat.ru/#join'; 25 25 26 $this->_min_commission = 2.5;26 $this->_min_commission = 3; 27 27 $this->_receiver_types = ['legal']; 28 28 … … 36 36 37 37 $this->_options = [ 38 $this->_id.'_new_api' => [ 39 'type' => 'checkbox', 40 'default' => false, 41 'title' => sprintf(__('Use %s new API', 'leyka'), $this->_title), 42 'comment' => sprintf(__('Check if your %s connection uses MIXPLAT API v3', 'leyka'), $this->_title), 43 'short_format' => true, 44 ], 38 45 'mixplat_service_id' => [ 39 46 'type' => 'text', 40 'title' => __('MIXPLAT Project ID', 'leyka'),41 'comment' => __(' Enter your project ID. It can be found in your MIXPLAT project settings page on MIXPLAT site.', 'leyka'),47 'title' => __('MIXPLAT project ID', 'leyka'), 48 'comment' => __('Please, enter your MIXPLAT project ID here. It can be found in your MIXPLAT project settings page on MIXPLAT site.', 'leyka'), 42 49 'required' => true, 43 50 'placeholder' => sprintf(__('E.g., %s', 'leyka'), '100359'), … … 45 52 'mixplat_secret_key' => [ 46 53 'type' => 'text', 47 'title' => __('MIXPLAT API key', 'leyka'),48 'comment' => __(' Enter your API key. It can be found in your MIXPLAT project settings page on MIXPLAT site.', 'leyka'),54 'title' => __('MIXPLAT project secret API key', 'leyka'), 55 'comment' => __('Please, enter your MIXPLAT project secret key (or API key for the new API) here. It can be found in your MIXPLAT project settings page on MIXPLAT site.', 'leyka'), 49 56 'required' => true, 50 57 'placeholder' => sprintf(__('E.g., %s', 'leyka'), 'c23a4398db8ef7b3ae1f4b07aeeb7c54f8e3c7c9'), 58 ], 59 'mixplat_test_mode' => [ 60 'type' => 'checkbox', 61 'default' => true, 62 'title' => __('Payments testing mode', 'leyka'), 63 'comment' => __('Check if the gateway integration is in test mode.', 'leyka'), 64 'short_format' => true, 65 'required' => false, 51 66 ], 52 67 ]; … … 139 154 $is_success = false; 140 155 141 // Use onlyAPI v3156 if(leyka_options()->opt('mixplat_new_api')) { // API v3 142 157 143 158 require_once LEYKA_PLUGIN_DIR.'gateways/mixplat/lib/autoload.php'; … … 158 173 $new_payment->paymentMethod = \MixplatClient\MixplatVars::PAYMENT_METHOD_MOBILE; 159 174 $new_payment->userPhone = $phone; 160 $new_payment->userEmail = $donation->donor_email;161 175 $new_payment->amount = $amount; 162 176 $new_payment->merchantFields = [ … … 164 178 'email' => $donation->donor_email, 165 179 'payment_title' => $donation->payment_title, 166 'campaign_id' => leyka_options()->opt('mixplat-sms_default_campaign_id'),167 180 ]; 168 181 … … 175 188 } 176 189 190 } else { // Older APIs 191 192 $ch = curl_init(); 193 curl_setopt_array($ch, [ 194 CURLOPT_URL => 'http://api.mixplat.com/mc/create_payment', 195 CURLOPT_CUSTOMREQUEST => 'POST', 196 CURLOPT_POSTFIELDS => json_encode([ 197 'service_id' => leyka_options()->opt('mixplat_service_id'), 198 'phone' => $phone, 199 'amount' => $amount, 200 'currency' => $currency, 201 'external_id' => $donation_id, 202 'test' => $is_test, 203 'signature' => md5( 204 leyka_options()->opt('mixplat_service_id').$phone.$amount.$currency.$donation_id.$is_test 205 .leyka_options()->opt('mixplat_secret_key') 206 ), 207 ]), 208 CURLOPT_VERBOSE => true, 209 CURLOPT_RETURNTRANSFER => true, 210 CURLOPT_CONNECTTIMEOUT => 60, 211 ]); 212 $answer = curl_exec($ch); 213 curl_close($ch); 214 215 $json = null; 216 if($answer) { 217 try { 218 $json = json_decode($answer, true); 219 } catch(Exception $ex) { 220 error_log($ex); 221 } 222 } 223 224 if($json) { 225 226 $donation->add_gateway_response($json); 227 228 if($json['result'] == 'ok') { 229 $is_success = true; 230 } 231 232 } 233 234 } 177 235 178 236 if($is_success) { … … 599 657 $this->_description = apply_filters( 600 658 'leyka_pm_description', 601 __('M obile payment is performed from user mobile account withoutsending SMS.', 'leyka'),659 __('MIXPLAT allows a simple and safe way to pay for goods and services with your mobile phone by sending SMS.', 'leyka'), 602 660 $this->_id, 603 661 $this->_gateway_id, … … 644 702 645 703 } 646 protected function _set_options_defaults() {647 648 if($this->_options) {649 return;650 }651 652 $this->_options = [653 'mixplat_test_mode' => [654 'type' => 'checkbox',655 'default' => false,656 'title' => __('Payments testing mode', 'leyka'),657 'comment' => __('Check if the gateway integration is in test mode.', 'leyka'),658 'short_format' => true,659 'required' => false,660 ],661 ];662 663 }664 704 665 705 } … … 677 717 $this->_description = apply_filters( 678 718 'leyka_pm_description', 679 __(' Payments via SMS are common way of collecting donations by sending SMS with keyword to short 4-digit number.', 'leyka'),719 __('MIXPLAT allows a simple and safe way to pay for goods and services with your mobile phone by sending SMS.', 'leyka'), 680 720 $this->_id, 681 721 $this->_gateway_id, … … 725 765 'list_entries' => 'leyka_get_campaigns_list', 726 766 ], 767 $this->full_id.'_description' => [ 768 'type' => 'html', 769 'title' => __('Comment to the message of donations via SMS', 'leyka'), 770 'comment' => __('Please, set a text of payments via SMS description.', 'leyka'), 771 ], 727 772 $this->full_id.'_details' => [ 728 773 'type' => 'html', 729 'default' => __(' Donate by sending SMS to short number 3434 with text XXXX and your donation amount.', 'leyka'),730 'title' => __(' Text howto donate via SMS', 'leyka'),731 'comment' => __(' Enter text describing donation via SMS. Change XXXX to your registered keyword in MIXPLAT system.', 'leyka'),774 'default' => __('You can make a donation by sending an SMS on the number XXXX.', 'leyka'), 775 'title' => __('Ways to donate via SMS', 'leyka'), 776 'comment' => __('Please, set a text to describe a donation via SMS.', 'leyka'), 732 777 'required' => true, 733 778 ],
Note: See TracChangeset
for help on using the changeset viewer.