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

feat(payments): [Payment links] add hide card nickname field config for secure payment links #6554

Merged
merged 8 commits into from
Nov 18, 2024

Conversation

srujanchikke
Copy link
Contributor

@srujanchikke srujanchikke commented Nov 13, 2024

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

Add hide card nickname field config for secure payment links. https://docs.hyperswitch.io/explore-hyperswitch/merchant-controls/integration-guide/web/customization#id-9.-hide-card-nickname-field .

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

Secure links

1. Update `allowed_domains` in business profile - (unfold to view cURL)
curl --location 'http://localhost:8080/account/merchant_1721984694/business_profile/pro_oXHnmgfZSnfe92PvodqP' \
--header 'Content-Type: application/json' \
--header 'api-key: test_admin' \
--data '{
    "payment_link_config": {
        "allowed_domains": [
            "*"
        ],
        "enabled_saved_payment_method": true,
        "hide_card_nickname_field" : true
    }
}'

2. Create a payment link - (unfold to view cURL)
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_eBTVu8OMN1HmE2xr0I0dsfypWOVwQBlietvkxf0sgYMdyFM5nRO40M8M4MLH42Jk' \
--data '{
    "customer_id": "cus_izAOZiynP5URGEvEfmgH",
    "amount": 100,
    "currency": "USD",
    "payment_link": true,
    "connector": [
        "stripe"
    ],
    "session_expiry": 1000000,
    "return_url": "http://127.0.0.1:5500/src/pl_iframe.html",
    "payment_link_config": {
        "theme": "#14356f",
        "logo": "https://logosandtypes.com/wp-content/uploads/2020/08/zurich.svg",
        "seller_name": "Zurich Inc."
    }
}'

3. Open the secure payment link (`secure_link` in API response) in an iframe for validating the functionality. card nickname field should be disabled even when Save card details checkbox is enabled in sdk. Screenshot 2024-11-13 at 4 19 23 PM

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@srujanchikke srujanchikke added A-core Area: Core flows S-waiting-on-review Status: This PR has been implemented and needs to be reviewed Payment Links labels Nov 13, 2024
@srujanchikke srujanchikke self-assigned this Nov 13, 2024
@srujanchikke srujanchikke requested review from a team as code owners November 13, 2024 10:40
@srujanchikke srujanchikke changed the title feature(payment link): [Payment links] add hide card nickname field config in secure payment links feat(payment link): [Payment links] add hide card nickname field config in secure payment links Nov 13, 2024
@srujanchikke srujanchikke changed the title feat(payment link): [Payment links] add hide card nickname field config in secure payment links feat(payment link): [Payment links] add hide card nickname field config for secure payment links Nov 13, 2024
@srujanchikke srujanchikke changed the title feat(payment link): [Payment links] add hide card nickname field config for secure payment links feat(payments): [Payment links] add hide card nickname field config for secure payment links Nov 13, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Nov 13, 2024
@@ -7,8 +7,8 @@ use api_models::{
use common_utils::{
consts::{
DEFAULT_ALLOWED_DOMAINS, DEFAULT_BACKGROUND_COLOR, DEFAULT_DISPLAY_SDK_ONLY,
DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_LOCALE, DEFAULT_MERCHANT_LOGO,
DEFAULT_PRODUCT_IMG, DEFAULT_SDK_LAYOUT, DEFAULT_SESSION_EXPIRY,
DEFAULT_ENABLE_SAVED_PAYMENT_METHOD, DEFAULT_HIDE_CARD_NICKNAME_FIELD, DEFAULT_LOCALE,
Copy link
Member

Choose a reason for hiding this comment

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

Nit:
If some (or all) of these constants are not being used outside of the router crate, I'd prefer moving them all to the router crate itself.

@@ -56,6 +56,7 @@ function initializeSDK() {
height: 55,
},
},
hideCardNicknameField: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not use what was configured in the payment link config?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since displaySavedPaymentMethodsCheckbox is set to false for open payment links, it doesn't matter whether we hide the card nick name field or not. So i mapped it to it's default value in SDK, which is false.

kashif-m
kashif-m previously approved these changes Nov 14, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Nov 18, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 18, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Nov 18, 2024
Merged via the queue into main with commit 0e026b7 Nov 18, 2024
17 checks passed
@Gnanasundari24 Gnanasundari24 deleted the hide_card_nickname_config branch November 18, 2024 12:32
@pixincreate pixincreate removed the S-waiting-on-review Status: This PR has been implemented and needs to be reviewed label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows M-api-contract-changes Metadata: This PR involves API contract changes Payment Links
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants