| Total Complexity | 7 |
| Total Lines | 51 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | class CancelOrderTransaction extends AbstractAmazonpayTransaction |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonPayCallTransfer |
||
| 17 | * |
||
| 18 | * @return \Generated\Shared\Transfer\AmazonpayCallTransfer |
||
| 19 | */ |
||
| 20 | public function execute(AmazonpayCallTransfer $amazonPayCallTransfer) |
||
| 21 | { |
||
| 22 | $amazonPayCallTransfer = parent::execute($amazonPayCallTransfer); |
||
| 23 | |||
| 24 | $this->updatePaymentEntity($amazonPayCallTransfer); |
||
| 25 | |||
| 26 | return $amazonPayCallTransfer; |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @param \Generated\Shared\Transfer\AmazonpayCallTransfer $amazonPayCallTransfer |
||
| 31 | * |
||
| 32 | * @return void |
||
| 33 | */ |
||
| 34 | protected function updatePaymentEntity(AmazonpayCallTransfer $amazonPayCallTransfer) |
||
| 35 | { |
||
| 36 | if ($this->paymentEntity === null) { |
||
| 37 | return; |
||
| 38 | } |
||
| 39 | |||
| 40 | $isPartialProcessing = $this->isPartialProcessing($this->paymentEntity, $amazonPayCallTransfer); |
||
| 41 | |||
| 42 | if (!$this->apiResponse->getResponseHeader()->getIsSuccess()) { |
||
| 43 | return; |
||
| 44 | } |
||
| 45 | |||
| 46 | if ($isPartialProcessing) { |
||
| 47 | $this->paymentEntity = $this->paymentProcessor->duplicatePaymentEntity($this->paymentEntity); |
||
| 48 | } |
||
| 49 | |||
| 50 | $this->paymentEntity->setStatus(AmazonPayConfig::STATUS_CANCELLED); |
||
| 51 | $this->paymentEntity->save(); |
||
| 52 | |||
| 53 | if ($isPartialProcessing) { |
||
| 54 | $this->paymentProcessor->assignAmazonpayPaymentToItems($this->paymentEntity, $amazonPayCallTransfer); |
||
| 55 | } |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @return bool |
||
| 60 | */ |
||
| 61 | protected function allowPartialProcessing() |
||
| 64 | } |
||
| 65 | } |
||
| 66 |