medusa icon indicating copy to clipboard operation
medusa copied to clipboard

Stripe Plugin tries to capture already captured payment, when capture is set to automatic resulting in 400

Open luluhoc opened this issue 4 months ago • 1 comments

"medusa-payment-stripe": "^6.0.7", medusa 1.20.2

Stripe Plugin tries to capture already captured payment, when capture is set to automatic resulting in 400 in stripe...

my stripe config

{
    resolve: `medusa-payment-stripe`,
    options: {
      api_key: process.env.STRIPE_API_KEY,
      webhook_secret: process.env.STRIPE_WEBHOOK_SECRET,
      automatic_payment_methods: true,
      capture: true,
    },
  },
{
  "error": {
    "code": "payment_intent_unexpected_state",
    "doc_url": "https://stripe.com/docs/error-codes/payment-intent-unexpected-state",
    "message": "This PaymentIntent could not be captured because it has already been captured.",
    "payment_intent": {
      "id": ["xxx"](https://dashboard.stripe.com/payments/xxx),
      "object": "payment_intent",
      "amount": 5100,
      "amount_capturable": 0,
      "amount_details": {
        "tip": {
        }
      },
      "amount_received": 5100,
      "application": null,
      "application_fee_amount": null,
      "automatic_payment_methods": {
        "allow_redirects": "always",
        "enabled": true
      },
      "canceled_at": null,
      "cancellation_reason": null,
      "capture_method": "automatic",
      "client_secret": "pi_xxx",
      "confirmation_method": "automatic",
      "created": xxxx,
      "currency": "pln",
      "customer": ["cus_xxx"](https://dashboard.stripe.com/customers/cus_xxx),
      "description": null,
      "invoice": null,
      "last_payment_error": null,
      "latest_charge": "ch_xxx",
      "livemode": true,
      "metadata": {
        "resource_id": "cart_xxx"
      },
      "next_action": null,
      "on_behalf_of": null,
      "payment_method": "pm_xxx",
      "payment_method_configuration_details": {
        "id": "pmc_xxx",
        "parent": null
      },
      "payment_method_options": {
        "blik": {
        },
        "card": {
          "installments": null,
          "mandate_options": null,
          "network": null,
          "request_three_d_secure": "automatic"
        },
        "klarna": {
          "preferred_locale": null
        },
        "link": {
          "persistent_token": null
        },
        "p24": {
        },
        "paypal": {
          "preferred_locale": null,
          "reference": null
        }
      },
      "payment_method_types": [
        "card",
        "p24",
        "blik",
        "link",
        "klarna",
        "paypal"
      ],
      "processing": null,
      "receipt_email": "xxx@",
      "review": null,
      "setup_future_usage": null,
      "shipping": null,
      "source": null,
      "statement_descriptor": null,
      "statement_descriptor_suffix": null,
      "status": "succeeded",
      "transfer_data": null,
      "transfer_group": null
    },
    "request_log_url": "https://dashboard.stripe.com/logs/req_mxi5GLp9in5ziG?t=1707579879",
    "type": "invalid_request_error"
  }
}

luluhoc avatar Feb 10 '24 16:02 luluhoc

Just to add I'm using medusa-cluster when in dev env the payment doesn't get captured twice possible that it is because of cluster mode

luluhoc avatar Mar 08 '24 22:03 luluhoc