-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Checkout: abstracting Brazil/Ebank form fields #24095
Conversation
29848c9
to
0a14521
Compare
Thanks for catching that @yoavf I didn't pull the existing css over to the new component. Now looks like this: Mobile Desktop |
Just realized, after looking how to introduce validation to the redirect payment box, that I need to abstract the ebanx validation rules as well. More to come on this PR... :) |
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 works well, but I think we need to go a little bit deeper and cleanup some of the intermediate code, maybe in a way combine some of shouldRenderAdditionalEbanxFields
, isEbanxEnabledForCountry
and ebanxFieldRules
. Let me know if that doesn't make sense :)
client/lib/checkout/validation.js
Outdated
*/ | ||
function paymentFieldRules( paymentDetails, paymentType ) { | ||
switch ( paymentType ) { | ||
case 'tef': |
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.
Let's simplify this for now and remove the 'tef' rule. We can add it to #23830 later.
* Internal dependencies | ||
*/ | ||
import { validatePaymentDetails, getCreditCardType } from '../validation'; | ||
import { isEbanxEnabledForCountry, isValidCPF } from 'lib/checkout/ebanx'; |
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.
Now that it's in lib/checkout this function should be renamed. The actual meaning right now is "Should ebanx be used for credit-card processing in this country"
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.
Bit of a mouthful, but the least prolix I could come up with was: isEbanxCreditCardProcessingEnabledForCountry
9dce9e8
to
21a9274
Compare
Thanks for testing. I agree, Ebanx is now peppered about the shop. By 'combine' do you mean in the same module, or aggregate some of the logic into higher-order functions? |
I've pulled together the common Ebanx methods, and genericized the Let me know if you see any further areas that could be cleaned up. |
d104bb7
to
1aaa846
Compare
Returning a fragment to enable testing in enzyme
…o we can use the validation lib for other payment handlers Updated paths and tests
…bledForCountry` to reflect usage and change in directory structure Removed switch condition `tef` until #23830 Added extra text for `paymentFieldRules()`
Genericizing <EbanxPaymentFields /> to handle multiple possible ebanx fields Updated tests and README
1aaa846
to
e6541c9
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.
Thanks 👍 Looks great now, and much saner.
Tested manually, and ran locally the relevant e2e tests (which is the reason for all the rebased/forced pushes - sorry about that).
This PR extracts extra fields required for Ebanx payments in Brazil from the credit card fields component, in order that we may use them in other payment-related forms such as bank transfer/redirect.
Along with the fields, I'm also moving clientside field validation for checkout/credit card fields into
lib/checkout
so that we can extend the rule to include the paypal/redirect panels and so on.There is no new functionality.
For a background see:
pxLjZ-4BN-p2
Screenshot
Testing
111.444.777-35
)Expectations
At 3: You should see the Ebanx extra fields
At 4: The fields should show validation messages
At 5: Valid form data should permit payment attempt