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(router): skip apple pay session call if the browser is not Safari #5136

Merged
merged 7 commits into from
Jun 27, 2024

Conversation

ShankarSinghC
Copy link
Contributor

@ShankarSinghC ShankarSinghC commented Jun 26, 2024

Type of Change

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

Description

Currently, the Apple Pay session call is mandatory in all cases. This requirement also mandates configuring the initiative_context, which is the domain name where the Apple Pay payment is being processed. However, in the case of an iOS app, a domain is not required, so this field can be made optional. Additionally, in this case, the session call to Apple Pay can be skipped.

On the web, Apple Pay is supported only in Safari. Therefore, the session call should be skipped in web environments when the browser is not Safari.

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?

-> Create merchant connector account with apple pay manual flow. Below is the metadata for the manual flow.

"session_token_data": {
                    "initiative": "web",
                    "certificate": "==",
                    "display_name": "applepay",
                    "certificate_keys": "",
                    "payment_processing_details_at": "Hyperswitch",
                    "payment_processing_certificate": "",
                    "payment_processing_certificate_key": "",
                    "initiative_context": "sdk-test-app.netlify.app",
                    "merchant_identifier": "",
                    "merchant_business_country": "US"
                }

-> Currently we make session call only if x_client_platform and browsername header None or if it is web and Safari respectively.

-> When mca is configured with write domain and header is not passed

curl --location 'http://localhost:8080/payments/session_tokens' \
--header 'Content-Type: application/json' \
--header 'api-key: pk_dev_7e0d9f48e20b430baa86eb956dc99142' \
--data '{
    "payment_id": "pay_7WAejcRN248R0Y7Kwsfh",
    "wallets": [],
    "client_secret": "pay_7WAejcRN248R0Y7Kwsfh_secret_CDL03LbGwQQnMPVA0Lq0"
}'
image

-> When mca is configured with write domain and header is passed as

curl --location 'http://localhost:8080/payments/session_tokens' \
--header 'Content-Type: application/json' \
--header 'browsername: Safari' \
--header 'x_client_platform: web' \
--header 'api-key: pk_dev_7e0d9f48e20b430baa86eb956dc99142' \
--data '{
    "payment_id": "pay_7WAejcRN248R0Y7Kwsfh",
    "wallets": [],
    "client_secret": "pay_7WAejcRN248R0Y7Kwsfh_secret_CDL03LbGwQQnMPVA0Lq0"
}'
image

-> mac with write domain and wrong value in header

curl --location 'http://localhost:8080/payments/session_tokens' \
--header 'Content-Type: application/json' \
--header 'browsername: aa' \
--header 'x-client-platform: bb' \
--header 'api-key: pk_dev_7e0d9f48e20b430baa86eb956dc99142' \
--data '{
    "payment_id": "pay_oisWpJs0i1gXIpdYMqFp",
    "wallets": [],
    "client_secret": "pay_oisWpJs0i1gXIpdYMqFp_secret_fkzm5bW5WR5wssQxEo3f"
}'
image

-> If only one header is passed

curl --location 'http://localhost:8080/payments/session_tokens' \
--header 'Content-Type: application/json' \
--header 'x-client-platform: ios' \
--header 'api-key: pk_dev_7e0d9f48e20b430baa86eb956dc99142' \
--data '{
    "payment_id": "pay_oisWpJs0i1gXIpdYMqFp",
    "wallets": [],
    "client_secret": "pay_oisWpJs0i1gXIpdYMqFp_secret_fkzm5bW5WR5wssQxEo3f"
}'
image

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

@ShankarSinghC ShankarSinghC requested review from a team as code owners June 26, 2024 14:53
@ShankarSinghC ShankarSinghC self-assigned this Jun 26, 2024
crates/common_enums/src/enums.rs Show resolved Hide resolved
let apple_pay_session_request =
get_session_request_for_manual_apple_pay(session_token_data.clone());
let apple_pay_session_request = match header_payload.browser_name {
Some(common_enums::BrowserName::Safari) | None => Some(
Copy link
Contributor

Choose a reason for hiding this comment

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

You tried to skip this match condition right? Didn't it work?

crates/router/src/routes/payments.rs Show resolved Hide resolved
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Jun 26, 2024
@ShankarSinghC ShankarSinghC force-pushed the apple_pay/skip-apple-pay-session-call branch from 875cf9d to e46d548 Compare June 26, 2024 17:02
@ShankarSinghC ShankarSinghC linked an issue Jun 26, 2024 that may be closed by this pull request
@@ -77,6 +77,7 @@ pub mod headers {
pub const X_CLIENT_SOURCE: &str = "X-Client-Source";
pub const X_PAYMENT_CONFIRM_SOURCE: &str = "X-Payment-Confirm-Source";
pub const CONTENT_LENGTH: &str = "Content-Length";
pub const BROWSER_NAME: &str = "browsername";
Copy link
Member

Choose a reason for hiding this comment

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

can you ensure that this key is case insensitive?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I have verified it.

@ShankarSinghC ShankarSinghC force-pushed the apple_pay/skip-apple-pay-session-call branch from 38a294e to 0836bd9 Compare June 27, 2024 07:35
@ShankarSinghC ShankarSinghC force-pushed the apple_pay/skip-apple-pay-session-call branch from 0836bd9 to 6d7f4c8 Compare June 27, 2024 08:24
@ShankarSinghC ShankarSinghC changed the title feat(router): skip apple pay session call if the browser is not apple pay feat(router): skip apple pay session call if the browser is not Safari Jun 27, 2024
Narayanbhat166
Narayanbhat166 previously approved these changes Jun 27, 2024
jagan-jaya
jagan-jaya previously approved these changes Jun 27, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Jun 27, 2024
Merged via the queue into main with commit d4dba55 Jun 27, 2024
11 checks passed
@likhinbopanna likhinbopanna deleted the apple_pay/skip-apple-pay-session-call branch June 27, 2024 12:53
pixincreate added a commit that referenced this pull request Jun 28, 2024
…ay/hyperswitch into iatapay-through-hyperswitch-cypress

* 'iatapay-through-hyperswitch-cypress' of github.com:juspay/hyperswitch:
  feat(router): skip apple pay session call if the browser is not Safari (#5136)
  fix(opensearch): show search results only if user has access permission to the index  (#5097)
  chore(version): 2024.06.27.0
  feat(users): add endpoint for terminate auth select (#5135)
  feat(users): implemented openidconnect (#5124)
  feat(router): add payments manual-update api (#5045)
  fix(docs): open-api fix for payment response (#5103)
  refactor(connector): [AdyenPlatform]Throw 4xx instead of 5xx for source_balance_account (#4990)
  feat: realtime user analytics (#5098)
  refactor(connector): added amount conversion framework for cashtocode (#4857)
  feat(email): Add `auth_id` in email types and send `auth_id` in email URLs (#5120)
  refactor(connector): add amount framework to payme & Trustpay with googlePay, ApplePay for bluesnap, Noon & Trustpay (#4833)
  fix(connector): [BOA/CYBS] make risk information message optional (#5107)
  chore(version): 2024.06.25.1
  fix(router): skip serialize if none for assurance_details_required in googlepay session response (#5118)
  refactor: separate DB queries and HTML creation for payout links (#4967)
  feat(router): updated `last_used_at` field for apple pay and google pay for CITs (#5087)
  fix(payment_methods): use existing field value of `nick_name` in db if not sent during request (#5105)
  chore(version): 2024.06.25.0
pixincreate added a commit that referenced this pull request Jun 28, 2024
…ay/hyperswitch into refactor-error-handling-in-cypress

* 'iatapay-through-hyperswitch-cypress' of github.com:juspay/hyperswitch:
  chore: clean up
  feat(router): skip apple pay session call if the browser is not Safari (#5136)
  fix(opensearch): show search results only if user has access permission to the index  (#5097)
  chore(version): 2024.06.27.0
  feat(users): add endpoint for terminate auth select (#5135)
  feat(users): implemented openidconnect (#5124)
  feat(router): add payments manual-update api (#5045)
  fix(docs): open-api fix for payment response (#5103)
  refactor(connector): [AdyenPlatform]Throw 4xx instead of 5xx for source_balance_account (#4990)
  feat: realtime user analytics (#5098)
  refactor(connector): added amount conversion framework for cashtocode (#4857)
  feat(email): Add `auth_id` in email types and send `auth_id` in email URLs (#5120)
  refactor(connector): add amount framework to payme & Trustpay with googlePay, ApplePay for bluesnap, Noon & Trustpay (#4833)
  fix(connector): [BOA/CYBS] make risk information message optional (#5107)
  chore(version): 2024.06.25.1
  fix(router): skip serialize if none for assurance_details_required in googlepay session response (#5118)
  refactor: separate DB queries and HTML creation for payout links (#4967)
  feat(router): updated `last_used_at` field for apple pay and google pay for CITs (#5087)
  fix(payment_methods): use existing field value of `nick_name` in db if not sent during request (#5105)
  chore(version): 2024.06.25.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Skip session to call pay when the browser is not Safari
4 participants