Giter Club home page Giter Club logo

ecommerce's Introduction

README

Run The Project

Versions:

  • Ruby 2.7.5
  • Rails 7.0.4.2
  • Bundler 2.4.3
  • Vite 4
  • Vue 3
  • PostgreSQL 14.6

Create a Account at Stripe

Register for Stripe if you don't have an account, after that create a store in test mode. In the Developers/API Keys tab are the api keys needed to run the project.

Clone the Project

Open Terminal in the directory you want and run:

git clone "https://github.com/IgorFZ/ecommerce.git"
cd ecommerce

After that install ruby gems with:

bundle install

At Frontend directory and run:

npm install

Rack Cors Configuration

At config/initializers/cors.rb:

Rails.application.config.middleware.insert_before 0, Rack::Cors do
  allow do
    origins "*"
    
    resource "*",
      headers: :any,
      methods: [:get, :post, :put, :patch, :delete, :options, :head],
      expose: %w[Authorization Uid]
  end
end

Rails Credentials

Go back to the root of the project and delete the credentials.yml.enc file from the config folder, then run:

rake secret

This will generate something like(copy this):

48818a178d8cc36e08590b3452bed41595fd8b2f052055c09da01205aa6b554eefa29559602ddf8e03ea8518a9ad81ac37f1ff7ed5589ad21cce5a2166dd6930

To recreate and edit your credentials run:

EDITOR=nano rails credentials:edit

This will create two files:

  • master.key
  • credentials.yml.enc

Add a jwt_secret_key with your generated secret:

devise:
  jwt_secret_key: 48818a178d8cc36e08590b3452bed41595fd8b2f052055c09da01205aa6b554eefa29559602ddf8e03ea8518a9ad81ac37f1ff7ed5589ad21cce5a2166dd6930

Open another tab in Terminal and install the Stripe CLI according to the documentation: Get started with the Stripe CLI | Stripe Documentation. After login:

stripe listen --forward-to localhost:3000/webhooks

Copy your webhook key and add to the credentials with your Stripe public and private keys like:

stripe:
  secret: sk_test_51Mde5UIlj...
  public: pk_test_51Mde5UIlj...
  webhook: whsec_f95e7bd5cb9...

Press Crtl+O, Enter And Ctrl+X to save and close rails credentials.

Database

rails db:create && rails db:migrate

And you can run rails db:seed to get some test data.

rails db:seed

Run

Open three tabs in the terminal, two tabs in the root, one for the Rails API, one for listen Stripe Webhooks. And the last one for Frontend with Vite/Vue:

At root:

rails s

And

stripe listen --forward-to localhost:3000/webhooks

The last one in the frontend directory:

npm run dev

Now project is running perfectly, you can test at your localhost.

ecommerce's People

Contributors

igorfz avatar

Watchers

 avatar

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.