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

refactor(webhooks): check event type not supported before checking for profile_id #3543

Conversation

Narayanbhat166
Copy link
Member

@Narayanbhat166 Narayanbhat166 commented Feb 5, 2024

Type of Change

  • Bugfix

Description

This PR fixes the 4xx that we have been encountering in webhooks.
More information can be found in this issue https://github.com/juspay/hyperswitch-cloud/issues/2691

Motivation and Context

There are certain webhook events that are not supposed to be processed by hyperswitch. But the current implementation has this check to skip the webhook event type later once we decode the profile_id to find the merchant connector account.

Few modifications have been made in this PR to overcome this problem.

How did you test it?

  • Create a payment and check if webhooks are received and then 200 response is sent
    Curl for creating the payment.
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'api-key:' \
--data-raw '{
    "amount": 6969,
    "currency": "USD",
    "confirm": true,
    "name": "John Dough",
    "capture_method": "automatic",
    "phone": "999999999",
    "phone_country_code": "+65",
    "customer_id": "cus_PAxm0MeCGM5TowgDKPc9",
    "email": "[email protected]",
    "setup_future_usage": "off_session",
    "description": "Its my fourth payment request",
    "authentication_type": "no_three_ds",
     "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrisoff Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "Narayan",
            "last_name": "Doe"
        }
    },
    "mandate_data": {
        "customer_acceptance": {
            "acceptance_type": "offline",
            "accepted_at": "1963-05-03T04:07:52.723Z",
            "online": {
                "ip_address": "127.0.0.1",
                "user_agent": "amet irure esse"
            }
        },
        "mandate_type": {
            "multi_use": {
                "amount": 7000,
                "currency": "USD"
            }
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        }
    },
    "statement_descriptor_name": "hola",
    "statement_descriptor_suffix": "JS",
    "metadata": {
        "key1":"hello"
    }
}'

image

The data can be found on stripe dashboard whether all webhooks are responded properly ( This is a reference image only and does not represent actual test data )
image

Impact area

Webhooks - All webhook events

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 A-webhooks Area: Webhook flows label Feb 5, 2024
@Narayanbhat166 Narayanbhat166 self-assigned this Feb 5, 2024
@Narayanbhat166 Narayanbhat166 requested review from a team as code owners February 5, 2024 09:06
srujanchikke
srujanchikke previously approved these changes Feb 7, 2024
@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Feb 15, 2024
Merged via the queue into main with commit 2d4f6b3 Feb 15, 2024
31 of 33 checks passed
@Gnanasundari24 Gnanasundari24 deleted the 2691-bug--skip-deserializing-webhook-body-for-eventnotsupported-events branch February 15, 2024 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-webhooks Area: Webhook flows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants