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

Stripe Checkout Failure Unknown column 'payment_plan' in 'field list' #90

Open
littletuna4 opened this issue Jun 23, 2024 · 2 comments
Open

Comments

@littletuna4
Copy link

littletuna4 commented Jun 23, 2024

On a fresh install of the payments app, my Stripe checkout isn't working :(

Description:

In short the payment_plan field isn't found?

Investigation

I can't fully discern how it's supposed to work from an inspection of the codebase

It's breaking at the checkout:

context.reference_doctype, context.reference_docname, "payment_plan"

Image of the payment request fields (no payment_plan field in it (even after bench-migration)):
image
image

But it seems the stripe settings should have the field too based on this:

for payment_plan in stripe_settings.payment_plans:
plan = frappe.db.get_value("Subscription Plan", payment_plan.plan, "product_price_id")
items.append({"price": plan, "quantity": payment_plan.qty})

Once again, I don't have the field in the doctype?
Image of the stripe settings fields (no payment_plan field here either):
342050125-729acb25-ee89-4d40-bcb1-2f9695b8f9c1

Logs

Nothing shows up in the backend logs
Haven't been able to find anything in the db either.

Thanks for any help!

Environment:

Custom Docker Build version 15 (Apps have been super fiddly to get going, so I've made lots of changes to get things sorta working - could have easily corrupted/broken something)

Error Message:

Traceback shown in client below:

Traceback (most recent call last):
  File "apps/frappe/frappe/website/serve.py", line 18, in get_response
    response = renderer_instance.render()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/website/page_renderers/template_page.py", line 84, in render
    html = self.get_html()
           ^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/website/utils.py", line 517, in cache_html_decorator
    html = func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/website/page_renderers/template_page.py", line 95, in get_html
    self.update_context()
  File "apps/frappe/frappe/website/page_renderers/template_page.py", line 162, in update_context
    data = self.run_pymodule_method("get_context")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/website/page_renderers/template_page.py", line 224, in run_pymodule_method
    return method(self.context)
           ^^^^^^^^^^^^^^^^^^^^
  File "apps/payments/payments/templates/pages/stripe_checkout.py", line 43, in get_context
    payment_plan = frappe.db.get_value(
                   ^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/database.py", line 509, in get_value
    result = self.get_values(
             ^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/database.py", line 606, in get_values
    out = self._get_values_from_table(
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/database.py", line 835, in _get_values_from_table
    return query.run(as_dict=as_dict, debug=debug, update=update, run=run, pluck=pluck)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/query_builder/utils.py", line 87, in execute_query
    result = frappe.db.sql(query, params, *args, **kwargs)  # nosemgrep
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "apps/frappe/frappe/database/database.py", line 220, in sql
    self._cursor.execute(query, values)
  File "env/lib/python3.11/site-packages/pymysql/cursors.py", line 158, in execute
    result = self._query(query)
             ^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/cursors.py", line 325, in _query
    conn.query(q)
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 549, in query
    self._affected_rows = self._read_query_result(unbuffered=unbuffered)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 779, in _read_query_result
    result.read()
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 1157, in read
    first_packet = self.connection._read_packet()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "env/lib/python3.11/site-packages/pymysql/connections.py", line 729, in _read_packet
    packet.raise_for_error()
  File "env/lib/python3.11/site-packages/pymysql/protocol.py", line 221, in raise_for_error
    err.raise_mysql_exception(self._data)
  File "env/lib/python3.11/site-packages/pymysql/err.py", line 143, in raise_mysql_exception
    raise errorclass(errno, errval)
pymysql.err.OperationalError: (1054, "Unknown column 'payment_plan' in 'field list'")
@littletuna4
Copy link
Author

I've upgraded from version-14 to version-15 and error persists.
So not looking like a versioning issue.

@demitchell14
Copy link

Running into the same issue, version-15.

I originally planned on trying to use Braintree for payments, however, subscriptions don't seem to be set up at all for it from what I read in the code, but Stripe looked like it was set up.. went to go play with it and ran into this issue as well.

I did a little digging myself earlier and it looks to me like the payment_plan directory was removed from ERPNext at some point, but was never added into the frappe/payments repo.

https://github.com/frappe/erpnext/tree/ba6f6d976d88b8bfd5ebc02e8dc33cb108b34fd5/erpnext/erpnext_integrations/doctype/payment_plan

Looking at the payment_plan.json and comparing it what subscription_plan.json originally was when it was released, to me it looks like these should be the same and this was simply missed.

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

No branches or pull requests

2 participants