dj-stripe / dj-stripe

dj-stripe automatically syncs your Stripe Data to your local database as pre-implemented Django Models allowing you to use the Django ORM, in your code, to work with the data making it easier and faster.

Home Page:https://dj-stripe.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for EU Bank Transfer payment method

PabloCastellano opened this issue · comments

Is your request related to a problem? Please describe.

I have recently had a bank transfer payment through Stripe that made the webhook fail with a payment_intent.succeeded event.

After some investigation it looks like we need to add eu_bank_transfer to the PaymentMethodType enum. (It was customer_balance instead)

This new value is 16 characters long while the field in the database is a StripeEnumField with max_length=15 so a migration is needed too. This actually masked a bit the root of the issue behind a DataError: value too long for type character varying(15)

Describe the solution you'd like

Accept european bank transfers through Stripe smoothly.

Additional context

Apparently I'm using a preview feature 🤔

image

It is not clear to me when they introduced this payment method.

This is the webhook event that crashed:

{
  "object": {
    "id": "pi_xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "object": "payment_intent",
    "amount": 123400,
    "amount_capturable": 0,
    "amount_details": {
      "tip": {
      }
    },
    "amount_received": 123400,
    "application": null,
    "application_fee_amount": null,
    "automatic_payment_methods": null,
    "canceled_at": null,
    "cancellation_reason": null,
    "capture_method": "automatic",
    "charges": {
      "object": "list",
      "data": [
        {
          "id": "py_xxxxxxxxxxxxxxxxxxxxxxx",
          "object": "charge",
          "amount": 123400,
          "amount_captured": 123400,
          "amount_refunded": 0,
          "application": null,
          "application_fee": null,
          "application_fee_amount": null,
          "balance_transaction": "txn_3xxxxxxxxxxxxxx",
          "billing_details": {
            "address": {
              "city": null,
              "country": null,
              "line1": null,
              "line2": null,
              "postal_code": null,
              "state": null
            },
            "email": null,
            "name": null,
            "phone": null
          },
          "calculated_statement_descriptor": null,
          "captured": true,
          "created": 14141177,
          "currency": "eur",
          "customer": "cus_Oxxxxxxxxxxxxxxxxx",
          "description": "Payment for Invoice",
          "destination": null,
          "dispute": null,
          "disputed": false,
          "failure_balance_transaction": null,
          "failure_code": null,
          "failure_message": null,
          "fraud_details": {
          },
          "invoice": "in_1xxxxxxxxxxxxxxxxxxxxxxx",
          "livemode": true,
          "metadata": {
          },
          "on_behalf_of": null,
          "order": null,
          "outcome": {
            "network_status": "approved_by_network",
            "reason": null,
            "risk_level": "not_assessed",
            "seller_message": "Payment complete.",
            "type": "authorized"
          },
          "paid": true,
          "payment_intent": "pi_3xxxxxxxxxxxxxxxxxxh",
          "payment_method": "pm_1xxxxxxxxxxxxxxxxxxxx",
          "payment_method_details": {
            "customer_balance": {
            },
            "type": "customer_balance"
          },
          "receipt_email": "vendor@pnlfin.tech",
          "receipt_number": "2496-1908",
          "receipt_url": "https://pay.stripe.com/receipts/invoices/xxxxxxxxxxxxx",
          "refunded": false,
          "refunds": {
            "object": "list",
            "data": [
            ],
            "has_more": false,
            "total_count": 0,
            "url": "/v1/charges/py_xxxxxxxxxxxxxxxxxx/refunds"
          },
          "review": null,
          "shipping": null,
          "source": null,
          "source_transfer": null,
          "statement_descriptor": null,
          "statement_descriptor_suffix": null,
          "status": "succeeded",
          "transfer_data": null,
          "transfer_group": null
        }
      ],
      "has_more": false,
      "total_count": 1,
      "url": "/v1/charges?payment_intent=pi_xxxxxxxxxxxxxxxxxxxxx"
    },
    "client_secret": "pi_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
    "confirmation_method": "automatic",
    "created": 15213131595,
    "currency": "eur",
    "customer": "cus_Oxxxxxxxxxxxxxxxxxxxxxx",
    "description": "Payment for Invoice",
    "invoice": "in_1xxxxxxxxxxxxxxxxxxxxxxxxxxxA",
    "last_payment_error": null,
    "latest_charge": "py_3Nxxxxxxxxxxxxxxxxxxxxxxxmdc",
    "livemode": true,
    "metadata": {
    },
    "next_action": null,
    "on_behalf_of": null,
    "payment_method": "pm_1Nxxxxxxxxxxxxxxxxxxxdxx0",
    "payment_method_options": {
      "customer_balance": {
        "bank_transfer": {
          "eu_bank_transfer": {
            "country": "NL"
          },
          "type": "eu_bank_transfer"
        },
        "funding_type": "bank_transfer"
      }
    },
    "payment_method_types": [
      "customer_balance"
    ],
    "processing": null,
    "receipt_email": "some@one.email",
    "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
  }
}

Upgrading to 2.8.1 has solved this issue. I was running an old version of dj-stripe