Git Product home page Git Product logo

frontend-app-payment's Introduction

build Status |Coveralls| |npm_version| |npm_downloads| license

frontend-app-payment

Please tag @edx/revenue-squad on any PRs or issues. Thanks.

Introduction

Micro-frontend for the single-page payment/checkout process; order history and receipt pages are still served by the ecommerce service. This application only supports PayPal, Cybersource, and Stripe credit card payments.

Getting Started

This MFE is bundled with Devstack, see the Getting Started section for setup instructions.

Once set up, this frontend and all its prerequisites can be started with:

cd devstack
make dev.up.frontend-app-payment

The frontend runs at http://localhost:1998, though it is rare to interact with it directly because the course key needs to be passed in a URL parameter to determine basket contents to check out. Rather, log into the LMS at http://localhost:18000/login and enroll in a course, choosing to upgrade to be taken to the checkout page.

Development

To work on this frontend: with the prerequisites running as above, bring down the frontend-app-payment container, then start the development server outside Docker as follows:

cd devstack
make dev.down.frontend-app-payment
cd ../frontend-app-payment
npm ci
npm start

Note: npm ci is recommended over npm install to match the way CI and production builds work and avoid unintentional changes to package_lock.json when doing other work.

The dev server also runs at http://localhost:1998, but again, it is rare to interact with it directly. By default it will show an empty basket view.

Configuration

This frontend is configured in ecommerce Django admin:

In Core > Site configurations > [YOUR CONFIG], set "Enable Microfrontend for Basket Page" and set the accompanying url to point to this frontend.

Devstack is configured this way by default.

Payment processors Cybersource and Paypal are enabled by default.

To enable Stripe and disable Cybersource, create and enable waffle flag enable_stripe_payment_processor in ecommerce Django admin under Waffle > Flag.

This must be also done in Devstack.

API Documentation

To view the API documentation, navigate to `http://localhost:18130/api-docs`_ and log in with a staff account. Related endpoints:

  • GET /bff/payment/v0/payment/
  • POST /bff/payment/v0/quantity/
  • POST /bff/payment/v0/vouchers/
  • DELETE /bff/payment/v0/vouchers/{voucherid}
  • POST /payment/cybersource/api-submit/
  • POST /payment/cybersource/apple-pay/authorize/
  • POST /payment/cybersource/apple-pay/start-session/

Note: bff means "Backend for frontend". BFF endpoints are designed specifically for this application.

Cart States

Empty Cart

Visit http://localhost:1998 without adding any product to your cart.

Single Course Purchase

Assuming you have a fairly standard devstack setup, if you click the "Upgrade to Verified" button on the Demonstration Course on http://localhost:18000/dashboard, that will populate your cart with a single course so that you see the cart, order summary, and checkout form.

Other Types

To be added. (Program Purchase, Bulk Enrollment Code Purchase)

Glossary

Cart Summary

A list of the product(s) being purchased. Also contains the update quantity form.

Order Summary

A breakdown of the price of the product(s) being purchased. Also home to the coupon form and offers display.

Order Details

A descriptive paragraph of text which provides additional context on the purchase. Varies by product type.

Payment Methods

Cybersource

Stripe

Apple Pay

PayPal

Feedback

A reusable component responsible for displaying alert messages at the top of the page. Can display success, warning, error, and info messages. Provides utilities to add messages and clear them. Is application agnostic (i.e., isn't specific to this micro-frontend)

Coupon

A code that provides a discount. It can apply to courses and programs. It can be created by edX or partners. A coupon is based on a code.

More on Enterprise coupons: Ecommerce (Enterprise) coupons explained.

Offer

A discount offered to a user automatically. It can be applied to a subset of users or everyone. It can be created by edX or partners. An offer is based on a user group.

Project Structure

The source for this project is organized into nested submodules according to the ADR Feature-based Application Organization.

Breakdown of the src directory:

assets
Image assets used by the top-level code.
common
Boilerplate code that is common to many of our frontend applications. Currently copied from place to place, it is intended to eventually live in edx/frontend-common.
components
Top-level App.jsx component, which is 95% shared across frontends and will eventually get similar treatment to the common directory.
data
Top-level redux/redux-saga reducers and sagas.
feedback
A reusable component which displays user feedback messages as alerts at the top of the page. While it is currently only in use by this application, it's intended to be generic and shared across applications, so should remain free of payment-specific code. It will eventually live in either edx/paragon or its own repo.
i18n
The language configuration for the app.
payment

The guts of this app. This includes all payment forms, payment methods, order details, data models, and associated API calls.

Please see src/payment/README.rst for more detail.

store
The redux store configuration for dev and production.

Configuration

All API keys, endpoints, etc are provided through the webpack EnvironmentPlugin at build time as configured in webpack/

Notable Libraries Leveraged

This application uses:

  • redux
  • redux-saga
  • redux-saga-routines
  • redux-form

Build Process Notes

Production Build

The production build is created with npm run build.

Internationalization

Please see edx/frontend-i18n for documentation on internationalization. The repository README.rst explains how to use it, and the How To has more detail.

Localized Pricing

The LocalizedPrice.jsx component makes use of a currency cookie to determine the user's preferred currency. The code for localized pricing can be found in:

src/payment/cart/LocalizedPrice.jsx

This is the localized pricing react component. If a currency cookie is found, it displays the price in that currency using the specified conversion rate.

src/payment/data/reducers.js

The "currency" reducer reads the cookie as part of its initial state.

src/payment/data/selectors.js

The "localizedCurrencySelector" reads the currency information defined in redux and is used to provide it to the LocalizedCurrency.jsx component.

Appendix A: Using Local Dev Server with stage.edx.org APIs

If you would like to run this frontend against stage.edx.org you can run npm run start:stage and access your development server at https://local.stage.edx.org after the initial setup described below:

  • Update the /etc/hosts file on your computer and add:

    127.0.0.1 local.stage.edx.org.

  • Log into stage: https://courses.stage.edx.org/login.

  • Run npm ci in this project directory

  • Start the frontend's dev server in staging mode:

    npm run start:stage

  • Navigate to https://local.stage.edx.org. You will see a warning that this page is unsecured because there is no valid SSL certificate. Proceed past this screen by clicking the "Advanced" button on the bottom left and then click the revealed link: "Proceed to local.stage.edx.org (unsafe)".

Appendix B: Adding No-Op Stuff to Test Sandbox Deploys

Let's try this.

frontend-app-payment's People

Contributors

abdullahwaheed avatar albemarle avatar bbaker6225 avatar christopappas avatar cpennington avatar davidjoy avatar dianekaplan avatar douglashall avatar edx-requirements-bot avatar edx-semantic-release avatar emma-green avatar feanil avatar inventhouse avatar julianajlk avatar lunyachek avatar mashal-m avatar matthewpiatetsky avatar mrazadar avatar mulby avatar nedbat avatar omarithawi avatar pshiu avatar renovate[bot] avatar robrap avatar syed-ali-abbas-zaidi avatar tj-tracy avatar usamasadiq avatar waheedahmed avatar wdrussell2015 avatar zubair-ce07 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

frontend-app-payment's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Warning

These dependencies are deprecated:

Datasource Name Replacement PR?
npm redux-devtools-extension Available

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): update dependency @openedx/frontend-build to v14
  • chore(deps): update dependency audit-ci to v7
  • chore(deps): update dependency axios-mock-adapter to v2
  • chore(deps): update dependency husky to v9
  • chore(deps): update dependency node to v20
  • chore(deps): update dependency webpack-merge to v6
  • chore(deps): update testing-library monorepo (major) (@testing-library/jest-dom, @testing-library/react)
  • fix(deps): update dependency @edx/frontend-component-footer to v14
  • fix(deps): update dependency @edx/frontend-platform to v8
  • fix(deps): update dependency @stripe/stripe-js to v4
  • fix(deps): update dependency react-redux to v9
  • fix(deps): update dependency redux to v5
  • fix(deps): update dependency redux-thunk to v3
  • fix(deps): update dependency reselect to v5
  • fix(deps): update dependency universal-cookie to v7
  • 🔐 Create all rate-limited PRs at once 🔐

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/add-depr-ticket-to-depr-board.yml
.github/workflows/add-remove-label-on-comment.yml
.github/workflows/ci.yml
  • actions/checkout v3
  • actions/setup-node v3
  • ubuntu 20.04
.github/workflows/commitlint.yml
.github/workflows/lockfileversion-check.yml
.github/workflows/self-assign-issue.yml
.github/workflows/update-browserslist-db.yml
npm
package.json
  • @edx/brand ^1.2.2
  • @edx/frontend-component-footer 13.0.2
  • @edx/frontend-component-header 5.0.2
  • @edx/frontend-platform 7.1.0
  • @edx/openedx-atlas ^0.6.0
  • @fortawesome/fontawesome-svg-core ^6.1.1
  • @fortawesome/free-brands-svg-icons ^6.1.1
  • @fortawesome/free-regular-svg-icons ^6.1.1
  • @fortawesome/free-solid-svg-icons ^6.1.1
  • @fortawesome/react-fontawesome ^0.2.0
  • @openedx/paragon 22.1.1
  • @stripe/react-stripe-js ^1.10.0
  • @stripe/stripe-js ^1.36.0
  • axios ^0.27.2
  • bootstrap 4.6.1
  • classnames ^2.3.1
  • core-js ^3.23.5
  • country-state-city ^3.2.1
  • form-urlencoded ^6.0.6
  • lodash.camelcase ^4.3.0
  • lodash.snakecase ^4.1.1
  • lodash.without ^4.4.0
  • moment-timezone ^0.5.43
  • prop-types ^15.8.1
  • react ^17.0.2
  • react-dom ^17.0.2
  • react-redux ^7.2.8
  • react-router-dom ^6.15.0
  • react-tooltip ^4.2.21
  • redux ^4.2.0
  • redux-devtools-extension ^2.13.9
  • redux-form ^8.3.8
  • redux-logger ^3.0.6
  • redux-saga ^1.1.3
  • redux-saga-routines ^3.2.3
  • redux-thunk ^2.4.1
  • regenerator-runtime ^0.13.9
  • reselect ^4.1.6
  • universal-cookie ^4.0.4
  • @edx/browserslist-config ^1.2.0
  • @edx/reactifex ^2.1.0
  • @openedx/frontend-build 13.0.27
  • @testing-library/jest-dom ^5.14.1
  • @testing-library/react ^12.1.5
  • audit-ci ^6.3.0
  • axios-mock-adapter ^1.21.1
  • chance ^1.1.8
  • html-webpack-plugin ^5.5.0
  • husky ^8.0.1
  • lodash.defaultsdeep ^4.6.1
  • qs ^6.11.0
  • redux-mock-store ^1.5.4
  • rosie ^2.1.0
  • webpack-merge ^5.8.0
nvm
.nvmrc
  • node 18

  • Check this box to trigger a request for Renovate to run again on this repository

Wrong translation?

I discovered an issue with the fr language.

"payment.card.holder.information.first.name.label": "Prénom (requis)",
"payment.card.holder.information.last.name.label": "Prénom (requis)",

The last name should be "Nom de famille (requis)" as is the case for fr_CA in Transifex. This will cause a problem for anyone using fr as their language. I am one of the reviewer for fr_CA but I do not have access to fr in order to correct it.

@Carlos-Muniz

Switch to Ansible-free Docker image

In order to advance implementation of both OEP-45: Configuring and Operating Open edX and openedx/public-engineering#51, we would like to switch devstack from using primarily Docker images built with Ansible code from the configuration repository to images built from Dockerfiles in each service's repository. We hope this will also help simplify Tutor by providing better base images to derive from, with fewer workarounds and duplicated code blocks required in Tutor.

A/C

Ensure that the repo's Dockerfile can create a base image which is appropriate for small production installations
Ensure that the repo's Dockerfile also defines an additional image derived from the base which adds dependencies and configuration changes needed for development environments
Check with the Tutor developers during code review to see if any further changes to the Dockerfile would help simplify Tutor
Automate uploads of both images when code changes are merged
Switch devstack to use the new Ansible-free development image, and do some basic testing to ensure it works before merging

Roadmap for Stripe frontend

Hello edx team,

I would like to know if there's any plan on your roadmap to integrate Stripe in this repo.

Thanks a lot for your great work !

Node 20 upgrade

Description

See the parent ticket for the general description and motivation, openedx/public-engineering#267. Make sure to follow its recommendations for each step of the process.

Tasks

Upgrade React JS to v17

This repo is currently using React JS v16. We need to upgrade it to React 17 before moving to latest React version(v18).
React 17 doesn’t add any new developer-facing features, so its upgrade might not cause any breaking changes. Our end goal is to upgrade React to v18 but v18 no longer support enzyme, so we are upgrading to React 17 and then we’ll migrate from enzyme.

Epic Link

React 17 upgrade

Action Required: Fix Renovate Configuration

There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.

Error type: undefined. Note: this is a nested preset so please contact the preset author if you are unable to fix it yourself.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.