PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/app/code/Magento/Vault/Model/PaymentToken.php

https://gitlab.com/crazybutterfly815/magento2
PHP | 217 lines | 104 code | 23 blank | 90 comment | 0 complexity | bf1e0f599c2b3d59cdf619fccad780b3 MD5 | raw file
  1. <?php
  2. /**
  3. * Copyright © 2016 Magento. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Vault\Model;
  7. use Magento\Framework\Model\AbstractModel;
  8. use Magento\Vault\Api\Data\PaymentTokenExtensionInterface;
  9. use Magento\Vault\Model\ResourceModel;
  10. use Magento\Vault\Api\Data\PaymentTokenInterface;
  11. /**
  12. * Vault Payment Token extension attribute model
  13. */
  14. class PaymentToken extends AbstractModel implements PaymentTokenInterface
  15. {
  16. /**
  17. * @var string
  18. */
  19. protected $_eventPrefix = 'vault_payment_token';
  20. /**
  21. * @inheritdoc
  22. */
  23. protected function _construct()
  24. {
  25. $this->_init(ResourceModel\PaymentToken::class);
  26. }
  27. /**
  28. * @inheritdoc
  29. */
  30. public function getCustomerId()
  31. {
  32. return $this->getData(PaymentTokenInterface::CUSTOMER_ID);
  33. }
  34. /**
  35. * @inheritdoc
  36. */
  37. public function setCustomerId($customerId)
  38. {
  39. $this->setData(PaymentTokenInterface::CUSTOMER_ID, $customerId);
  40. return $this;
  41. }
  42. /**
  43. * @inheritdoc
  44. */
  45. public function getPaymentMethodCode()
  46. {
  47. return $this->getData(PaymentTokenInterface::PAYMENT_METHOD_CODE);
  48. }
  49. /**
  50. * @inheritdoc
  51. */
  52. public function setPaymentMethodCode($code)
  53. {
  54. $this->setData(PaymentTokenInterface::PAYMENT_METHOD_CODE, $code);
  55. return $this;
  56. }
  57. /**
  58. * @inheritdoc
  59. */
  60. public function getType()
  61. {
  62. return $this->getData(PaymentTokenInterface::TYPE);
  63. }
  64. /**
  65. * @inheritdoc
  66. */
  67. public function setType($type)
  68. {
  69. $this->setData(PaymentTokenInterface::TYPE, $type);
  70. return $this;
  71. }
  72. /**
  73. * @inheritdoc
  74. */
  75. public function getCreatedAt()
  76. {
  77. return $this->getData(PaymentTokenInterface::CREATED_AT);
  78. }
  79. /**
  80. * @inheritdoc
  81. */
  82. public function setCreatedAt($timestamp)
  83. {
  84. $this->setData(PaymentTokenInterface::CREATED_AT, $timestamp);
  85. return $this;
  86. }
  87. /**
  88. * @inheritdoc
  89. */
  90. public function getExpiresAt()
  91. {
  92. return $this->getData(PaymentTokenInterface::EXPIRES_AT);
  93. }
  94. /**
  95. * @inheritdoc
  96. */
  97. public function setExpiresAt($timestamp)
  98. {
  99. $this->setData(PaymentTokenInterface::EXPIRES_AT, $timestamp);
  100. return $this;
  101. }
  102. /**
  103. * @inheritdoc
  104. */
  105. public function getGatewayToken()
  106. {
  107. return $this->getData(PaymentTokenInterface::GATEWAY_TOKEN);
  108. }
  109. /**
  110. * @inheritdoc
  111. */
  112. public function setGatewayToken($token)
  113. {
  114. $this->setData(PaymentTokenInterface::GATEWAY_TOKEN, $token);
  115. return $this;
  116. }
  117. /**
  118. * @inheritdoc
  119. */
  120. public function getTokenDetails()
  121. {
  122. return $this->getData(PaymentTokenInterface::DETAILS);
  123. }
  124. /**
  125. * @inheritdoc
  126. */
  127. public function setTokenDetails($details)
  128. {
  129. $this->setData(PaymentTokenInterface::DETAILS, $details);
  130. return $this;
  131. }
  132. /**
  133. * Gets is vault payment record active.
  134. *
  135. * @return bool Is active.
  136. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  137. */
  138. public function getIsActive()
  139. {
  140. return (bool)$this->getData(PaymentTokenInterface::IS_ACTIVE);
  141. }
  142. /**
  143. * Sets is vault payment record active.
  144. *
  145. * @param bool $isActive
  146. * @return $this
  147. */
  148. public function setIsActive($isActive)
  149. {
  150. $this->setData(PaymentTokenInterface::IS_ACTIVE, (int)$isActive);
  151. return $this;
  152. }
  153. /**
  154. * Get frontend hash
  155. *
  156. * @return string
  157. */
  158. public function getPublicHash()
  159. {
  160. return $this->getData(PaymentTokenInterface::PUBLIC_HASH);
  161. }
  162. /**
  163. * Set frontend hash
  164. *
  165. * @param string $hash
  166. * @return $this
  167. */
  168. public function setPublicHash($hash)
  169. {
  170. $this->setData(PaymentTokenInterface::PUBLIC_HASH, $hash);
  171. return $this;
  172. }
  173. /**
  174. * Gets is vault payment record visible.
  175. *
  176. * @return bool Is visible.
  177. * @SuppressWarnings(PHPMD.BooleanGetMethodName)
  178. */
  179. public function getIsVisible()
  180. {
  181. return (bool) (int) $this->getData(PaymentTokenInterface::IS_VISIBLE);
  182. }
  183. /**
  184. * Sets is vault payment record visible.
  185. *
  186. * @param bool $isVisible
  187. * @return $this
  188. */
  189. public function setIsVisible($isVisible)
  190. {
  191. $this->setData(PaymentTokenInterface::IS_VISIBLE, (bool) $isVisible);
  192. return $this;
  193. }
  194. }