Model/Factory/VaultTokenFactory.php
public function create(array $card, $customerId = null) {
        $expiryMonth    = str_pad($card['expiryMonth'], 2, '0', STR_PAD_LEFT);
        $expiryYear     = $card['expiryYear'];
        $expiresAt      = $this->getExpirationDate($expiryMonth, $expiryYear);
        $ccType         = $this->ccTypeAdapter->getFromGateway($card['paymentMethod']);

        /** @var PaymentTokenInterface $paymentToken */
        $paymentToken = $this->creditCardTokenFactory->create();
        $paymentToken->setExpiresAt($expiresAt);

        if( array_key_exists('id', $card) ) {
            $paymentToken->setGatewayToken($card['id']);
        }

        $tokenDetails = [
            'type'              => $ccType,
            'maskedCC'          => $card['last4'],
            'expirationDate'    => $expiryMonth . '/' . $expiryYear,
        ];

        $paymentToken->setTokenDetails($this->convertDetailsToJSON($tokenDetails));
        $paymentToken->setIsActive(true);
        $paymentToken->setPaymentMethodCode(ConfigProvider::CODE);

        if($customerId) {
            $paymentToken->setCustomerId($customerId);
        }

        $paymentToken->setPublicHash($this->generatePublicHash($paymentToken));

        return $paymentToken;
    }
public function create(array $card, $customerId = null) {
        $expiryMonth    = str_pad($card['expiryMonth'], 2, '0', STR_PAD_LEFT);
        $expiryYear     = $card['expiryYear'];
        $expiresAt      = $this->getExpirationDate($expiryMonth, $expiryYear);
        $ccType         = $this->ccTypeAdapter->getFromGateway($card['paymentMethod']);

        /** @var PaymentTokenInterface $paymentToken */
        $paymentToken = $this->creditCardTokenFactory->create();
        $paymentToken->setExpiresAt($expiresAt);

        if( array_key_exists('id', $card) ) {
            $paymentToken->setGatewayToken($card['id']);
        }

        $tokenDetails = [
            'type'              => $ccType,
            'maskedCC'          => $card['last4'],
            'expirationDate'    => $expiryMonth . '/' . $expiryYear,
        ];

        $paymentToken->setTokenDetails($this->convertDetailsToJSON($tokenDetails));
        $paymentToken->setIsActive(true);
        $paymentToken->setPaymentMethodCode(ConfigProvider::CODE);

        if($customerId) {
            $paymentToken->setCustomerId($customerId);
        }

        $paymentToken->setPublicHash($this->generatePublicHash($paymentToken));

        return $paymentToken;
    }
public function create ( array $ card , $ customerId = null ) { $ expiryMonth = str_pad ( $ card [ 'expiryMonth' ] , 2 , '0' , STR_PAD_LEFT ) ; $ expiryYear = $ card [ 'expiryYear' ] ; $ expiresAt = $ this -> getExpirationDate ( $ expiryMonth , $ expiryYear ) ; $ ccType = $ this -> ccTypeAdapter -> getFromGateway ( $ card [ 'paymentMethod' ] ) ; /** @var PaymentTokenInterface $paymentToken */ $ paymentToken = $ this -> creditCardTokenFactory -> create ( ) ; $ paymentToken -> setExpiresAt ( $ expiresAt ) ; if ( array_key_exists ( 'id' , $ card ) ) { $ paymentToken -> setGatewayToken ( $ card [ 'id' ] ) ; } $ tokenDetails = [ 'type' => $ ccType , 'maskedCC' => $ card [ 'last4' ] , 'expirationDate' => $ expiryMonth . '/' . $ expiryYear , ] ; $ paymentToken -> setTokenDetails ( $ this -> convertDetailsToJSON ( $ tokenDetails ) ) ; $ paymentToken -> setIsActive ( true ) ; $ paymentToken -> setPaymentMethodCode ( ConfigProvider :: CODE ) ; if ( $ customerId ) { $ paymentToken -> setCustomerId ( $ customerId ) ; } $ paymentToken -> setPublicHash ( $ this -> generatePublicHash ( $ paymentToken ) ) ; return $ paymentToken ; }
Returns the prepared payment token.

@param array $card
@param int|null $customerId
@return PaymentTokenInterface
Returns the prepared payment token .