/**
  * Returns list of payment tokens for current customer session
  *
  * @return PaymentTokenInterface[]
  */
 public function getCustomerSessionTokens()
 {
     $vaultPayments = [];
     $customerId = $this->session->getCustomerId();
     if (!$customerId) {
         return $vaultPayments;
     }
     $storeId = $this->storeManager->getStore()->getId();
     if (!$this->vaultPayment->isActive($storeId)) {
         return $vaultPayments;
     }
     $providerCode = $this->vaultPayment->getProviderCode($storeId);
     return $this->tokenManagement->getVisibleAvailableTokens($customerId, $providerCode);
 }
 /**
  * Retrieve assoc array of checkout configuration
  *
  * @return array
  */
 public function getConfig()
 {
     $vaultPayments = [];
     $customerId = $this->session->getCustomerId();
     if (!$customerId) {
         return $vaultPayments;
     }
     $storeId = $this->storeManager->getStore()->getId();
     if (!$this->vaultPayment->isActive($storeId)) {
         return $vaultPayments;
     }
     $vaultProviderCode = $this->vaultPayment->getProviderCode($storeId);
     $componentProvider = $this->getComponentProvider($vaultProviderCode);
     if (null === $componentProvider) {
         return $vaultPayments;
     }
     $filters[] = $this->filterBuilder->setField(PaymentTokenInterface::CUSTOMER_ID)->setValue($customerId)->create();
     $filters[] = $this->filterBuilder->setField(PaymentTokenInterface::IS_VISIBLE)->setValue(1)->create();
     $filters[] = $this->filterBuilder->setField(PaymentTokenInterface::PAYMENT_METHOD_CODE)->setValue($vaultProviderCode)->create();
     $searchCriteria = $this->searchCriteriaBuilder->addFilters($filters)->create();
     foreach ($this->paymentTokenRepository->getList($searchCriteria)->getItems() as $index => $token) {
         $component = $componentProvider->getComponentForToken($token);
         $vaultPayments[VaultPaymentInterface::CODE . '_item_' . $index] = ['config' => $component->getConfig(), 'component' => $component->getName()];
     }
     return ['payment' => [VaultPaymentInterface::CODE => $vaultPayments]];
 }
 /**
  * Get code of payment method provider
  * @return null|string
  */
 private function getProviderMethodCode()
 {
     if (!$this->providerCode) {
         $storeId = $this->getStoreId();
         $this->providerCode = $storeId ? $this->vaultPayment->getProviderCode($storeId) : null;
     }
     return $this->providerCode;
 }
 /**
  * Retrieve assoc array of checkout configuration
  *
  * @return array
  */
 public function getConfig()
 {
     $vaultPayments = [];
     $storeId = $this->storeManager->getStore()->getId();
     if (!$this->vaultPayment->isActive($storeId)) {
         return $vaultPayments;
     }
     $providerCode = $this->vaultPayment->getProviderCode($storeId);
     $componentProvider = $this->getComponentProvider($providerCode);
     if (null === $componentProvider) {
         return $vaultPayments;
     }
     foreach ($this->customerTokenManagement->getCustomerSessionTokens() as $i => $token) {
         $component = $componentProvider->getComponentForToken($token);
         $vaultPayments[VaultPaymentInterface::CODE . '_item_' . $i] = ['config' => $component->getConfig(), 'component' => $component->getName()];
     }
     return ['payment' => [VaultPaymentInterface::CODE => $vaultPayments]];
 }
 /**
  * Retrieve assoc array of checkout configuration
  *
  * @return array
  */
 public function getConfig()
 {
     $storeId = $this->storeManager->getStore()->getId();
     $customerId = $this->session->getCustomerId();
     return [VaultPaymentInterface::CODE => ['vault_provider_code' => $this->vault->getProviderCode($storeId), 'is_enabled' => $customerId !== null && $this->vault->isActive($storeId)]];
 }