PaypalPayment::capture()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
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\Heidelpay\Business\Adapter\Payment;
9
10
use Generated\Shared\Transfer\HeidelpayRequestTransfer;
11
use Generated\Shared\Transfer\HeidelpayResponseTransfer;
12
use Heidelpay\PhpPaymentApi\PaymentMethods\PayPalPaymentMethod;
13
14
class PaypalPayment extends BasePayment implements PaypalPaymentInterface
15
{
16
    /**
17
     * @param \Generated\Shared\Transfer\HeidelpayRequestTransfer $authorizeRequestTransfer
18
     *
19
     * @return \Generated\Shared\Transfer\HeidelpayResponseTransfer
20
     */
21
    public function authorize(HeidelpayRequestTransfer $authorizeRequestTransfer): HeidelpayResponseTransfer
22
    {
23
        $paypalMethod = new PayPalPaymentMethod();
24
        $this->prepareRequest($authorizeRequestTransfer, $paypalMethod->getRequest());
25
        $paypalMethod->authorize();
26
27
        return $this->verifyAndParseResponse($paypalMethod->getResponse());
28
    }
29
30
    /**
31
     * @param \Generated\Shared\Transfer\HeidelpayRequestTransfer $captureRequestTransfer
32
     *
33
     * @return \Generated\Shared\Transfer\HeidelpayResponseTransfer
34
     */
35
    public function capture(HeidelpayRequestTransfer $captureRequestTransfer): HeidelpayResponseTransfer
36
    {
37
        $paypalMethod = new PayPalPaymentMethod();
38
        $this->prepareRequest($captureRequestTransfer, $paypalMethod->getRequest());
39
        $paypalMethod->capture($captureRequestTransfer->getIdPaymentReference());
40
41
        return $this->verifyAndParseResponse($paypalMethod->getResponse());
42
    }
43
44
    /**
45
     * @param \Generated\Shared\Transfer\HeidelpayRequestTransfer $debitRequestTransfer
46
     *
47
     * @return \Generated\Shared\Transfer\HeidelpayResponseTransfer
48
     */
49
    public function debit(HeidelpayRequestTransfer $debitRequestTransfer): HeidelpayResponseTransfer
50
    {
51
        $paypalMethod = new PayPalPaymentMethod();
52
        $this->prepareRequest($debitRequestTransfer, $paypalMethod->getRequest());
53
        $paypalMethod->debit();
54
55
        return $this->verifyAndParseResponse($paypalMethod->getResponse());
56
    }
57
}
58