Integration with paypal problem

I am integrating paypal with my openedx ironwood install.

It works to the point where one can enter their credit card information and submit the form.

However after submitting the form the following error occurs


and this is the corresponding address

https://http/payment/paypal/execute/?paymentId=PAYID-LZWTHVY60U970153W662623L&token=EC-45D081042G524235T&PayerID=UBRT2SFRKASXL

Any idea on how I can fix this?

I think the problem is related to no defining the return_url variable

Im quite sure this is done via the paypal developer platform as shown below:

The question is - what do I state as the oauth return url?

I have been told by other developers who are familiar with paypal that the return url is defined within oscar and is set prior to the API call.

Am I right in thinking this would be in the ecommerce.yml file in
/edx/etc/ecommerce.yml
?

@kribby can you please tell us more about your configuration ?

Are you using devstack (master branch) or production (open-release/ironwood.master branch) ?
there are lots of changes in code, installed packages and configuration files so it’s important to point your exact configuration.

Regards

@ARMBouhali
I have installed “open-release/ironwood.master branch”

I have used these instructions

Thanks in advance

the return_url is defined in the function def get_transaction_parameters

I “hardcoded” the return_url and cancel_url directly into paypal.py - and this resolved the problem.

How do I avoid hardcoding this and applying to a configuration file e.g. ecommerce.yml or the env.json e.t.c.?

hi @kribby, hope you are doing great. Have you successfully integrated paypal?
If so can you please put on the steps to do so? I’ve set up the ecommerce site successfully and wanted to integrate paypal payment? I’ve not found the doc clear enough on where to do the required steps.
Thanks!

Hi @Natnael
Apologies for the delay and hope you’ve solved this. In any case, the instructions are as follows, I hope this helps you:

E-commerce service configuration in Open edx

E-commerce service configuration in Open edx

===============================================

  1. Create E-commerce and Discover client in LMS admin.:
    a. http://example.com/admin/oauth2/client/ :
    b. E-commerce:
    1. User: ecommerce_worker
    2. URL: http://example.com:18130/
    3. Redirct URL: http://example.com:18130/complete/edx-oidc/
    4. Client ID:
    5. Client Secret:
    6. Client Type: Confidential

  2. Enable E-commerce from LMS admin
    a. http://example.com/admin/commerce/commerceconfiguration/ :
    b. Enabled: True
    c. Checkout on ecommerce service: True
    d. Basket checkout page: /basket/add/
    e. Cache Time To Live: 0
    f. Receipt page: /checkout/receipt/?order_number=
    g. Enable automatic refund approval: True
    h. save

  3. Do following changes in lms.env.json file:
    FEATURES[‘ENABLE_OAUTH2_PROVIDER’] = True
    OAUTH_ENFORCE_SECURE = False if not using SSL;
    JWT_ISSUER = “http://example.com/oauth2”,
    OAUTH_OIDC_ISSUER = “http://example.com/oauth2”,
    ECOMMERCE_API_URL = “http://example.com:18130/api/v2”,
    ECOMMERCE_PUBLIC_URL_ROOT = “http://example.com:18130”,
    JWT_AUTH [ “JWT_ISSUER” ] = “http://example.com/oauth2
    JWT_AUTH [“JWT_PRIVATE_SIGNING_JWK”] = null,
    JWT_AUTH [“JWT_PUBLIC_SIGNING_JWK_SET”] = null,
    CMS_BASE = “http://studio.example.com
    LMS_BASE = “http://example.com
    LMS_ROOT_URL = “http://example.com
    PREVIEW_LMS_BASE = “”

  4. Restart LMS service:
    sudo /edx/bin/supervisorctl restart lms

  5. Configure E-commerce:
    a. sudo -H -u ecommerce bash
    b. source ~/ecommerce_env
    c. cd ~/ecommerce/
    d. ./manage.py makemigrations
    e. ./manage.py migrate
    f. ./manage.py create_or_update_site
    –site-id=1 \ # You can get this id from step 2.a
    –site-domain=http://example.com:18130 \ # it is important to not include the http:// or https://
    –partner-code=edX
    –partner-name=‘Open edX’
    –lms-url-root=http://example.com
    –payment-processors=cybersource,paypal
    –client-id= \ # You can get it from step 1.b
    –client-secret= \ # You can get it from step 1.b
    --from-email=user@example.com
    –discovery_api_url=http://example.com:18381

Example:
./manage.py create_or_update_site
–site-id=1
–site-domain=http://ec2-3-9-173-10.eu-west-2.compute.amazonaws.com:18130
–partner-code=edX
–partner-name=‘Open edX’
–lms-url-root=http://ec2-3-9-173-10.eu-west-2.compute.amazonaws.com
–payment-processors=cybersource,paypal
–client-id=3faf9bdc19f10decb44e
–client-secret=1b0252a6fac75f1e089574e8cb34b9e15f289178
--from-email=user@example.com
–discovery_api_url=http://ec2-3-9-173-10.eu-west-2.compute.amazonaws.com:18381

  1. Edit /edx/etc/ecommerce.yml
    a. sudo nano /edx/etc/ecommerce.yml
    b.
    ECOMMERCE_URL_ROOT: http://example.com:18130
    ENROLLMENT_API_URL: http://example.com/api/enrollment/v1/enrollment
    SOCIAL_AUTH_EDX_OIDC_URL_ROOT: http://ec2-3-9-173-10.eu-west-2.compute.amazonaws.com/oauth2
    EDX_DRF_EXTENSIONS:
    OAUTH2_USER_INFO_URL: http://example.com/oauth2/user_info
    JWT_AUTH:
    JWT_ISSUERS:
    - http://example.com/oauth2
    SESSION_COOKIE_SECURE: false
    SESSION_EXPIRE_AT_BROWSER_CLOSE: false
    SOCIAL_AUTH_EDX_OIDC_ID_TOKEN_DECRYPTION_KEY:
    SOCIAL_AUTH_EDX_OIDC_ISSUER: http://example.com/oauth2
    SOCIAL_AUTH_EDX_OIDC_KEY:
    SOCIAL_AUTH_EDX_OIDC_LOGOUT_URL: http://example.com/logout
    SOCIAL_AUTH_EDX_OIDC_PUBLIC_URL_ROOT: http://example.com/oauth2
    SOCIAL_AUTH_EDX_OIDC_SECRET:
    SOCIAL_AUTH_EDX_OIDC_URL_ROOT: http://example.com/oauth2
    SOCIAL_AUTH_REDIRECT_IS_HTTPS: false

  2. Restart ecommerce service:
    sudo /edx/bin/supervisorctl restart ecommerce

  3. Make sure ecommerce_worker user is staff and superuser.

This is about E-commerce setup.

Set Course price in E-commerce:

  1. Create seat products for individual course runs of a course, do the following in the Course Administration Tool (in Ecommerce)
    a. http://example.com:18130/courses/
    b. Select Add new course
    c. Assign the “Course ID” from the Studio course creation step
    d. Fill in the information including price
    f. Enter valid enrollment deadline and verification dates (typically good to set these close to the course end date)
    g. Save the Changes
    h. Verify the course has an upgrade to Verified option in the LMS Dashboard
1 Like

hey @kribby I just saw the reply, I’ve not found solution yet. Thanks for the help though!
So In the steps You have put above, the first problem I encountered was this ( http://example.com/admin/oauth2/client/ ) does not exist on my instance, I am not sure if this is related to the version of the open edx. I am running Openedx/juniper release and the page that resembles the inputs is found on this url for me https://example.com/admin/oauth2_provider/application/ and this is the page

And when I try to create the “application” as reffered in the platform , It gave me the following error on the User field: Select a valid choice. That choice is not one of the available choices.
What do you think is the problem?

The instructions I provided worked for Ironwood. I suspect there might be a compatibility issue.

hello. did you fix this error?

not yet, but if you are using Juniper release you might want to check this out…
Setting up OAuth Client

oh no. i’m using koa

After Ironwood release, Django Oauth configuration is updated here are also other things that are updated after ironwood.