Skip to content

Commit 82742b2

Browse files
rafaelzaleskidiegocurbelolovo-hcesarcosta99Kristófer Reykjalín
authored
Release/6.0.0 trunk update (#2264)
* Use node version from .nvmrc (#2221) * Use node version from .nvmrc * Use node versin from .nvmrc for linting * Reword "Stripe docs" to "Stripe plugin docs" (#2219) Rewording "Stripe docs" to "Stripe plugin docs" in order to avoid any confusion as to which documentation these links will navigate to. * Fix payment methods' capitalization (#2218) * Fix payment method names in sections: iDEAL, giropay, & Sofort Before, when managing WooCommerce payment methods, the section names of iDEAL, giropay, & Sofort were incorrectly capitalized. This fixes that and also updates the POT extension file so that the reference links are correct. * Fix payment method names in "Get started with Stripe" description Before, if one was not connected to Stripe, a card that allowed one to connect to Stripe would appear. In that card, a description was displayed where iDEAL and Sofort were not capitalized correctly. This fixes the capitalization of these payment methods. * Fix payment method names in admin notices: giropay, iDEAL, & Sofort Before, if a payment method was enabled but the incorrect currency was set, a notice would appear in the WooCommerce admin panel. These notices had payment method names with incorrect capitalization. This has now been fixed. * Fix payment method names in customer checkout: iDEAL, giropay, Sofort Before, when a customer was checking out with either iDEAL, giropay, or Sofort, an icon would appear but the icon's "alt" text had the payment method names incorrectly capitalized. This commit fixes that. * Fix payment method names in payments tab: iDEAL, giropay, & Sofort Before, when visiting the "Payments" tab of WooCommerce, the title of the tab would have the payment method names incorrectly capitalized. This commit fixes that. Also, the POT extension file's references were updated to point to the correct file-lines. And, log statements were updated to reflect the correct capitalization of the payment methods. * Fix Sofort's capitalization in invalid_sofort_country value Before, at checkout, if a non-supported country was selected for Sofort, a message indicating invalid country would appear but the capitalization was incorrect. This commit fixes that. * Fix payment method names in WC "Payments" tab: iDEAL, giropay, & Sofort Before, in WooCommerce (WC) "Payments" tab, the names of some payment methods were capitalized incorrectly. This commit fixes that. * Fix Sofort payment method name's capitalization in title and label Also, fix the corresponding tests. * Fix payment method names in WC "Payments" tab: iDEAL and Sofort Also, fix the capitalization of iDEAL in the tests file. * Fix payment method names in comments: iDEAL, giropay, Sofort Before, there was an inconsistency between the capitalization of the payment method names that were displayed to the user versus what was in the comments. This commit removes that inconsistency. * Fix payment method names in readme.txt: Sofort, iDEAL, & giropay This update fixes the capitalization of the payment methods: Sofort, iDEAL, and giropay in the readme.txt file. * Fix payment method names in the manual testing instructions Before, some of the payment methods (iDEAL, giropay, Sofort) were incorrectly capitalized in the plugin. So, the instructions were also incorrectly capitalized. But since these payment methods' names have been updated to reflect correct capitalization, these testing instructions also need to be updated in order to stay consistent. * Update changelog: Fixed capitalization for payment method names * Update changelog * Add webhook information to api key dialog (#2213) * Add additional tests for payment capture failure cases (#2215) * Add additional tests for payment capture failure cases * Fix error code for refunded order capture * Add tests for error codes * Fix phpcs warnings Co-authored-by: César Costa <[email protected]> * Fix fragile payment gateway names (#2230) * Use payment gateway label instead of array key, for gateway name Before, payment gateway names were retrieved from array keys. This made the code a bit fragile and required lowercasing the name for some use- cases. Now, a label property was added into WC_Stripe_Payment_Gateway class and that property is used to store the payment gateway name, instead. * Remove redundant lowercase call for UPE payment method names Before, payment method names were being lowercased, even though the name was already lowercase in all the respective payment method classes. * Reuse method_title property, as opposed to adding a label property Because the WC_Stripe_Payment_Gateway class already had a `method_title` property that has the name of the payment gateway, it was a bit redundant to add the `label` property. This commit removes the `label` property and reuses the `method_title` property, instead. This does mean that the payment method/gateway will read slightly different when UPE is enabled/disabled. See the following GH comment for more info: #2230 (comment) * chore: add listen npm script (#2236) * Redirect to settings tab after account is connected (#2226) * Change OAuth return URL for the settings page * Redirect to settings page after keys are added * Update changelog * Remove code to enable Stripe after OAuth connect * Correct the Stripe Account link URL on the Update Now Button (#2242) * Correct the Stripe Account link URL Fixes #2241 so that the link takes the customer to the Stripe Account page * Fix linting errors on index.js Fixed linting errors preventing #2242 from being merged * Add conditional before trying to add mask to CPF/CNPJ field (#2237) * added validation to prevent applying mask on non existent element when boleto is not active #2233 * added changelog entry #2233 * Show toast when payment methods list is updated (#2235) * Add selectors to help with account capabilities * Add filter to capability name * Update tests * Update changelog * Update translation instructions * Update pull request template (#2246) * fixed bug that would require customer to click on use new payment met… (#2216) * fixed bug that would require customer to click on use new payment method on pay order page when no payment card was saved #2163 * added changelog #2163 * change how the "Use new payment method" input is hidden on pay order #2163 * moved changelog entry to latest version * Prompt message when navigating out Stripe settings with unsaved changes (#2243) * Prompt message when navigating away with unsaved changes * Do not prompt message on navigation triggered by WooCommerce * Add changelog entries * Typo * Reset initial settings after form is saved * Update copy * Add missing changelog entries in readme.txt * Add a reference to the transpiled JS file in POT file reference comments (#2250) * Add wp-cli as dev dependency to composer * Generate hidden-source-maps during production build * Add the combine/update POT script from wc payments * Update package.json scripts to inlcude POT combination during build * Remove @wordpress/babel-plugin-makepot plugin from babel config * Tweaks in the connect account modal (#2245) * Disable autocomplete on account keys fields * Does not close the modal when keys are invalid * Refresh account before closing the modal * Disable autocomplete on webhook url field * Fix tests * Update changelog * Update version date * Update release date placeholder to 2022 * Update readme.txt * Product version bump update Co-authored-by: Diego Curbelo <[email protected]> Co-authored-by: Hector Lovo <[email protected]> Co-authored-by: César Costa <[email protected]> Co-authored-by: Kristófer Reykjalín <[email protected]> Co-authored-by: Brian Yu <[email protected]> Co-authored-by: Joash Rajin <[email protected]> Co-authored-by: leonardo lopes de albuquerque <[email protected]> Co-authored-by: Alfredo Sumaran <[email protected]>
1 parent b8a1d32 commit 82742b2

File tree

66 files changed

+5479
-3127
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+5479
-3127
lines changed

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Please follow the following guidelines when writing testing instructions:
4242
---
4343

4444
- [ ] Covered with tests (or have a good reason not to test in description ☝️)
45-
- [ ] Added changelog entry (or does not apply)
45+
- [ ] Added changelog entry **in both** `changelog.txt` and `readme.txt` (or does not apply)
4646
- [ ] Tested on mobile (or does not apply)
4747

4848
**Post merge**

.github/workflows/js-tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ jobs:
1010
steps:
1111
# clone the repository
1212
- uses: actions/checkout@v2
13+
# use the node version defined in nvmrc
14+
- uses: actions/setup-node@v2
15+
with:
16+
node-version-file: '.nvmrc'
1317
# enable dependencies caching
1418
- uses: actions/cache@v2
1519
with:

.github/workflows/linting.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ jobs:
3333
steps:
3434
# clone the repository
3535
- uses: actions/checkout@v2
36+
# use the node version defined in nvmrc
37+
- uses: actions/setup-node@v2
38+
with:
39+
node-version-file: '.nvmrc'
3640
# enable dependencies caching
3741
- uses: actions/cache@v2
3842
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ vendor
1515
release/
1616
build/
1717
woocommerce-gateway-stripe.zip
18+
languages/woocommerce-gateway-stripe.pot
1819

1920
# Ignore all log files except for .htaccess
2021
/logs/*

assets/js/stripe.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,10 @@ jQuery( function( $ ) {
267267

268268
//Mask CPF/CNPJ field when using Boleto
269269
$( document ).on( 'change', '.wc_payment_methods', function () {
270+
if ( ! $( '#stripe_boleto_tax_id' ).length ) {
271+
return;
272+
}
273+
270274
var TaxIdMaskBehavior = function ( val ) {
271275
return val.replace( /\D/g, '' ).length >= 12 ? '00.000.000/0000-00' : '000.000.000-009999';
272276
},
@@ -325,7 +329,7 @@ jQuery( function( $ ) {
325329
},
326330

327331
/**
328-
* Check if Stripe Giropay is being used.
332+
* Check if Stripe giropay is being used.
329333
*
330334
* @return {boolean}
331335
*/
@@ -334,7 +338,7 @@ jQuery( function( $ ) {
334338
},
335339

336340
/**
337-
* Check if Stripe iDeal is being used.
341+
* Check if Stripe iDEAL is being used.
338342
*
339343
* @return {boolean}
340344
*/
@@ -343,7 +347,7 @@ jQuery( function( $ ) {
343347
},
344348

345349
/**
346-
* Check if Stripe SOFORT is being used.
350+
* Check if Stripe Sofort is being used.
347351
*
348352
* @return {boolean}
349353
*/

assets/js/stripe.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

babel.config.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,4 @@ module.exports = {
99
'@babel/plugin-proposal-optional-chaining',
1010
'@babel/plugin-proposal-nullish-coalescing-operator',
1111
],
12-
env: {
13-
production: {
14-
plugins: [
15-
'@emotion',
16-
[
17-
'@wordpress/babel-plugin-makepot',
18-
{
19-
output: 'languages/woocommerce-gateway-stripe.pot',
20-
},
21-
],
22-
],
23-
},
24-
},
2512
};

bin/update-pot-file-references.php

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
<?php
2+
// phpcs:ignoreFile - This is an auxiliary build tool, and not part of the plugin.
3+
4+
/**
5+
* Command line script for updating the file references of JS files in a .pot file.
6+
*/
7+
8+
/**
9+
* Get the file name from the command line.
10+
*/
11+
if ( $argc !== 2 ) {
12+
echo "Usage: {$argc} php -f {$argv[0]} file.pot\n";
13+
exit;
14+
}
15+
16+
$pot_filename = $argv[1];
17+
18+
if ( ! is_file( $pot_filename ) ) {
19+
echo "[ERROR] File not found: {$pot_filename}\n";
20+
exit;
21+
}
22+
23+
/**
24+
* Parses a .pot file into an array.
25+
*
26+
* @param string $file_name Pot file name.
27+
* @return array Translation messages
28+
*/
29+
function read_pot_translations( string $file_name ): array {
30+
$fh = fopen( $file_name, 'r' );
31+
$originals = [];
32+
$references = [];
33+
$messages = [];
34+
$have_msgid = false;
35+
36+
while ( ! feof( $fh ) ) {
37+
$line = trim( fgets( $fh ) );
38+
if ( ! $line ) {
39+
$message = implode( "\n", $messages );
40+
$originals[ $message ] = $references;
41+
$references = [];
42+
$messages = [];
43+
$have_msgid = false;
44+
continue;
45+
}
46+
47+
if ( 'msgid' == substr( $line, 0, 5 ) ) {
48+
$have_msgid = true;
49+
}
50+
51+
if ( $have_msgid ) {
52+
$messages[] = $line;
53+
} else {
54+
$references[] = $line;
55+
}
56+
}
57+
58+
fclose( $fh );
59+
60+
$message = implode( "\n", $messages );
61+
$originals[ $message ] = $references;
62+
return $originals;
63+
}
64+
65+
/**
66+
* Generates a map with the mapping for 'original source file' -> final transpiled/minified file in the 'dist' folder.
67+
* Format example:
68+
* [
69+
* 'client/card-readers/settings/file-upload.js' => [
70+
* 'build/index.js',
71+
* 'build/tos.js',
72+
* ]
73+
* ]
74+
*
75+
* @return array Mapping of source js files and the generated files that use them.
76+
*/
77+
function load_js_transpiling_source_maps(): array {
78+
$mappings = [];
79+
foreach ( glob( "build/*.js.map", GLOB_NOSORT ) as $filename ) {
80+
$file_content = file_get_contents( $filename );
81+
if ( $file_content === false ) {
82+
echo "[WARN] Unable to read file '". $filename . "'. Some translation strings might not have the correct references as a result.\n";
83+
continue;
84+
}
85+
$file_json = json_decode( $file_content, true );
86+
if ( $file_json === null ) {
87+
echo "[WARN] Unable to parse JSON file: '". $filename . "'. Some translation strings might not have the correct references as a result.\n";
88+
continue;
89+
}
90+
91+
foreach ( $file_json[ 'sources' ] as $source ) {
92+
$source = preg_replace( '%^webpack:///\./(client/.*)$%', '${1}', $source );
93+
if ( 'webpack' !== substr( $source, 0, 7 ) ) {
94+
$mappings[ $source ][] = $file_json[ 'file' ];
95+
}
96+
}
97+
}
98+
99+
if ( empty( $mappings ) ) {
100+
echo "[ERROR] Unable to load JS transpiling mappings from 'build/*.js.map' files. Make sure the JS assets compilation was successful (e.g. npm run build:webpack).\n";
101+
die();
102+
}
103+
104+
return $mappings;
105+
}
106+
107+
/**
108+
* For each file reference to a javascript/typescript file (from the client folder) in the comments, it adds file
109+
* references to the generated files (from the build folder) that use that particular javascript/typescript as source.
110+
*
111+
* @param array $js_mappings Mapping of source js files and the generated files that use them.
112+
* @param array $translations POT translations (including references/comments).
113+
* @return array Translation messages
114+
*/
115+
function add_transpiled_filepath_reference_to_comments( array $js_mappings, array $translations ): array {
116+
foreach ( $translations as $message => $references ) {
117+
// Check references for js/jsx/ts/tsx files
118+
$dist_js_to_add = [];
119+
foreach ( $references as $ref ) {
120+
if ( preg_match( '%^#: (.+\.(js|jsx|ts|tsx)):\d+$%', $ref, $m ) ) {
121+
if ( ! array_key_exists( $m[1], $js_mappings ) ) {
122+
// The file $m[1] is not used in any of the generated client JS files. Skip it.
123+
continue;
124+
}
125+
126+
foreach ( $js_mappings[ $m[1] ] as $mapping ) {
127+
$dist_js_to_add[] = '#: build/' . $mapping . ':1';
128+
}
129+
}
130+
}
131+
132+
// Add the new file references to the top of the list.
133+
if ( ! empty( $dist_js_to_add ) ) {
134+
array_splice( $translations[ $message], 0, 0, array_unique( $dist_js_to_add ) );
135+
}
136+
}
137+
138+
return $translations;
139+
}
140+
141+
// Read the translation .pot file.
142+
$originals = read_pot_translations( $pot_filename );
143+
144+
// For transpiled JS client files, we need to add a reference to the generated build file.
145+
$js_source_maps = load_js_transpiling_source_maps();
146+
$originals = add_transpiled_filepath_reference_to_comments( $js_source_maps, $originals );
147+
148+
// Delete the original source.
149+
unlink( $pot_filename );
150+
151+
$fh = fopen( $pot_filename, 'w' );
152+
153+
foreach ( $originals as $message => $original ) {
154+
fwrite( $fh, implode( "\n", $original ) );
155+
fwrite( $fh, "\n" . $message . "\n\n" );
156+
}
157+
158+
fclose( $fh );
159+
160+
echo "Updated {$pot_filename}\n";

changelog.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
*** Changelog ***
22

3+
= 6.0.0 - 2022-01-05 =
4+
* Fix - Fixed capitalization for payment method names: iDEAL, giropay, and Sofort.
5+
* Add - Text to explain how to enable webhooks when manually entering your API keys in the new Stripe settings.
6+
* Tweak - Redirect to the settings tab after an account is connected.
7+
* Tweak - Prompt message when navigating out Stripe settings with unsaved changes
8+
* Tweak - Show toast when payment methods list is updated with new payment methods.
9+
* Fix - JS error on checkout when Boleto method was not active.
10+
* Fix - Fixed bug that show "Use new payment method" on pay order page when there were no saved card was.
11+
* Tweak - Autocomplete for account keys and webhooks fields were disabled.
12+
* Fix - The settings page is not reloaded when the user enters invalid account keys.
13+
314
= 5.9.0 - 2021-12-09 =
415
* Add - Add Stripe API to generate connection tokens, manage terminal locations, create customers, get account summary, capture payment.
516
* Tweak - Remove `_wcstripe_feature_upe` flag and all traces of old settings.

client/classic/upe/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,17 @@ jQuery( function ( $ ) {
336336
setSelectedUPEPaymentType( selectedUPEPaymentType );
337337
isUPEComplete = event.complete;
338338
} );
339+
340+
/*
341+
* Trigger this event to ensure the tokenization-form.js init
342+
* is executed.
343+
*
344+
* This script handles the radio input interaction when toggling
345+
* between the user's saved card / entering new card details.
346+
*
347+
* Ref: https://github.com/woocommerce/woocommerce/blob/2429498/assets/js/frontend/tokenization-form.js#L109
348+
*/
349+
$( document.body ).trigger( 'wc-credit-card-form-init' );
339350
} )
340351
.catch( ( error ) => {
341352
unblockUI( $( upeLoadingSelector ) );

0 commit comments

Comments
 (0)