Failed Conditions
Push — develop ( 612159...14294b )
by Reüel
03:14
created

PaymentSessionRequest   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 122
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 122
ccs 0
cts 34
cp 0
rs 10
c 0
b 0
f 0
wmc 11

8 Methods

Rating   Name   Duplication   Size   Complexity  
A get_allowed_payment_methods() 0 2 1
A get_json() 0 20 4
A set_origin() 0 2 1
A get_sdk_version() 0 2 1
A __construct() 0 4 1
A set_sdk_version() 0 2 1
A set_allowed_payment_methods() 0 2 1
A get_origin() 0 2 1
1
<?php
2
/**
3
 * Payment session 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 session request
15
 *
16
 * @link https://docs.adyen.com/api-explorer/#/PaymentSetupAndVerificationService/v41/paymentSession
17
 *
18
 * @author  Remco Tolsma
19
 * @version 1.0.0
20
 * @since   1.0.0
21
 */
22
class PaymentSessionRequest extends AbstractPaymentRequest {
23
	/**
24
	 * Allowed payment methods.
25
	 *
26
	 * List of payments methods to be presented to the shopper. To refer to payment methods,
27
	 * use their brandCode from https://docs.adyen.com/developers/payment-methods/payment-methods-overview
28
	 *
29
	 * @var array
30
	 */
31
	private $allowed_payment_methods;
32
33
	/**
34
	 * Origin.
35
	 *
36
	 * Required for the Web integration. Set this parameter to the
37
	 * origin URL of the page that you are loading the SDK from.
38
	 *
39
	 * @var string|null
40
	 */
41
	private $origin;
42
43
	/**
44
	 * SDK version.
45
	 *
46
	 * @var string|null
47
	 */
48
	private $sdk_version;
49
50
	/**
51
	 * Construct a payment request object.
52
	 *
53
	 * @param Amount $amount           The amount information for the transaction.
54
	 * @param string $merchant_account The merchant account identifier, with which you want to process the transaction.
55
	 * @param string $reference        The reference to uniquely identify a payment.
56
	 * @param string $return_url       The URL to return to.
57
	 * @param string $country_code     The collection that contains the type of the payment method and its specific information (e.g. idealIssuer).
58
	 */
59
	public function __construct( Amount $amount, $merchant_account, $reference, $return_url, $country_code ) {
60
		parent::__construct( $amount, $merchant_account, $reference, $return_url );
61
62
		$this->set_country_code( $country_code );
63
	}
64
65
	/**
66
	 * Get allowed payment methods.
67
	 *
68
	 * @return array
69
	 */
70
	public function get_allowed_payment_methods() {
71
		return $this->allowed_payment_methods;
72
	}
73
74
	/**
75
	 * Set allowed payment methods.
76
	 *
77
	 * @param array $allowed_payment_methods Allowed payment methods.
78
	 */
79
	public function set_allowed_payment_methods( $allowed_payment_methods ) {
80
		$this->allowed_payment_methods = $allowed_payment_methods;
81
	}
82
83
	/**
84
	 * Get origin.
85
	 *
86
	 * @return string
87
	 */
88
	public function get_origin() {
89
		return $this->origin;
90
	}
91
92
	/**
93
	 * Set origin.
94
	 *
95
	 * @param string $origin Origin.
96
	 */
97
	public function set_origin( $origin ) {
98
		$this->origin = $origin;
99
	}
100
101
	/**
102
	 * Get SDK version.
103
	 *
104
	 * @return string
105
	 */
106
	public function get_sdk_version() {
107
		return $this->sdk_version;
108
	}
109
110
	/**
111
	 * Set SDK version.
112
	 *
113
	 * @param string $sdk_version SDK version.
114
	 */
115
	public function set_sdk_version( $sdk_version ) {
116
		$this->sdk_version = $sdk_version;
117
	}
118
119
	/**
120
	 * Get JSON.
121
	 *
122
	 * @return object
123
	 */
124
	public function get_json() {
125
		$object = parent::get_json();
126
127
		// Allowed payment methods.
128
		if ( null !== $this->allowed_payment_methods ) {
129
			$object->allowedPaymentMethods = $this->allowed_payment_methods;
130
		}
131
132
		// Origin.
133
		if ( null !== $this->origin ) {
134
			$object->origin = $this->origin;
135
		}
136
137
		// SDK version.
138
		if ( null !== $this->sdk_version ) {
139
			$object->sdkVersion = $this->sdk_version;
140
		}
141
142
		// Return object.
143
		return $object;
144
	}
145
}
146