How to config Stripe Payment in Palm?

I’m testing this in tutor v16.0.0.

Does Stripe payment work in Palm?
I tried to follow the config in this docs
I got this error:

stripe.error.InvalidRequestError: Request req_... : Received unknown parameter: secret_key_confirmation

I think secret_key_confirmation is used in this file.

stripe_response = stripe.PaymentIntent.create(
    **self._build_payment_intent_parameters(basket),
    # This means this payment intent can only be confirmed with secret key (as in, from ecommerce)
    secret_key_confirmation='required',
    # don't create a new intent for the same basket
    idempotency_key=self.generate_basket_pi_idempotency_key(basket),
)

According to the docs:

The E-Commerce Service uses Stripe Custom Actions to send payments through a backend before payment. Ask your Stripe representative to enable this feature on your account. For more information, see frontend-app-payment ADR-5.

I think I need to enable Stripe Custom Actions to make it work, do I actually have to ask a Stripe representative to do it for me or can I do it myself (and how)?

@Anh_Vu_Nguy_n I’m in the same boat. I also tried Palm release installation everything is working smoothly except the Stripe payment gateway.

I’m also having exact same issue

unknown parameter: secret_key_confirmation

Apparently, I didn’t find any resource from Stripe Custom Action. Did you able to enable the same from Stripe?

I would appreciate any assistance you can provide.

Thanks!

@amit you have to ask Stipe support to enable Stripe Custom Action for your Stripe account.
Also, you have to config frontend env correctly because the project does not support runtime configuration, all Stripe_* variables must be configured.
Though, I could get it to work in the end, some other errors happened after so I decided to use Cybersource and wait for the new ecommerce project.

1 Like

Hello. What is the current state of payment feature in Open edX? If anyone managed to make it working I would appreciate updated instructions

I did manage to make it work.
3 things need to be done.

  1. Email Stripe support to enable Stripe Custom Action for your account.
  2. Config.yml
  3. Make a plugins as following and run tutor images build mfe:
from tutor import hooks
hooks.Filters.ENV_PATCHES.add_items(
[(
        "mfe-dockerfile-pre-npm-build-payment",
"""
ENV STRIPE_PUBLISHABLE_KEY={stripe_publish_key}
ENV STRIPE_RESPONSE_URL= {your_ecommerce_host}/payment/stripe/checkout/
"""
)])

Config.yml

ECOMMERCE_ENABLED_PAYMENT_PROCESSORS:
- stripe
ECOMMERCE_PAYMENT_PROCESSORS:
  stripe:
    api_version: 2020-08-27;server_side_confirmation_beta=v1
    enable_telemetry: ''
    log_level: ''
    max_network_retries: 3
    proxy: ''
    publishable_key: {stripe_public_key}
    secret_key: {stripe_secret_key}.
    webhook_endpoint_secret: ''

stripe_publish_key usually starts with pk_ and stripe_secret_key usually starts with sk_ and you get it from your Stripe developer dashboard.
your_ecommerce_host is something likes https://ecommerce.lms.example.com.

1 Like

It looks like some E-commerce plugin already comes with latest open edx: tutor plugins search
shows ecommerce installed

Hopefully it is operational, otherwise I would need to learn how to make plugins

These conclusions are taken from when I tested Stripe sometime in the past. I don’t know if anything changed to make it easier, but it is still working on Redwood release.
You need to install tutor-ecommerce plugin but it isn’t enough for Stripe.
This is because the frontend-app-payment does not take the publishable_key from the backend, ideally, it should take the key from MFE_CONFIG but it doesn’t that’s why I made an extra plugin to set the public key at the build time.
About how to make a plugin you can refer to this doc.

2 Likes

Thanks for the hints and links, plugin is clear now.
How to assure correct configuration of my {your_ecommerce_host}?
-for my site url in a form https://ecommerce.mylms.example.com shows page with login button and “Server Error”. Looks like something with the user, when I’m trying to create (or re-use an existing LMS user)
tutor local run ecommerce ./manage.py createsuperuser
getting error:
django.db.utils.OperationalError: (1045, "Access denied for user ‘ecommerce’@'1…

I found that others have similar issue too - Tutor E-Commerce: Server error - #2 by Ievgenii_Vasiuk

Hey man,

I have tried this and I am running into this issue in the logs at checkout:

Make sure you follow instructions in tutor-ecommerce git repo (choose the git tag that matched your instance for the right document).
tutor-ecommerce doesn’t any bugs reported so check your configurations.

1 Like

It looks like a stripe api error, have you enabled Stripe Custom Action for your account?

As per the support team, they have said yes, but I have contacted them to check once more.

You’re right, potentially I might have problem in configuration. I not fully understand where each configuration is located?
Instruction says “modify this configuration, save it to ecommerce-config.yml

Are configs by default under each plugin folder, or instruction means I have to create it manually there, e.g at …/tutor/env/plugins/ecommerce/… ?

  • I can see two main configs under /tutor/env/apps/openedx/config$

cms.env.yml lms.env.yml

let’s identify what caused Server error on your payment page.
you can run this command:
tutor local logs --tail=0 -f
and then go to your payment page, and check what errors output in the console.

About the config, by default e-commerce host will be “ecommerce.{{ LMS_HOST }}”, so make sure the subdomain pointed to your server.
I don’t use ecommerce-config.yml to set my variables. I set it directly in config.yml using vim.
run
$(tutor config printroot)/config.yml
and check if these configs exist and are probably set. Other e-commerce configs you can leave it as default.

ECOMMERCE_ENABLED_PAYMENT_PROCESSORS:
- stripe
ECOMMERCE_PAYMENT_PROCESSORS:
  stripe:
    api_version: 2020-08-27;server_side_confirmation_beta=v1
    enable_telemetry: ''
    log_level: ''
    max_network_retries: 3
    proxy: ''
    publishable_key: {stripe_public_key}
    secret_key: {stripe_secret_key}.
    webhook_endpoint_secret: ''

For me the support responded with this question: What specifically are you referring to when you say ‘Stripe Custom Action’? how to explain them more details about the query?

the error is "Access denied for user ‘ecommerce’:

ecommerce-1                   |     super(Connection, self).__init__(*args, **kwargs2)
ecommerce-1                   | MySQLdb._exceptions.OperationalError: (1045, "Access denied for user 'ecommerce'@'xxx.xx.x.xx' (using password: YES)")
ecommerce-1                   |
ecommerce-1                   | The above exception was the direct cause of the following exception:
ecommerce-1                   |
ecommerce-1                   | Traceback (most recent call last):
ecommerce-1                   |   File "/openedx/venv/lib/python3.12/site-packages/django/core/handlers/exception.py", line 47, in inner
ecommerce-1                   |     response = get_response(request)

When I try to grant my existing lms user rights using:

tutor local run ecommerce ./manage.py shell -c "from django.contrib.auth import get_user_model; get_user_model().objects.filter(email='user.email@gmail.com').update(is_staff=True, is_superuser=True)"

I’m getting:

File "/openedx/venv/lib/python3.12/site-packages/MySQLdb/connections.py", line 179, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (1045, "Access denied for user 'ecommerce'@'xxx.xx.x.xx' (using password: YES)")
Error: Command failed with status 1: docker compose -f /home/openedx/.local/share/tutor/env/local/docker-compose.yml -f /home/openedx/.local/share/tutor/env/local/docker-compose.prod.yml --project-name tutor_local run --rm ecommerce ./manage.py shell -c from django.contrib.auth import get_user_model; get_user_model().objects.filter(email='user.email@gmail.com').update(is_staff=True, is_superuser=True)

what tutor and tutor-ecommerce plugin version are you using? check it using tutor --version , tutor plugins list.
Do you run MySQL separately or using default container? if you run MySQL separately, what is your MySQL version?

About Custom action.
I sent them the error response from client browser and Stripe developer dashboard.
I explained as follow:

The Stripe Custom Action is mentioned in this document: frontend-app-payment/docs/decisions/0005-stripe-custom-actions.rst at master · openedx/frontend-app-payment · GitHub .

We followed their document but could not make it work. The only missing thing is “The E-Commerce Service uses Stripe Custom Actions to send payments through a backend before payment. Ask your Stripe representative to enable this feature on your account.”

After a few more emails explaining that I was using an open-source, I didn’t know how to customize it to use newer APIs.
They responded:

Hi there,

Thanks for holding on. I’m writing back to inform that we’ve gated your current Stripe account (acct_…) into Stripe Custom Actions.

Please try making a similar request, and let us know if you run into any errors.

1 Like

tutor version 18.1.1

After applying

run tutor local do init --limit=ecommerce.

as suggested at 10608 those access denied for ‘ecommerce’ error gone, but got other one:

ecommerce-1  | 2024-07-11 01:58:40,188 ERROR 7 [django.request] /openedx/venv/lib/python3.12/site-packages/django/utils/log.py:224 - Internal Server Error: /complete/edx-oauth2/
ecommerce-1  | Traceback (most recent call last):
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/connection.py", line 174, in _new_conn
ecommerce-1  |     conn = connection.create_connection(
ecommerce-1  |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/util/connection.py", line 95, in create_connection
ecommerce-1  |     raise err
ecommerce-1  |   File "/openedx/venv/lib/python3.12/site-packages/urllib3/util/connection.py", line 85, in create_connection
ecommerce-1  |     sock.connect(sa)
ecommerce-1  | ConnectionRefusedError: [Errno 111] Connection refused

I’ve noticed the URL is getting this redirect at the end: https://my.host.name/complete/edx-oauth2/?redirect_state=OCrC

tutor plugins list
NAME STATUS VERSION
android installed 18.0.0
cairn :white_check_mark: enabled 18.0.0
credentials installed 18.0.0
discovery :white_check_mark: enabled 18.0.0
ecommerce :white_check_mark: enabled 18.0.0
forum :white_check_mark: enabled 18.0.0
indigo :white_check_mark: enabled 18.0.0
jupyter installed 18.0.0
mfe :white_check_mark: enabled 18.0.0
minio :white_check_mark: enabled 18.0.0
myecommerce :white_check_mark: enabled /home/openedx/.local/share/tutor-plugins/myecommerce.py
notes :white_check_mark: enabled 18.0.0
webui :white_check_mark: enabled 18.0.0
xqueue installed 18.0.0

I run it using default