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
🚧🧠🌴 Fix Braintree 3DS in Dev portal (and much more) #3079
🚧🧠🌴 Fix Braintree 3DS in Dev portal (and much more) #3079
Conversation
f162381
to
4c816ad
Compare
Can't really review but looks much better than before. |
fields: { | ||
number: { | ||
selector: '#customer_credit_card_number', | ||
placeholder: '4111 1111 1111 1111' |
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.
does this come from automatically now?
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 it comes from https://github.com/3scale/porta/pull/3079/files#diff-e5280eb9a5ca2994755960970425ea7ff092eef504a1a954682533ea1d1cc75c and it's the same as in the Dev portal form.
This was copy-pasted from a Braintree docs example.
4c816ad
to
cd50a02
Compare
6a2ffa5
to
7c97ffa
Compare
7c97ffa
to
bfbc176
Compare
app/javascript/src/PaymentGateways/braintree/utils/formValidation.ts
Outdated
Show resolved
Hide resolved
app/views/provider/admin/account/payment_gateways/braintree_blue/edit.html.slim
Show resolved
Hide resolved
app/views/provider/admin/account/payment_gateways/braintree_blue/edit.html.slim
Outdated
Show resolved
Hide resolved
braintree-web
/** | ||
* Use when mounting a component with promises or side effects, such as BraintreeForm#onSubmit | ||
*/ | ||
async function waitForPromises (): Promise<void> { | ||
await act(async () => { | ||
await new Promise((resolve) => setTimeout(resolve)) | ||
}) | ||
} | ||
|
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.
May you explain this? I don't understand it. AIUI this won't return a Promise
b/c the only call in the function is preceded by an await
. Besides, there's no return
keyword. What does act()
do?
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.
async / await
is syntactic sugar for wrapping something with a promise. Not returning means the method returns undefined
. But if method awaits something inside, then it has to be marked as async and it will wrap this undefined inside a Promise, therefore it will return Promise<void>
. In this scenario, a return
statement is redundant.
Does that make sense?
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.
Yes, but still don't understand the code. What does act()
do? and why calling setTimeout
?
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.
Anything that triggers a change in the component has to be wrapped around act.
setTimeout
is used to add a delay to the promise so that it doesn't resolve immediately.
braintree-web
braintree-web
8b29d5d
to
fad142e
Compare
braintree-web
braintree-web
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 don't feel able to review all the TS code, so I cloned the branch and tried to make it work locally. Everything seems to work fine for me, so approved.
braintree-web
braintree-web
…of cdn and separate some logic
b77edd4
to
f575e10
Compare
braintree-web
Related:
What this PR does / why we need it:
THREESCALE-8967: Adding Braintree SCA card fails
We load braintree-web SDK from node_modules AND as a cdn. Besides, the whole braintree flow is implemented in a convoluted way and it's hard to maintain.
First, this PR cleans up the pack used in developer portal that renders a React component which uses braintree-web imported from node_modules.
Second, it removes the dependency from braintre-web CDN by moving the script from admin portal's view into a pack and importing the SDK from node_nodules.
TODO:
verification
Testing credit cards:
NOTE: both forms: payment details (admin portal) and credit card details (dev portal), are basically the same. They share the same logic and have the same fields. However, one is renders via formtastic in a slim template (edit.html.slim) whereas the other is a React component (BraintreeForm.tsx). The only problem is mainly the differences between class names. Example:
Admin portal (PF4 style)
Dev portal (dev portal style)
This to me looks like repetition and we should be able to use React in both (or none..) but it goes out of scope of this PR.