PendingCapture.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <?php
  2. /**
  3. * Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License").
  6. * You may not use this file except in compliance with the License.
  7. * A copy of the License is located at
  8. *
  9. * http://aws.amazon.com/apache2.0
  10. *
  11. * or in the "license" file accompanying this file. This file is distributed
  12. * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  13. * express or implied. See the License for the specific language governing
  14. * permissions and limitations under the License.
  15. */
  16. namespace Amazon\Payment\Model;
  17. use Amazon\Payment\Api\Data\PendingCaptureInterface;
  18. use Amazon\Payment\Model\ResourceModel\PendingCapture as PendingCaptureResourceModel;
  19. use Magento\Framework\Data\Collection\AbstractDb;
  20. use Magento\Framework\Model\AbstractModel;
  21. use Magento\Framework\Model\Context;
  22. use Magento\Framework\Model\ResourceModel\AbstractResource;
  23. use Magento\Framework\Registry;
  24. use Magento\Framework\Stdlib\DateTime\DateTimeFactory;
  25. class PendingCapture extends AbstractModel implements PendingCaptureInterface
  26. {
  27. /**
  28. * @var DateTimeFactory
  29. */
  30. private $dateFactory;
  31. /**
  32. * @var boolean
  33. */
  34. private $lockOnLoad = false;
  35. /**
  36. * PendingCapture constructor.
  37. *
  38. * @param Context $context
  39. * @param Registry $registry
  40. * @param DateTimeFactory $dateFactory
  41. * @param AbstractResource|null $resource
  42. * @param AbstractDb|null $resourceCollection
  43. * @param array $data
  44. */
  45. public function __construct(
  46. Context $context,
  47. Registry $registry,
  48. DateTimeFactory $dateFactory,
  49. AbstractResource $resource = null,
  50. AbstractDb $resourceCollection = null,
  51. array $data = []
  52. ) {
  53. parent::__construct(
  54. $context,
  55. $registry,
  56. $resource,
  57. $resourceCollection,
  58. $data
  59. );
  60. $this->dateFactory = $dateFactory;
  61. }
  62. /**
  63. * {@inheritDoc}
  64. */
  65. protected function _construct()
  66. {
  67. $this->_init(PendingCaptureResourceModel::class);
  68. }
  69. /**
  70. * {@inheritDoc}
  71. */
  72. public function getCaptureId()
  73. {
  74. return $this->getData(PendingCaptureInterface::CAPTURE_ID);
  75. }
  76. /**
  77. * {@inheritDoc}
  78. */
  79. public function setCaptureId($captureId)
  80. {
  81. return $this->setData(PendingCaptureInterface::CAPTURE_ID, $captureId);
  82. }
  83. /**
  84. * {@inheritDoc}
  85. */
  86. public function getOrderId()
  87. {
  88. return $this->getData(PendingCaptureInterface::ORDER_ID);
  89. }
  90. /**
  91. * {@inheritDoc}
  92. */
  93. public function setOrderId($orderId)
  94. {
  95. return $this->setData(PendingCaptureInterface::ORDER_ID, $orderId);
  96. }
  97. /**
  98. * {@inheritDoc}
  99. */
  100. public function getPaymentId()
  101. {
  102. return $this->getData(PendingCaptureInterface::PAYMENT_ID);
  103. }
  104. /**
  105. * {@inheritDoc}
  106. */
  107. public function setPaymentId($paymentId)
  108. {
  109. return $this->setData(PendingCaptureInterface::PAYMENT_ID, $paymentId);
  110. }
  111. /**
  112. * {@inheritDoc}
  113. */
  114. public function setCreatedAt($createdAt)
  115. {
  116. return $this->setData(PendingCaptureInterface::CREATED_AT, $createdAt);
  117. }
  118. /**
  119. * {@inheritDoc}
  120. */
  121. public function getCreatedAt()
  122. {
  123. return $this->getData(PendingCaptureInterface::CREATED_AT);
  124. }
  125. /**
  126. * {@inheritDoc}
  127. */
  128. public function beforeSave()
  129. {
  130. if (! $this->getId()) {
  131. $this->setCreatedAt($this->dateFactory->create()->gmtDate());
  132. }
  133. return parent::beforeSave();
  134. }
  135. /**
  136. * {@inheritDoc}
  137. */
  138. public function setLockOnLoad($lockOnLoad)
  139. {
  140. $this->lockOnLoad = $lockOnLoad;
  141. return $this;
  142. }
  143. /**
  144. * {@inheritDoc}
  145. */
  146. public function hasLockOnLoad()
  147. {
  148. return $this->lockOnLoad;
  149. }
  150. }