-
Notifications
You must be signed in to change notification settings - Fork 685
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
Pwa 2968::[Issue] Gomage/plugin braintree three d secure #4311
Open
glo82145
wants to merge
13
commits into
develop
Choose a base branch
from
PWA-2968-v1
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a986a12
The current problem is that the 3D Secure feature is not working. Whe…
rtsehynka-gm 36fd306
[PWA Studio] - Test Braintree #D Secure fix for Venia
rtsehynka-gm 5fc8db3
[PWA Studio] - Add to frame-src *.cardinalcommerce.com (for test only)
rtsehynka-gm 3440add
[PWA Studio] - Add to frame-src *.cardinalcommerce.com (for test only)
rtsehynka-gm dc8fc3f
Merge branch 'develop' into gomage/plugin-braintree-three-d-secure
rtsehynka-gm 7b33ab5
Merge branch 'develop' into gomage/plugin-braintree-three-d-secure
dpatil-magento 7d26462
Merge branch 'develop' into gomage/plugin-braintree-three-d-secure
rtsehynka-gm 3eca535
PWA-2968::[Issue] Gomage/plugin braintree three d secure
glo82145 dcd95e5
PWA-2968::[Issue] Gomage/plugin braintree three d secure
glo82145 050189a
PWA-2968::[Issue] Gomage/plugin braintree three d secure
glo82145 efbb67c
Resolve clean issue
glo82145 287a68c
PWA-2968:updating version
chetana11 8bf8c5b
Adding license field else showing error during yarn clean:all
chetana11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
111 changes: 111 additions & 0 deletions
111
packages/extensions/gomage-plugin-braintree-three-d-secure/Intercepts/brainTreeDropIn.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/** | ||
* adding to brainTreeDropIn 3D secure part | ||
* @param targets | ||
*/ | ||
function localIntercept(targets) { | ||
const { Targetables } = require('@magento/pwa-buildpack'); | ||
const targetables = Targetables.using(targets); | ||
|
||
/** | ||
* We can disable the logic if you will add to .env param CHECKOUT_BRAINTREE_3D with value false | ||
*/ | ||
if (process.env.CHECKOUT_BRAINTREE_3D != 'false') { | ||
const brainTreeDropIn = targetables.reactComponent( | ||
'@magento/venia-ui/lib/components/CheckoutPage/PaymentInformation/brainTreeDropIn.js' | ||
); | ||
|
||
/** | ||
* import 3d secure plugin | ||
*/ | ||
brainTreeDropIn.addImport( | ||
'{useBraintreeThreeDSecure} from "@gomage/plugin-braintree-three-d-secure"' | ||
); | ||
brainTreeDropIn.addImport( | ||
'{usePriceSummary} from "@magento/peregrine/lib/talons/CartPage/PriceSummary/usePriceSummary"' | ||
); | ||
|
||
/** | ||
* add hook for getting of client token | ||
*/ | ||
brainTreeDropIn.insertAfterSource( | ||
'const [dropinInstance, setDropinInstance] = useState();', | ||
'\n const clientToken = useBraintreeThreeDSecure();' + | ||
'\n const talonProps = usePriceSummary();' | ||
); | ||
/** | ||
* check if exist clientToken | ||
*/ | ||
brainTreeDropIn.insertAfterSource( | ||
'const createDropinInstance = useCallback(async () => {', | ||
'\n if(clientToken){ ' | ||
); | ||
/** | ||
* end condition of check if exist clientToken | ||
*/ | ||
brainTreeDropIn.insertAfterSource('return dropinInstance;', '\n}'); | ||
/** | ||
* setting new dependency clientToken to useCallback createDropinInstance hook | ||
*/ | ||
brainTreeDropIn.insertAfterSource( | ||
'[containerId', | ||
' ,clientToken, talonProps.flatData.total.value' | ||
); | ||
|
||
/** | ||
* check if exist clientToken | ||
*/ | ||
brainTreeDropIn.insertBeforeSource( | ||
'const renderDropin = async () => {', | ||
'\n if(clientToken){ ' | ||
); | ||
|
||
/** | ||
* end condition of check if exist clientToken | ||
*/ | ||
brainTreeDropIn.insertBeforeSource( | ||
'}, [createDropinInstance, onReady]);', | ||
'} \n' | ||
); | ||
|
||
/** | ||
* setting new dependency clientToken to useEffect hook | ||
*/ | ||
brainTreeDropIn.insertAfterSource( | ||
'[createDropinInstance, onReady', | ||
' ,clientToken' | ||
); | ||
|
||
/** | ||
* change of value token to client Token | ||
*/ | ||
brainTreeDropIn.insertAfterSource( | ||
'const dropinInstance = await dropIn.create({\n' + | ||
' authorization', | ||
':clientToken' | ||
); | ||
|
||
/** | ||
* enable 3d secure | ||
*/ | ||
brainTreeDropIn.insertAfterSource( | ||
'container: `#${containerId}`,', | ||
'\n threeDSecure: {amount:talonProps.flatData.total.value},' | ||
); | ||
|
||
/** | ||
* update brain tree if total was changes | ||
*/ | ||
brainTreeDropIn.insertBeforeSource( | ||
'if (isError) {', | ||
'useEffect(() => {\n' + | ||
' if(dropinInstance) {\n' + | ||
' dropinInstance.teardown();\n' + | ||
' }\n' + | ||
' }, [\n' + | ||
' talonProps.flatData.total.value,\n' + | ||
']);' | ||
); | ||
} | ||
} | ||
|
||
module.exports = localIntercept; |
24 changes: 24 additions & 0 deletions
24
packages/extensions/gomage-plugin-braintree-three-d-secure/Model/useBraintreeThreeDSecure.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useMutation } from '@apollo/client'; | ||
import { useEffect } from 'react'; | ||
import { GET_BRAINTREE_CLIENT_TOKEN } from '../Queries/createBraintreeClientToken.gql'; | ||
|
||
/** | ||
* | ||
* @returns {*|string} | ||
*/ | ||
export const useBraintreeThreeDSecure = () => { | ||
const [setBraintreeClientToken, { data }] = useMutation( | ||
GET_BRAINTREE_CLIENT_TOKEN | ||
); | ||
const clientToken = data ? data.createBraintreeClientToken : ''; | ||
/** | ||
* set Braintree Client Token | ||
*/ | ||
useEffect(() => { | ||
if (!clientToken) { | ||
setBraintreeClientToken(); | ||
} | ||
}, [clientToken, setBraintreeClientToken]); | ||
|
||
return clientToken; | ||
}; |
10 changes: 10 additions & 0 deletions
10
...tensions/gomage-plugin-braintree-three-d-secure/Queries/createBraintreeClientToken.gql.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { gql } from '@apollo/client'; | ||
/** | ||
* | ||
* @type {DocumentNode} | ||
*/ | ||
export const GET_BRAINTREE_CLIENT_TOKEN = gql` | ||
mutation { | ||
createBraintreeClientToken | ||
} | ||
`; |
7 changes: 7 additions & 0 deletions
7
packages/extensions/gomage-plugin-braintree-three-d-secure/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# GoMage Braintree 3D Secure | ||
|
||
GoMage Braintree 3D Secure | ||
|
||
That plugin works only as a fix bugs of PWA Studio and adds 3d secure part. | ||
|
||
If you need to disable the module, you can add to the .env parameter CHECKOUT_BRAINTREE_3D=false, or remove the plugin. |
1 change: 1 addition & 0 deletions
1
packages/extensions/gomage-plugin-braintree-three-d-secure/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { useBraintreeThreeDSecure } from './Model/useBraintreeThreeDSecure'; |
11 changes: 11 additions & 0 deletions
11
packages/extensions/gomage-plugin-braintree-three-d-secure/intercept.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* | ||
* @param targets | ||
*/ | ||
function localIntercept(targets) { | ||
require('@gomage/plugin-braintree-three-d-secure/Intercepts/brainTreeDropIn')( | ||
targets | ||
); | ||
} | ||
|
||
module.exports = localIntercept; |
20 changes: 20 additions & 0 deletions
20
packages/extensions/gomage-plugin-braintree-three-d-secure/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "@gomage/plugin-braintree-three-d-secure", | ||
"version": "3.94.0", | ||
"description": "GoMage Braintree 3D Secure", | ||
"main": "./index.js", | ||
"author": "GoMage", | ||
"dependencies": { | ||
"braintree-web-drop-in": "~1.43.0" | ||
}, | ||
|
||
"scripts": { | ||
"clean": " " | ||
}, | ||
"license": "SEE LICENSE IN LICENSE.txt", | ||
"pwa-studio": { | ||
"targets": { | ||
"intercept": "./intercept.js" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Shouldn't this get pulled into @magento instead? Alternatively anything published as gomage https://www.npmjs.com/search?q=gomage would come into scope.