Contains documentation and back/front end components required to integrate circle payments into a project. You probably just want API.md
and USAGE.md
.
- Circle Homepage
- Circle Payments API Documentation
- Neon District Circle Integration Dev Server: 54.211.86.53 54.211.86.53
- Neon District Circle Integration Dev Server By Host: dev.circle-integration.neondistrict.io dev.circle-integration.neondistrict.io
Circle is a payment processor who is ool with blockchain applications, which is why we use them. This repository contains:
- The circle integration server module
server.js
which can be run withindex.js
. - The circle integration client module
circle_integration_client.js
which is included in the game frontend and handles all calls to the circle integration server module. - The circle integration crm module
circle_integration_crm_client.js
(customer relationship management) which is included in the admin panel frontend to access details about purchases and to cancel or refund purchases.
- You will need keys to make your own server, they go into the root of project in a folder called
keys/
. - You require
circle_key_dev
which contains the key for interacting with circle,email_keys.js
which contains the keys for aws ses to send emails,fullchain.pem
privkey.pem
which together provide SSL/HTTPS support via lets encrypt, andpostgres_dev.js
which contains the user, host, password, port, and database for accessing postgres. - The circle integration server can only run on AWS EC2 because of it's hard requirement to use AWS SNS which does not run locally (without extreme workarounds).
- You don't want to create your own development server, you want to use the development server already established on EC2 (which is linked above in useful links and has a hostname setup for it).
- All logs go out to paper trail, let adrian know if you need access to it.
- Create an amazon linux ec2 instance, if you use a micro instance the remote vs code connection will drop a lot, make sure you use a C or M machine type at least.
- Add to security group
neon-district-circle-integration-dev
orneon-district-circle-integration-prod
- Make sure you have access to the appropriate keypair namely
neon-district-circle-integration-dev.pem
orneon-district-circle-integration-prod.pem
- When the instance is created provide is a meaningful name like
neon-district-circle-integration-dev
(are you sensing the pattern here yet?) - If an old machine exists, dissassociate the existing elastic IP
- Go to elastic IPs and assign the appropriate IP to your new instance, it should already exist and be called
neon-district-circle-integration-dev
orneon-district-circle-integration-prod
- SSH in
- Run the following to prep the machine:
sudo yum groupinstall 'Development Tools' -y sudo curl --silent --location https://rpm.nodesource.com/setup_14.x | sudo bash - sudo yum install nodejs -y sudo npm install pm2 -g sudo amazon-linux-extras install epel sudo yum install certbot-apache -y
- Copy all keys to the
./keys
directory at the root of the project, for the love of god make sure you dont put the prod keys in dev, or the dev keys on prod
- Create an elastic IP and point it at the ec2 instance
- In Route53 setup a subdomain and point it at the elastic IP
- Stop the server
- Run
sudo certbot certonly --standalone
- Follow prompts, for dev use
dev.circle-integration.neondistrict.io
- Certs will be placed at:
/etc/letsencrypt/live/dev.circle-integration.neondistrict.io/fullchain.pem /etc/letsencrypt/live/dev.circle-integration.neondistrict.io/privkey.pem
- Copy these to the keys directory:
sudo cp /etc/letsencrypt/live/dev.circle-integration.neondistrict.io/fullchain.pem ~/circle-integration/keys/fullchain.pem sudo cp /etc/letsencrypt/live/dev.circle-integration.neondistrict.io/privkey.pem ~/circle-integration/keys/privkey.pem
- Restart the server
- Install VS Code
- Install the
Remote - SSH
extension for VS Code - In the bottom left corner of VS Code is a small green icon, click on this icon
- Select
Connect to host
- Select
Add new SSH Host
- Enter the SSH connection string for the ec2 instance, such as:
ssh -i ~/keys/neon-district-circle-integration-dev.pem [email protected]
- Select your user's SSH config to be updated, such as
/home/adrian/.ssh/config
- You are now setup for SSH remote working via VS Code, click the small green icon in the bottom left again to connect to the ec2 instance
- Sometimes the SSH connection can get droppy you can restart the SSH daemon on the ec2 instance with
sudo systemctl restart sshd
which allegedly helps
- While connected to the ec2 instance, run
ssh-keygen -t rsa -b 4096 -C "[email protected]"
to generate an SSH keypair - Ensure that you add a passphrase to this keypair, otherwise if the machine is comprimised so will your git access
- Run
cat ~/.ssh/id_rsa.pub
to output the public key to the terminal, which can then be copied to the clipboard - Add this public key to your github SSH keys
- You can now interact with git from the ec2 instance
A VS Code launch.json
is included in the project, simply select Launch Program
or Mocha Tests
from the Run and Debug
dropdown to run either with full debug support. Make sure the pm2 instance is stopped before running tests.
- Setup PM2 to recover on reboot by running:
pm2 startup
- Copy and paste the script it provides and run it, this will add PM2 to systemd
- Start the server:
pm2 start ./src/index.js --node-args="--unhandled-rejections=strict"
- Run the following to save the PM2 processes which will recover them on reboot:
pm2 save
The node argument for unhandled rejections allows the server to crash on unhandled exceptions which is desired behaviour. These types of crashes are representitive of a critical failure, critical bug, or malicious event - all of which should stop the server for human investigation and intervention. No payments are better than fraudulent payments.