-
Notifications
You must be signed in to change notification settings - Fork 579
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
[DTPPCPSDK-2824] [DTPRP-1734] [DTPRP-1751] Limit eligible button to Paypal when new createSubscription is used #2456
Open
9zees
wants to merge
13
commits into
paypal:main
Choose a base branch
from
9zees:feature/DTPPCPSDK-2824-limitFssBtns
base: main
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 3 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
3a124c6
Limit eligible button to Paypal when new createSubscription is used
9zees 49ab6a1
Fix lint error
9zees 8f3c869
Fix typecheck errors
9zees 6a24f62
Merge branch 'main' of https://github.com/paypal/paypal-checkout-comp…
9zees 1c4750e
Add FSS as a flow, clean up isFsSubscription prop
9zees aa6caa7
Merge branch 'main' of https://github.com/paypal/paypal-checkout-comp…
9zees cb34480
Reverting code from isFsSubscription
9zees 2aa4bdb
Reverting change from isFsSubscription
9zees 64a7853
Passing more properties into eligible
9zees 4d83d23
Temp removal of DISPLAY_ONLY and eligible
9zees e5ef586
Checking intent to determine flow
9zees 7fff30b
Rebase and resolve merge conflict
9zees 1747b5b
Resolve merge conflict
9zees 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
/* @flow */ | ||
import { describe, expect } from "vitest"; | ||
|
||
import { Buttons } from "./buttons"; | ||
|
||
/* NOTE: We want to give a "complete" fundingEligibility object since this is what determines how many buttons there will be to start with, before we try to limit the buttons */ | ||
const fundingEligibility = { | ||
paypal: { | ||
eligible: true, | ||
vaultable: true, | ||
}, | ||
paylater: { | ||
eligible: true, | ||
vaultable: true, | ||
products: { | ||
payIn3: { | ||
eligible: false, | ||
variant: null, | ||
}, | ||
payIn4: { | ||
eligible: false, | ||
variant: null, | ||
}, | ||
paylater: { | ||
eligible: true, | ||
variant: null, | ||
}, | ||
}, | ||
}, | ||
card: { | ||
eligible: true, | ||
branded: false, | ||
installments: false, | ||
vendors: { | ||
visa: { | ||
eligible: true, | ||
vaultable: true, | ||
}, | ||
mastercard: { | ||
eligible: true, | ||
vaultable: true, | ||
}, | ||
amex: { | ||
eligible: true, | ||
vaultable: true, | ||
}, | ||
discover: { | ||
eligible: true, | ||
vaultable: true, | ||
}, | ||
hiper: { | ||
eligible: false, | ||
vaultable: false, | ||
}, | ||
elo: { | ||
eligible: false, | ||
vaultable: true, | ||
}, | ||
jcb: { | ||
eligible: false, | ||
vaultable: true, | ||
}, | ||
maestro: { | ||
eligible: true, | ||
vaultable: true, | ||
}, | ||
diners: { | ||
eligible: true, | ||
vaultable: true, | ||
}, | ||
cup: { | ||
eligible: true, | ||
vaultable: true, | ||
}, | ||
}, | ||
guestEnabled: false, | ||
}, | ||
venmo: { | ||
eligible: false, | ||
vaultable: false, | ||
}, | ||
itau: { | ||
eligible: false, | ||
}, | ||
credit: { | ||
eligible: false, | ||
}, | ||
applepay: { | ||
eligible: true, | ||
}, | ||
sepa: { | ||
eligible: false, | ||
}, | ||
ideal: { | ||
eligible: false, | ||
}, | ||
bancontact: { | ||
eligible: false, | ||
}, | ||
giropay: { | ||
eligible: false, | ||
}, | ||
eps: { | ||
eligible: false, | ||
}, | ||
sofort: { | ||
eligible: false, | ||
}, | ||
mybank: { | ||
eligible: false, | ||
}, | ||
p24: { | ||
eligible: false, | ||
}, | ||
wechatpay: { | ||
eligible: false, | ||
}, | ||
payu: { | ||
eligible: false, | ||
}, | ||
blik: { | ||
eligible: false, | ||
}, | ||
trustly: { | ||
eligible: false, | ||
}, | ||
oxxo: { | ||
eligible: false, | ||
}, | ||
boleto: { | ||
eligible: false, | ||
}, | ||
boletobancario: { | ||
eligible: false, | ||
}, | ||
mercadopago: { | ||
eligible: false, | ||
}, | ||
multibanco: { | ||
eligible: false, | ||
}, | ||
satispay: { | ||
eligible: false, | ||
}, | ||
paidy: { | ||
eligible: false, | ||
}, | ||
}; | ||
|
||
describe("Smart Payment Buttons - limit button to PayPal for FSS", () => { | ||
test("should return only 1 PayPal button if isFsSubscription=true", () => { | ||
const mockedButtonProps = { | ||
// isFsSubscription is the determinant of how many buttons get shown | ||
isFsSubscription: true, | ||
flow: "subscription_setup", | ||
fundingEligibility, | ||
}; | ||
|
||
// $FlowFixMe | ||
const jsxElems = Buttons(mockedButtonProps); | ||
|
||
const allButtonsTotalCount = jsxElems?.children.filter( | ||
// $FlowFixMe | ||
(elem) => elem?.component?.name === "Button" | ||
).length; | ||
|
||
const hasPayPalButton = | ||
jsxElems?.children.filter( | ||
// $FlowFixMe | ||
(elem) => elem?.props?.fundingSource === "paypal" | ||
).length === 1; | ||
|
||
expect(allButtonsTotalCount).toBe(1); | ||
expect(hasPayPalButton).toBe(true); | ||
}); | ||
|
||
test("should return 1 or more buttons if not isFsSubscription", () => { | ||
const mockedButtonProps = { | ||
// isFsSubscription is the determinant of how many buttons get shown | ||
isFsSubscription: false, | ||
flow: "subscription_setup", | ||
fundingEligibility, | ||
}; | ||
|
||
// $FlowFixMe | ||
const jsxElems = Buttons(mockedButtonProps); | ||
|
||
const allButtonsTotalCount = jsxElems?.children.filter( | ||
// $FlowFixMe | ||
(elem) => elem?.component?.name === "Button" | ||
).length; | ||
|
||
const hasPayPalButton = | ||
jsxElems?.children.filter( | ||
// $FlowFixMe | ||
(elem) => elem?.props?.fundingSource === "paypal" | ||
).length === 1; | ||
|
||
expect(allButtonsTotalCount).toBeGreaterThanOrEqual(1); | ||
expect(hasPayPalButton).toBe(true); | ||
}); | ||
}); |
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.
Can we utilize the
flow
param to pass this value instead of introducing another paramhttps://github.com/paypal/paypal-checkout-components/blob/8f3c86937696fa5605c961dd02b883ab94be77a4/src/zoid/buttons/component.jsx#L473C7-L473C11
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.
@ravishekhar @imbrian What new flow should I name it as?
Do we want a way to distinguish the FSS and NGS here?

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.
We need to differentiate is from existing subscriptions.
full_stack_subscription_setup
?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 can do that @imbrian
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.
@ravishekhar @imbrian I'm noticing that when we use
flow
, we have to update the config for each funding each time. I can submit this code, but wanted to check once if this is the expected behavior. Thank you.Right now since we're only enabling the PayPal button, I'm only adding this in the PayPal config:
https://github.com/paypal/paypal-checkout-components/blob/main/src/funding/paypal/config.jsx#L21-L26