Completed
Push — master ( e2eed5...73dfaa )
by Oleksandr
13s queued 10s
created

CaptureOrderTransaction   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 35
rs 10
c 1
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getTransactionType() 0 3 1
A doTransaction() 0 3 1
A getTransactionCode() 0 3 1
A capture() 0 4 1
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Zed\Braintree\Business\Payment\Transaction;
9
10
use Braintree\Transaction as BraintreeTransaction;
11
use SprykerEco\Zed\Braintree\Business\Payment\Method\ApiConstants;
12
13
class CaptureOrderTransaction extends AbstractTransaction
14
{
15
    protected const ATTRIBUTE_KEY_ORDER_ID = 'orderId';
16
17
    /**
18
     * @return string
19
     */
20
    protected function getTransactionType(): string
21
    {
22
        return ApiConstants::SALE;
23
    }
24
25
    /**
26
     * @return string
27
     */
28
    protected function getTransactionCode(): string
29
    {
30
        return ApiConstants::TRANSACTION_CODE_CAPTURE;
31
    }
32
33
    /**
34
     * @return \Braintree\Result\Error|\Braintree\Result\Successful
35
     */
36
    protected function doTransaction()
37
    {
38
        return $this->capture();
39
    }
40
41
    /**
42
     * @return \Braintree\Result\Error|\Braintree\Result\Successful
43
     */
44
    protected function capture()
45
    {
46
        return BraintreeTransaction::submitForSettlement($this->getTransactionIdentifier(), null, [
47
            static::ATTRIBUTE_KEY_ORDER_ID => $this->transactionMetaTransfer->getOrderReference(),
48
        ]);
49
    }
50
}
51