WC_Payment_Token_Data_Store::validate_token
Validate a payment token.
Method of the class: WC_Payment_Token_Data_Store{}
No Hooks.
Returns
null. Nothing (null).
Usage
// protected - for code of main (parent) or child class $result = $this->validate_token( $token ): void;
- $token(WC_Payment_Token) (required)
- Payment token object.
Changelog
| Since 11.3.0 | Introduced. |
WC_Payment_Token_Data_Store::validate_token() WC Payment Token Data Store::validate token code WC 11.3.0
protected function validate_token( $token ): void {
if ( false === $token->validate() ) {
if ( method_exists( $token, 'get_invalid_token_fields' ) ) {
$invalid_fields = $token->get_invalid_token_fields();
if ( array() !== $invalid_fields ) {
throw new WC_Data_Exception(
'woocommerce_invalid_payment_token_fields',
__( 'Invalid or missing payment token fields.', 'woocommerce' ), // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
0, // Use 0 for backwards compatibility with the Exception below.
array( 'invalid_fields' => $invalid_fields ) // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
);
}
}
throw new Exception( __( 'Invalid or missing payment token fields.', 'woocommerce' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
}
}