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(connector): [Stripe] fix cashapp webhooks response deserialization failure #5690

Merged
merged 3 commits into from
Oct 8, 2024

Conversation

srujanchikke
Copy link
Contributor

@srujanchikke srujanchikke commented Aug 26, 2024

Type of Change

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

Description

Bug found in sandbox

extra_error : {"error":{"type":"api","message":"Something went wrong","code":"HE_00"}}
├╴at crates/router/src/services/api.rs:793:14
│
├─:arrow_forward: {"error":{"type":"server_not_available","code":"HE_00","message":"Something went wrong"}}
│   ├╴at crates/router/src/core/errors/utils.rs:316:17
│   ╰╴Incoming webhook flow for payments failed
│
├─:arrow_forward: Failed to deserialize connector response
│   ╰╴at crates/router/src/connector/stripe.rs:839:22
│
├─:arrow_forward: Failed to parse struct: PaymentIntentSyncResponse
│   ├╴at /router/crates/common_utils/src/ext_traits.rs:194:14
│   ╰╴Unable to parse router::connector::stripe::transformers::PaymentIntentSyncResponse from bytes b"{\n  \"id\": \"pi_3Pq6AWIasQF2Tofd0q05qOYT\",\n  \"object\": \"payment_intent\",\n  \"amount\": 20000,\n  \"amount_capturable\": 0,\n  \"amount_details\": {\n    \"tip\": {}\n  },\n  \"amount_received\": 0,\n  \"application\": null,\n  \"application_fee_amount\": null,\n  \"automatic_payment_methods\": null,\n  \"canceled_at\": null,\n  \"cancellation_reason\": null,\n  \"capture_method\": \"automatic\",\n  \"client_secret\": \"pi_3Pq6AWIasQF2Tofd0q05qOYT_secret_zRpwrVb0HKRjVax0lXN1qRRTc\",\n  \"confirmation_method\": \"automatic\",\n  \"created\": 1724214552,\n  \"currency\": \"usd\",\n  \"customer\": \"cus_QhVAKiUOOO3CMQ\",\n  \"description\": \"Test tran\",\n  \"invoice\": null,\n  \"last_payment_error\": {\n    \"code\": \"payment_intent_payment_attempt_failed\",\n    \"decline_code\": \"generic_decline\",\n    \"doc_url\": \"[https://stripe.com/docs/error-codes/payment-intent-payment-attempt-failed\](https://stripe.com/docs/error-codes/payment-intent-payment-attempt-failed/)",\n    \"message\": \"The payment failed.\",\n    \"type\": \"card_error\"\n  },\n  \"latest_charge\": {\n    \"id\": \"py_3Pq6AWIasQF2Tofd0hGYCDrO\",\n    \"object\": \"charge\",\n    \"amount\": 20000,\n    \"amount_captured\": 20000,\n    \"amount_refunded\": 0,\n    \"application\": null,\n    \"application_fee\": null,\n    \"application_fee_amount\": null,\n    \"balance_transaction\": null,\n    \"billing_details\": {\n      \"address\": {\n        \"city\": null,\n        \"country\": null,\n        \"line1\": null,\n        \"line2\": null,\n        \"postal_code\": null,\n        \"state\": null\n      },\n      \"email\": null,\n      \"name\": null,\n      \"phone\": null\n    },\n    \"calculated_statement_descriptor\": null,\n    \"captured\": true,\n    \"created\": 1724218156,\n    \"currency\": \"usd\",\n    \"customer\": \"cus_QhVAKiUOOO3CMQ\",\n    \"description\": \"Test tran\",\n    \"destination\": null,\n    \"dispute\": null,\n    \"disputed\": false,\n    \"failure_balance_transaction\": null,\n    \"failure_code\": \"payment_intent_payment_attempt_expired\",\n    \"failure_message\": \"The customer did not approve the payment before it expired.\",\n    \"fraud_details\": {},\n    \"invoice\": null,\n    \"livemode\": false,\n    \"metadata\": {\n      \"order_id\": \"1724214546718_1\"\n    },\n    \"on_behalf_of\": null,\n    \"order\": null,\n    \"outcome\": {\n      \"network_status\": \"declined_by_network\",\n      \"reason\": \"cashapp_customer_request_expired\",\n      \"risk_level\": \"not_assessed\",\n      \"seller_message\": \"The Cash App Pay authorization request expired.\",\n      \"type\": \"issuer_declined\"\n    },\n    \"paid\": false,\n    \"payment_intent\": \"pi_3Pq6AWIasQF2Tofd0q05qOYT\",\n    \"payment_method\": \"pm_1Pq6AWIasQF2TofdYFr05rUR\",\n    \"payment_method_details\": {\n      \"cashapp\": {\n        \"buyer_id\": \"test_buyer_id\",\n        \"cashtag\": \"$test_cashtag\"\n      },\n      \"type\": \"cashapp\"\n    },\n    \"receipt_email\": null,\n    \"receipt_number\": null,\n    \"receipt_url\": null,\n    \"refunded\": false,\n    \"review\": null,\n    \"shipping\": null,\n    \"source\": null,\n    \"source_transfer\": null,\n    \"statement_descriptor\": null,\n    \"statement_descriptor_suffix\": \"test transaction\",\n    \"status\": \"failed\",\n    \"transfer_data\": null,\n    \"transfer_group\": null\n  },\n  \"livemode\": false,\n  \"metadata\": {\n    \"order_id\": \"1724214546718_1\"\n  },\n  \"next_action\": null,\n  \"on_behalf_of\": null,\n  \"payment_method\": null,\n  \"payment_method_configuration_details\": null,\n  \"payment_method_options\": {\n    \"cashapp\": {}\n  },\n  \"payment_method_types\": [\n    \"cashapp\"\n  ],\n  \"processing\": null,\n  \"receipt_email\": null,\n  \"review\": null,\n  \"setup_future_usage\": null,\n  \"shipping\": null,\n  \"source\": null,\n  \"statement_descriptor\": null,\n  \"statement_descriptor_suffix\": \"test transaction\",\n  \"status\": \"requires_payment_method\",\n  \"transfer_data\": null,\n  \"transfer_group\": null\n}"
│
╰─:arrow_forward: data did not match any variant of untagged enum StripeChargeEnum at line 103 column 3
   ╰╴at /router/crates/common_utils/src/ext_traits.rs:194:14
message : [SERVER_WRAP - EVENT] router::services::api
request_url_path : /webhooks/merchant_1716383080/mca_roUcY9AzrJXRCYQHQHPu
*request_method : *POST
*flow :*IncomingWebhookReceive
*line : *1075
*hostname: *bach-2024-08-15-0-658b7fddd8-qfwcm
*job: *router/bach

Stripe webhooks response try to deserialize payment method details for which Cashapp has not been included . This PR adds support for CashApp webhooks.

Additional Changes

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

Motivation and Context

How did you test it?

Test Webhooks for Stripe CashApp.

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

@srujanchikke srujanchikke self-assigned this Aug 26, 2024
@srujanchikke srujanchikke requested a review from a team as a code owner August 26, 2024 05:12
Copy link

semanticdiff-com bot commented Aug 26, 2024

Review changes with SemanticDiff.

Analyzed 1 of 1 files.

Overall, the semantic diff is 21% smaller than the GitHub diff.

Filename Status
✔️ crates/router/src/connector/stripe/transformers.rs 20.74% smaller

@hyperswitch-bot hyperswitch-bot bot requested a review from a team as a code owner August 26, 2024 05:15
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Aug 26, 2024
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Sep 5, 2024
@srujanchikke srujanchikke changed the title fix(connector): [Stripe]fix cashapp webhooks response deserialization failure fix(connector): [Stripe] fix cashapp webhooks response deserialization failure Sep 8, 2024
@srujanchikke srujanchikke requested review from a team as code owners September 8, 2024 18:19
@hyperswitch-bot hyperswitch-bot bot added M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Sep 8, 2024
@hyperswitch-bot hyperswitch-bot bot removed M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Sep 8, 2024
@srujanchikke srujanchikke removed request for a team September 8, 2024 18:24
@likhinbopanna likhinbopanna added this pull request to the merge queue Oct 8, 2024
Merged via the queue into main with commit 2ccce01 Oct 8, 2024
38 of 40 checks passed
@likhinbopanna likhinbopanna deleted the stripe-webhooks-fix branch October 8, 2024 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants