CardRenderer.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Braintree\Block\Customer;
  7. use Magento\Braintree\Model\Ui\ConfigProvider;
  8. use Magento\Framework\View\Element\Template;
  9. use Magento\Vault\Api\Data\PaymentTokenInterface;
  10. use Magento\Vault\Block\AbstractCardRenderer;
  11. /**
  12. * @api
  13. * @since 100.1.0
  14. */
  15. class CardRenderer extends AbstractCardRenderer
  16. {
  17. /**
  18. * Can render specified token
  19. *
  20. * @param PaymentTokenInterface $token
  21. * @return boolean
  22. * @since 100.1.0
  23. */
  24. public function canRender(PaymentTokenInterface $token)
  25. {
  26. return $token->getPaymentMethodCode() === ConfigProvider::CODE;
  27. }
  28. /**
  29. * @return string
  30. * @since 100.1.0
  31. */
  32. public function getNumberLast4Digits()
  33. {
  34. return $this->getTokenDetails()['maskedCC'];
  35. }
  36. /**
  37. * @return string
  38. * @since 100.1.0
  39. */
  40. public function getExpDate()
  41. {
  42. return $this->getTokenDetails()['expirationDate'];
  43. }
  44. /**
  45. * @return string
  46. * @since 100.1.0
  47. */
  48. public function getIconUrl()
  49. {
  50. return $this->getIconForType($this->getTokenDetails()['type'])['url'];
  51. }
  52. /**
  53. * @return int
  54. * @since 100.1.0
  55. */
  56. public function getIconHeight()
  57. {
  58. return $this->getIconForType($this->getTokenDetails()['type'])['height'];
  59. }
  60. /**
  61. * @return int
  62. * @since 100.1.0
  63. */
  64. public function getIconWidth()
  65. {
  66. return $this->getIconForType($this->getTokenDetails()['type'])['width'];
  67. }
  68. }