-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add country-specific test card numbers for credit card testing #9688
Conversation
Test the buildOption 1. Jetpack Beta
Option 2. Jurassic Ninja - available for logged-in A12s🚀 Launch a JN site with this branch 🚀 ℹ️ Install this Tampermonkey script to get more options. Build info:
Note: the build is updated when a new commit is pushed to this PR. |
Size Change: 0 B Total Size: 1.33 MB ℹ️ View Unchanged
|
I've mentioned a couple of JN sites here, feel free to click around there but also it'd be great to setup a new one for a new country and test this out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is working well in shortcode checkout/blocks checkout/my account/pay-for-order/subscription renewal.
I have a question about the default value of null
on the function's argument, when it's typed as string
and its usage consistency.
* @return string | ||
*/ | ||
abstract public function get_testing_instructions(); | ||
abstract public function get_testing_instructions( string $account_country = null ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find it a little bit confusing to type the argument's $account_country
as string
(both with PHP 7.0 typing and with the PHP docblock), but setting null
as its default value.
A few questions:
- In which scenario would
$account_country
benull
or need a default value?get_account_country()
will returnUS
in case ofnull
value:return $account['country'] ?? Country_Code::UNITED_STATES; - Should
null
be also typed in the docblock?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, no nullable default is needed. I removed it in 5712fbb
* @return string Test card number | ||
*/ | ||
public static function get_test_card_for_country( string $country_code ) { | ||
return self::$country_test_cards[ $country_code ] ?? self::$country_test_cards['US']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of using the country codes in Country_Code
for consistency? (you'll probably need to flip the include_once
in includes/class-wc-payments.php
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, applied in 11a914b but let me know if I misunderstood your comment and you meant something different.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's great, thank you! Just this one missing:
return self::$country_test_cards[ $country_code ] ?? self::$country_test_cards['US']; | |
return self::$country_test_cards[ $country_code ] ?? self::$country_test_cards[ Country_Code::UNITED_STATES ]; |
d3a6bc0
to
5712fbb
Compare
a1921e8
to
3fc0170
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the changes!
My only nitpick here would be that |
@aheckler good point, thank you. Looking at the list of country codes WooPayments implemented which contains all the countries added as part of the testing card addition and even more, I think it's fine to keep them. In terms of the code, it shouldn't be a big deal. If there is any concern about keeping non-supported countries in the plugin, we can remove them pretty quick, just let us know! |
Closes #9619
Changes proposed in this Pull Request
This PR adds support for country-specific test card numbers in test mode. When a merchant is testing payments, they will now see the appropriate test card number based on their account's country. The test card numbers are sourced from Stripe's documentation.
Testing instructions
Country_Test_Cards
is in line with countries list mentioned in Stripe docs$account_response['country'] = 'GB';
before this line on the server4242 ...
card number is usednpm run changelog
to add a changelog file, choosepatch
to leave it empty if the change is not significant. You can add multiple changelog files in one PR by running this command a few times.Post merge