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

fix(routing): do not update perform_session_flow_routing output if the SessionRoutingChoice is none #5336

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

ShankarSinghC
Copy link
Contributor

@ShankarSinghC ShankarSinghC commented Jul 16, 2024

Type of Change

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

Description

While performing the session token routing we create an empty vec that will contain the Routing choices for that particular session. In case if there is no connectors that requires session call then the perform_session_flow_routing will return the empty vec. Instead if there is no connectors that requires session call, then we should just return empty hashmap.

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 mca for stripe with apple pay, google pay and klarna

{
    "connector_type": "fiz_operations",
    "connector_name": "stripe",
    "connector_account_details": {
        "auth_type": "HeaderKey",
        "api_key": ""
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "payment_experience": null,
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": -1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "payment_experience": null,
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": -1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "wallet",
            "payment_method_types": [
                {
                    "payment_method_type": "apple_pay",
                    "payment_experience": "invoke_sdk_client",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "google_pay",
                    "payment_experience": "invoke_sdk_client",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "payment_method_type": "klarna",
                    "payment_experience": "redirect_to_url",
                    "card_networks": null,
                    "accepted_currencies": null,
                    "accepted_countries": null,
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "metadata": {
        "apple_pay_combined": {
            "manual": {
                "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"
                },
                "payment_request_data": {
                    "label": "applepay",
                    "supported_networks": [
                        "visa",
                        "masterCard",
                        "amex",
                        "discover"
                    ],
                    "merchant_capabilities": [
                        "supports3DS"
                    ]
                }
            }
        },
        "google_pay": {
            "merchant_info": {
                "merchant_name": "Stripe"
            },
            "allowed_payment_methods": [
                {
                    "type": "CARD",
                    "parameters": {
                        "allowed_auth_methods": [
                            "PAN_ONLY",
                            "CRYPTOGRAM_3DS"
                        ],
                        "allowed_card_networks": [
                            "AMEX",
                            "DISCOVER",
                            "INTERAC",
                            "JCB",
                            "MASTERCARD",
                            "VISA"
                        ]
                    },
                    "tokenization_specification": {
                        "type": "PAYMENT_GATEWAY",
                        "parameters": {
                            "gateway": "stripe",
                            "stripe:version": "2018-10-31",
                            "stripe:publishableKey": "pk_test_51Msk2GAGHc77EJXX78h549SX2uaOnEkUYqBfjcoD05PIpAnDkYxMn8nQ4d19im85NQuX4Z6WDyHaUw2fFTPBWsIY00Wa7oNerO"
                        }
                    }
                }
            ]
        }
    }
}
image

-> Also enable klarna via klarna
-> Now configure volume based routing for the connector
-> Create a payment and make a session call

curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_1l8FEkupRHGMJp9gZyj9HDUwgsSgAVgiKjtvdiDfocYs5Gjo2cn3UTpjNTBzYRHH' \
--data '{
  "amount": 10000,
  "currency": "USD",
  "capture_method": "automatic",
  "authentication_type": "no_three_ds",
  "confirm": false,
  "customer_id": "cu_1720854397"
}'
curl --location 'http://localhost:8080/payments/session_tokens' \
--header 'Content-Type: application/json' \
--header 'x-browser-name: Safari' \
--header 'x-client-platform: web' \
--header 'x-merchant-domain: sdk-test-app.netlify.app' \
--header 'api-key: pk_dev_2a79cad91c884bc7bb425a9822d09d0b' \
--data '{
    "payment_id": "pay_wp2gnnTNuK1oxMF2T6Yf",
    "wallets": [],
    "client_secret": "pay_wp2gnnTNuK1oxMF2T6Yf_secret_T10Mxvzq3hqBWfxOfIJI"
}'
image

-> Now disable klarna for stripe, create a payment and make a session call.
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 added C-bug Category: Bug A-routing Area: Routing labels Jul 16, 2024
@ShankarSinghC ShankarSinghC self-assigned this Jul 16, 2024
@ShankarSinghC ShankarSinghC requested a review from a team as a code owner July 16, 2024 09:34
@ShankarSinghC ShankarSinghC changed the title fix(routing): check if SessionRoutingChoice is empty during the session call fix(routing): do not update perform_session_flow_routing output if the SessionRoutingChoice is none Jul 16, 2024
@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 16, 2024
Merged via the queue into main with commit f07689e Jul 16, 2024
25 of 29 checks passed
@likhinbopanna likhinbopanna deleted the fix/session_token_routing branch July 16, 2024 11:29
pixincreate added a commit that referenced this pull request Jul 16, 2024
* 'main' of github.com:juspay/hyperswitch: (25 commits)
  fix(logs): ignore request headers while logging (#5273)
  feat(webhooks): add support for custom outgoing webhook http headers (#5275)
  fix(payment_methods): set `requires_cvv` to false when either `connector_mandate_details` or `network_transaction_id` is present during MITs (#5331)
  chore: create justfile for running commands for v1 and v2 migrations (#5325)
  fix(routing): do not update `perform_session_flow_routing` output if the `SessionRoutingChoice` is none (#5336)
  fix(database): modified_at updated for every state change for Payment Attempts (#5312)
  feat(mca): Added recipient connector call for open banking connectors (#3758)
  chore(version): 2024.07.16.0
  refactor(connector): [Mifinity] add a field language_preference in payment request for mifinity payment method data (#5326)
  fix(router): store `customer_acceptance` in payment_attempt, use it in confirm flow for delayed authorizations like external 3ds flow (#5308)
  feat(proxy): add support to pass proxy bypass urls from configs (#5322)
  Docs: Updating Error codes in API-ref (#5296)
  feat(core): [Payouts] Add retrieve flow for payouts (#4936)
  fix(connector): [AUTHORIZEDOTNET] Populate error reason for failure transactions (#5319)
  chore(version): 2024.07.15.0
  feat(logging): Emit a setup error when a restricted keys are used for logging default keys (#5185)
  feat(payment_methods): add support to migrate existing customer PMs from processor to hyperswitch (#5306)
  feat(connector): [DATATRANS] Implement card payments (#5028)
  chore: making of function create_encrypted_data (#5251)
  fix(payments): populate merchant order ref id in list (#5310)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-routing Area: Routing C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

do not update perform_session_flow_routing output if the SessionRoutingChoice is none
4 participants