https://github.com/quochuydev/go-pos-bot
Learning...
https://github.com/quochuydev/go-pos-bot
Last synced: 7 months ago
JSON representation
Learning...
- Host: GitHub
- URL: https://github.com/quochuydev/go-pos-bot
- Owner: quochuydev
- License: mit
- Created: 2024-08-29T08:07:04.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-03T03:37:11.000Z (almost 2 years ago)
- Last Synced: 2024-12-28T17:41:41.449Z (over 1 year ago)
- Language: Go
- Homepage: https://t.me/Goposv1Bot
- Size: 26.8 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## DIY
### Manual create Telegram bot
#### Test BOT

### Setup free MongoDB Atlas
#### - Register a free mongo cluster
https://cloud.mongodb.com
#### - Create a new cluster

#### - Create a new cluster

### Deploy Golang in AWS EC2
OS: AWS Linux
```
uname -s
uname -m
```
If the outputs match Linux and x86_64, then the corresponding values in Go would be:
```
GOOS=linux GOARCH=amd64 go build -o myapp
```
#### Setup nginx
```sh
sudo yum update
sudo yum install nginx
```
```sh
sudo systemctl enable nginx
sudo systemctl start nginx
sudo systemctl status nginx
```
```sh
sudo mkdir -p /etc/nginx/conf.d
sudo nano /etc/nginx/conf.d/default.conf
```
```nginx
server {
listen 80;
location / {
proxy_pass http://localhost:12345;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
server {
listen 443 ssl;
server_name gopos.quochuy.dev;
ssl_certificate /etc/letsencrypt/live/gopos.quochuy.dev/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/gopos.quochuy.dev/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
proxy_pass http://localhost:12345;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
```
```sh
sudo yum install certbot python3-certbot-nginx -y
sudo certbot --nginx -d gopos.quochuy.dev
```
Test nginx
```sh
sudo nginx -t
```
expect: `nginx: configuration file /etc/nginx/nginx.conf test is successful`
```sh
sudo systemctl reload nginx
```
### Integrate to POS application
#### Setup shopify webhook
```curl
NGROK_URL=https://gopos.quochuy.dev
SHOPIFY_TOKEN=
curl -X POST "https://quickstart-fa54a928.myshopify.com/admin/api/2023-07/webhooks.json" \
-H "X-Shopify-Access-Token: $SHOPIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"webhook": {
"topic": "orders/create",
"address": "'$NGROK_URL'/api/shopify/webhook",
"format": "json"
}
}'
```
==> webhook_id:1660397355317
#### Setup shopify discount verify with there APIs
```curl
SHOPIFY_STORE_URL=https://quickstart-fa54a928.myshopify.com
SHOPIFY_TOKEN=
curl -X GET "$SHOPIFY_STORE_URL/admin/api/2023-07/price_rules.json" \
-H "X-Shopify-Access-Token: $SHOPIFY_TOKEN"
curl -X GET "$SHOPIFY_STORE_URL/admin/api/2023-07/price_rules/1716197753141/discount_codes.json" \
-H "X-Shopify-Access-Token: $SHOPIFY_TOKEN"
curl -X GET "$SHOPIFY_STORE_URL/admin/api/2023-07/webhooks.json" \
-H "X-Shopify-Access-Token: $SHOPIFY_TOKEN"
curl -X DELETE "$SHOPIFY_STORE_URL/admin/api/2023-07/webhooks/1660398174517.json" \
-H "X-Shopify-Access-Token: $SHOPIFY_TOKEN"
```