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 origin. |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | public function get_origin() { |
||
71 | return $this->origin; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * Set origin. |
||
76 | * |
||
77 | * @param string $origin Origin. |
||
78 | */ |
||
79 | public function set_origin( $origin ) { |
||
80 | $this->origin = $origin; |
||
81 | } |
||
82 | |||
83 | /** |
||
84 | * Get SDK version. |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | public function get_sdk_version() { |
||
89 | return $this->sdk_version; |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * Set SDK version. |
||
94 | * |
||
95 | * @param string $sdk_version SDK version. |
||
96 | */ |
||
97 | public function set_sdk_version( $sdk_version ) { |
||
98 | $this->sdk_version = $sdk_version; |
||
99 | } |
||
100 | |||
101 | /** |
||
102 | * Get JSON. |
||
103 | * |
||
104 | * @return object |
||
105 | */ |
||
106 | public function get_json() { |
||
107 | $object = parent::get_json(); |
||
108 | |||
109 | // Allowed payment methods. |
||
110 | if ( null !== $this->allowed_payment_methods ) { |
||
111 | $object->allowedPaymentMethods = $this->allowed_payment_methods; |
||
112 | } |
||
113 | |||
114 | // Origin. |
||
115 | if ( null !== $this->origin ) { |
||
116 | $object->origin = $this->origin; |
||
117 | } |
||
118 | |||
119 | // SDK version. |
||
120 | if ( null !== $this->sdk_version ) { |
||
121 | $object->sdkVersion = $this->sdk_version; |
||
122 | } |
||
123 | |||
124 | // Return object. |
||
125 | return $object; |
||
126 | } |
||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||
127 |