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

Error in Payment page #65

Closed
johnny77221 opened this issue Jan 26, 2024 · 12 comments
Closed

Error in Payment page #65

johnny77221 opened this issue Jan 26, 2024 · 12 comments
Assignees

Comments

@johnny77221
Copy link

johnny77221 commented Jan 26, 2024

Hello

I followed this https://overhang.io/tutor/plugin/ecommerce page to setup with cybersource sandbox keys
in the payment page, Its showing error HTTP 400 for http://ecommerce.local.edly.io/bff/payment/v0/capture-context/

and tutor local logs Ecommerce shows these message:

tutor_local-ecommerce-1  | CyberSource.rest.ApiException: (400)
tutor_local-ecommerce-1  | Reason: 
tutor_local-ecommerce-1  | HTTP response headers: HTTPHeaderDict({'Strict-Transport-Security': 'max-age=31536000', 'Cache-Control': 'no-cache, no-store, must-revalidate', 'Pragma': 'no-cache', 'Expires': '-1', 'X-Download-Options': 'noopen', 'Digest': 'SHA-256=kcJGmEfpVx1KkQUJj3YNlGPU7vyl8tMwhbRLy67MM+c=', 'Content-Type': 'application/json;charset=UTF-8', 'Content-Length': '323', 'Date': 'Fri, 26 Jan 2024 07:20:49 GMT', 'X-Cnection': 'close', 'Connection': 'keep-alive', 'v-c-correlation-id': '59951d89-02d7-45cf-b347-407dfa607dc0'})
tutor_local-ecommerce-1  | HTTP response body: {"responseStatus":{"status":400,"reason":"VALIDATION_ERROR","message":"One or more validation errors occurred","correlationId":null,"details":[{"location":"targetOrigin","message":"Target Origin[0] cannot use http protocol unless the host is localhost"}],"_embedded":{}},"_links":{"self":null,"documentation":[],"next":[]}}

would you have idea how to fix this?
is it able to run a test environment in development (local.edly.io) mode? or it just need to be a production server?

@johnny77221
Copy link
Author

I have moved the machine into a public web with assigned domain and SSL
the error turns into:
jwt.exceptions.DecodeError: It is required that you pass in a value for the "algorithms" argument when calling decode().
截圖 2024-02-05 下午6 17 22

@muhammadali286
Copy link

muhammadali286 commented Feb 13, 2024

is it able to run a test environment in development (local.edly.io) mode? or it just need to be a production server?

Yes, you can run test environment locally with tutor dev.

@muhammadali286
Copy link

jwt.exceptions.DecodeError: It is required that you pass in a value for the "algorithms" argument when calling decode().

Hi @johnny77221 could you please mention the steps to regenerate this issue?

@johnny77221
Copy link
Author

first, I installed and enabled plugins: tutor plugins enable discovery ecommerce mfe
then set cybersource key in config: tutor config save --set "ECOMMERCE_PAYMENT_PROCESSORS=$(cat ecommerce-config.yml)"
and rebuild images: tutor images build
then I run with tutor local launch and setup a paid course with http://ecommerce.local.edly.io/courses

after above steps, the config needs to change in Home/Core/Site configurations: http://ecommerce.local.edly.io/admin/core/siteconfiguration/

the payment page should be /payment/ the slash in the end is required or it will display a blank page when added to cart

after above steps, user can add a paid course into cart
the first mentioned error appears and I got a server and domain to run in production mode (re-run tutor local launch with SSL settings)

and change payment URL again (this seems required every time after tutor local launch)
and this JWT error appears

@johnny77221
Copy link
Author

johnny77221 commented Feb 15, 2024

It seems pyJWT version had a breaking change after 1.7.1, here is a similar problem in azure sdk
Azure/azure-sdk-for-python#16035 (comment)

also I looked up https://github.com/openedx/ecommerce-worker
found pyjwt==2.6.0 in pip requirements but I have not found .decode() calling in the repo
maybe downgrading pyjwt to 1.7.1 is a choice but not sure if any side effects will happen

@johnny77221
Copy link
Author

I tried to fork both tutor-ecommerce and ecommerce repo to specify algorithm

in line 225 of cybersource.py in Ecommerce repo I changed to
(capture_context, jwt.decode(capture_context['key_id'], algorithms=['RS256'], verify=False))
to specify the algorithm, but no luck.
when I use HS256 it says jwt.exceptions.InvalidAlgorithmError: The specified alg value is not allowed
when I use RS256 it says ValueError: ('Could not deserialize key data. The data may be in an incorrect format, it may be encrypted with an unsupported algorithm, or it may be an unsupported key type (e.g. EC curves with explicit parameters).', [<OpenSSLError(code=503841036, lib=60, reason=524556, reason_text=unsupported)>])

seems they used some algorithm but I didn't know for decoding

@Faraz32123
Copy link
Collaborator

Hi @johnny77221 ,
Can u please attach some more screenshots about where are you getting the error in payment mfe or its a completely blank page.
What is the tutor version you are running. If you are using mounted version of payment mfe, then what is it? Can u please specify the versions?

is it able to run a test environment in development (local.edly.io) mode?

after above steps, the config needs to change in Home/Core/Site configurations: http://ecommerce.local.edly.io/admin/core/siteconfiguration/

the payment page should be /payment/ the slash in the end is required or it will display a blank page when added to cart

I tried running tutor-ecommerce and payment mfe in tutor dev mode, its working. If you can please specify the issue in detail and the versions, it will be easy to debug the cause.
Screenshot 2024-02-20 at 2 48 22 PM

@johnny77221
Copy link
Author

Hi, I am using following versions (from pip freeze)
tutor==17.0.0
tutor-android==17.0.0
tutor-cairn==17.0.0
tutor-credentials==17.0.0
tutor-discovery==17.0.0
utor-forum==17.0.0
tutor-indigo==17.2.0
tutor-jupyter==17.0.0
tutor-mfe==17.0.0
tutor-minio==17.0.0
tutor-notes==17.0.0
tutor-webui==17.0.0
tutor-xqueue==17.0.0

in your screenshot, there is an error message about "unexpected problem", and that's the problem
in the browser console, you should see HTTP 400 error
if you type tutor local logs e-commerce, it will show up errors what I pasted

@johnny77221
Copy link
Author

It seems need to modify Ecommerce repo
this modification works:

openedx/ecommerce@open-release/quince.master...johnny77221:ecommerce:open-release/quince.master

@Faraz32123
Copy link
Collaborator

Hi @johnny77221,
Thanks for the PR. The solution looks good to me.
I'll also test it.

@Faraz32123
Copy link
Collaborator

Faraz32123 commented Mar 1, 2024

first, I installed and enabled plugins: tutor plugins enable discovery ecommerce mfe then set cybersource key in config: tutor config save --set "ECOMMERCE_PAYMENT_PROCESSORS=$(cat ecommerce-config.yml)" and rebuild images: tutor images build then I run with tutor local launch and setup a paid course with http://ecommerce.local.edly.io/courses

after above steps, the config needs to change in Home/Core/Site configurations: http://ecommerce.local.edly.io/admin/core/siteconfiguration/

the payment page should be /payment/ the slash in the end is required or it will display a blank page when added to cart

after above steps, user can add a paid course into cart the first mentioned error appears and I got a server and domain to run in production mode (re-run tutor local launch with SSL settings)

and change payment URL again (this seems required every time after tutor local launch) and this JWT error appears

Hi @johnny77221, Thanks for this awesome explanation!
Payment page was indeed appearing as blank. I have created a PR for this issue. It will be merged soon.

It seems need to modify Ecommerce repo this modification works:

openedx/ecommerce@open-release/quince.master...johnny77221:ecommerce:open-release/quince.master

Your above solution worked as well as it resolved decoding issue. Hello @regisb, Can you look at his PR. It is closed without being merged although it resolved the above decoding error.

@DawoudSheraz
Copy link

The upstream PR openedx/ecommerce#4138 has been merged, this should be good to close now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

No branches or pull requests

4 participants