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

PIMOB: Java sample app updated for CVV tokenization #246

Conversation

chintan-soni-cko
Copy link
Contributor

@chintan-soni-cko chintan-soni-cko commented Oct 12, 2023

Issue

PIMOB-2176

Proposed changes

  1. Updated java sample app
  2. Added a new button for cvv tokenisation to redirect to the new screen
  3. Added a new overloaded method name as provideCvvComponentContent for the merchant who is not using compose in Java or kotlin language

Note: This is a traditional sample app and added minimal UI design just for demonstrating how it will work without compose UI

Tes

java.webm
  1. open java sample app
  2. click on cvv tokenisation
  3. verify amex cvv component and pay button working along with cvv validation working as expected
  4. Try to add more customise option for cvv input field
  5. Create token with success and failure scenario to test the behaviour

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • Reviewers assigned
  • I have performed a self-review of my code and manual testing
  • Lint and unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if applicable)

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you choose the solution you did and what alternatives you considered, etc...

Comment on lines 92 to 103
private void createCVVComponentMediator(CVVComponentApi cvvComponentApi) {
// Create config for CVV component
CVVComponentConfig visaCVVComponentConfig = new CVVComponentConfig(
CardScheme.Companion.fromString("unknown"),
isEnteredCVVValid -> Unit.INSTANCE,
DefaultCVVInputFieldStyle.INSTANCE.create()
);

// Create CVVComponentMediator for CVV component
CVVComponentMediator defaultCVVComponentMediator = cvvComponentApi.createComponentMediator(visaCVVComponentConfig);
View defaultCVVComponentView = defaultCVVComponentMediator.provideCvvComponentContent(cvvComponentLinearLayout);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add final for all the immutable variables, same for all the other code

Suggested change
private void createCVVComponentMediator(CVVComponentApi cvvComponentApi) {
// Create config for CVV component
CVVComponentConfig visaCVVComponentConfig = new CVVComponentConfig(
CardScheme.Companion.fromString("unknown"),
isEnteredCVVValid -> Unit.INSTANCE,
DefaultCVVInputFieldStyle.INSTANCE.create()
);
// Create CVVComponentMediator for CVV component
CVVComponentMediator defaultCVVComponentMediator = cvvComponentApi.createComponentMediator(visaCVVComponentConfig);
View defaultCVVComponentView = defaultCVVComponentMediator.provideCvvComponentContent(cvvComponentLinearLayout);
private void createCVVComponentMediator(CVVComponentApi cvvComponentApi) {
// Create config for CVV component
final CVVComponentConfig visaCVVComponentConfig = new CVVComponentConfig(
CardScheme.Companion.fromString("unknown"),
isEnteredCVVValid -> Unit.INSTANCE,
DefaultCVVInputFieldStyle.INSTANCE.create()
);
// Create CVVComponentMediator for CVV component
final CVVComponentMediator defaultCVVComponentMediator = cvvComponentApi.createComponentMediator(visaCVVComponentConfig);
final View defaultCVVComponentView = defaultCVVComponentMediator.provideCvvComponentContent(cvvComponentLinearLayout);

Comment on lines 60 to 66
override fun provideCvvComponentContent(
container: View,
): View = ComposeView(container.context).apply {
// Dispose of the Composition when the view's LifecycleOwner is destroyed
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent { InternalCVVComponent() }
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be this?

Suggested change
override fun provideCvvComponentContent(
container: View,
): View = ComposeView(container.context).apply {
// Dispose of the Composition when the view's LifecycleOwner is destroyed
setViewCompositionStrategy(ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)
setContent { InternalCVVComponent() }
}
override fun provideCvvComponentContent(
container: View,
): View = provideCvvComponentContent(view, ViewCompositionStrategy.DisposeOnViewTreeLifecycleDestroyed)

@chintan-soni-cko chintan-soni-cko force-pushed the feature/PIMOB-2176_update_cvv_tokenisation_java_sample_app branch from b3a37d5 to 0c87c11 Compare October 13, 2023 11:33
@chintan-soni-cko chintan-soni-cko merged commit a984e91 into master Oct 13, 2023
7 of 8 checks passed
@chintan-soni-cko chintan-soni-cko deleted the feature/PIMOB-2176_update_cvv_tokenisation_java_sample_app branch October 13, 2023 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants