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): [V2] Return connector customer reference IDs in CustomerResponse #7319

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

AnuthaDev
Copy link
Contributor

@AnuthaDev AnuthaDev commented Feb 19, 2025

Type of Change

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

Description

Add a field connector_customer to CustomerResponse that contains a map between MerchantConnectorAccountId and connector customer id

Additional Changes

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

Motivation and Context

From #7246:

with respect to the multi-use tokens that were created with Stripe (support added in #7106), the payment methods were created on Stripe's end, but were not associated with a customer, due to which they could not be used to make transactions again, we used to receive such an error:

The provided PaymentMethod cannot be attached. To reuse a PaymentMethod, you must attach it to a Customer first.

To address this, we have to create a customer on Stripe's end first, and then pass Stripe's customer ID when saving the payment method with Stripe.

How did you test it?

  • Request:
curl --location 'http://localhost:8080/v2/customers/12345_cus_01951dbc16d57d03ac193a7e297d4899' \
--header 'x-profile-id: pro_Vb32qOaqvkJClXH7aNWK' \
--header 'Authorization: api-key=dev_f4mNrhkUeCtLcsqUaG1fpzHpqTCnPdJMBSPNZAP2nWwwr7FRYtbj1RUdWBPKBKZ0' \
--header 'api-key: dev_f4mNrhkUeCtLcsqUaG1fpzHpqTCnPdJMBSPNZAP2nWwwr7FRYtbj1RUdWBPKBKZ0'
  • Response:
{
    "id": "12345_cus_01951dbc16d57d03ac193a7e297d4899",
    "merchant_reference_id": "customer_1739960621",
    "connector_customer": {
        "mca_hwySG2NtpzX0qr7toOy8": "cus_Rnm2pDKGyQi506"
    },
    "name": "John Doe",
    "email": "guest@example.com",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "First customer",
    "default_billing_address": null,
    "default_shipping_address": null,
    "created_at": "2025-02-19T10:23:40.758Z",
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "default_payment_method_id": null
}

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

@AnuthaDev AnuthaDev added A-core Area: Core flows api-v2 labels Feb 19, 2025
@AnuthaDev AnuthaDev added this to the February 2025 Release milestone Feb 19, 2025
@AnuthaDev AnuthaDev self-assigned this Feb 19, 2025
@AnuthaDev AnuthaDev requested a review from a team as a code owner February 19, 2025 12:31
Copy link

semanticdiff-com bot commented Feb 19, 2025

Review changes with  SemanticDiff

Changed Files
File Status
  api-reference-v2/openapi_spec.json  0% smaller
  crates/api_models/src/customers.rs  0% smaller
  crates/common_types/src/customers.rs  0% smaller
  crates/common_types/src/lib.rs  0% smaller
  crates/diesel_models/src/customers.rs  0% smaller
  crates/hyperswitch_domain_models/src/customer.rs  0% smaller
  crates/router/src/types/api/customers.rs  0% smaller

@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Feb 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows api-v2 M-api-contract-changes Metadata: This PR involves API contract changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[V2]: Return connector specific customer reference ID in CustomerResponse
1 participant