Skip to content

Conversation

@AnkitKmrGupta
Copy link
Collaborator

@AnkitKmrGupta AnkitKmrGupta commented Nov 4, 2025

This pull request standardizes the naming conventions for struct fields and variables in the gateway decider flow code, moving from camelCase to snake_case across multiple functions and files. This improves code readability and consistency, and reduces the risk of errors due to inconsistent naming.

The most important changes are:

Field and Variable Naming Standardization:

Logging and Debug Statements:

Comments and Documentation:

  • Updated comments and example code to use snake_case field names, maintaining consistency in documentation and code samples. [1] [2]

Functionality Preservation:

  • Ensured that all logic, including utility function calls and business logic, now references the updated field names, preventing runtime errors due to mismatched field names. [1] [2] [3] [4] [5]

These changes collectively make the codebase more idiomatic to Rust and easier to maintain.

curl --location 'http://localhost:8082/decision_gateway' \
--header 'Content-Type: application/json' \
--header 'x-request-id: 87364723649864' \
--data-raw '{
  "orderMetadata": {
    "device": null,
    "id": 25137330826,
    "ipAddress": "130.176.24.166",
    "partitionKey": "2025-03-29T07:25:54",
    "operatingSystem": "Darwin",
    "dateCreated": "2025-03-29T07:25:54Z",
    "mobile": false,
    "orderReferenceId": 25173953244,
    "referer": null,
    "metadata": "{\"order_expiry\":\"2025-04-01T07:25:54Z\",\"payment_page_client_id\":\"urbanclapone\",\"payment_links\":{\"mobile\":\"https://payments.juspay.in/payment-page/order/ordeh_45b2e8033d8244a69b09c97dc8d8a39e\",\"web\":\"https://payments.juspay.in/payment-page/order/ordeh_45b2e8033d8244a69b09c97dc8d8a39e\",\"iframe\":\"https://payments.juspay.in/payment-page/order/ordeh_45b2e8033d8244a69b09c97dc8d8a39e\"}}",
    "userAgent": "azharamin/6.41.10 CFNetwork/1220.1 Darwin/20.3.0",
    "browserVersion": "6.41.10",
    "lastUpdated": "2025-03-29T07:25:54Z",
    "browser": "azharamin"
  },
  "enforceGatewayList": null,
  "txnCardInfo": {
    "cardType": "UPI",
    "txnId": "azharamin-559e1b9bfd8f413bbe728-1",
    "authType": null,
    "cardFingerprint": null,
    "id": 24501647023,
    "partitionKey": "2025-03-29T07:25:54",
    "dateCreated": "2025-03-29T07:25:57Z",
    "cardIsin": null,
    "cardLastFourDigits": null,
    "cardIssuerBankName": "UPI",
    "paymentMethodType": "UPI",
    "cardReferenceId": null,
    "paymentSource": "tez://upi/pay",
    "cardGlobalFingerprint": null,
    "cardExpMonth": null,
    "cardSwitchProvider": null,
    "paymentMethod": "UPI",
    "txnDetailId": 24501647023,
    "cardExpYear": null,
    "nameOnCard": null
  },
  "merchantAccount": {
    "autoRefundMultipleChargedTransactions": false,
    "cardEncodingKey": "3574B8FE48941F2B6B14075D723AA1",
    "gatewaySuccessRateBasedOutageInput": "",
    "country": null,
    "resellerId": null,
    "autoRefundConflictTransactions": false,
    "enableSendingCardIsin": true,
    "merchantCategoryCode": null,
   "gatewaySuccessRateBasedDeciderInput": "{\"gatewayWiseInputs\":null,\"defaultEliminationThreshold\":0.75,\"defaultEliminationLevel\":\"PAYMENT_METHOD\",\"defaultSelectionLevel\":null,\"enabledPaymentMethodTypes\":[\"CARD\",\"UPI\"],\"eliminationV2SuccessRateInputs\":null,\"globalGatewayWiseInputs\":null,\"defaultGlobalEliminationThreshold\":0.8,\"defaultGlobalEliminationMaxCountThreshold\":3,\"defaultGlobalEliminationLevel\":\"PAYMENT_METHOD\",\"defaultGlobalSelectionMaxCountThreshold\":5,\"selectionTransactionCountThreshold\":100,\"defaultGlobalSoftTxnResetCount\":10,\"defaultGatewayLevelEliminationThreshold\":0.6,\"defaultEliminationV2SuccessRate\":0.9}",
    "mandateConfig": null,
    "enableSaveCardBeforeAuth": null,
    "executeMandateAutoRetryEnabled": null,
    "apiPathPrefix": null,
    "id": 3332,
    "enableTransactionFilter": null,
    "installmentEnabled": null,
    "cardConfig": null,
    "shouldAddSurcharge": false,
    "offerEnabled": true,
    "merchantName": "Urban Company",
    "mobile": null,
    "enableSuccessRateBasedGatewayElimination": true,
    "enableGatewayReferenceIdBasedRouting": true,
    "zip": null,
    "internalHashKey": "0399968ea13a4daa9cfeab0db40957ef",
    "gatewayPriority": "PAYTM,PAYU,IPG",
    "ipHops": null,
    "gatewayPriorityLogic": "def priorities = ['\''PAYTM_V2'\'','\''RAZORPAY'\'','\''IPG'\'','\''PAYTM'\'','\''PAYU'\'']\ndef systemtimemills = System.currentTimeMillis() % 100\ndef enforceFlag = false\n\nif ((txn.sourceObject)=='\''UPI_QR'\''  && (payment.paymentMethodType)=='\''UPI'\'') {\n  priorities = ['\''PAYTM_V2'\'','\''RAZORPAY'\'','\''PAYU'\'']\n} else if ((txn.isEmi)==true) {\n  priorities = ['\''PAYU'\'']\n  enforceFlag = true\n} else if (['\''AMEX'\'','\''DINERS'\''].contains(payment.cardBrand)) {\n  priorities = ['\''PAYTM_V2'\'','\''RAZORPAY'\'']\n} else if ((payment.cardType)=='\''CREDIT'\'') {\n  priorities = ['\''IPG'\'','\''PAYTM_V2'\'','\''RAZORPAY'\'','\''PAYU'\'']\n} else if ((payment.cardType)=='\''DEBIT'\'') {\n  priorities = ['\''PAYTM_V2'\'','\''IPG'\'','\''RAZORPAY'\'','\''PAYU'\'']\n} else if ((payment.paymentMethodType)=='\''UPI'\'') {\n if (systemtimemills < 70) {\n  priorities = ['\''PAYTM_V2'\'','\''RAZORPAY'\'','\''PAYU'\'']\n } else if (systemtimemills < 90) {\n  priorities = ['\''RAZORPAY'\'','\''PAYU'\'','\''PAYTM_V2'\'']\n } else if (systemtimemills < 100) {\n  priorities = ['\''PAYU'\'','\''PAYTM_V2'\'','\''RAZORPAY'\'']\n }\n} else if ((payment.paymentMethodType)=='\''NB'\'') {\n  priorities = ['\''PAYTM_V2'\'','\''PAYTM'\'','\''RAZORPAY'\'']\n}\n\nif (enforceFlag == true) {\n  enforceGatewayPriority(priorities)\n} else {\n  setGatewayPriority(priorities) \n}",
    "externalMetadata": "{}",
    "tokenLockerId": "m0197",
    "autoRefundConflictThresholdInMins": null,
    "webHookURL": null,
    "userId": 5451,
    "returnUrl": "",
    "enabledInstantRefund": false,
    "useCodeForGatewayPriority": true,
    "realModeOnly": false,
    "basiliskKeyId": "516af52b-ae1a-40cf-9e42-16436e9ede74",
    "lockerId": "m0197",
    "officeLine2": null,
    "encryptionKeyIds": "JSPY02",
    "priorityLogicConfig": null,
    "fingerprintOnTokenize": null,
    "merchantId": "azharamin",
    "website": null,
    "tenantAccountId": "jt_29bd8266cbdc4e76938cfaa2d80db4d6",
    "mustUseGivenOrderIdForTxn": null,
    "mandateRetryConfig": null,
    "secondaryMerchantAccountId": null,
    "contactPersonEmail": null,
    "city": null,
    "gatewayDecidedByHealthEnabled": true,
    "apiVersion": null,
    "contactPersonPrimary": null,
    "officeLine1": null,
    "autoRevokeMandate": null,
    "webHookAPIVersion": null,
    "internalMetadata": "{\"is_pii_encrypted\":true,\"integration_type\":[\"PP\"],\"track\":\"F2\",\"active_priority_logic_name\":\"Aug23 - Repricing - v2\",\"industry\":\"Hyperlocal\"}"
  },
  "txnOfferDetails": [],
  "priorityLogicOutput": null,
  "priorityLogicScript": null,
  "txnType": "UPI_PAY",
  "cardToken": null,
  "isEdccApplied": false,
  "shouldCreateMandate": false,
  "orderReference": {
    "lastSynced": null,
    "refundedEntirely": false,
    "parentOrderId": null,
    "udfs": [
      null,
      null,
      "hyperPayMIDSupported",
      "noonMIDSupported",
      null,
      null,
      null,
      null,
      null,
      "ios|6.41"
    ],
    "billingAddressId": null,
    "preferredGateway": null,
    "amountRefunded": 0,
    "status": "NEW",
    "id": 25173953244,
    "partitionKey": "2025-03-29T07:25:54",
    "dateCreated": "2025-03-29T07:25:54Z",
    "version": 1,
    "customerId": "6052cc984c76383daa7e59c7",
    "metadata": "{\"get_payment_link_qr\":false}",
    "orderId": "559e1b9bfd8f413bbe728",
    "shippingAddressId": null,
    "returnUrl": "https://www.urbancompany.com/api/v1/paymentGateway/payu_surl",
    "currency": "INR",
    "lastModified": "2025-03-29T07:25:54Z",
    "customerEmail": "[email protected]",
    "customerPhone": "8145260463",
    "mandateFeature": "DISABLED",
    "description": "",
    "productId": null,
    "merchantId": "azharamin",
    "amount": 9050000,
    "amountInfo": null,
    "orderUuid": "ordeh_45b2e8033d8244a69b09c97dc8d8a39e",
    "orderType": "ORDER_PAYMENT",
    "internalMetadata": "{\"create_order_api_tag\":\"\\\"ORDER_CREATE_OR_UPDATE\\\"\",\"pii_hash\":{\"customer_phone_hash\":\"36ebf59f2f995fe347c8436909f567e88a998e21f7ab82b4ed9ba6e6e3fbeae5\",\"customer_email_hash\":\"a6c496e6a41d4909cc4edc16e81e7a5e2fdf70c2340bb5275658edce09f7649a\"},\"gateway_ref_ids\":{}}"
  },
  "txnDetail": {
    "offerDeductionAmount": null,
    "errorMessage": null,
    "emiTenure": 0,
    "gateway": null,
    "username": "TRANSACTION",
    "addToLocker": false,
    "txnId": "urbanclap-559e1b9bfd8f413bbe728-1",
    "gatewayPayload": null,
    "txnObjectType": "ORDER_PAYMENT",
    "taxAmount": null,
    "status": "STARTED",
    "id": 24589731757,
    "partitionKey": "2025-03-29T07:25:54",
    "dateCreated": "2025-03-29T07:25:57Z",
    "successResponseId": null,
    "emiBank": null,
    "version": 0,
    "netAmount": 9050000,
    "metadata": null,
    "txnFlowType": "INTENT",
    "orderId": "559e1b9bfd8f413bbe728",
    "currency": "INR",
    "lastModified": "2025-03-29T07:25:57Z",
    "bankErrorCode": null,
    "isEmi": false,
    "sourceObjectId": null,
    "txnType": "AUTH_AND_SETTLE",
    "surchargeAmount": null,
    "compactPgResponse": null,
    "merchantId": "azharamin",
    "bankErrorMessage": null,
    "responseCode": null,
    "redirect": true,
    "sourceObject": "UPI_PAY",
    "txnAmountBreakup": [
      {
        "sno": 1,
        "method": "ADD",
        "name": "BASE",
        "amount": 905
      }
    ],
    "responseMessage": null,
    "paymentMethodSubDetail": null,
    "txnUuid": "moz4GPRiqxZq1mdHTqg",
    "merchantGatewayAccountId": null,
    "expressCheckout": false,
    "txnMode": "PROD",
    "txnAmount": 9050000,
    "txnFlowSubType": null,
    "internalTrackingInfo": "{\"tokenizationInfo\":{\"eligibleServices\":[],\"serviceInEligibleReasons\":[[\"JP_HDFC\",\"NON_CARD_TRANSACTION\"]]},\"tokenizationConsentFailureReason\":\"NON_CARD_TRANSACTION\",\"sdkDetails\":{\"integrationType\":\"HEADLESS\",\"clientId\":\"urbanclap\",\"paymentChannel\":\"IOS\",\"dotpVersion\":\"4.5.14\"},\"paymentFlowInfo\":{\"paymentFlowsNumericIds\":[31],\"paymentFlows\":[\"INTENT\"]},\"issuerTokenizationConsentFailureReason\":\"NON_CARD_TRANSACTION\"}",
    "txnLinkUuid": null,
    "internalMetadata": "{\"paymentOption\":\"\",\"juspayBankCode\":\"JP_GOOGLEPAY\",\"useTxnDetail\":true,\"paymentChannel\":\"IOS\",\"gatewayError\":{},\"useSafeAmountFunction\":\"true\"}"
  }
}'
{
    "decided_gateway": {
        "decided_gateway": "EASEBUZZ",
        "gateway_priority_map": {
            "EASEBUZZ": 1.0
        },
        "filter_wise_gateways": null,
        "priority_logic_tag": "Aug23 - Repricing - v2",
        "routing_approach": "DEFAULT",
        "gateway_before_evaluation": "EASEBUZZ",
        "priority_logic_output": {
            "isEnforcement": false,
            "gws": [],
            "priorityLogicTag": "Aug23 - Repricing - v2",
            "gatewayReferenceIds": {},
            "primaryLogic": {
                "name": "Aug23 - Repricing - v2",
                "status": "FAILURE",
                "failure_reason": "CONNECTION_FAILED"
            },
            "fallbackLogic": null
        },
        "debit_routing_output": null,
        "reset_approach": "NO_RESET",
        "routing_dimension": "ORDER_PAYMENT, UPI, UPI_PAY",
        "routing_dimension_level": "PM_LEVEL",
        "is_scheduled_outage": false,
        "is_dynamic_mga_enabled": true,
        "gateway_mga_id_map": {
            "EASEBUZZ": 150
        },
        "is_rust_based_decider": false
    },
    "filter_list": [
        [
            "filterFunctionalGatewaysForCurrency",
            [
                "AXISNB",
                "CYBERSOURCE",
                "EASEBUZZ",
                "GOCASHFREE",
                "PAYTM",
                "PINELABS"
            ]
        ],
        [
            "filterFunctionalGatewaysForReversePennyDrop",
            [
                "AXISNB",
                "CYBERSOURCE",
                "EASEBUZZ",
                "GOCASHFREE",
                "PAYTM",
                "PINELABS"
            ]
        ],
        [
            "filterFunctionalGateways",
            [
                "AXISNB",
                "CYBERSOURCE",
                "EASEBUZZ",
                "GOCASHFREE",
                "PAYTM",
                "PINELABS"
            ]
        ],
        [
            "filterFunctionalGatewaysForBrand",
            [
                "AXISNB",
                "CYBERSOURCE",
                "EASEBUZZ",
                "GOCASHFREE",
                "PAYTM",
                "PINELABS"
            ]
        ],
        [
            "filterFunctionalGatewaysForAuthType",
            [
                "AXISNB",
                "CYBERSOURCE",
                "EASEBUZZ",
                "GOCASHFREE",
                "PAYTM",
                "PINELABS"
            ]
        ],
        [
            "filterFunctionalGatewaysForValidationType",
            [
                "AXISNB",
                "CYBERSOURCE",
                "EASEBUZZ",
                "GOCASHFREE",
                "PAYTM",
                "PINELABS"
            ]
        ],
        [
            "filterFunctionalGatewaysForEmi",
            [
                "AXISNB",
                "CYBERSOURCE",
                "EASEBUZZ",
                "GOCASHFREE",
                "PAYTM",
                "PINELABS"
            ]
        ],
        [
            "filterFunctionalGatewaysForTxnOfferDetails",
            [
                "AXISNB",
                "CYBERSOURCE",
                "EASEBUZZ",
                "GOCASHFREE",
                "PAYTM",
                "PINELABS"
            ]
        ],
        [
            "filterFunctionalGatewaysForPaymentMethod",
            [
                "CYBERSOURCE",
                "EASEBUZZ"
            ]
        ],
        [
            "filterFunctionalGatewaysForWallet",
            [
                "CYBERSOURCE",
                "EASEBUZZ"
            ]
        ],
        [
            "filterFunctionalGatewaysForNbOnly",
            [
                "CYBERSOURCE",
                "EASEBUZZ"
            ]
        ],
        [
            "filterFunctionalGatewaysForConsumerFinance",
            [
                "CYBERSOURCE",
                "EASEBUZZ"
            ]
        ],
        [
            "filterFunctionalGatewaysForUpi",
            [
                "EASEBUZZ"
            ]
        ],
        [
            "filterFunctionalGatewaysForTxnType",
            [
                "EASEBUZZ"
            ]
        ],
        [
            "filterFunctionalGatewaysForTxnDetailType",
            [
                "EASEBUZZ"
            ]
        ],
        [
            "filterFunctionalGatewaysForReward",
            [
                "EASEBUZZ"
            ]
        ],
        [
            "filterFunctionalGatewaysForCash",
            [
                "EASEBUZZ"
            ]
        ],
        [
            "filterFunctionalGatewaysForSplitSettlement",
            [
                "EASEBUZZ"
            ]
        ],
        [
            "filterFunctionalGatewaysForMerchantRequiredFlow",
            [
                "EASEBUZZ"
            ]
        ],
        [
            "filterGatewaysForEMITenureSpecficGatewayCreds",
            [
                "EASEBUZZ"
            ]
        ],
        [
            "filterGatewaysForMGASelectionIntegrity",
            [
                "EASEBUZZ"
            ]
        ],
        [
            "filterFunctionalGatewaysForOTM",
            [
                "EASEBUZZ"
            ]
        ]
    ],
    "latency": 177
}

Copilot AI review requested due to automatic review settings November 4, 2025 10:03
@AnkitKmrGupta AnkitKmrGupta self-assigned this Nov 4, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors field names across multiple data structures from camelCase to snake_case to follow Rust naming conventions. The changes include:

  • Converting struct field names in core domain types (Order, TxnDetail, TxnCardInfo, TxnOfferDetail, DomainDeciderRequest)
  • Adding #[serde(rename_all = "camelCase")] attributes to maintain JSON serialization compatibility
  • Updating all references throughout the codebase to use the new snake_case field names

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/types/txn_offer_detail.rs Renamed 8 fields in TxnOfferDetail struct to snake_case
src/types/txn_details/types.rs Converted TxnDetail struct fields and removed individual serde rename attributes in favor of struct-level camelCase conversion
src/types/order.rs Updated Order struct with snake_case fields and added serde rename_all attribute
src/types/card/txn_card_info.rs Renamed TxnCardInfo fields and updated conversion function
src/routes/decision_gateway.rs Updated field references in decision gateway route handler
src/feedback/utils.rs Updated field references in transaction detail creation utilities
src/feedback/gateway_selection_scoring_v3/flow.rs Updated field references in SR v3 scoring logic
src/feedback/gateway_scoring_service.rs Updated field references throughout gateway scoring service
src/feedback/gateway_elimination_scoring/flow.rs Updated field references in elimination scoring flow
src/decider/storage/utils/txn_card_info.rs Updated field references in storage utility
src/decider/storage/utils/merchant_gateway_card_info.rs Updated field references in payment method filtering
src/decider/gatewaydecider/validators.rs Updated field references in API type parsing functions
src/decider/gatewaydecider/utils.rs Updated extensive field references throughout gateway decider utilities
src/decider/gatewaydecider/types.rs Renamed DomainDeciderRequest fields and updated construction logic
src/decider/gatewaydecider/runner.rs Updated field references in decider runner logic
src/decider/gatewaydecider/gw_scoring.rs Updated field references throughout gateway scoring logic
src/decider/gatewaydecider/gw_filter.rs Updated field references in gateway filtering logic
src/decider/gatewaydecider/flows.rs Updated field references in decider flow orchestration
src/decider/gatewaydecider/flow_new.rs Updated field references in new flow implementation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants