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

CaptureOrderTransaction::capture()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 1
b 0
f 0
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