blob: 6f0525d34e943e68860b3ce3e5a7df99cc9865df [file] [log] [blame]
swissChilif0cbdc32023-01-05 17:21:38 -05001<?php
2if ( ! defined( 'ABSPATH' ) ) {
3 exit;
4}
5
6$is_gte_wc6_6 = defined( WC_VERSION ) && version_compare( WC_VERSION, '6.6', '>=' );
7
8$stripe_settings = apply_filters(
9 'wc_stripe_settings',
10 [
11 'enabled' => [
12 'title' => __( 'Enable/Disable', 'woocommerce-gateway-stripe' ),
13 'label' => __( 'Enable Stripe', 'woocommerce-gateway-stripe' ),
14 'type' => 'checkbox',
15 'description' => '',
16 'default' => 'no',
17 ],
18 'title' => [
19 'title' => __( 'Title', 'woocommerce-gateway-stripe' ),
20 'type' => $is_gte_wc6_6 ? 'safe_text' : 'text',
21 'description' => __( 'This controls the title which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
22 'default' => __( 'Credit Card (Stripe)', 'woocommerce-gateway-stripe' ),
23 'desc_tip' => true,
24 ],
25 'title_upe' => [
26 'title' => __( 'Title', 'woocommerce-gateway-stripe' ),
27 'type' => $is_gte_wc6_6 ? 'safe_text' : 'text',
28 'description' => __( 'This controls the title which the user sees during checkout when multiple payment methods are enabled.', 'woocommerce-gateway-stripe' ),
29 'default' => __( 'Popular payment methods', 'woocommerce-gateway-stripe' ),
30 'desc_tip' => true,
31 ],
32 'description' => [
33 'title' => __( 'Description', 'woocommerce-gateway-stripe' ),
34 'type' => 'text',
35 'description' => __( 'This controls the description which the user sees during checkout.', 'woocommerce-gateway-stripe' ),
36 'default' => __( 'Pay with your credit card via Stripe.', 'woocommerce-gateway-stripe' ),
37 'desc_tip' => true,
38 ],
39 'api_credentials' => [
40 'title' => __( 'Stripe Account Keys', 'woocommerce-gateway-stripe' ),
41 'type' => 'stripe_account_keys',
42 ],
43 'testmode' => [
44 'title' => __( 'Test mode', 'woocommerce-gateway-stripe' ),
45 'label' => __( 'Enable Test Mode', 'woocommerce-gateway-stripe' ),
46 'type' => 'checkbox',
47 'description' => __( 'Place the payment gateway in test mode using test API keys.', 'woocommerce-gateway-stripe' ),
48 'default' => 'yes',
49 'desc_tip' => true,
50 ],
51 'test_publishable_key' => [
52 'title' => __( 'Test Publishable Key', 'woocommerce-gateway-stripe' ),
53 'type' => 'text',
54 'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_test_" will be saved.', 'woocommerce-gateway-stripe' ),
55 'default' => '',
56 'desc_tip' => true,
57 ],
58 'test_secret_key' => [
59 'title' => __( 'Test Secret Key', 'woocommerce-gateway-stripe' ),
60 'type' => 'password',
61 'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_test_" or "rk_test_" will be saved.', 'woocommerce-gateway-stripe' ),
62 'default' => '',
63 'desc_tip' => true,
64 ],
65 'publishable_key' => [
66 'title' => __( 'Live Publishable Key', 'woocommerce-gateway-stripe' ),
67 'type' => 'text',
68 'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "pk_live_" will be saved.', 'woocommerce-gateway-stripe' ),
69 'default' => '',
70 'desc_tip' => true,
71 ],
72 'secret_key' => [
73 'title' => __( 'Live Secret Key', 'woocommerce-gateway-stripe' ),
74 'type' => 'password',
75 'description' => __( 'Get your API keys from your stripe account. Invalid values will be rejected. Only values starting with "sk_live_" or "rk_live_" will be saved.', 'woocommerce-gateway-stripe' ),
76 'default' => '',
77 'desc_tip' => true,
78 ],
79 'webhook' => [
80 'title' => __( 'Webhook Endpoints', 'woocommerce-gateway-stripe' ),
81 'type' => 'title',
82 'description' => $this->display_admin_settings_webhook_description(),
83 ],
84 'test_webhook_secret' => [
85 'title' => __( 'Test Webhook Secret', 'woocommerce-gateway-stripe' ),
86 'type' => 'password',
87 'description' => __( 'Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe' ),
88 'default' => '',
89 'desc_tip' => true,
90 ],
91 'webhook_secret' => [
92 'title' => __( 'Webhook Secret', 'woocommerce-gateway-stripe' ),
93 'type' => 'password',
94 'description' => __( 'Get your webhook signing secret from the webhooks section in your stripe account.', 'woocommerce-gateway-stripe' ),
95 'default' => '',
96 'desc_tip' => true,
97 ],
98 'inline_cc_form' => [
99 'title' => __( 'Inline Credit Card Form', 'woocommerce-gateway-stripe' ),
100 'type' => 'checkbox',
101 'description' => __( 'Choose the style you want to show for your credit card form. When unchecked, the credit card form will display separate credit card number field, expiry date field and cvc field.', 'woocommerce-gateway-stripe' ),
102 'default' => 'no',
103 'desc_tip' => true,
104 ],
105 'statement_descriptor' => [
106 'title' => __( 'Statement Descriptor', 'woocommerce-gateway-stripe' ),
107 'type' => 'text',
108 'description' => __( 'Statement descriptors are limited to 22 characters, cannot use the special characters >, <, ", \, \', *, /, (, ), {, }, and must not consist solely of numbers. This will appear on your customer\'s statement in capital letters.', 'woocommerce-gateway-stripe' ),
109 'default' => '',
110 'desc_tip' => true,
111 ],
112 'short_statement_descriptor' => [
113 'title' => __( 'Short Statement Descriptor', 'woocommerce-gateway-stripe' ),
114 'type' => 'text',
115 'description' => __( 'Shortened version of the statement descriptor in combination with the customer order number.', 'woocommerce-gateway-stripe' ),
116 'default' => '',
117 'desc_tip' => true,
118 ],
119 'capture' => [
120 'title' => __( 'Capture', 'woocommerce-gateway-stripe' ),
121 'label' => __( 'Capture charge immediately', 'woocommerce-gateway-stripe' ),
122 'type' => 'checkbox',
123 'description' => __( 'Whether or not to immediately capture the charge. When unchecked, the charge issues an authorization and will need to be captured later. Uncaptured charges expire in 7 days.', 'woocommerce-gateway-stripe' ),
124 'default' => 'yes',
125 'desc_tip' => true,
126 ],
127 'payment_request' => [
128 'title' => __( 'Payment Request Buttons', 'woocommerce-gateway-stripe' ),
129 'label' => sprintf(
130 /* translators: 1) br tag 2) Stripe anchor tag 3) Apple anchor tag 4) Stripe dashboard opening anchor tag 5) Stripe dashboard closing anchor tag */
131 __( 'Enable Payment Request Buttons. (Apple Pay/Google Pay) %1$sBy using Apple Pay, you agree to %2$s and %3$s\'s terms of service. (Apple Pay domain verification is performed automatically in live mode; configuration can be found on the %4$sStripe dashboard%5$s.)', 'woocommerce-gateway-stripe' ),
132 '<br />',
133 '<a href="https://stripe.com/apple-pay/legal" target="_blank">Stripe</a>',
134 '<a href="https://developer.apple.com/apple-pay/acceptable-use-guidelines-for-websites/" target="_blank">Apple</a>',
135 '<a href="https://dashboard.stripe.com/settings/payments/apple_pay" target="_blank">',
136 '</a>'
137 ),
138 'type' => 'checkbox',
139 'description' => __( 'If enabled, users will be able to pay using Apple Pay or Chrome Payment Request if supported by the browser.', 'woocommerce-gateway-stripe' ),
140 'default' => 'yes',
141 'desc_tip' => true,
142 ],
143 'payment_request_button_type' => [
144 'title' => __( 'Payment Request Button Type', 'woocommerce-gateway-stripe' ),
145 'label' => __( 'Button Type', 'woocommerce-gateway-stripe' ),
146 'type' => 'select',
147 'description' => __( 'Select the button type you would like to show.', 'woocommerce-gateway-stripe' ),
148 'default' => 'buy',
149 'desc_tip' => true,
150 'options' => [
151 'default' => __( 'Default', 'woocommerce-gateway-stripe' ),
152 'buy' => __( 'Buy', 'woocommerce-gateway-stripe' ),
153 'donate' => __( 'Donate', 'woocommerce-gateway-stripe' ),
154 'branded' => __( 'Branded', 'woocommerce-gateway-stripe' ),
155 'custom' => __( 'Custom', 'woocommerce-gateway-stripe' ),
156 ],
157 ],
158 'payment_request_button_theme' => [
159 'title' => __( 'Payment Request Button Theme', 'woocommerce-gateway-stripe' ),
160 'label' => __( 'Button Theme', 'woocommerce-gateway-stripe' ),
161 'type' => 'select',
162 'description' => __( 'Select the button theme you would like to show.', 'woocommerce-gateway-stripe' ),
163 'default' => 'dark',
164 'desc_tip' => true,
165 'options' => [
166 'dark' => __( 'Dark', 'woocommerce-gateway-stripe' ),
167 'light' => __( 'Light', 'woocommerce-gateway-stripe' ),
168 'light-outline' => __( 'Light-Outline', 'woocommerce-gateway-stripe' ),
169 ],
170 ],
171 'payment_request_button_height' => [
172 'title' => __( 'Payment Request Button Height', 'woocommerce-gateway-stripe' ),
173 'label' => __( 'Button Height', 'woocommerce-gateway-stripe' ),
174 'type' => 'text',
175 'description' => __( 'Enter the height you would like the button to be in pixels. Width will always be 100%.', 'woocommerce-gateway-stripe' ),
176 'default' => '44',
177 'desc_tip' => true,
178 ],
179 'payment_request_button_label' => [
180 'title' => __( 'Payment Request Button Label', 'woocommerce-gateway-stripe' ),
181 'label' => __( 'Button Label', 'woocommerce-gateway-stripe' ),
182 'type' => 'text',
183 'description' => __( 'Enter the custom text you would like the button to have.', 'woocommerce-gateway-stripe' ),
184 'default' => __( 'Buy now', 'woocommerce-gateway-stripe' ),
185 'desc_tip' => true,
186 ],
187 'payment_request_button_branded_type' => [
188 'title' => __( 'Payment Request Branded Button Label Format', 'woocommerce-gateway-stripe' ),
189 'label' => __( 'Branded Button Label Format', 'woocommerce-gateway-stripe' ),
190 'type' => 'select',
191 'description' => __( 'Select the branded button label format.', 'woocommerce-gateway-stripe' ),
192 'default' => 'long',
193 'desc_tip' => true,
194 'options' => [
195 'short' => __( 'Logo only', 'woocommerce-gateway-stripe' ),
196 'long' => __( 'Text and logo', 'woocommerce-gateway-stripe' ),
197 ],
198 ],
199 'payment_request_button_locations' => [
200 'title' => __( 'Payment Request Button Locations', 'woocommerce-gateway-stripe' ),
201 'type' => 'multiselect',
202 'description' => __( 'Select where you would like Payment Request Buttons to be displayed', 'woocommerce-gateway-stripe' ),
203 'desc_tip' => true,
204 'class' => 'wc-enhanced-select',
205 'options' => [
206 'product' => __( 'Product', 'woocommerce-gateway-stripe' ),
207 'cart' => __( 'Cart', 'woocommerce-gateway-stripe' ),
208 'checkout' => __( 'Checkout', 'woocommerce-gateway-stripe' ),
209 ],
210 'default' => [ 'product', 'cart' ],
211 'custom_attributes' => [
212 'data-placeholder' => __( 'Select pages', 'woocommerce-gateway-stripe' ),
213 ],
214 ],
215 'payment_request_button_size' => [
216 'title' => __( 'Payment Request Button Size', 'woocommerce-gateway-stripe' ),
217 'type' => 'select',
218 'description' => __( 'Select the size of the button.', 'woocommerce-gateway-stripe' ),
219 'default' => 'default',
220 'desc_tip' => true,
221 'options' => [
222 'default' => __( 'Default (40px)', 'woocommerce-gateway-stripe' ),
223 'medium' => __( 'Medium (48px)', 'woocommerce-gateway-stripe' ),
224 'large' => __( 'Large (56px)', 'woocommerce-gateway-stripe' ),
225 ],
226 ],
227 'saved_cards' => [
228 'title' => __( 'Saved Cards', 'woocommerce-gateway-stripe' ),
229 'label' => __( 'Enable Payment via Saved Cards', 'woocommerce-gateway-stripe' ),
230 'type' => 'checkbox',
231 'description' => __( 'If enabled, users will be able to pay with a saved card during checkout. Card details are saved on Stripe servers, not on your store.', 'woocommerce-gateway-stripe' ),
232 'default' => 'yes',
233 'desc_tip' => true,
234 ],
235 'logging' => [
236 'title' => __( 'Logging', 'woocommerce-gateway-stripe' ),
237 'label' => __( 'Log debug messages', 'woocommerce-gateway-stripe' ),
238 'type' => 'checkbox',
239 'description' => __( 'Save debug messages to the WooCommerce System Status log.', 'woocommerce-gateway-stripe' ),
240 'default' => 'no',
241 'desc_tip' => true,
242 ],
243 ]
244);
245
246if ( WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
247 // in the new settings, "checkout" is going to be enabled by default (if it is a new WCStripe installation).
248 $stripe_settings['payment_request_button_locations']['default'][] = 'checkout';
249
250 // no longer needed in the new settings.
251 unset( $stripe_settings['payment_request_button_branded_type'] );
252 unset( $stripe_settings['payment_request_button_height'] );
253 unset( $stripe_settings['payment_request_button_label'] );
254 // injecting some of the new options.
255 $stripe_settings['payment_request_button_type']['options']['default'] = __( 'Only icon', 'woocommerce-gateway-stripe' );
256 $stripe_settings['payment_request_button_type']['options']['book'] = __( 'Book', 'woocommerce-gateway-stripe' );
257 // no longer valid options.
258 unset( $stripe_settings['payment_request_button_type']['options']['branded'] );
259 unset( $stripe_settings['payment_request_button_type']['options']['custom'] );
260} else {
261 unset( $stripe_settings['payment_request_button_size'] );
262}
263
264if ( WC_Stripe_Feature_Flags::is_upe_preview_enabled() ) {
265 $upe_settings = [
266 WC_Stripe_Feature_Flags::UPE_CHECKOUT_FEATURE_ATTRIBUTE_NAME => [
267 'title' => __( 'New checkout experience', 'woocommerce-gateway-stripe' ),
268 'label' => sprintf(
269 /* translators: 1) br tag 2) Stripe anchor tag 3) Apple anchor tag 4) Stripe dashboard opening anchor tag 5) Stripe dashboard closing anchor tag */
270 __( 'Try the new payment experience (Early access) %1$sGet early access to a new, smarter payment experience on checkout and let us know what you think by %2$s. We recommend this feature for experienced merchants as the functionality is currently limited. %3$s', 'woocommerce-gateway-stripe' ),
271 '<br />',
272 '<a href="https://woocommerce.survey.fm/woocommerce-stripe-upe-opt-out-survey" target="_blank">submitting your feedback</a>',
273 '<a href="https://woocommerce.com/document/stripe/#new-checkout-experience" target="_blank">Learn more</a>'
274 ),
275 'type' => 'checkbox',
276 'description' => __( 'New checkout experience allows you to manage all payment methods on one screen and display them to customers based on their currency and location.', 'woocommerce-gateway-stripe' ),
277 'default' => 'no',
278 'desc_tip' => true,
279 ],
280 ];
281 if ( WC_Stripe_Feature_Flags::is_upe_checkout_enabled() ) {
282 // This adds the payment method section
283 $upe_settings['upe_checkout_experience_accepted_payments'] = [
284 'title' => __( 'Payments accepted on checkout (Early access)', 'woocommerce-gateway-stripe' ),
285 'type' => 'upe_checkout_experience_accepted_payments',
286 'default' => [ 'card' ],
287 ];
288 }
289 // Insert UPE options below the 'logging' setting.
290 $stripe_settings = array_merge( $stripe_settings, $upe_settings );
291}
292
293return apply_filters(
294 'wc_stripe_settings',
295 $stripe_settings
296);