src/gateways/Gateway.php
private function _normalizePaymentToken(string $token = ''): string
    {
        if (StringHelper::substr($token, 0, 4) === 'tok_') {
            try {
                /** @var Source $tokenSource */
                $tokenSource = Source::create([
                    'type' => 'card',
                    'token' => $token
                ]);

                return $tokenSource->id;
            } catch (\Exception $exception) {
                Craft::error('Unable to normalize payment token: ' . $token . ', because ' . $exception->getMessage());
            }
        }

        return $token;
    }
private function _normalizePaymentToken(string $token = ''): string
    {
        if (StringHelper::substr($token, 0, 4) === 'tok_') {
            try {
                /** @var Source $tokenSource */
                $tokenSource = Source::create([
                    'type' => 'card',
                    'token' => $token
                ]);

                return $tokenSource->id;
            } catch (\Exception $exception) {
                Craft::error('Unable to normalize payment token: ' . $token . ', because ' . $exception->getMessage());
            }
        }

        return $token;
    }
private function _normalizePaymentToken ( string $ token = '' ) : string { if ( StringHelper :: substr ( $ token , 0 , 4 ) === 'tok_' ) { try { /** @var Source $tokenSource */ $ tokenSource = Source :: create ( [ 'type' => 'card' , 'token' => $ token ] ) ; return $ tokenSource -> id ; } catch ( \ Exception $ exception ) { Craft :: error ( 'Unable to normalize payment token: ' . $ token . ', because ' . $ exception -> getMessage ( ) ) ; } } return $ token ; }
Normalize one-time payment token to a source token, that may or may not be multi-use.

@param string $token
@return string
Normalize one - time payment token to a source token that may or may not be multi - use .