You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 6, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+53-21Lines changed: 53 additions & 21 deletions
Original file line number
Diff line number
Diff line change
@@ -14,56 +14,82 @@ Built and mantained by **[Ptorx](https://ptorx.com)** and other **[Xyfir](https:
14
14
- Accept popular **c**rypto**c**urrencies like Bitcoin with [**C**oinbase **C**ommerce](https://commerce.coinbase.com)
15
15
- Configurable fiat currency
16
16
- No dependencies other than Node and what npm will install
17
-
- Older Node versions not actively supported
18
17
- No database needed
19
-
- Data is saved on disk in simple JSON files
20
-
- Standalone server and web client
21
-
- Easy integration into new and existing applications of any stack
22
-
- JSON Web Tokens (JWT)
23
-
- Secure and easy communication between your app and CCashCow
18
+
- Standalone server and web client that integrates into apps of any stack
19
+
- JSON Web Tokens (JWT) for secure and easy communication between your app and CCashCow
24
20
- Easy theming via [Material-UI](https://material-ui.com/style/color/#color-tool)
25
21
26
22
# Install
27
23
24
+
From now on we'll assume commands are run from `ccashcow/`.
25
+
28
26
As simple as CCashCow is, you'll still need to download, configure, build, and integrate it into your app. We've made it just about as easy as it could possibly be.
29
27
30
28
**Note #1:** If your system does not yet have Node installed, start with [nvm](https://github.com/creationix/nvm#install-script) (or [nvm for Windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows)).
31
29
32
30
**Note #2:** You may alternatively download CCashCow through npm (see [here](http://npmjs.com/package/ccashcow)), however this is not currently the recommended installation method. In the future we'll likely have a CLI tool available through npm to make configuring, running, and managing CCashCow instances easier.
33
31
34
-
## Server
32
+
## Step 0: Clone the repo
35
33
36
34
```bash
37
35
git clone https://github.com/Xyfir/ccashcow.git
38
-
cd ccashcow/server
36
+
cd ccashcow
37
+
```
38
+
39
+
## Step 1: Download npm dependencies
40
+
41
+
Install npm depencies for each module:
42
+
43
+
```bash
44
+
cd server
39
45
npm install
40
-
touch .env
46
+
cd ../web
47
+
npm install
48
+
cd ../ # back to ccashcow/
41
49
```
42
50
43
-
Now open up `ccashcow/server/.env` in your editor and fill out the values. See the `CCashCow.Env.Common` and `CCashCow.Env.Server` interfaces in [types/ccashcow.d.ts](https://github.com/Xyfir/ccashcow/blob/master/types/ccashcow.d.ts) for expected environment variables. Format is `KEY=VALUE` (`PORT=1234`, `NAME="CCashCow"`, etc).
51
+
## Step 2: Set environment variables
52
+
53
+
The CCashCow modules are configured via environment variables which are loaded into the applications via `.env` files located in each module's directory.
54
+
55
+
To understand the syntax of the `.env` files, know that they are first loaded via [dotenv](https://www.npmjs.com/package/dotenv) and then the string values provided by dotenv are parsed by [enve](https://www.npmjs.com/package/dotenv).
56
+
57
+
### Step 2a: Create `.env` files
58
+
59
+
First we'll create each file by copying the example `.env` files and then we'll work our way through populating them with values.
44
60
45
61
```bash
46
-
npm run build
47
-
npm run start # or launch ./dist/app.js however you like
62
+
cp server/example.env server/.env
63
+
cp web/example.env web/.env
48
64
```
49
65
50
-
At this point the setup is based on your environment and what your needs are. Probably you'll run the server with [pm2](https://www.npmjs.com/package/pm2) and put Node behind Nginx or Apache.
66
+
### Step 2b: Edit `.env` files
67
+
68
+
Edit the files `server/.env` and `web/.env`. Update the config keys with your own values. You can find descriptions for each one under the `CCashCow` -> `Env` namespaces in the [type definitions](https://github.com/Xyfir/ccashcow/blob/master/types/ccashcow.d.ts). Use the appropriate `interface` for each corresponding file.
51
69
52
-
## Web Client
70
+
## Step 3: Build from source
53
71
54
72
```bash
73
+
cd server
74
+
npm run build
55
75
cd ../web
56
-
npm install
57
-
touch .env
76
+
npm run build
77
+
cd ../
58
78
```
59
79
60
-
Now open up `ccashcow/web/.env` in your editor and fill out the values. See the `CCashCow.Env.Common` and `CCashCow.Env.Web` interfaces in [types/ccashcow.d.ts](https://github.com/Xyfir/ccashcow/blob/master/types/ccashcow.d.ts) for expected environment variables.
80
+
## Step 4: Start the server
81
+
82
+
Now you'll need to start the server and serve the built files. The simplest way to do this is:
61
83
62
84
```bash
63
-
npm run build
85
+
cd server
86
+
npm run start
87
+
cd ../
64
88
```
65
89
66
-
## Integration Into Your App
90
+
If you're in production, you'll probably run the server with [pm2](https://www.npmjs.com/package/pm2) and proxy the server through Nginx or Apache while serving static files through them instead of Node. For you, know that files to be served to the client are located in `web/dist` with `web/dist/index.html` serving as the web client's entry file.
91
+
92
+
## Step 5: Integrate into your app
67
93
68
94
This part is largely up to you, so it's important to understand the flow of data between your app and CCashCow:
69
95
@@ -79,6 +105,12 @@ To be a bit more specific:
79
105
5. At some point the user will be redirected back to your app with the JWT in the url as you configured. Verify and decode this JWT to retrieve the payment information.
80
106
6. Using the JWT's payload, your app will check if the payment as been paid, and if your app has not already fulfilled the user's order it will do so then.
81
107
82
-
### Payment JWT Payload
83
-
84
108
Check the [CCashCow.Payment](https://github.com/Xyfir/ccashcow/blob/master/types/ccashcow.d.ts) interface. Your app should only ever send a JWT containing `id`, `amount`, and `methods`; everything else will be added by CCashCow and sent back to your app with the user later. To check if a payment has been paid, all you have to do is check that `paid` is a number, and not `undefined`. Other values sent back to your app like `method` or `squareTransactionId` can be ignored unless you have some other use for them.
109
+
110
+
# Contribute
111
+
112
+
If you'd like to help work on CCashCow, the tutorial above will suffice to get you up and running. Certain things however will make your life easier:
113
+
114
+
- Make sure your `NODE_ENV` variables in the `.env` files are set to `"development"`.
115
+
- Run the web client's dev server via `npm run start` when in `web/`. Connect to it via the `PORT` you set in `web/.env`.
116
+
- Check the `scripts` in each module's `package.json` for helpful scripts.
0 commit comments