From cb64b41f2a3f9070e9bb9fffe20ba66d7935924a Mon Sep 17 00:00:00 2001 From: Mauricio Astudillo Toledo Date: Thu, 1 Aug 2024 16:24:16 -0400 Subject: [PATCH] feat: use user id instead of the email --- .../WC_Gateway_Transbank_Oneclick_Mall_REST.php | 4 ++-- .../src/Tokenization/WC_Payment_Token_Oneclick.php | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/plugin/src/PaymentGateways/WC_Gateway_Transbank_Oneclick_Mall_REST.php b/plugin/src/PaymentGateways/WC_Gateway_Transbank_Oneclick_Mall_REST.php index a1aac1e0..1bb896e9 100644 --- a/plugin/src/PaymentGateways/WC_Gateway_Transbank_Oneclick_Mall_REST.php +++ b/plugin/src/PaymentGateways/WC_Gateway_Transbank_Oneclick_Mall_REST.php @@ -717,8 +717,8 @@ private function getTotalAmountFromOrder(WC_Order $order): int private function validatePayerMatchesCardInscription(WC_Payment_Token_Oneclick $paymentToken): bool { $currentUser = wp_get_current_user(); - $userEmail = $currentUser->user_email; - $inscriptionEmail = $paymentToken->get_email(); + $userEmail = $currentUser->id; + $inscriptionEmail = $paymentToken->get_userId(); return $userEmail == $inscriptionEmail; } diff --git a/plugin/src/Tokenization/WC_Payment_Token_Oneclick.php b/plugin/src/Tokenization/WC_Payment_Token_Oneclick.php index b274ab3d..a8c2934d 100644 --- a/plugin/src/Tokenization/WC_Payment_Token_Oneclick.php +++ b/plugin/src/Tokenization/WC_Payment_Token_Oneclick.php @@ -197,4 +197,16 @@ public function set_email($email) { $this->set_prop('email', $email); } + + /** + * Returns the user id of the inscriptions. + * + * @param string $context What the value is for. Valid values are view and edit. + * + * @return int The user id. + */ + public function get_userId($context = 'view') + { + return $this->get_prop('user_id', $context); + } }