checkout / frames-android

Frames Android: making native card payments simple
https://www.checkout.com/docs/integrate/sdks/android-sdk
MIT License
47 stars 32 forks source link

PIMOB: 2117 - adding capabilities for phone number and country field optional and hidden #225

Closed chintan-soni-cko closed 10 months ago

chintan-soni-cko commented 10 months ago

Issue

PIMOB-2117

Proposed changes

Scenarios in data models

  1. If the phone number is optional and not filled then the phone object should not pass in tokenisation
  2. If the country is optional and not selected, then the country field in tokenisation should not pass
  3. if the phone number is mandatory and the country field is optional, then if the country is not selected and the phone number is entered then the phone number object only number should pass.

Test Steps

  1. Add country as an optional field in the custom sample app, then verify without selecting country user is able to save the billing form and accordingly reflected in the payment details form
  2. Add phone as an optional field in the custom sample app, then verify without entering phone user is able to save the billing form and accordingly reflected in the payment details form
  3. Add country and phone both optional then without entering and selecting country user should be able to save the billing form and accordingly reflected in the payment details form In above all scenarios, user should be able to create a token

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.

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...

chintan-soni-cko commented 10 months ago

Well done 🔥 🔥 🔥 🔥 🔥

Coverage and Duplications on New Code 80.6% 80.6% Coverage on New Code

What's the expected behaviour for the request when a country or number field is set to optional? Should the country or number fields be included in the request and set to null? Verified with Custom UI screen, country is set to optional and it's included in the request with null value; Same for the phone field

Verified locally, phone or country field can be set optional and still generate the token.

@jheng-hao-lin-cko Thanks for verifying it. If any of the fields for country and phone is empty, it will not generate the token and throw the validation error from the server. In the SDK, it will mapped in the final request and respective fields will be not sent along with the token request. below are logs for requests.

  1. When a phone number is optional {"type":"card","number":"4242424242424242","expiry_month":"12","expiry_year":"33","name":"Test Name","cvv":"233","billing_address":{"address_line1":"Checkout.com","address_line2":"90 Tottenham Court Road","city":"London","state":"London","zip":"W1T 4TJ","country":"GB"}}
  2. When country is optional {"type":"card","number":"4242424242424242","expiry_month":"12","expiry_year":"33","name":"Test Name","cvv":"123","billing_address":{"address_line1":"","address_line2":"","city":"city","state":"","zip":"postcode"},"phone":{"number":"232332323232323"}}