Skip to content

Conversation

@apoorvdixit88
Copy link
Contributor

Type of Change

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

Description

This PR introduces Platform-aware support for resolving a customer during the payments create flow. The logic now correctly determines whether to fetch an existing customer or create a new one, while ensuring the appropriate Provider or Processor context is propagated throughout the flow. The PR does the following

  • Adds a populate_raw_customer_details preprocessing step so payments always encrypt and store processor-sourced customer info before any lookups happen.
  • Replace the old (key_store, storage_scheme) get customer related plumbing with a single Provider handle, letting every payment flow pull the right context.
  • Introduce get_customer_if_exists and branch customer handling by merchant type: standard merchants still create/update customers, while platform/connected merchants only fetch existing processor-managed records.
  • Wire the new flow through all payment operations (create, confirm, start, session, status, update, etc.) so platform requests stop trying to create customers they don’t own.

Additional Changes

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

Motivation and Context

Closes https://github.com/juspay/hyperswitch-cloud/issues/13315

How did you test it?

Existing behaviour remained intact, no flows failing for standard merchants with these changes.

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

@apoorvdixit88 apoorvdixit88 self-assigned this Dec 16, 2025
@apoorvdixit88 apoorvdixit88 requested a review from a team as a code owner December 16, 2025 12:04
@apoorvdixit88 apoorvdixit88 added A-core Area: Core flows C-feature Category: Feature request or enhancement A-payments Area: payments T-Core For Work done by the core team platform labels Dec 16, 2025
@semanticdiff-com
Copy link

semanticdiff-com bot commented Dec 16, 2025

@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

❌ Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@c844cbf). Learn more about missing BASE report.

Files with missing lines Patch % Lines
crates/router/src/core/payments/operations.rs 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #10684   +/-   ##
=======================================
  Coverage        ?    6.42%           
=======================================
  Files           ?     1262           
  Lines           ?   315689           
  Branches        ?        0           
=======================================
  Hits            ?    20290           
  Misses          ?   295399           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.