--- a/wallet-system-for-woocommerce/includes/class-wallet-system-ajaxhandler.php
+++ b/wallet-system-for-woocommerce/includes/class-wallet-system-ajaxhandler.php
@@ -145,6 +145,8 @@
$requesting_user_id = empty( $_POST['requesting_user_id'] ) ? 0 : sanitize_text_field( wp_unslash( $_POST['requesting_user_id'] ) );
+ $requested_user_id = empty( $_POST['requested_user_id'] ) ? 0 : sanitize_text_field( wp_unslash( $_POST['requested_user_id'] ) );
+
$status = ( isset( $_POST['status'] ) ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : '';
$withdrawal_balance = empty( $_POST['withdrawal_balance'] ) ? 0 : sanitize_text_field( wp_unslash( $_POST['withdrawal_balance'] ) );
@@ -155,159 +157,168 @@
$withdrawal_request = get_post( $request_id );
- if ( 'approved' == $status ) {
-
- $requesting_user_wallet = get_user_meta( $requesting_user_id, 'wps_wallet', true );
- $requesting_user_wallet = (float) $requesting_user_wallet;
- $user_wallet = get_user_meta( $user_id, 'wps_wallet', true );
- $user_wallet = (float) $user_wallet;
-
- if ( $user_wallet >= $withdrawal_balance ) {
- $requesting_user_wallet += $withdrawal_balance;
- $returnid = update_user_meta( $requesting_user_id, 'wps_wallet', $requesting_user_wallet );
-
- if ( $returnid ) {
- $wallet_payment_gateway = new Wallet_System_For_Woocommerce();
- $send_email_enable = get_option( 'wps_wsfw_enable_email_notification_for_wallet_update', '' );
- // first user.
- $user1 = get_user_by( 'id', $requesting_user_id );
- $name1 = $user1->first_name . ' ' . $user1->last_name;
-
- $user2 = get_user_by( 'id', $user_id );
- $name2 = $user2->first_name . ' ' . $user2->last_name;
- $balance = $current_currency . ' ' . $withdrawal_balance;
- if ( isset( $send_email_enable ) && 'on' === $send_email_enable ) {
-
- $mail_text1 = esc_html__( 'Hello ', 'wallet-system-for-woocommerce' ) . esc_html( $name1 ) . ",rn";
- $mail_text1 .= __( 'Wallet credited by ', 'wallet-system-for-woocommerce' ) . esc_html( $balance ) . __( ' through wallet fund request by ', 'wallet-system-for-woocommerce' ) . $name2;
- $to1 = $user1->user_email;
- $from = get_option( 'admin_email' );
- $subject = __( 'Wallet updating notification', 'wallet-system-for-woocommerce' );
- $headers1 = 'MIME-Version: 1.0' . "rn";
- $headers1 .= 'Content-Type: text/html; charset=UTF-8' . "rn";
- $headers1 .= 'From: ' . $from . "rn" .
- 'Reply-To: ' . $to1 . "rn";
-
- if ( key_exists( 'wps_wswp_wallet_credit', WC()->mailer()->emails ) ) {
-
- $customer_email = WC()->mailer()->emails['wps_wswp_wallet_credit'];
- if ( ! empty( $customer_email ) ) {
- $user = get_user_by( 'id', $requesting_user_id );
- $currency = get_woocommerce_currency();
- $balance_mail = $balance;
- $user_name = $user->first_name . ' ' . $user->last_name;
- $email_status = $customer_email->trigger( $requesting_user_id, $user_name, $balance_mail, '' );
- }
- } else {
-
- $wallet_payment_gateway->send_mail_on_wallet_updation( $to1, $subject, $mail_text1, $headers1 );
- }
- }
-
- $transaction_type = __( 'Wallet credited by user ', 'wallet-system-for-woocommerce' ) . $user2->user_email . __( ' to user ', 'wallet-system-for-woocommerce' ) . $user1->user_email;
- $wallet_transfer_data = array(
- 'user_id' => $requesting_user_id,
- 'amount' => $withdrawal_balance,
- 'currency' => $current_currency,
- 'payment_method' => __( 'Wallet Fund Request', 'wallet-system-for-woocommerce' ),
- 'transaction_type' => $transaction_type,
- 'transaction_type_1' => 'credit',
- 'order_id' => '',
- 'note' => '',
-
- );
-
- $wallet_payment_gateway->insert_transaction_data_in_table( $wallet_transfer_data );
-
- $user_wallet -= $withdrawal_balance;
- $update_user = update_user_meta( $user_id, 'wps_wallet', abs( $user_wallet ) );
- if ( $update_user ) {
+ if ( $requested_user_id != $user_id ) {
+ $wps_wsfw_error_text = esc_html__( 'You are not authorized to perform this action', 'wallet-system-for-woocommerce' );
+ $message = array(
+ 'msg' => $wps_wsfw_error_text,
+ 'msgType' => 'error',
+ );
+ } else {
+ if ( 'approved' == $status ) {
+
+ $requesting_user_wallet = get_user_meta( $requesting_user_id, 'wps_wallet', true );
+ $requesting_user_wallet = (float) $requesting_user_wallet;
+ $user_wallet = get_user_meta( $user_id, 'wps_wallet', true );
+ $user_wallet = (float) $user_wallet;
+
+ if ( $user_wallet >= $withdrawal_balance ) {
+ $requesting_user_wallet += $withdrawal_balance;
+ $returnid = update_user_meta( $requesting_user_id, 'wps_wallet', $requesting_user_wallet );
+
+ if ( $returnid ) {
+ $wallet_payment_gateway = new Wallet_System_For_Woocommerce();
+ $send_email_enable = get_option( 'wps_wsfw_enable_email_notification_for_wallet_update', '' );
+ // first user.
+ $user1 = get_user_by( 'id', $requesting_user_id );
+ $name1 = $user1->first_name . ' ' . $user1->last_name;
+
+ $user2 = get_user_by( 'id', $user_id );
+ $name2 = $user2->first_name . ' ' . $user2->last_name;
$balance = $current_currency . ' ' . $withdrawal_balance;
if ( isset( $send_email_enable ) && 'on' === $send_email_enable ) {
- $mail_text2 = esc_html__( 'Hello ', 'wallet-system-for-woocommerce' ) . esc_html( $name2 ) . ",rn";
- $mail_text2 .= __( 'Wallet debited by ', 'wallet-system-for-woocommerce' ) . esc_html( $balance ) . __( ' through wallet fund request to ', 'wallet-system-for-woocommerce' ) . $name1;
- $to2 = $user2->user_email;
- $headers2 = 'MIME-Version: 1.0' . "rn";
- $headers2 .= 'Content-Type: text/html; charset=UTF-8' . "rn";
- $headers2 .= 'From: ' . $from . "rn" .
- 'Reply-To: ' . $to2 . "rn";
- if ( key_exists( 'wps_wswp_wallet_debit', WC()->mailer()->emails ) ) {
-
- $customer_email = WC()->mailer()->emails['wps_wswp_wallet_debit'];
+
+ $mail_text1 = esc_html__( 'Hello ', 'wallet-system-for-woocommerce' ) . esc_html( $name1 ) . ",rn";
+ $mail_text1 .= __( 'Wallet credited by ', 'wallet-system-for-woocommerce' ) . esc_html( $balance ) . __( ' through wallet fund request by ', 'wallet-system-for-woocommerce' ) . $name2;
+ $to1 = $user1->user_email;
+ $from = get_option( 'admin_email' );
+ $subject = __( 'Wallet updating notification', 'wallet-system-for-woocommerce' );
+ $headers1 = 'MIME-Version: 1.0' . "rn";
+ $headers1 .= 'Content-Type: text/html; charset=UTF-8' . "rn";
+ $headers1 .= 'From: ' . $from . "rn" .
+ 'Reply-To: ' . $to1 . "rn";
+
+ if ( key_exists( 'wps_wswp_wallet_credit', WC()->mailer()->emails ) ) {
+
+ $customer_email = WC()->mailer()->emails['wps_wswp_wallet_credit'];
if ( ! empty( $customer_email ) ) {
- $user = get_user_by( 'id', $user_id );
+ $user = get_user_by( 'id', $requesting_user_id );
$currency = get_woocommerce_currency();
$balance_mail = $balance;
$user_name = $user->first_name . ' ' . $user->last_name;
- $customer_email->trigger( $user_id, $user_name, $balance_mail, '' );
+ $email_status = $customer_email->trigger( $requesting_user_id, $user_name, $balance_mail, '' );
}
} else {
-
- $wallet_payment_gateway->send_mail_on_wallet_updation( $to2, $subject, $mail_text2, $headers2 );
+
+ $wallet_payment_gateway->send_mail_on_wallet_updation( $to1, $subject, $mail_text1, $headers1 );
}
}
-
- $transaction_type = __( 'Wallet debited from user ', 'wallet-system-for-woocommerce' ) . $user2->user_email . __( ' wallet, transferred to user ', 'wallet-system-for-woocommerce' ) . $user1->user_email;
- $transaction_data = array(
- 'user_id' => $user_id,
+
+ $transaction_type = __( 'Wallet credited by user ', 'wallet-system-for-woocommerce' ) . $user2->user_email . __( ' to user ', 'wallet-system-for-woocommerce' ) . $user1->user_email;
+ $wallet_transfer_data = array(
+ 'user_id' => $requesting_user_id,
'amount' => $withdrawal_balance,
'currency' => $current_currency,
'payment_method' => __( 'Wallet Fund Request', 'wallet-system-for-woocommerce' ),
'transaction_type' => $transaction_type,
- 'transaction_type_1' => 'debit',
+ 'transaction_type_1' => 'credit',
'order_id' => '',
'note' => '',
-
- );
-
- $result = $wallet_payment_gateway->insert_transaction_data_in_table( $transaction_data );
- $withdrawal_request->post_status = 'approved';
- wp_update_post( $withdrawal_request );
- $wps_wsfw_error_text = esc_html__( 'Wallet fund request is approved for user #', 'wallet-system-for-woocommerce' ) . $requesting_user_id;
- $message = array(
- 'msg' => $wps_wsfw_error_text,
- 'msgType' => 'success',
+
);
- } else {
- $wps_wsfw_error_text = esc_html__( 'There is an error in database', 'wallet-system-for-woocommerce' );
- $message = array(
- 'msg' => $wps_wsfw_error_text,
- 'msgType' => 'error',
- );
+
+ $wallet_payment_gateway->insert_transaction_data_in_table( $wallet_transfer_data );
+
+ $user_wallet -= $withdrawal_balance;
+ $update_user = update_user_meta( $user_id, 'wps_wallet', abs( $user_wallet ) );
+ if ( $update_user ) {
+ $balance = $current_currency . ' ' . $withdrawal_balance;
+ if ( isset( $send_email_enable ) && 'on' === $send_email_enable ) {
+ $mail_text2 = esc_html__( 'Hello ', 'wallet-system-for-woocommerce' ) . esc_html( $name2 ) . ",rn";
+ $mail_text2 .= __( 'Wallet debited by ', 'wallet-system-for-woocommerce' ) . esc_html( $balance ) . __( ' through wallet fund request to ', 'wallet-system-for-woocommerce' ) . $name1;
+ $to2 = $user2->user_email;
+ $headers2 = 'MIME-Version: 1.0' . "rn";
+ $headers2 .= 'Content-Type: text/html; charset=UTF-8' . "rn";
+ $headers2 .= 'From: ' . $from . "rn" .
+ 'Reply-To: ' . $to2 . "rn";
+ if ( key_exists( 'wps_wswp_wallet_debit', WC()->mailer()->emails ) ) {
+
+ $customer_email = WC()->mailer()->emails['wps_wswp_wallet_debit'];
+ if ( ! empty( $customer_email ) ) {
+ $user = get_user_by( 'id', $user_id );
+ $currency = get_woocommerce_currency();
+ $balance_mail = $balance;
+ $user_name = $user->first_name . ' ' . $user->last_name;
+ $customer_email->trigger( $user_id, $user_name, $balance_mail, '' );
+ }
+ } else {
+
+ $wallet_payment_gateway->send_mail_on_wallet_updation( $to2, $subject, $mail_text2, $headers2 );
+ }
+ }
+
+ $transaction_type = __( 'Wallet debited from user ', 'wallet-system-for-woocommerce' ) . $user2->user_email . __( ' wallet, transferred to user ', 'wallet-system-for-woocommerce' ) . $user1->user_email;
+ $transaction_data = array(
+ 'user_id' => $user_id,
+ 'amount' => $withdrawal_balance,
+ 'currency' => $current_currency,
+ 'payment_method' => __( 'Wallet Fund Request', 'wallet-system-for-woocommerce' ),
+ 'transaction_type' => $transaction_type,
+ 'transaction_type_1' => 'debit',
+ 'order_id' => '',
+ 'note' => '',
+
+ );
+
+ $result = $wallet_payment_gateway->insert_transaction_data_in_table( $transaction_data );
+ $withdrawal_request->post_status = 'approved';
+ wp_update_post( $withdrawal_request );
+ $wps_wsfw_error_text = esc_html__( 'Wallet fund request is approved for user #', 'wallet-system-for-woocommerce' ) . $requesting_user_id;
+ $message = array(
+ 'msg' => $wps_wsfw_error_text,
+ 'msgType' => 'success',
+ );
+ } else {
+ $wps_wsfw_error_text = esc_html__( 'There is an error in database', 'wallet-system-for-woocommerce' );
+ $message = array(
+ 'msg' => $wps_wsfw_error_text,
+ 'msgType' => 'error',
+ );
+ }
}
+ } else {
+ $wps_wsfw_error_text = esc_html__( 'There is an error in database', 'wallet-system-for-woocommerce' );
+ $message = array(
+ 'msg' => $wps_wsfw_error_text,
+ 'msgType' => 'error',
+ );
}
- } else {
- $wps_wsfw_error_text = esc_html__( 'There is an error in database', 'wallet-system-for-woocommerce' );
- $message = array(
- 'msg' => $wps_wsfw_error_text,
- 'msgType' => 'error',
- );
}
- }
- if ( 'rejected' == $status ) {
- if ( $user_id ) {
-
- $withdrawal_request->post_status = 'rejected';
- wp_update_post( $withdrawal_request );
- $wps_wsfw_error_text = esc_html__( 'Wallet fund request is rejected for user #', 'wallet-system-for-woocommerce' ) . $requesting_user_id;
- $message = array(
- 'msg' => $wps_wsfw_error_text,
- 'msgType' => 'success',
- );
+ if ( 'rejected' == $status ) {
+ if ( $user_id ) {
+
+ $withdrawal_request->post_status = 'rejected';
+ wp_update_post( $withdrawal_request );
+ $wps_wsfw_error_text = esc_html__( 'Wallet fund request is rejected for user #', 'wallet-system-for-woocommerce' ) . $requesting_user_id;
+ $message = array(
+ 'msg' => $wps_wsfw_error_text,
+ 'msgType' => 'success',
+ );
+ }
+ }
+ if ( 'pending1' === $status ) {
+
+ if ( $user_id ) {
+ $withdrawal_request->post_status = 'pending1';
+ wp_update_post( $withdrawal_request );
+ $wps_wsfw_error_text = esc_html__( 'Wallet withdrawal request status is changed to pending for user #', 'wallet-system-for-woocommerce' ) . $user_id;
+ $message = array(
+ 'msg' => $wps_wsfw_error_text,
+ 'msgType' => 'success',
+ );
+ };
}
}
- if ( 'pending1' === $status ) {
- if ( $user_id ) {
- $withdrawal_request->post_status = 'pending1';
- wp_update_post( $withdrawal_request );
- $wps_wsfw_error_text = esc_html__( 'Wallet withdrawal request status is changed to pending for user #', 'wallet-system-for-woocommerce' ) . $user_id;
- $message = array(
- 'msg' => $wps_wsfw_error_text,
- 'msgType' => 'success',
- );
- };
- }
wp_send_json( $message );
}
--- a/wallet-system-for-woocommerce/includes/class-wallet-system-for-woocommerce.php
+++ b/wallet-system-for-woocommerce/includes/class-wallet-system-for-woocommerce.php
@@ -81,7 +81,7 @@
$this->version = WALLET_SYSTEM_FOR_WOOCOMMERCE_VERSION;
} else {
- $this->version = '2.7.2';
+ $this->version = '2.7.3';
}
$this->plugin_name = 'wallet-system-for-woocommerce';
--- a/wallet-system-for-woocommerce/public/partials/wallet-system-for-woocommerce-wallet-fund-request.php
+++ b/wallet-system-for-woocommerce/public/partials/wallet-system-for-woocommerce-wallet-fund-request.php
@@ -274,6 +274,7 @@
<option class="rejected" value="rejected" > <?php esc_html_e( 'rejected', 'wallet-system-for-woocommerce' ); ?></option>
</select>
<input type="hidden" name="requesting_user_id" value="<?php echo esc_attr( $userid ); ?>" />
+ <input type="hidden" name="requested_user_id" value="<?php echo esc_attr( $requested_user_id ); ?>" />
<input type="hidden" name="withdrawal_balance" value="<?php echo esc_attr( $withdrawal_balance ); ?>" />
<input type="hidden" name="request_id" value="<?php echo esc_attr( $request_id ); ?>" />
<div id="overlay">
--- a/wallet-system-for-woocommerce/wallet-system-for-woocommerce.php
+++ b/wallet-system-for-woocommerce/wallet-system-for-woocommerce.php
@@ -15,16 +15,16 @@
* Plugin Name: Wallet System For WooCommerce
* Plugin URI: https://wordpress.org/plugins/wallet-system-for-woocommerce
* Description: <code><strong>Wallet System for WooCommerce</strong></code> is a digital wallet plugin where users can add or delete balances in bulk, give refunds and earn cashback. <a href="https://wpswings.com/woocommerce-plugins/?utm_source=wpswings-wallet-shop&utm_medium=wallet-org-backend&utm_campaign=shop-page" target="_blank"> Elevate your e-commerce store by exploring more on <strong> WP Swings </strong></a>.
- * Version: 2.7.2
+ * Version: 2.7.3
* Author: WP Swings
* Author URI: https://wpswings.com/?utm_source=wpswings-wallet-official&utm_medium=wallet-org-backend&utm_campaign=official
* Text Domain: wallet-system-for-woocommerce
* Domain Path: /languages
* Requires Plugins: woocommerce
* WC Requires at least: 5.5.0
- * WC tested up to: 10.3.3
+ * WC tested up to: 10.4.3
* WP Requires at least: 6.7.0
- * WP tested up to: 6.8.3
+ * WP tested up to: 6.9
* Requires PHP: 7.4
*
* License: GNU General Public License v3.0