1 | <?php |
||||
2 | /** |
||||
3 | * Gateway |
||||
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 | use Pronamic\WordPress\Pay\Core\Gateway as Core_Gateway; |
||||
14 | use Pronamic\WordPress\Pay\Core\PaymentMethods; |
||||
15 | use Pronamic\WordPress\Pay\Payments\Payment; |
||||
16 | |||||
17 | /** |
||||
18 | * Gateway |
||||
19 | * |
||||
20 | * @author Remco Tolsma |
||||
21 | * @version 2.0.0 |
||||
22 | * @since 1.0.0 |
||||
23 | * @link https://github.com/adyenpayments/php/blob/master/generatepaymentform.php |
||||
24 | */ |
||||
25 | class Gateway extends Core_Gateway { |
||||
26 | /** |
||||
27 | * Slug of this gateway |
||||
28 | * |
||||
29 | * @var string |
||||
30 | */ |
||||
31 | const SLUG = 'adyen'; |
||||
32 | |||||
33 | ///////////////////////////////////////////////// |
||||
34 | |||||
35 | /** |
||||
36 | * Constructs and initializes an InternetKassa gateway |
||||
37 | * |
||||
38 | * @param Pronamic_WP_Pay_GatewayConfig $config |
||||
0 ignored issues
–
show
|
|||||
39 | */ |
||||
40 | public function __construct( Config $config ) { |
||||
41 | parent::__construct( $config ); |
||||
42 | |||||
43 | $this->set_method( self::METHOD_HTTP_REDIRECT ); |
||||
44 | $this->set_has_feedback( true ); |
||||
45 | $this->set_amount_minimum( 0.01 ); |
||||
46 | $this->set_slug( self::SLUG ); |
||||
47 | |||||
48 | $this->client = new Adyen(); |
||||
0 ignored issues
–
show
|
|||||
49 | } |
||||
50 | |||||
51 | ///////////////////////////////////////////////// |
||||
52 | |||||
53 | /** |
||||
54 | * Start |
||||
55 | * |
||||
56 | * @param Pronamic_Pay_Payment $payment |
||||
0 ignored issues
–
show
The type
Pronamic\WordPress\Pay\G...en\Pronamic_Pay_Payment was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths ![]() |
|||||
57 | * @see Pronamic_WP_Pay_Gateway::start() |
||||
58 | */ |
||||
59 | public function start( Payment $payment ) { |
||||
60 | $url = 'https://checkout-test.adyen.com/v40/paymentMethods'; |
||||
61 | |||||
62 | $data = (object) array( |
||||
63 | 'merchantAccount' => $this->config->merchant_account, |
||||
64 | 'allowedPaymentMethods' => array( |
||||
65 | // 'ideal', |
||||
66 | ), |
||||
67 | ); |
||||
68 | |||||
69 | $response = wp_remote_post( $url, array( |
||||
70 | 'headers' => array( |
||||
71 | 'X-API-key' => $this->config->api_key, |
||||
72 | 'Content-Type' => 'application/json', |
||||
73 | ), |
||||
74 | 'body' => wp_json_encode( $data ), |
||||
75 | ) ); |
||||
76 | |||||
77 | $body = wp_remote_retrieve_body( $response ); |
||||
0 ignored issues
–
show
It seems like
$response can also be of type WP_Error ; however, parameter $response of wp_remote_retrieve_body() does only seem to accept array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
78 | |||||
79 | $result = json_decode( $body ); |
||||
80 | |||||
81 | $payment_methods = $result->paymentMethods; |
||||
82 | $payment_method = reset( $payment_methods ); |
||||
83 | |||||
84 | $url = 'https://checkout-test.adyen.com/v40/payments'; |
||||
85 | |||||
86 | $data = (object) array( |
||||
87 | 'amount' => (object) array( |
||||
88 | 'currency' => $payment->get_total_amount()->get_currency()->get_alphabetic_code(), |
||||
89 | 'value' => $payment->get_total_amount()->get_cents(), |
||||
90 | ), |
||||
91 | 'reference' => $payment->get_id(), |
||||
92 | 'paymentMethod' => (object) array( |
||||
93 | 'type' => 'ideal', |
||||
94 | ), |
||||
95 | 'returnUrl' => $payment->get_return_url(), |
||||
96 | 'merchantAccount' => $this->config->merchant_account, |
||||
97 | ); |
||||
98 | |||||
99 | $response = wp_remote_post( $url, array( |
||||
100 | 'headers' => array( |
||||
101 | 'X-API-key' => $this->config->api_key, |
||||
102 | 'Content-Type' => 'application/json', |
||||
103 | ), |
||||
104 | 'body' => wp_json_encode( $data ), |
||||
105 | ) ); |
||||
106 | |||||
107 | if ( '200' !== strval( wp_remote_retrieve_response_code( $response ) ) ) { |
||||
0 ignored issues
–
show
It seems like
$response can also be of type WP_Error ; however, parameter $response of wp_remote_retrieve_response_code() does only seem to accept array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
108 | return; |
||||
109 | } |
||||
110 | |||||
111 | $body = wp_remote_retrieve_body( $response ); |
||||
112 | |||||
113 | $result = json_decode( $body ); |
||||
114 | |||||
115 | if ( isset( $result->redirect, $result->redirect->url ) ) { |
||||
116 | $payment->set_action_url( $result->redirect->url ); |
||||
117 | } |
||||
118 | } |
||||
119 | |||||
120 | ///////////////////////////////////////////////// |
||||
121 | |||||
122 | /** |
||||
123 | * Get output HTML |
||||
124 | * |
||||
125 | * @see Pronamic_WP_Pay_Gateway::get_output_html() |
||||
126 | */ |
||||
127 | public function get_output_html() { |
||||
128 | return $this->client->get_html_fields(); |
||||
0 ignored issues
–
show
The method
get_html_fields() does not exist on Pronamic\WordPress\Pay\Gateways\Adyen\Adyen .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||
129 | } |
||||
130 | } |
||||
131 |
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