芝麻web文件管理V1.00
编辑当前文件:/home/royashxg/www/wp-content/plugins/fluentformpro/src/Payments/PaymentMethods/Paystack/API.php
0) { // Append the data $encoded_data .= $arg_separator . $post_data; } else { // Check if POST is empty if (empty($_POST)) { // Nothing to do return; } else { // Loop through each POST foreach ($_POST as $key => $value) { // Encode the value and append the data $encoded_data .= $arg_separator . "$key=" . urlencode($value); } } } // Convert collected post data to an array parse_str($encoded_data, $encoded_data_array); foreach ($encoded_data_array as $key => $value) { if (false !== strpos($key, 'amp;')) { $new_key = str_replace('&', '&', $key); $new_key = str_replace('amp;', '&', $new_key); unset($encoded_data_array[$key]); $encoded_data_array[$new_key] = $value; } } $defaults = $_REQUEST; $encoded_data_array = wp_parse_args($encoded_data_array, $defaults); $this->handleIpn($encoded_data_array); exit(200); } protected function handleIpn($data) { $submissionId = intval(ArrayHelper::get($data, 'submission_id')); if (!$submissionId || empty($data['id'])) { return; } $submission = wpFluent()->table('fluentform_submissions')->where('id', $submissionId)->first(); if (!$submission) { return; } $vendorTransaction = $this->makeApiCall('payments/' . $data['id'], [], $submission->form_id, 'GET'); if (is_wp_error($vendorTransaction)) { $logData = [ 'parent_source_id' => $submission->form_id, 'source_type' => 'submission_item', 'source_id' => $submission->id, 'component' => 'Payment', 'status' => 'error', 'title' => __('Mollie Payment Webhook Error', 'fluentformpro'), 'description' => $vendorTransaction->get_error_message() ]; do_action('fluentform/log_data', $logData); } $status = $vendorTransaction['status']; if ($status == 'captured') { $status = 'paid'; } do_action_deprecated( 'fluentform_ipn_razorpay_action_' . $status, [ $submission, $vendorTransaction, $data ], FLUENTFORM_FRAMEWORK_UPGRADE, 'fluentform/ipn_razorpay_action_' . $status, 'Use fluentform/ipn_razorpay_action_' . $status . ' instead of fluentform_ipn_razorpay_action_' . $status ); do_action('fluentform/ipn_razorpay_action_' . $status, $submission, $vendorTransaction, $data); if ($refundAmount = ArrayHelper::get($vendorTransaction, 'amountRefunded.value')) { $refundAmount = intval($refundAmount * 100); // in cents do_action_deprecated( 'fluentform_ipn_razorpay_action_refunded', [ $refundAmount, $submission, $vendorTransaction, $data ], FLUENTFORM_FRAMEWORK_UPGRADE, 'fluentform/ipn_razorpay_action_refunded', 'Use fluentform/ipn_razorpay_action_refunded instead of fluentform_ipn_razorpay_action_refunded.' ); do_action('fluentform/ipn_razorpay_action_refunded', $refundAmount, $submission, $vendorTransaction, $data); } } public function makeApiCall($path, $args, $formId, $method = 'GET') { $keys = PaystackSettings::getApiKeys($formId); $headers = [ 'Authorization' => 'Bearer ' . $keys['api_secret'], 'Content-type' => 'application/json' ]; if ($method == 'POST') { $response = wp_remote_post('https://api.paystack.co/' . $path, [ 'headers' => $headers, 'body' => json_encode($args) ]); } else { $response = wp_remote_get('https://api.paystack.co/' . $path, [ 'headers' => $headers, 'body' => $args ]); } if (is_wp_error($response)) { return $response; } $body = wp_remote_retrieve_body($response); $responseData = json_decode($body, true); if(!$responseData) { return new \WP_Error(423, 'Unknown Paystack API request error', $responseData); } if (!empty($responseData['error'])) { $message = ArrayHelper::get($responseData, 'error.description'); if (!$message) { $message = __('Unknown Paystack API request error', 'fluentformpro'); } return new \WP_Error(423, $message, $responseData); } else if (empty($responseData['status']) && !$responseData['status']) { // this is an error $message = __('Paystack API Error', 'fluentformpro'); if (!empty($responseData['message'])) { $message = $responseData['message']; } return new \WP_Error(423, $message, $responseData); } return $responseData; } }