PendingRefund.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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\PendingRefundInterface;
  18. use Amazon\Payment\Model\ResourceModel\PendingRefund as PendingRefundResourceModel;
  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 PendingRefund extends AbstractModel implements PendingRefundInterface
  26. {
  27. /**
  28. * @var DateTimeFactory
  29. */
  30. private $dateFactory;
  31. /**
  32. * @var boolean
  33. */
  34. private $lockOnLoad = false;
  35. /**
  36. * @param Context $context
  37. * @param Registry $registry
  38. * @param DateTimeFactory $dateFactory
  39. * @param AbstractResource|null $resource
  40. * @param AbstractDb|null $resourceCollection
  41. * @param array $data
  42. */
  43. public function __construct(
  44. Context $context,
  45. Registry $registry,
  46. DateTimeFactory $dateFactory,
  47. AbstractResource $resource = null,
  48. AbstractDb $resourceCollection = null,
  49. array $data = []
  50. ) {
  51. parent::__construct(
  52. $context,
  53. $registry,
  54. $resource,
  55. $resourceCollection,
  56. $data
  57. );
  58. $this->dateFactory = $dateFactory;
  59. }
  60. /**
  61. * {@inheritDoc}
  62. */
  63. protected function _construct()
  64. {
  65. $this->_init(PendingRefundResourceModel::class);
  66. }
  67. /**
  68. * {@inheritDoc}
  69. */
  70. public function getRefundId()
  71. {
  72. return $this->getData(PendingRefundInterface::REFUND_ID);
  73. }
  74. /**
  75. * {@inheritDoc}
  76. */
  77. public function setRefundId($refundId)
  78. {
  79. return $this->setData(PendingRefundInterface::REFUND_ID, $refundId);
  80. }
  81. /**
  82. * {@inheritDoc}
  83. */
  84. public function getOrderId()
  85. {
  86. return $this->getData(PendingRefundInterface::ORDER_ID);
  87. }
  88. /**
  89. * {@inheritDoc}
  90. */
  91. public function setOrderId($orderId)
  92. {
  93. return $this->setData(PendingRefundInterface::ORDER_ID, $orderId);
  94. }
  95. /**
  96. * {@inheritDoc}
  97. */
  98. public function getPaymentId()
  99. {
  100. return $this->getData(PendingRefundInterface::PAYMENT_ID);
  101. }
  102. /**
  103. * {@inheritDoc}
  104. */
  105. public function setPaymentId($paymentId)
  106. {
  107. return $this->setData(PendingRefundInterface::PAYMENT_ID, $paymentId);
  108. }
  109. /**
  110. * {@inheritDoc}
  111. */
  112. public function setCreatedAt($createdAt)
  113. {
  114. return $this->setData(PendingRefundInterface::CREATED_AT, $createdAt);
  115. }
  116. /**
  117. * {@inheritDoc}
  118. */
  119. public function getCreatedAt()
  120. {
  121. return $this->getData(PendingRefundInterface::CREATED_AT);
  122. }
  123. /**
  124. * {@inheritDoc}
  125. */
  126. public function beforeSave()
  127. {
  128. if (! $this->getId()) {
  129. $this->setCreatedAt($this->dateFactory->create()->gmtDate());
  130. }
  131. return parent::beforeSave();
  132. }
  133. /**
  134. * {@inheritDoc}
  135. */
  136. public function setLockOnLoad($lockOnLoad)
  137. {
  138. $this->lockOnLoad = $lockOnLoad;
  139. return $this;
  140. }
  141. /**
  142. * {@inheritDoc}
  143. */
  144. public function hasLockOnLoad()
  145. {
  146. return $this->lockOnLoad;
  147. }
  148. }