Skip to content

Commit

Permalink
Merge pull request #252 from TransbankDevelopers/feat/improve-oneclic…
Browse files Browse the repository at this point in the history
…k-payment-flow

feat: use user id instead of the email
  • Loading branch information
mastudillot authored Aug 19, 2024
2 parents 92868f6 + ac42a86 commit 08e8c68
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -717,10 +717,10 @@ 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();
$userId = $currentUser->id;
$inscriptionId = $paymentToken->get_userId();

return $userEmail == $inscriptionEmail;
return $userId == $inscriptionId;
}

public function getOneclickPaymentTokenClass()
Expand Down
12 changes: 12 additions & 0 deletions plugin/src/Tokenization/WC_Payment_Token_Oneclick.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 08e8c68

Please sign in to comment.