Skip to content
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

Add validation for SDK token when createSubscription is being passed #2450

Merged
merged 15 commits into from
Nov 5, 2024

Conversation

9zees
Copy link
Contributor

@9zees 9zees commented Oct 29, 2024

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:

  1. A validation error is thrown when attempting to use Card Fields subscriptions without the SDK token.
  2. A validation error is not thrown when attempting to use Card Fields without subscriptions when an SDK token is not provided.

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

image

(2) Use validate() function in individual props
https://krakenjs.com/zoid/docs/api/prop-definitions.html#validate

image

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:
image

Use-Case 2: When we don't pass SdkToken but pass createSubscription:
image

Use-Case 3: When we don't pass SdkToken and don't pass createSubscription (but pass createOrder instead) :
image

Dependent Changes (if applicable)

Groups who should review (if applicable)

❤️ Thank you!

@9zees 9zees marked this pull request as ready for review October 31, 2024 16:49
@9zees 9zees requested a review from a team as a code owner October 31, 2024 16:49
@imbrian imbrian merged commit f0483a1 into paypal:main Nov 5, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants