async-stripe icon indicating copy to clipboard operation
async-stripe copied to clipboard

error on parse webhook event

Open i18nsite opened this issue 1 year ago • 0 comments

Describe the bug

image

thread 'main' panicked at src/main.rs:133:47: called Result::unwrap() on an Err value: Error("missing field refunds", line: 120, column: 3) note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

To Reproduce

use stripe::Event;
fn main() {
    let json = r#"
  {
"id": "evt_3OZrKABS6OLyeF2Q0Jd6Unwp",
  "object": "event",
  "api_version": "2023-10-16",
  "created": 1705567906,
  "data": {
    "object": {
      "id": "ch_3OZrKABS6OLyeF2Q0p5rkApJ",
      "object": "charge",
      "amount": 921,
      "amount_captured": 921,
      "amount_refunded": 0,
      "amount_updates": [
      ],
      "application": null,
      "application_fee": null,
      "application_fee_amount": null,
      "balance_transaction": "txn_3OZrKABS6OLyeF2Q0aYg7A1N",
      "billing_details": {
        "address": {
          "city": null,
          "country": "HK",
          "line1": null,
          "line2": null,
          "postal_code": null,
          "state": null
        },
        "email": null,
        "name": null,
        "phone": null
      },
      "calculated_statement_descriptor": "I18N.SITE",
      "captured": true,
      "created": 1705567906,
      "currency": "eur",
      "customer": "cus_POLP7kduwzrOZO",
      "description": null,
      "destination": null,
      "dispute": null,
      "disputed": false,
      "failure_balance_transaction": null,
      "failure_code": null,
      "failure_message": null,
      "fraud_details": {
      },
      "invoice": null,
      "livemode": false,
      "metadata": {
      },
      "on_behalf_of": null,
      "order": null,
      "outcome": {
        "network_status": "approved_by_network",
        "reason": null,
        "risk_level": "normal",
        "risk_score": 46,
        "seller_message": "Payment complete.",
        "type": "authorized"
      },
      "paid": true,
      "payment_intent": "pi_3OZrKABS6OLyeF2Q0R7Sy2br",
      "payment_method": "pm_1OZYiKBS6OLyeF2QypFO5uz4",
      "payment_method_details": {
        "card": {
          "amount_authorized": 921,
          "brand": "visa",
          "checks": {
            "address_line1_check": null,
            "address_postal_code_check": null,
            "cvc_check": null
          },
          "country": "US",
          "exp_month": 2,
          "exp_year": 2026,
          "extended_authorization": {
            "status": "disabled"
          },
          "fingerprint": "8ucVymgWvAPOS3CE",
          "funding": "credit",
          "incremental_authorization": {
            "status": "unavailable"
          },
          "installments": null,
          "last4": "4242",
          "mandate": null,
          "multicapture": {
            "status": "unavailable"
          },
          "network": "visa",
          "network_token": {
            "used": false
          },
          "overcapture": {
            "maximum_amount_capturable": 921,
            "status": "unavailable"
          },
          "three_d_secure": null,
          "wallet": null
        },
        "type": "card"
      },
      "radar_options": {
      },
      "receipt_email": null,
      "receipt_number": null,
      "receipt_url": "https://pay.stripe.com/receipts/payment/CAcaFwoVYWNjdF8xT09kZVpCUzZPTHllRjJRKKLNo60GMgYwDXSEzjM6LBZtxL67he86-l2kL_oWbNJg3F_WDxJvrbx831Cl2dspC6D38NyT_I6IEW89",
      "refunded": false,
      "review": null,
      "shipping": null,
      "source": null,
      "source_transfer": null,
      "statement_descriptor": null,
      "statement_descriptor_suffix": null,
      "status": "succeeded",
      "transfer_data": null,
      "transfer_group": null
    }
  },
  "livemode": false,
  "pending_webhooks": 2,
  "request": {
    "id": "req_vGZL0NgxwRyn2t",
    "idempotency_key": "137e565f-ee38-4e3a-bf49-bf3d460cfb7c"
  },
  "type": "charge.succeeded"
}
      "#;
    let t: Event = serde_json::from_str(json).unwrap();
    dbg!(t);
}

Expected behavior

parse

Code snippets

No response

OS

mac

Rust version

cargo 1.77.0-nightly (3e428a38a 2024-01-09)

Library version

v0.29.0

API version

latest

Additional context

No response

i18nsite avatar Jan 18 '24 08:01 i18nsite