-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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(connector): [Stripe] Deserialization Error while parsing Dispute Webhook Body #3256
Conversation
} | ||
|
||
#[derive(Debug, Deserialize)] | ||
pub struct WebhookEventObjectDataWithMetaData { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of having this new struct, let's make metadata->order_id as option field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done👍
3c7accb
to
f1d8eec
Compare
@@ -1861,7 +1861,11 @@ impl api::IncomingWebhook for Stripe { | |||
match details.event_data.event_object.metadata { | |||
// if order_id is present | |||
Some(meta_data) => api_models::webhooks::ObjectReferenceId::PaymentId( | |||
api_models::payments::PaymentIdType::PaymentAttemptId(meta_data.order_id), | |||
api_models::payments::PaymentIdType::PaymentAttemptId( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since our condition is based on order_id and not metadata, match statement can be rewritten as
api_models::payments::PaymentIdType::PaymentAttemptId( | |
match details | |
.event_data | |
.event_object | |
.metadata | |
.and_then(|metadata| metadata.order_id) | |
{ | |
// if order_id is present | |
Some(order_id) => api_models::webhooks::ObjectReferenceId::PaymentId( | |
api_models::payments::PaymentIdType::PaymentAttemptId(order_id), | |
), | |
// else used connector_transaction_id | |
None => api_models::webhooks::ObjectReferenceId::PaymentId( | |
api_models::payments::PaymentIdType::ConnectorTransactionId( | |
details.event_data.event_object.id, | |
), | |
), | |
} |
@@ -1875,7 +1879,11 @@ impl api::IncomingWebhook for Stripe { | |||
match details.event_data.event_object.metadata { | |||
// if order_id is present | |||
Some(meta_data) => api_models::webhooks::ObjectReferenceId::PaymentId( | |||
api_models::payments::PaymentIdType::PaymentAttemptId(meta_data.order_id), | |||
api_models::payments::PaymentIdType::PaymentAttemptId( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, Instead of checking metadata, extract order_id and match order_id for some or None
@@ -1915,7 +1923,11 @@ impl api::IncomingWebhook for Stripe { | |||
match meta_data.is_refund_id_as_reference { | |||
// if the order_id is refund_id | |||
Some(_) => api_models::webhooks::ObjectReferenceId::RefundId( | |||
api_models::webhooks::RefundIdType::RefundId(meta_data.order_id), | |||
api_models::webhooks::RefundIdType::RefundId( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, Instead of checking metadata, extract order_id and match order_id for some or None
* 'main' of github.com:juspay/hyperswitch: fix(connector): [Stripe] Deserialization Error while parsing Dispute Webhook Body (#3256) refactor(euclid_wasm): Update wasm config (#3222) fix(analytics): added response to the connector outgoing event (#3129) fix(analytics): fixed response code to 501 (#3119) fix(connector): [NMI] Populating `ErrorResponse` with required fields and Mapping `connector_response_reference_id` (#3214) feat(merchant_account): Add list multiple merchants in `MerchantAccountInterface` (#3220) feat: include version number in response headers and on application startup (#3045) chore: address Rust 1.75 clippy lints (#3231) feat: add deep health check (#3210) feat(analytics): adding outgoing webhooks kafka event (#3140) refactor: address panics due to indexing and slicing (#3233) fix(users): Fix wrong redirection url in magic link (#3217) fix(user): add integration_completed enum in metadata type (#3245) chore(version): v1.106.1 fix(connector): [iatapay] change refund amount (#3244) chore(version): v1.106.0 test(postman): update postman collection files fix(core): fix recurring mandates flow for cyber source (#3224) chore: fix channel handling for consumer workflow loop (#3223)
Type of Change
Description
meta_data
struct is not present in case of dispute resulting in error during deserialization.Additional Changes
Motivation and Context
How did you test it?
Steps to test:
Through Postman
merchant_secret
In Stripe dashboard, update the webhook url to hyperswitch's webhook endpoint with formant
Different Events:
{ "amount": 6540, "currency": "USD", "confirm": true, "capture_method": "automatic", "capture_on": "2022-09-10T10:11:12Z", "amount_to_capture": 6540, "customer_id": "StripeCustomer", "email": "guest@example.com", "name": "John Doe", "phone": "999999999", "phone_country_code": "+65", "description": "Its my first payment request", "authentication_type": "no_three_ds", "return_url": "https://duck.com", "setup_future_usage": "on_session", "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": "Harrison Street", "city": "San Fransico", "state": "California", "zip": "94122", "country": "US", "first_name": "joseph", "last_name": "Doe" }, "phone": { "number": "8056594427", "country_code": "+91" } }, "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" }, "phone": { "number": "8056594427", "country_code": "+91" } }, "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "metadata": { "udf1": "value1", "new_customer": "true", "login_date": "2019-09-10T10:11:12Z" }, "routing": { "type": "single", "data": "stripe" } }
Following are the webhook recieved through hyperswitch
{ "payment_id": "{{payment_id}}", "amount": 600, "reason": "Customer returned product", "refund_type": "instant", "metadata": { "udf1": "value1", "new_customer": "true", "login_date": "2019-09-10T10:11:12Z" } }
Following are the webhooks recieved through hyperswitch:
{ "amount": 6540, "currency": "USD", "confirm": true, "capture_method": "automatic", "capture_on": "2022-09-10T10:11:12Z", "amount_to_capture": 6540, "customer_id": "StripeCustomer", "email": "guest@example.com", "name": "John Doe", "phone": "999999999", "phone_country_code": "+65", "description": "Its my first payment request", "authentication_type": "no_three_ds", "return_url": "https://duck.com", "setup_future_usage": "on_session", "payment_method": "card", "payment_method_type": "credit", "payment_method_data": { "card": { "card_number": "4000000000000259", "card_exp_month": "10", "card_exp_year": "25", "card_holder_name": "joseph Doe", "card_cvc": "123" } }, "billing": { "address": { "line1": "1467", "line2": "Harrison Street", "line3": "Harrison Street", "city": "San Fransico", "state": "California", "zip": "94122", "country": "US", "first_name": "joseph", "last_name": "Doe" }, "phone": { "number": "8056594427", "country_code": "+91" } }, "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" }, "phone": { "number": "8056594427", "country_code": "+91" } }, "statement_descriptor_name": "joseph", "statement_descriptor_suffix": "JS", "metadata": { "udf1": "value1", "new_customer": "true", "login_date": "2019-09-10T10:11:12Z" }, "routing": { "type": "single", "data": "stripe" } }
Payment through this card will create a dispute option against that payment in Stripe Dashboard
Raise a counter or accept the dispute in dashboard to receive the webhooks.
Checklist
cargo +nightly fmt --all
cargo clippy