1 | <?php |
||||||
2 | |||||||
3 | namespace Pronamic\WordPress\Pay\Gateways\Nocks; |
||||||
4 | |||||||
5 | use Pronamic\WordPress\Pay\Core\GatewaySettings; |
||||||
6 | use Pronamic\WordPress\Pay\Util as Pay_Util; |
||||||
7 | |||||||
8 | /** |
||||||
9 | * Title: Nocks settings |
||||||
10 | * Description: |
||||||
11 | * Copyright: 2005-2019 Pronamic |
||||||
12 | * Company: Pronamic |
||||||
13 | * |
||||||
14 | * @author Reüel van der Steege |
||||||
15 | * @version 2.0.0 |
||||||
16 | * @since 1.0.0 |
||||||
17 | */ |
||||||
18 | class Settings extends GatewaySettings { |
||||||
19 | /** |
||||||
20 | * Settings constructor. |
||||||
21 | */ |
||||||
22 | public function __construct() { |
||||||
23 | add_filter( 'pronamic_pay_gateway_sections', array( $this, 'sections' ) ); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
24 | add_filter( 'pronamic_pay_gateway_fields', array( $this, 'fields' ) ); |
||||||
25 | } |
||||||
26 | |||||||
27 | /** |
||||||
28 | * Settings sections. |
||||||
29 | * |
||||||
30 | * @param array $sections Sections. |
||||||
31 | * |
||||||
32 | * @return array |
||||||
33 | */ |
||||||
34 | public function sections( array $sections ) { |
||||||
35 | $sections['nocks'] = array( |
||||||
36 | 'title' => __( 'Nocks', 'pronamic_ideal' ), |
||||||
0 ignored issues
–
show
The function
__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
37 | 'methods' => array( 'nocks' ), |
||||||
38 | ); |
||||||
39 | |||||||
40 | // Transaction feedback. |
||||||
41 | $sections['nocks_feedback'] = array( |
||||||
42 | 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
||||||
43 | 'methods' => array( 'nocks' ), |
||||||
44 | 'description' => __( 'Payment status updates will be processed without any additional configuration. The <em>Webhook URL</em> is being used to receive the status updates.', 'pronamic_ideal' ), |
||||||
45 | ); |
||||||
46 | |||||||
47 | return $sections; |
||||||
48 | } |
||||||
49 | |||||||
50 | /** |
||||||
51 | * Settings fields. |
||||||
52 | * |
||||||
53 | * @param array $fields Settings fields. |
||||||
54 | * |
||||||
55 | * @return array |
||||||
56 | */ |
||||||
57 | public function fields( array $fields ) { |
||||||
58 | // Access token. |
||||||
59 | $fields[] = array( |
||||||
60 | 'filter' => FILTER_SANITIZE_STRING, |
||||||
61 | 'section' => 'nocks', |
||||||
62 | 'meta_key' => '_pronamic_gateway_nocks_access_token', |
||||||
63 | 'title' => _x( 'Access Token', 'nocks', 'pronamic_ideal' ), |
||||||
0 ignored issues
–
show
The function
_x was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
64 | 'type' => 'textarea', |
||||||
65 | 'classes' => array( 'code' ), |
||||||
66 | ); |
||||||
67 | |||||||
68 | // Merchant profile. |
||||||
69 | $fields[] = array( |
||||||
70 | 'filter' => FILTER_SANITIZE_STRING, |
||||||
71 | 'section' => 'nocks', |
||||||
72 | 'meta_key' => '_pronamic_gateway_nocks_merchant_profile', |
||||||
73 | 'title' => _x( 'Merchant Profile', 'nocks', 'pronamic_ideal' ), |
||||||
74 | 'type' => 'description', |
||||||
75 | 'callback' => array( $this, 'field_merchant_profile' ), |
||||||
76 | ); |
||||||
77 | |||||||
78 | // Transaction feedback. |
||||||
79 | $fields[] = array( |
||||||
80 | 'section' => 'nocks', |
||||||
81 | 'title' => __( 'Transaction feedback', 'pronamic_ideal' ), |
||||||
0 ignored issues
–
show
The function
__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
82 | 'type' => 'description', |
||||||
83 | 'html' => sprintf( |
||||||
84 | '<span class="dashicons dashicons-yes"></span> %s', |
||||||
85 | __( 'Payment status updates will be processed without any additional configuration.', 'pronamic_ideal' ) |
||||||
86 | ), |
||||||
87 | ); |
||||||
88 | |||||||
89 | // Webhook URL. |
||||||
90 | $fields[] = array( |
||||||
91 | 'section' => 'nocks_feedback', |
||||||
92 | 'title' => __( 'Webhook URL', 'pronamic_ideal' ), |
||||||
93 | 'type' => 'text', |
||||||
94 | 'classes' => array( 'large-text', 'code' ), |
||||||
95 | 'value' => add_query_arg( 'nocks_webhook', '', home_url( '/' ) ), |
||||||
0 ignored issues
–
show
The function
home_url was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The function
add_query_arg was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
96 | 'readonly' => true, |
||||||
97 | 'methods' => array( 'nocks' ), |
||||||
98 | 'tooltip' => __( 'The Webhook URL as sent with each transaction to receive automatic payment status updates on.', 'pronamic_ideal' ), |
||||||
99 | ); |
||||||
100 | |||||||
101 | return $fields; |
||||||
102 | } |
||||||
103 | |||||||
104 | /** |
||||||
105 | * Field merchant profile select. |
||||||
106 | * |
||||||
107 | * @param array $field Settings field. |
||||||
108 | */ |
||||||
109 | public function field_merchant_profile( $field ) { |
||||||
110 | $access_token = get_post_meta( get_the_ID(), '_pronamic_gateway_nocks_access_token', true ); |
||||||
0 ignored issues
–
show
The function
get_post_meta was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() The function
get_the_ID was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
111 | $merchant_profile = get_post_meta( get_the_ID(), '_pronamic_gateway_nocks_merchant_profile', true ); |
||||||
112 | |||||||
113 | if ( ! $access_token ) { |
||||||
114 | esc_html_e( 'First enter an API Key and save the configuration, to be able to choose from your Nocks merchant profiles.', 'pronamic_ideal' ); |
||||||
0 ignored issues
–
show
The function
esc_html_e was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
115 | |||||||
116 | return; |
||||||
117 | } |
||||||
118 | |||||||
119 | $client = new Client(); |
||||||
120 | |||||||
121 | $client->set_access_token( $access_token ); |
||||||
122 | |||||||
123 | // Select merchant profile. |
||||||
124 | printf( '<select name="%s">', esc_attr( $field['meta_key'] ) ); |
||||||
0 ignored issues
–
show
The function
esc_attr was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
125 | |||||||
126 | $options = array( |
||||||
127 | __( '— Select Merchant Profile —', 'pronamic_ideal' ), |
||||||
0 ignored issues
–
show
The function
__ was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
128 | ); |
||||||
129 | |||||||
130 | $options = array_merge( $options, $client->get_merchant_profiles() ); |
||||||
131 | |||||||
132 | $options = array( |
||||||
133 | array( |
||||||
134 | 'options' => $options, |
||||||
135 | ), |
||||||
136 | ); |
||||||
137 | |||||||
138 | echo Pay_Util::select_options_grouped( $options, $merchant_profile ); // WPCS: xss ok. |
||||||
139 | |||||||
140 | echo '</select>'; |
||||||
141 | } |
||||||
142 | } |
||||||
143 |