Passed
Push — develop ( ee4d39...b0da7b )
by Remco
03:39
created

PaymentRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 50
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get_payment_method() 0 2 1
A __construct() 0 4 1
A get_json() 0 12 1
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 2
	public function __construct( Amount $amount, $merchant_account, $reference, $return_url, PaymentMethod $payment_method ) {
41 2
		parent::__construct( $amount, $merchant_account, $reference, $return_url );
42
43 2
		$this->payment_method = $payment_method;
44 2
	}
45
46
	/**
47
	 * Get payment method.
48
	 *
49
	 * @return PaymentMethod
50
	 */
51 2
	public function get_payment_method() {
52 2
		return $this->payment_method;
53
	}
54
55
	/**
56
	 * Get JSON.
57
	 *
58
	 * @return object
59
	 */
60 2
	public function get_json() {
61 2
		$object = parent::get_json();
62
63 2
		$properties = (array) $object;
64
65
		// Payment method.
66 2
		$properties['paymentMethod'] = $this->get_payment_method()->get_json();
67
68
		// Return object.
69 2
		$object = (object) $properties;
70
71 2
		return $object;
72
	}
73
}
74