Add validation for SDK token when createSubscription is being passed #2450
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.
Description
When the Unbranded CardFields is used for Subscriptions, we require an SDK token data-attribute to be passed, similar to 3DS Component. This PR adds a validation for this token when a createSubscription callback has been passed. This validation should not be invoked when a createSubscription callback is not passed.
Acceptance Criteria:
NOTE: I was intending on using Zoid's validate() method but not able to get it invoked despite of following the documentation. Leaving this here as proof that I did attempt to use this method.
There are 2 ways we can validate on Zoid.
(1) Use validate() function in zoid.create(...)
https://krakenjs.com/zoid/docs/api/create.html#validate--props---void
(2) Use validate() function in individual props
https://krakenjs.com/zoid/docs/api/prop-definitions.html#validate
I'm choosing the prop-level validation because we only want to check for createSubscription (prop-level) as opposed to running the validate method each time on all the props.
=================== End of Note ====================
Why are we making these changes? Include references to any related Jira tasks or GitHub Issues
https://paypal.atlassian.net/browse/DTPPCPSDK-2628
Reproduction Steps (if applicable)
Screenshots (if applicable)
Use-Case 1: When we pass in SdkToken and createSubscription:
Use-Case 2: When we don't pass SdkToken but pass createSubscription:
Use-Case 3: When we don't pass SdkToken and don't pass createSubscription (but pass createOrder instead) :
Dependent Changes (if applicable)
Groups who should review (if applicable)
❤️ Thank you!