PaypalPayment   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 13
dl 0
loc 42
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A debit() 0 7 1
A authorize() 0 7 1
A capture() 0 7 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\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