Skip to content

Commit

Permalink
Merge pull request #429 from Payselection/master
Browse files Browse the repository at this point in the history
Deleted site ip
  • Loading branch information
BootWP authored Jan 25, 2024
2 parents 3c2159c + 4f89c53 commit ef5c8a8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
10 changes: 6 additions & 4 deletions gateways/payselection/js/leyka.payselection.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
$form.data('submit-in-process', 1);
}

$errors.html('').hide();

// Donation form validation already passed in the main script (public.js)

const $_form = $form.clone(),
Expand Down Expand Up @@ -105,16 +107,16 @@
key: response.widget_key
}, response.request, {
onSuccess: (res) => {
$errors.html('').hide();
window.location.href = response.success_page;
},
onError: (res) => {
let errorMeggage = res.errorMessage ? ' - '+res.errorMessage : '';
addError($errors, leyka.payselection_error + leyka.payselection_widget_errors[res.code] + errorMeggage || res.code);
},
onClose: (res) => {
if (res.code === 'PAY_WIDGET:CLOSE_AFTER_FAIL') {
window.location.href = response.failure_page;
}
addError($errors, leyka.payselection_error + res.code);
},
onClose: () => {
}
});
}
Expand Down
30 changes: 11 additions & 19 deletions gateways/payselection/leyka-class-payselection-gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,27 +115,9 @@ protected function _set_options_defaults() {
'comment' => __('If this option is enabled order receipts will be created and sent to your customer and to the revenue service via Payselection.', 'leyka'),
'short_format' => true,
],
'site_ip' => [
'type' => 'static_text',
'title' => __('Site IP', 'leyka'),
'is_html' => true,
'value' => $this->get_site_ip_content(),
],
];
}

public function get_site_ip_content() {

$response = wp_remote_get('https://api.ipify.org/');

if ( is_array($response) && !is_wp_error($response) ) {
return '<div>'.$response['body'].'</div>';
}

return false;

}

public function is_setup_complete($pm_id = false) {
return leyka_options()->opt('payselection_host')
&& leyka_options()->opt('payselection_create_host')
Expand All @@ -154,6 +136,16 @@ public function localize_js_strings(array $js_data) {
'ajax_wrong_server_response' => __('Error in server response. Please report to the website tech support.', 'leyka'),
'payselection_not_set_up' => __('Error in Payselection settings. Please report to the website tech support.', 'leyka'),
'payselection_error' => __('Payselection Error:', 'leyka'). ' ',
'payselection_widget_errors' => [
'PAY_WIDGET:CREATE_INVALID_PARAMS' => __('Parameter error', 'leyka'), //onError
'PAY_WIDGET:CREATE_BAD_REQUEST_ERROR' => __('System error', 'leyka'), //onError
'PAY_WIDGET:CREATE_NETWORK_ERROR' => __('Network error', 'leyka'), //onError
'PAY_WIDGET:TRANSACTION_FAIL' => __('Transaction error', 'leyka'), //onError
'PAY_WIDGET:CLOSE_COMMON_ERROR' => __('Close after an error', 'leyka'), //onClose
'PAY_WIDGET:CLOSE_BEFORE_PAY' => __('Payment not completed', 'leyka'), //onClose
'PAY_WIDGET:CLOSE_AFTER_FAIL' => __('Close after fail', 'leyka'), //onClose
'PAY_WIDGET:CLOSE_AFTER_SUCCESS' => __('Close after success', 'leyka'), //onClose
],
]);
}

Expand Down Expand Up @@ -815,7 +807,7 @@ public function _set_attributes() {
LEYKA_PLUGIN_BASE_URL.'img/pm-icons/card-mir.svg',
]);

$this->_supported_currencies = ['rub', 'eur', 'usd', 'kgs'];
$this->_supported_currencies = ['rub'];
$this->_default_currency = 'rub';

$this->_processing_type = 'custom-process-submit-event';
Expand Down

0 comments on commit ef5c8a8

Please sign in to comment.