Cuelogic Blog Icon
Cuelogic Career Icon
Home > Blog > All > PayPal Integration in EdX Platform

PayPal Integration in EdX Platform

PayPal Integration in EdX Platform

EdX is now one of the largest massive online course providers (MOOC). Ever since the advent of MOOC, edX has proved to be the most ambitious MOOC service entity. Planning to rope in over 1 billion learners within a decade, edX has been constantly updating and reworking their learning interface to suit a new generation of students.

Though most courses on edX are free, there are quite a number of paid courses. These are especially courses where certification is critical. Such courses can help you procure admission in a college, get you a better job or promotion. That is why edX have implemented their own shopping cart facility, as a default feature. There will be no need to enhance or customize the feature. Now, the catch is that, at the time of writing, edX has only CyberSource as a payment gateway option. There is where the necessity for integrating an alternate payment gateway like PayPal arises.

As paid course registration is disabled by default, certain code has to be entered within the edXstudio/CMS admin panel:


The next step is to configure the course that it is a Paid Course Enrollment, the system administrator needs to access the Django Admin website to access the /admin url. 'Superuser' rights must be given to the user.

After logging in to Django Admin and clicking on the 'Course modes' link, you will view all existent Course Modes defined. Click on the 'Add course mode', located on the top right of the page.

You will then view the following form that needs to be filled out with:

1) Course id: Enter course id related to the course. The format will be "{org}/{course}/{run}" and match the course ID Studio set up.

2) Mode slug: This must be set to "honor".

3) Mode display name: Set this "mode" as per your wishes."Honor Code" will be a recommended value.

4) Min Price: Fill course price.

5) Suggested Prices: Use same price as mentioned in #4.

6) Currency: It shows "usd" (US Dollars) as default. Change this to different ISO

code (e.g. 'INR' for Indian Rupees).

7) Expiration Date/Date Time: Leave it blank (Recommended).


Payment Integration

EdX has provided admin users with an API for integrating CyberSource or any other payment processor, for that matter. Now, PayPal offers a REST API and also presents a PayPal REST SDK for Python. As for the latter, the edX payment API has to be so marked that PayPal can be integrated with edX shopping cart.


The Integration Process

i. Seek the shopping cart app at the following location: edx-platform/lms/djangoapps/shoppingcart. The app itself will have an package called 'processors', available at the path: edx-platform/lms/djangoapps/shoppingcart/processors/. The 'processors' package holds the key to implementation of all payment processors. CyberSource files are found by default here.

ii. You may use the 'processors' package to settle on a particular payment processor from the global setting file. Implementing the following four api functions is necessary to integrate PayPal (or any other particular payment processor) to the edX shopping cart:

  • 'render_purchase_form_html'
  • 'process_postpay_callback'
  • 'get_purchase_endpoint'
  • 'get_signed_purchase_params'


iii. Other helper api functions also need to be implemented along with the four prime functions, mentioned above. Appropriate code also needs to be typed in to set payment processor in settings file.

Add following in lms.auth.json:

"CyberSource": {







"CyberSource2": {






"PayPal": {

"CLIENT_ID": "add your client id here",

"CLIENT_SECRET": "add your secret here",

"MODE": "sandbox"




The CC_PROCESSOR_NAME lets one decide which payment processor to use from the ones available.

Below is an example of the shoppingcart and PayPal (classic api) payment processor execution flow:

flow of shoppingcart and paypal (classic api) payment processor execution

  1. Start with enrolling for a course. Use the shoppingcart url route to view the edx shoppingcart app. (
  2. Using the paypal api, the shoppingcart view loads the payment form. (Create payment form template for PayPal payment processor.)
  3. Data related to shopping cart and payment is posted to PayPal site. The user is then redirected to PayPal site. (Posted data includes order no, amount, and return url, cancel url etc.)
  4. User either completes payment process or cancels payment.
  5. User is then redirected to return url, based on action taken at step iv.
  6. Return/Cancel url is routed to callback function.
  7. Callback function confirmed the payment. (Order status is recorded in system and other helper functions in edX API are called.)

Paypal can also be integrated through REST API, here's an illustration of how:

PayPal through REST

  1.  Start with enrolling for a course. The shoppingcart url is route to edX shoppingcart app view. (
  2. The payment form is loaded using PayPal API by shoppingcart view. (Create payment form template for PayPal payment processor.) (Post data and view function at
  3.  Create a different view at in shopping_cart app for using paypal REST SDK. (SDK functions like configure, create, execute are handled here.) (Created to manage new PayPal REST SDK and old edX payment.) (Acts like a wrapper.)
  4. The form post request mentioned in step 2 is mapped to
  5. Payment related and shopping cart data is posted to PayPal site and user is redirected to the same. (Posted data includes order no., amount, cancel url, return url. etc) (PayPal REST SDK's create function is used here.) (User redirected to paypal site for payment.)
  6. User either completes payment or cancels it.
  7.  User redirected to return url/cancel as per step 6.
  8. Return/cancel url is routed back to callback function in paypal_view. (Callback function confirmed payment.) (Use of PayPal REST SDK's execute function.) (Handling on cancellation order too.)
  9. Simulating a request to mapped original shopping cart view.
  10. shopping cart view calls original edX payment API’s callback function in
  11. Order status recorded in system. Other helper functions in edX API called.

This concludes the process of integrating PayPal into edX. With more such features, edX looks to be more compatible and user-friendly in the time to come for its countless learners.