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(payments_create): save the customer_id in payments create #5262

Merged
merged 6 commits into from
Jul 10, 2024

Conversation

Narayanbhat166
Copy link
Member

@Narayanbhat166 Narayanbhat166 commented Jul 9, 2024

Type of Change

  • Bugfix

Description

In case we receive a 4xx when creating the payment before calling the connector, we do not save the customer_id in payment intent. This PR fixes it

This PR also includes changes to ensure that customer_id is always taken from both the places in the PaymentsRequest. The root customer_id and customer.id field.

Motivation and Context

How did you test it?

  • Create a merchant account
curl --location 'http://localhost:8080/accounts' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "merchant_id": "merchant_1720593206"
}'
  • Create an api key
curl --location 'http://localhost:8080/api_keys/merchant_1720593134' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
  "name": "API Key 1",
  "description": null,
  "expiration": "2038-01-19T03:14:08.000Z"
}'
  • Create a payment
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_RMV9h1z6QVqWHW9B7LBRl6peSokwQ7go96pfAjehuGZDGiwlenKAbgtyqUlXny9J' \
--data '{
    "amount": 0,
    "payment_id": "pay_1720593248",
    "customer_id": "cus_123",
    "currency": "USD",
    "confirm": true,
    "payment_type": "setup_mandate",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "card_number": "4111111111111111",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        }
    }
}'

Fails with the error message

{
    "error": {
        "type": "invalid_request",
        "message": "No eligible connector was found for the current payment method configuration",
        "code": "HE_04"
    }
}
  • Check in the database whether customer_id is updated
image

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code

@Narayanbhat166 Narayanbhat166 added the C-bug Category: Bug label Jul 9, 2024
@Narayanbhat166 Narayanbhat166 added this to the July 2024 Release milestone Jul 9, 2024
@Narayanbhat166 Narayanbhat166 self-assigned this Jul 9, 2024
@Narayanbhat166 Narayanbhat166 requested review from a team as code owners July 9, 2024 17:16
@Narayanbhat166 Narayanbhat166 linked an issue Jul 9, 2024 that may be closed by this pull request
2 tasks
crates/api_models/src/payments.rs Outdated Show resolved Hide resolved
crates/api_models/src/payments.rs Outdated Show resolved Hide resolved
crates/api_models/src/payments.rs Outdated Show resolved Hide resolved
hrithikesh026
hrithikesh026 previously approved these changes Jul 10, 2024
crates/router/src/core/payments/helpers.rs Show resolved Hide resolved
@likhinbopanna likhinbopanna added this pull request to the merge queue Jul 10, 2024
Merged via the queue into main with commit 53cb953 Jul 10, 2024
12 of 13 checks passed
@likhinbopanna likhinbopanna deleted the 5259-bug-retrieve-payment-id-throwing-4xx branch July 10, 2024 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Retrieve Payment Id Throwing 4xx
5 participants