Failed Conditions
Push — develop ( 511b66...00af81 )
by Remco
02:50
created

PaymentRequest::get_payment_method()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Payment request
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2019 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\Adyen
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\Adyen;
12
13
/**
14
 * Payment request
15
 *
16
 * @link https://docs.adyen.com/api-explorer/#/PaymentSetupAndVerificationService/v40/payments
17
 *
18
 * @author  Reüel van der Steege
19
 * @version 1.0.0
20
 * @since   1.0.0
21
 */
22
class PaymentRequest extends AbstractPaymentRequest {
23
	/**
24
	 * The collection that contains the type of the payment method and its
25
	 * specific information (e.g. idealIssuer).
26
	 *
27
	 * @var PaymentMethod
28
	 */
29
	private $payment_method;
30
31
	/**
32
	 * Construct a payment request object.
33
	 *
34
	 * @param Amount        $amount           The amount information for the transaction.
35
	 * @param string        $merchant_account The merchant account identifier, with which you want to process the transaction.
36
	 * @param string        $reference        The reference to uniquely identify a payment.
37
	 * @param string        $return_url       The URL to return to.
38
	 * @param PaymentMethod $payment_method   The collection that contains the type of the payment method and its specific information (e.g. idealIssuer).
39
	 */
40 1
	public function __construct( Amount $amount, $merchant_account, $reference, $return_url, PaymentMethod $payment_method ) {
41 1
		parent::__construct( $amount, $merchant_account, $reference, $return_url );
42
43 1
		$this->set_payment_method( $payment_method );
44 1
	}
45
46
	/**
47
	 * Get payment method.
48
	 *
49
	 * @return PaymentMethod
50
	 */
51 1
	public function get_payment_method() {
52 1
		return $this->payment_method;
53
	}
54
55
	/**
56
	 * Set payment method.
57
	 *
58
	 * @param PaymentMethod $payment_method Payment method.
59
	 */
60 1
	public function set_payment_method( PaymentMethod $payment_method ) {
61 1
		$this->payment_method = $payment_method;
62 1
	}
63
64
	/**
65
	 * Get JSON.
66
	 *
67
	 * @return object
68
	 */
69 1
	public function get_json() {
70 1
		$object = parent::get_json();
71
72
		// Payment method.
73 1
		$object->paymentMethod = $this->get_payment_method()->get_json();
74
75
		// Return object.
76 1
		return $object;
77
	}
78
}
79