wp-pay-gateways /
adyen
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * Abstract 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 | * Abstract payment request |
||
| 15 | * |
||
| 16 | * @link https://docs.adyen.com/api-explorer/#/PaymentSetupAndVerificationService/v41/payments |
||
| 17 | * @link https://docs.adyen.com/api-explorer/#/PaymentSetupAndVerificationService/v41/paymentSession |
||
| 18 | * |
||
| 19 | * @author Remco Tolsma |
||
| 20 | * @version 1.0.0 |
||
| 21 | * @since 1.0.0 |
||
| 22 | */ |
||
| 23 | abstract class AbstractPaymentRequest { |
||
| 24 | /** |
||
| 25 | * Amount. |
||
| 26 | * |
||
| 27 | * @var Amount |
||
| 28 | */ |
||
| 29 | private $amount; |
||
| 30 | |||
| 31 | /** |
||
| 32 | * Billing address. |
||
| 33 | * |
||
| 34 | * @var Address|null |
||
| 35 | */ |
||
| 36 | private $billing_address; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Channel. |
||
| 40 | * |
||
| 41 | * The platform where a payment transaction takes place. This field is optional for filtering out |
||
| 42 | * payment methods that are only available on specific platforms. If this value is not set, |
||
| 43 | * then we will try to infer it from the sdkVersion or token. |
||
| 44 | * |
||
| 45 | * Possible values: Android, iOS, Web. |
||
| 46 | * |
||
| 47 | * @var string|null |
||
| 48 | */ |
||
| 49 | private $channel; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * The shopper country. |
||
| 53 | * |
||
| 54 | * Format: ISO 3166-1 alpha-2 Example: NL or DE |
||
| 55 | * |
||
| 56 | * @var string|null |
||
| 57 | */ |
||
| 58 | private $country_code; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * The merchant account identifier, with which you want to process the transaction. |
||
| 62 | * |
||
| 63 | * @var string |
||
| 64 | */ |
||
| 65 | private $merchant_account; |
||
| 66 | |||
| 67 | /** |
||
| 68 | * The reference to uniquely identify a payment. This reference is used in all communication |
||
| 69 | * with you about the payment status. We recommend using a unique value per payment; |
||
| 70 | * however, it is not a requirement. If you need to provide multiple references for |
||
| 71 | * a transaction, separate them with hyphens ("-"). Maximum length: 80 characters. |
||
| 72 | * |
||
| 73 | * @var string |
||
| 74 | */ |
||
| 75 | private $reference; |
||
| 76 | |||
| 77 | /** |
||
| 78 | * The URL to return to. |
||
| 79 | * |
||
| 80 | * @var string |
||
| 81 | */ |
||
| 82 | private $return_url; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * The shopper's IP address. |
||
| 86 | * |
||
| 87 | * @var string|null |
||
| 88 | */ |
||
| 89 | private $shopper_ip; |
||
| 90 | |||
| 91 | /** |
||
| 92 | * The combination of a language code and a country code to specify the language to be used in the payment. |
||
| 93 | * |
||
| 94 | * @var string|null |
||
| 95 | */ |
||
| 96 | private $shopper_locale; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * The shopper's full name and gender (if specified) |
||
| 100 | * |
||
| 101 | * @var ShopperName|null |
||
|
0 ignored issues
–
show
|
|||
| 102 | */ |
||
| 103 | private $shopper_name; |
||
| 104 | |||
| 105 | /** |
||
| 106 | * The shopper's reference to uniquely identify this shopper (e.g. user ID or account ID). This field is |
||
| 107 | * required for recurring payments |
||
| 108 | * |
||
| 109 | * @var string|null |
||
| 110 | */ |
||
| 111 | private $shopper_reference; |
||
| 112 | |||
| 113 | /** |
||
| 114 | * The text to appear on the shopper's bank statement. |
||
| 115 | * |
||
| 116 | * @var string|null |
||
| 117 | */ |
||
| 118 | private $shopper_statement; |
||
| 119 | |||
| 120 | /** |
||
| 121 | * The shopper's telephone number |
||
| 122 | * |
||
| 123 | * @var string|null |
||
| 124 | */ |
||
| 125 | private $telephone_number; |
||
| 126 | |||
| 127 | /** |
||
| 128 | * Construct a payment request object. |
||
| 129 | * |
||
| 130 | * @param Amount $amount The amount information for the transaction. |
||
| 131 | * @param string $merchant_account The merchant account identifier, with which you want to process the transaction |
||
| 132 | * @param string $reference The reference to uniquely identify a payment. |
||
| 133 | * @param string $return_url The URL to return to. |
||
| 134 | */ |
||
| 135 | public function __construct( Amount $amount, $merchant_account, $reference, $return_url ) { |
||
| 136 | $this->set_amount( $amount ); |
||
| 137 | $this->set_merchant_account( $merchant_account ); |
||
| 138 | $this->set_reference( $reference ); |
||
| 139 | $this->set_return_url( $return_url ); |
||
| 140 | } |
||
| 141 | |||
| 142 | /** |
||
| 143 | * Get amount. |
||
| 144 | * |
||
| 145 | * @return Amount |
||
| 146 | */ |
||
| 147 | public function get_amount() { |
||
| 148 | return $this->amount; |
||
| 149 | } |
||
| 150 | |||
| 151 | /** |
||
| 152 | * Set amount. |
||
| 153 | * |
||
| 154 | * @param Amount $amount Amount. |
||
| 155 | */ |
||
| 156 | public function set_amount( Amount $amount ) { |
||
| 157 | $this->amount = $amount; |
||
| 158 | } |
||
| 159 | |||
| 160 | /** |
||
| 161 | * Get billing address. |
||
| 162 | * |
||
| 163 | * @return Address|null |
||
| 164 | */ |
||
| 165 | public function get_billing_address() { |
||
| 166 | return $this->billing_address; |
||
| 167 | } |
||
| 168 | |||
| 169 | /** |
||
| 170 | * Set billing address. |
||
| 171 | * |
||
| 172 | * @param Address|null $billing_address Billing address. |
||
| 173 | */ |
||
| 174 | public function set_billing_address( Address $billing_address = null ) { |
||
| 175 | $this->billing_address = $billing_address; |
||
| 176 | } |
||
| 177 | |||
| 178 | /** |
||
| 179 | * Get channel. |
||
| 180 | * |
||
| 181 | * @return string|null |
||
| 182 | */ |
||
| 183 | public function get_channel() { |
||
| 184 | return $this->channel; |
||
| 185 | } |
||
| 186 | |||
| 187 | /** |
||
| 188 | * Set channel. |
||
| 189 | * |
||
| 190 | * @param string|null $channel Channel. |
||
| 191 | */ |
||
| 192 | public function set_channel( $channel ) { |
||
| 193 | $this->channel = $channel; |
||
| 194 | } |
||
| 195 | |||
| 196 | /** |
||
| 197 | * Get country code. |
||
| 198 | * |
||
| 199 | * @return string|null |
||
| 200 | */ |
||
| 201 | public function get_country_code() { |
||
| 202 | return $this->country_code; |
||
| 203 | } |
||
| 204 | |||
| 205 | /** |
||
| 206 | * Set country code. |
||
| 207 | * |
||
| 208 | * @param string|null $country_code Country code. |
||
| 209 | */ |
||
| 210 | public function set_country_code( $country_code ) { |
||
| 211 | $this->country_code = $country_code; |
||
| 212 | } |
||
| 213 | |||
| 214 | /** |
||
| 215 | * Get merchant account. |
||
| 216 | * |
||
| 217 | * @return string |
||
| 218 | */ |
||
| 219 | public function get_merchant_account() { |
||
| 220 | return $this->merchant_account; |
||
| 221 | } |
||
| 222 | |||
| 223 | /** |
||
| 224 | * Set merchant account. |
||
| 225 | * |
||
| 226 | * @param string $merchant_account Merchant account. |
||
| 227 | */ |
||
| 228 | public function set_merchant_account( $merchant_account ) { |
||
| 229 | $this->merchant_account = $merchant_account; |
||
| 230 | } |
||
| 231 | |||
| 232 | /** |
||
| 233 | * Get reference. |
||
| 234 | * |
||
| 235 | * @return string |
||
| 236 | */ |
||
| 237 | public function get_reference() { |
||
| 238 | return $this->reference; |
||
| 239 | } |
||
| 240 | |||
| 241 | /** |
||
| 242 | * Set reference. |
||
| 243 | * |
||
| 244 | * @param string $reference Reference. |
||
| 245 | */ |
||
| 246 | public function set_reference( $reference ) { |
||
| 247 | $this->reference = $reference; |
||
| 248 | } |
||
| 249 | |||
| 250 | /** |
||
| 251 | * Get return URL. |
||
| 252 | * |
||
| 253 | * @return string |
||
| 254 | */ |
||
| 255 | public function get_return_url() { |
||
| 256 | return $this->return_url; |
||
| 257 | } |
||
| 258 | |||
| 259 | /** |
||
| 260 | * Set return URL. |
||
| 261 | * |
||
| 262 | * @param string $return_url Return URL. |
||
| 263 | */ |
||
| 264 | public function set_return_url( $return_url ) { |
||
| 265 | $this->return_url = $return_url; |
||
| 266 | } |
||
| 267 | |||
| 268 | /** |
||
| 269 | * Get shopper IP. |
||
| 270 | * |
||
| 271 | * @return string|null |
||
| 272 | */ |
||
| 273 | public function get_shopper_ip() { |
||
| 274 | return $this->shopper_ip; |
||
| 275 | } |
||
| 276 | |||
| 277 | /** |
||
| 278 | * Set shopper IP. |
||
| 279 | * |
||
| 280 | * @param string|null $shopper_ip Shopper IP. |
||
| 281 | */ |
||
| 282 | public function set_shopper_ip( $shopper_ip ) { |
||
| 283 | $this->shopper_ip = $shopper_ip; |
||
| 284 | } |
||
| 285 | |||
| 286 | /** |
||
| 287 | * Get shopper locale. |
||
| 288 | * |
||
| 289 | * @return string|null |
||
| 290 | */ |
||
| 291 | public function get_shopper_locale() { |
||
| 292 | return $this->shopper_locale; |
||
| 293 | } |
||
| 294 | |||
| 295 | /** |
||
| 296 | * Set shopper locale. |
||
| 297 | * |
||
| 298 | * @param string|null $shopper_ip Shopper locale. |
||
| 299 | */ |
||
| 300 | public function set_shopper_ip( $shopper_locale ) { |
||
| 301 | $this->shopper_locale = $shopper_locale; |
||
| 302 | } |
||
| 303 | |||
| 304 | /** |
||
| 305 | * Get shopper name. |
||
| 306 | * |
||
| 307 | * @return ShopperName|null |
||
| 308 | */ |
||
| 309 | public function get_shopper_name() { |
||
| 310 | return $this->shopper_name; |
||
| 311 | } |
||
| 312 | |||
| 313 | /** |
||
| 314 | * Set shopper name. |
||
| 315 | * |
||
| 316 | * @param ShopperName|null $shopper_name Shopper name. |
||
| 317 | */ |
||
| 318 | public function set_shopper_name( ShopperName $shopper_name = null ) { |
||
| 319 | $this->shopper_name = $shopper_name; |
||
| 320 | } |
||
| 321 | |||
| 322 | /** |
||
| 323 | * Get shopper reference. |
||
| 324 | * |
||
| 325 | * @return string|null |
||
| 326 | */ |
||
| 327 | public function get_shopper_reference() { |
||
| 328 | return $this->shopper_reference; |
||
| 329 | } |
||
| 330 | |||
| 331 | /** |
||
| 332 | * Set shopper reference. |
||
| 333 | * |
||
| 334 | * @param string|null $shopper_reference Shopper reference. |
||
| 335 | */ |
||
| 336 | public function set_shopper_reference( $shopper_reference ) { |
||
| 337 | $this->shopper_reference = $shopper_reference; |
||
| 338 | } |
||
| 339 | |||
| 340 | /** |
||
| 341 | * Get shopper statement. |
||
| 342 | * |
||
| 343 | * @return string|null |
||
| 344 | */ |
||
| 345 | public function get_shopper_statement() { |
||
| 346 | return $this->shopper_statement; |
||
| 347 | } |
||
| 348 | |||
| 349 | /** |
||
| 350 | * Set shopper statement. |
||
| 351 | * |
||
| 352 | * @param string|null $shopper_statement Shopper statement. |
||
| 353 | */ |
||
| 354 | public function set_shopper_statement( $shopper_statement ) { |
||
| 355 | $this->shopper_statement = $shopper_statement; |
||
| 356 | } |
||
| 357 | |||
| 358 | /** |
||
| 359 | * Get telephone number. |
||
| 360 | * |
||
| 361 | * @return string|null |
||
| 362 | */ |
||
| 363 | public function get_telephone_number() { |
||
| 364 | return $this->telephone_number; |
||
| 365 | } |
||
| 366 | |||
| 367 | /** |
||
| 368 | * Set shopper statement. |
||
| 369 | * |
||
| 370 | * @param string|null $telephone_number Telephone number. |
||
| 371 | */ |
||
| 372 | public function set_telephone_number( $telephone_number ) { |
||
| 373 | $this->telephone_number = $telephone_number; |
||
| 374 | } |
||
| 375 | |||
| 376 | /** |
||
| 377 | * Get JSON. |
||
| 378 | * |
||
| 379 | * @return object |
||
| 380 | */ |
||
| 381 | public function get_json() { |
||
| 382 | $object = (object) array(); |
||
| 383 | |||
| 384 | // Amount. |
||
| 385 | $object->amount = $this->get_amount()->get_json(); |
||
| 386 | |||
| 387 | // Billing address. |
||
| 388 | if ( null !== $this->billing_address ) { |
||
| 389 | $object->billingAddress = $this->billing_address->get_json(); |
||
| 390 | } |
||
| 391 | |||
| 392 | // Channel. |
||
| 393 | if ( null !== $this->channel ) { |
||
| 394 | $object->channel = $this->channel; |
||
| 395 | } |
||
| 396 | |||
| 397 | // Country code. |
||
| 398 | if ( null !== $this->country_code ) { |
||
| 399 | $object->countryCode = $this->country_code; |
||
| 400 | } |
||
| 401 | |||
| 402 | // Merchant account. |
||
| 403 | $object->merchantAccount = $this->get_merchant_account(); |
||
| 404 | |||
| 405 | // Reference. |
||
| 406 | $object->reference = $this->get_reference(); |
||
| 407 | |||
| 408 | // Return URL. |
||
| 409 | $object->returnUrl = $this->get_return_url(); |
||
| 410 | |||
| 411 | // Shopper IP. |
||
| 412 | if ( null !== $this->shopper_ip ) { |
||
| 413 | $object->shopperIP = $this->shopper_ip; |
||
| 414 | } |
||
| 415 | |||
| 416 | // Shopper locale. |
||
| 417 | if ( null !== $this->shopper_locale ) { |
||
| 418 | $object->shopperLocale = $this->shopper_locale; |
||
| 419 | } |
||
| 420 | |||
| 421 | // Shopper name. |
||
| 422 | if ( null !== $this->shopper_name ) { |
||
| 423 | $object->shopperName = $this->shopper_name->get_json(); |
||
| 424 | } |
||
| 425 | |||
| 426 | // Shopper reference. |
||
| 427 | if ( null !== $this->shopper_reference ) { |
||
| 428 | $object->shopperReference = $this->shopper_reference; |
||
| 429 | } |
||
| 430 | |||
| 431 | // Shopper statement. |
||
| 432 | if ( null !== $this->shopper_statement ) { |
||
| 433 | $object->shopperStatement = $this->shopper_statement; |
||
| 434 | } |
||
| 435 | |||
| 436 | // Telephone number. |
||
| 437 | if ( null !== $this->telephone_number ) { |
||
| 438 | $object->telephoneNumber = $this->telephone_number; |
||
| 439 | } |
||
| 440 | |||
| 441 | // Return object. |
||
| 442 | return $object; |
||
| 443 | } |
||
| 444 | } |
||
| 445 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths