Video Introduction — วิดีโอแนะนำ
Thai intro: websites, payments, GitHub, and AI — วิดีโอแนะนำภาษาไทย
Why This Works — ทำไมถึงได้ผล
🇹🇭 ภาษาไทย
คุณสามารถ
🇬🇧 English
You can host a real website with a custom domain, HTTPS, and a global CDN without paying anything. GitHub Pages hosts your files. Cloudflare sits in front and provides speed, security, and DNS management. Millions of websites use this exact setup.
Traditional Hosting
โฮสติ้งแบบเดิม
- Shared hosting plan — แผนโฮสติ้งแบบแชร์
- SSL certificate (sometimes extra) — ใบรับรอง SSL (บางทีจ่ายเพิ่ม)
- Limited bandwidth — แบนด์วิดท์จำกัด
- Slow in distant regions — ช้าในภูมิภาคไกลๆ
- Server maintenance — ต้องดูแลเซิร์ฟเวอร์
GitHub + Cloudflare
ฟรีทั้งคู่
- GitHub Pages (free) — ฟรี
- Free SSL from Cloudflare — SSL ฟรีจาก Cloudflare
- Unlimited bandwidth — แบนด์วิดท์ไม่จำกัด
- Global CDN (300+ cities) — CDN ทั่วโลก (300+ เมือง)
- Zero maintenance — ไม่ต้องดูแลเลย
What Can You Host? — โฮสต์อะไรได้บ้าง?
- Personal portfolios and resumes — พอร์ตโฟลิโอและเรซูเม่ส่วนตัว
- Business landing pages — หน้าแลนดิ้งเพจธุรกิจ
- Documentation sites — เว็บไซต์เอกสาร
- Blogs (with Jekyll or plain HTML) — บล็อก
- Single-page applications (React, Vue, etc.) — แอปพลิเคชันหน้าเดียว
- Any static website (HTML, CSS, JavaScript) — เว็บไซต์แบบ static ทุกประเภท
Limitation / ข้อจำกัด: ไม่รองรับ
Useful Phrases — วลีที่มีประโยชน์
Architecture Overview — ภาพรวมสถาปัตยกรรม
🇹🇭 ภาษาไทย
มีสองวิธีในการ
🇬🇧 English
There are two ways to set up your free website: the simple way (GitHub Pages only) and the full way (GitHub Pages + Cloudflare with a custom domain). Both are completely free!
Simple — แบบง่าย
No domain needed — ไม่ต้องมีโดเมน
types
username.github.ioGitHub provides free SSL — GitHub ให้ SSL ฟรี
serves HTML/CSS/JS — ส่งไฟล์เว็บไซต์
เว็บไซต์โหลดแล้ว!
URL:
username.github.io/repoSetup time / เวลาตั้งค่า: 5 minutes
Full — แบบเต็ม
Custom domain + Cloudflare
types
mysite.comresolves domain — แปลงชื่อโดเมน
cache + DDoS protection — แคชและป้องกัน
encrypted end-to-end — เข้ารหัสทั้งหมด
serves HTML/CSS/JS — ส่งไฟล์เว็บไซต์
เว็บไซต์โหลดเร็ว!
URL:
mysite.comSetup time / เวลาตั้งค่า: 30 minutes
What You Need — สิ่งที่ต้องมี
🇹🇭 ภาษาไทย
ก่อนเริ่มต้น คุณต้องมีสิ่งเหล่านี้:
🇬🇧 English
Before starting, you need these things:
Free to create. Go to github.com and sign up.
Only needed with a custom domain. GitHub Pages handles everything on its own.
username.github.io ถ้าต้องการโดเมนเอง (เช่น mysite.com) ต้องซื้อ ($10-15/ปี)Without a domain, your site will be at
username.github.io.index.html หนึ่งไฟล์ สามารถเพิ่ม CSS, JavaScript และรูปภาพได้At minimum, an
index.html file.Part 1: Set Up GitHub Pages — ตั้งค่า GitHub Pages
1 Create a New Repository — สร้าง Repository ใหม่
🇹🇭 ภาษาไทย
ไปที่ github.com แล้วกดปุ่ม + มุมขวาบน เลือก New
- Repository name: ตั้งชื่ออะไรก็ได้ (เช่น
my-website) สำหรับเว็บไซต์ผู้ใช้ ให้ตั้งชื่อว่าusername.github.io - Public:
Repo ต้องเป็นpublic สำหรับ GitHub Pages ฟรี - Add a README: ติ๊กช่องนี้เพื่อไม่ให้ repo ว่างเปล่า
กดปุ่ม Create repository
🇬🇧 English
Go to github.com and click the + button in the top-right corner, then New repository.
- Repository name: Choose any name (e.g.,
my-website). For a user site, name itusername.github.io. - Public: The repo must be public for free GitHub Pages (or you need GitHub Pro for private repos).
- Add a README: Check this box so the repo isn't empty.
Click Create repository.
2 Add Your Website Files — เพิ่มไฟล์เว็บไซต์
🇹🇭 ภาษาไทย
คุณสามารถ
- ใน repo ใหม่ กด Add file → Upload files
- ลากไฟล์
index.html, CSS, JS และรูปภาพเข้าไป - กด
Commit changes
🇬🇧 English
You can upload files directly through the GitHub web interface:
- In your new repo, click Add file → Upload files
- Drag your
index.html, CSS, JS, and image files into the upload area - Click Commit changes
Minimal index.html to Start — ไฟล์ index.html เริ่มต้น
ถ้ายังไม่มีเว็บไซต์ ให้สร้างไฟล์ชื่อ index.html ด้วยเนื้อหานี้: / If you don't have a website yet, create a file called index.html with this content:
🇹🇭 หรือใช้ Git จาก command line
🇬🇧 Or use Git from the command line
3 Enable GitHub Pages — เปิดใช้งาน GitHub Pages
🇹🇭 ภาษาไทย
- ไปที่ repo บน GitHub
- กด
Settings (ไอคอนรูปเฟือง) - ในเมนูด้านซ้าย กด Pages
- ตรง Source เลือก
Deploy from a branch - เลือก main branch และ / (root) folder
- กด Save
รอ 1-2 นาที เว็บไซต์จะใช้งานได้ที่:
🇬🇧 English
- Go to your repo on GitHub
- Click Settings (gear icon in the tab bar)
- In the left sidebar, click Pages
- Under Source, select Deploy from a branch
- Choose the main branch and / (root) folder
- Click Save
Wait 1-2 minutes. Your site will be live at:
ถ้าตั้งชื่อ repo ว่า username.github.io URL จะเป็น: / If you named your repo username.github.io, the URL is simply:
4 Verify It Works — ตรวจสอบว่าใช้งานได้
🇹🇭 ภาษาไทย
เปิด URL ในเบราว์เซอร์ คุณจะเห็นเว็บไซต์ของคุณ ถ้าเห็น
🇬🇧 English
Visit the URL in your browser. You should see your website. If you see a 404, wait another minute — GitHub Pages can take a few minutes for the first deployment.
Troubleshooting — การแก้ปัญหา
- ไฟล์ต้องชื่อ
index.html(ไม่ใช่Index.htmlหรือhome.html) — Make sure your file is namedindex.html - Repo ต้องเป็น public — Make sure the repo is public
- ดูแท็บ Actions ใน repo เพื่อดูสถานะการ deploy — Check the Actions tab for deployment status
Your site is now live! — เว็บไซต์ออนไลน์แล้ว!
ทุกครั้งที่คุณ push การเปลี่ยนแปลงไป GitHub เว็บไซต์จะอัปเดตอัตโนมัติภายในไม่กี่นาที
Every time you push changes to GitHub, the site updates automatically within minutes.
ไม่มี custom domain? เสร็จแล้ว! GitHub Pages ให้ HTTPS ฟรีที่ username.github.io ส่วนที่ 2 และ 3 ต้องทำเฉพาะเมื่อต้องการโดเมนเอง
No custom domain? You're done! Parts 2 and 3 are only for custom domains.
Tech Phrases — วลีเทคโนโลยี
Part 2: Add a Custom Domain (Optional) — เพิ่มโดเมนเอง
🇹🇭 ภาษาไทย
ข้ามส่วนนี้ถ้าไม่มี custom domain เว็บไซต์ที่ username.github.io มี HTTPS ฟรีอยู่แล้วและใช้งานได้ดี ทำต่อเฉพาะเมื่อต้องการใช้โดเมนเอง เช่น mysite.com
🇬🇧 English
Skip this section if you don't have a custom domain. Your site at username.github.io already has free HTTPS and works great. Continue here only if you want to use your own domain like mysite.com.
5 Buy a Domain — ซื้อโดเมน
🇹🇭 ภาษาไทย
ซื้อ
🇬🇧 English
Purchase a domain from any registrar. Popular affordable options:
| Registrar | Typical Cost / ราคาโดยประมาณ | Notes / หมายเหตุ |
|---|---|---|
| Cloudflare Registrar | $8-10/year (.com) | ราคาทุน ไม่บวกเพิ่ม — At-cost pricing, no markup |
| Namecheap | $9-13/year (.com) | ยอดนิยม UI ดี — Popular, good UI, free WhoisGuard |
| Porkbun | $9-10/year (.com) | ราคาถูก ใช้ง่าย — Low prices, clean interface |
Avoid These Traps — หลีกเลี่ยงกับดัก
- บาง registrar โฆษณา $1 ปีแรก แต่ต่ออายุ $15+/ปี ดูราคา
renewal — Check the renewal price - ไม่ต้องจ่ายเพิ่มสำหรับ "
SSL certificate " — Cloudflare ให้ฟรี - ไม่ต้องจ่ายสำหรับ "website hosting" เสริม — GitHub Pages ทำให้ฟรี
6 Tell GitHub About Your Domain — บอก GitHub เรื่องโดเมน
🇹🇭 ภาษาไทย
- ไปที่ repo → Settings → Pages
- ตรง Custom domain พิมพ์โดเมนของคุณ (เช่น
www.mysite.com) - กด Save
- ติ๊ก
Enforce HTTPS
ระบบจะสร้างไฟล์ CNAME ใน repo ของคุณอัตโนมัติ
🇬🇧 English
- Go to your repo → Settings → Pages
- Under Custom domain, type your domain (e.g.,
www.mysite.com) - Click Save
- Check Enforce HTTPS (you may need to wait for DNS to propagate first)
This creates a CNAME file in your repo automatically.
Part 3: Set Up Cloudflare (Optional) — ตั้งค่า Cloudflare
🇹🇭 ภาษาไทย
ไม่มี custom domain? ข้ามส่วนนี้ทั้งหมด GitHub Pages ให้ HTTPS ฟรีและ
🇬🇧 English
No custom domain? Skip this entire section. GitHub Pages already provides free HTTPS and hosting. Cloudflare adds CDN speed, DDoS protection, and DNS management — but only makes sense if you have your own domain.
7 Add Your Site to Cloudflare — เพิ่มเว็บไซต์ใน Cloudflare
🇹🇭 ภาษาไทย
- เข้าสู่ระบบที่ cloudflare.com
- กด Add a site
- ใส่ชื่อ
domain ของคุณ (เช่นmysite.com) - เลือกแผน Free แล้วกด Continue
- Cloudflare จะสแกน
DNS records ที่มีอยู่ ตรวจสอบแล้วกด Continue
🇬🇧 English
- Log in to cloudflare.com
- Click Add a site
- Enter your domain name (e.g.,
mysite.com) - Select the Free plan and click Continue
- Cloudflare will scan your existing DNS records. Review them and click Continue.
8 Change Your Nameservers — เปลี่ยน Nameservers
🇹🇭 ภาษาไทย
Cloudflare จะให้
ไปที่
🇬🇧 English
Cloudflare will give you two nameservers like:
Go to your domain registrar (where you bought the domain) and replace the existing nameservers with Cloudflare's. This tells the internet "Cloudflare manages DNS for this domain."
Nameserver Propagation — การแพร่กระจาย Nameserver
อาจใช้เวลา สูงสุด 24 ชั่วโมง แต่ปกติจะเสร็จใน 1-2 ชั่วโมง Cloudflare จะส่งอีเมลเมื่อเปิดใช้งานแล้ว
This can take up to 24 hours but usually works within 1-2 hours. Cloudflare will email you when it's active.
9 Configure DNS Records — ตั้งค่าระเบียน DNS
🇹🇭 ภาษาไทย
ในแดชบอร์ด Cloudflare ไปที่ DNS → Records เพิ่มหรือแก้ไข records เหล่านี้:
🇬🇧 English
In your Cloudflare dashboard, go to DNS → Records. Add or edit these records:
| Type | Name | Content | Proxy |
|---|---|---|---|
| CNAME | www | YOUR-USERNAME.github.io | Proxied (orange cloud) |
| CNAME | @ | YOUR-USERNAME.github.io | Proxied (orange cloud) |
"Proxied" คืออะไร? — What Does "Proxied" Mean?
เมื่อเปิดคลาวด์สีส้ม ทราฟฟิกจะผ่านเครือข่าย Cloudflare ซึ่งให้
When the orange cloud is on, traffic goes through Cloudflare's network. This gives you CDN caching, DDoS protection, and SSL. Always keep it proxied for your website.
🇹🇭 ทางเลือก: ใช้ A records
บางการตั้งค่าใช้ A records ชี้ไปยัง IP ของ GitHub แทน:
🇬🇧 Alternative: A records
Some setups prefer A records pointing to GitHub's IPs:
CNAME flattening (both as CNAME) works well on Cloudflare. On other DNS providers, you'd need A records for the root domain.
10 Configure SSL/TLS — ตั้งค่า SSL/TLS
🇹🇭 ภาษาไทย
ในแดชบอร์ด Cloudflare:
- ไปที่ SSL/TLS → Overview
- ตั้ง
encryption mode เป็น Full
🇬🇧 English
In your Cloudflare dashboard:
- Go to SSL/TLS → Overview
- Set the encryption mode to Full
| Mode / โหมด | What It Does / ทำอะไร | Use When / ใช้เมื่อ |
|---|---|---|
| Off | ไม่มีการเข้ารหัส — No encryption | อย่าใช้ — Never |
| Flexible | HTTPS ถึง Cloudflare, HTTP ถึง GitHub | หลีกเลี่ยง — เกิด redirect loop |
| Full | HTTPS ทั้งหมด — HTTPS everywhere | ใช้อันนี้สำหรับ GitHub Pages |
| Full (Strict) | HTTPS + ตรวจสอบ certificate | ดีที่สุดเมื่อ GitHub ออก cert แล้ว |
Common Mistake: "Too Many Redirects" — ข้อผิดพลาดที่พบบ่อย
ถ้าเห็นข้อผิดพลาด
If you see a redirect loop error, your SSL mode is probably set to Flexible. Change it to Full.
11 Recommended Settings — ค่าแนะนำ
| Setting / การตั้งค่า | Where / ที่ไหน | Value / ค่า | Why / ทำไม |
|---|---|---|---|
| SSL/TLS → Edge Certificates | On | เปลี่ยน HTTP เป็น HTTPS อัตโนมัติ | |
| Speed → Optimization | HTML, CSS, JS | ลดขนาดไฟล์ให้โหลดเร็วขึ้น | |
| Speed → Optimization | On | บีบอัดดีกว่า gzip | |
| Caching → Configuration | 1 month | ผู้เยี่ยมชมที่กลับมาโหลดเร็วขึ้น | |
| Security → Settings | Medium | บล็อกทราฟฟิกอันตราย | |
| Security → Bots | On | บล็อกบอทอันตราย |
เว็บไซต์อยู่หลังเครือข่าย Cloudflare แล้ว!
Your site is now behind Cloudflare's global network!
ผู้เยี่ยมชมจะได้รับบริการจาก Cloudflare data center ที่ใกล้ที่สุด (300+ เมืองทั่วโลก) พร้อมการป้องกัน DDoS และ SSL — ฟรีทั้งหมด
Cloudflare Phrases — วลี Cloudflare
Updating Your Website — อัปเดตเว็บไซต์
🇹🇭 ภาษาไทย
ทุกครั้งที่คุณ
🇬🇧 English
Every time you push changes to your GitHub repo, your site updates automatically:
Option A: Through GitHub Website — ผ่านเว็บไซต์ GitHub
🇹🇭 ภาษาไทย
- ไปที่ repo บน GitHub
- กดไฟล์ที่ต้องการแก้ไข
- กดไอคอนดินสอ (
Edit ) - ทำการเปลี่ยนแปลง
- กด Commit changes
- รอ 1-2 นาที — เว็บอัปเดตอัตโนมัติ
🇬🇧 English
- Go to your repo on GitHub
- Click on the file you want to edit
- Click the pencil icon (Edit)
- Make your changes
- Click Commit changes
- Wait 1-2 minutes — the site updates automatically
Option B: Using Git (Command Line) — ใช้ Git (Command Line)
Cloudflare Cache — แคชของ Cloudflare
หลังจาก push การเปลี่ยนแปลง เว็บจะอัปเดตบน GitHub ภายในไม่กี่นาที แต่ Cloudflare อาจส่งเวอร์ชันที่
After pushing changes, Cloudflare might serve a cached version. If you need changes to appear immediately:
- ไปที่ Cloudflare dashboard → Caching → Configuration
- กด
Purge Everything
Troubleshooting — การแก้ปัญหา
| Problem / ปัญหา | Cause / สาเหตุ | Fix / วิธีแก้ |
|---|---|---|
| Site shows | ไม่มี index.html หรือไม่ได้เปิด Pages | ตรวจสอบ Settings → Pages และไฟล์ index.html |
| "Too Many | Cloudflare SSL ตั้งเป็น Flexible | เปลี่ยน SSL mode เป็น Full |
| Custom domain ไม่ทำงาน | DNS ยังไม่ | รอสูงสุด 24 ชั่วโมง ตรวจสอบด้วย DNS checker |
| HTTPS ไม่ทำงาน | รอ 15-30 นาทีหลัง DNS propagation แล้วเปิด Enforce HTTPS | |
| เนื้อหาเก่าแสดงอยู่ | Cloudflare | ล้างแคชในแดชบอร์ด Cloudflare หรือรอ TTL หมดอายุ |
| CSS/JS ไม่โหลด | ใช้ relative paths (./style.css) และตรวจสอบว่าใช้ HTTPS ทั้งหมด |
Troubleshooting Phrases — วลีการแก้ปัญหา
Free Tier Limits — ขีดจำกัดแผนฟรี
| Service / บริการ | Free Limit / ขีดจำกัดฟรี | Plenty For / เพียงพอสำหรับ |
|---|---|---|
| GitHub Pages | 1 GB | เว็บไซต์ส่วนตัวและธุรกิจขนาดเล็กส่วนใหญ่ |
| GitHub Pages | 10 | การทำงานพัฒนาปกติ |
| Cloudflare CDN | ทราฟฟิกทุกระดับ | |
| Cloudflare SSL | Free universal | HTTPS เต็มรูปแบบสำหรับโดเมนของคุณ |
| Cloudflare DNS | Unlimited | ทราฟฟิกทุกระดับ |
| Cloudflare Workers | 100,000 |
When Do You Need to Pay? — เมื่อไหร่ต้องจ่ายเงิน?
สำหรับเว็บไซต์ส่วนตัว พอร์ตโฟลิโอ และธุรกิจขนาดเล็กส่วนใหญ่ แผนฟรีเพียงพอมากๆ ต้องอัปเกรดก็ต่อเมื่อ:
For most personal sites, portfolios, and small businesses, the free tier is more than enough. You'd only need to upgrade if you:
- ต้องการ
private repositories กับ GitHub Pages (GitHub Pro: $4/month) - ต้องการฟีเจอร์ Cloudflare ขั้นสูง เช่น custom
firewall rules - ต้องการ
server-side rendering หรือdatabases - ใช้เกิน 100 GB/month bandwidth บน GitHub Pages (ไม่ค่อยเกิดขึ้นกับเว็บ static)
Part 4: Accept Payments with Stripe — รับชำระเงินด้วย Stripe
🇹🇭 ภาษาไทย
เว็บไซต์แบบ
🇬🇧 English
Static websites can't run server-side code, but you can still accept payments using Stripe.js + Stripe Checkout. Stripe handles all the server-side processing — your website just redirects customers to Stripe's secure hosted checkout page. No backend needed.
Stripe Checkout Flow — ขั้นตอนการชำระเงิน
clicks "Buy Now" — กดปุ่ม "ซื้อเลย"
Stripe.js redirects to checkout — เปลี่ยนเส้นทางไปหน้าชำระเงิน
hosted payment page — หน้าชำระเงินที่ Stripe โฮสต์
Stripe handles everything — Stripe จัดการทุกอย่าง
customer returns to your site — ลูกค้ากลับมาที่เว็บไซต์
1 Create a Stripe Account — สร้างบัญชี Stripe
🇹🇭 ภาษาไทย
- ไปที่ stripe.com แล้วสมัครบัญชี (ฟรี)
- Stripe เก็บค่าธรรมเนียมเฉพาะเมื่อคุณรับเงินได้ (2.9% + $0.30 ต่อรายการ)
- คุณจะได้
test API keys ทันทีเพื่อทดสอบก่อนเปิดใช้งานจริง
🇬🇧 English
- Go to stripe.com and sign up (free)
- Stripe only charges fees when you receive payments (2.9% + $0.30 per transaction)
- You'll get test API keys immediately to test before going live
2 Create a Product in Stripe Dashboard — สร้างสินค้าในแดชบอร์ด Stripe
🇹🇭 ภาษาไทย
- เข้าสู่ระบบ Stripe Dashboard
- ไปที่ Products → Add product
- ตั้งชื่อ ราคา และคำอธิบาย
product - เลือกแบบชำระครั้งเดียว (
one-time ) หรือsubscription - คัดลอก
Price ID (เริ่มต้นด้วยprice_)
🇬🇧 English
- Log in to Stripe Dashboard
- Go to Products → Add product
- Set the name, price, and description for your product
- Choose one-time payment or subscription
- Copy the Price ID (starts with
price_)
3 Add Stripe.js to Your Page — เพิ่ม Stripe.js ในหน้าเว็บ
🇹🇭 ภาษาไทย
เพิ่ม <head> ของหน้า HTML:
🇬🇧 English
Add the Stripe script tag to the <head> of your HTML page:
4 Create a Buy Button — สร้างปุ่มซื้อ
🇹🇭 ภาษาไทย
เพิ่มปุ่มในหน้าเว็บของคุณแล้วเชื่อมต่อกับ
🇬🇧 English
Add a button to your page and connect it to Stripe Checkout:
API Keys — คีย์ API
pk_) ปลอดภัยที่จะใช้ในโค้ด
sk_) ห้ามใส่ในเว็บไซต์เด็ดขาด! — ใช้ฝั่งเซิร์ฟเวอร์เท่านั้น
The publishable key (pk_) is safe for client-side code. The secret key (sk_) must NEVER be in your website code — it's server-side only.
5 Create Success and Cancel Pages — สร้างหน้าสำเร็จและยกเลิก
🇹🇭 ภาษาไทย
สร้างไฟล์ success.html ที่แสดงข้อความขอบคุณหลังชำระเงินสำเร็จ:
🇬🇧 English
Create a success.html file that shows a thank-you message after successful payment:
6 Test with Stripe Test Mode — ทดสอบด้วยโหมดทดสอบ
🇹🇭 ภาษาไทย
ก่อนเปิดใช้งานจริง ให้ทดสอบด้วย
- ใช้
test keys (pk_test_) ใน JavaScript - ใช้หมายเลขบัตรทดสอบ:
4242 4242 4242 4242 - วันหมดอายุ: อนาคตใดก็ได้ CVC: ตัวเลข 3 ตัวใดก็ได้
- ตรวจสอบ
payments ในแดชบอร์ด Stripe
🇬🇧 English
Before going live, test with test mode:
- Use test keys (
pk_test_) in your JavaScript - Use test card number:
4242 4242 4242 4242 - Expiry: any future date. CVC: any 3 digits
- Check payments in Stripe Dashboard
Going Live — เปิดใช้งานจริง
เมื่อพร้อมรับเงินจริง เปลี่ยน pk_test_ เป็น pk_live_ ใน JavaScript และเปลี่ยน price_ ID เป็นสินค้าจริง
When ready to accept real money, swap pk_test_ for pk_live_ in your JavaScript and use your live product's price_ ID.
What Stripe Handles for You — สิ่งที่ Stripe จัดการให้
PCI compliance — คุณไม่ต้องจัดการข้อมูลบัตรเครดิตเลย — You never touch credit card dataReceipts — ส่งอีเมลใบเสร็จอัตโนมัติ — Automatic email receiptsFraud prevention — ตรวจจับรายการที่น่าสงสัย — Built-in fraud detectionMulti-currency — รองรับ 135+ สกุลเงิน — Supports 135+ currenciesMobile optimization — หน้าชำระเงินรองรับมือถือ — Checkout works on all devices
Payment Phrases — วลีเกี่ยวกับการชำระเงิน
Your static site can now accept payments!
เว็บไซต์ static ของคุณรับชำระเงินได้แล้ว!
No server, no backend, no monthly hosting fees — just Stripe's 2.9% + $0.30 per transaction.
Part 5: Advanced — Stripe + Cloudflare Workers
🇹🇭 ภาษาไทย
Stripe Checkout (Part 4) ทำงานได้ดีสำหรับปุ่มซื้อแบบง่าย แต่ถ้าคุณต้องการ
🇬🇧 English
Stripe Checkout (Part 4) works great for simple buy buttons. But if you need custom logic — like coupon codes, dynamic pricing, or processing webhooks — you need server-side code. Cloudflare Workers gives you free serverless functions (100,000 requests/day) that work with the Cloudflare setup you already have!
Workers + Stripe Flow — ขั้นตอน Workers + Stripe
clicks "Buy Now" — กดปุ่ม "ซื้อเลย"
calls Worker API — เรียก API ของ Worker
creates Stripe session (server-side) — สร้าง session ฝั่งเซิร์ฟเวอร์
checkout.sessions.create — สร้างเซสชันชำระเงิน
customer redirected — ลูกค้าถูกเปลี่ยนเส้นทาง
1 Install Wrangler CLI — ติดตั้ง Wrangler CLI
🇹🇭 ภาษาไทย
🇬🇧 English
Wrangler is Cloudflare's CLI tool for building and deploying Workers:
2 Write the Worker — เขียน Worker
🇹🇭 ภาษาไทย
แก้ไขไฟล์ src/index.js — Worker นี้สร้าง Stripe
🇬🇧 English
Edit src/index.js — this Worker creates a Stripe Checkout Session server-side (safe to use the secret key here):
3 Add Your Secret Key — เพิ่ม Secret Key
🇹🇭 ภาษาไทย
ใช้ Wrangler เพื่อเก็บ Stripe
🇬🇧 English
Use Wrangler to securely store your Stripe secret key as an environment variable:
Why This Is Secure — ทำไมถึงปลอดภัย
env.STRIPE_SECRET_KEY ใน Worker เท่านั้น
Secret keys are stored as encrypted secrets in Cloudflare — not in your code or Git repo. Only accessible via env.STRIPE_SECRET_KEY inside the Worker.
4 Deploy and Connect — ดีพลอยและเชื่อมต่อ
🇹🇭 ภาษาไทย
Deploy Worker ของคุณ:
🇬🇧 English
- Deploy your Worker:
จากนั้นอัปเดตปุ่มซื้อในเว็บไซต์ให้เรียก Worker แทน: / Then update your site's buy button to call the Worker instead:
Why Workers over Stripe.js Checkout? — ทำไมต้อง Workers?
| Feature / ฟีเจอร์ | Stripe.js (Part 4) | Workers (Part 5) |
|---|---|---|
| Difficulty / ความยาก | Easy — ง่าย | Medium — ปานกลาง |
| Server needed / ต้องมีเซิร์ฟเวอร์ | No | Cloudflare Workers (free) |
| Limited | Full control — ควบคุมได้เต็มที่ | |
| No | Yes | |
| No | Yes — Workers can receive them | |
| Secret key exposure | Not needed | Stored securely in Workers |
| Cost / ค่าใช้จ่าย | Free + Stripe fees | Free (100k req/day) + Stripe fees |
Use Part 4 for simple buy buttons. Use Part 5 when you need server-side control.
ใช้ Part 4 สำหรับปุ่มซื้อแบบง่าย ใช้ Part 5 เมื่อต้องการควบคุมฝั่งเซิร์ฟเวอร์
Workers Phrases — วลี Workers
Part 6: QR Code Payments — การชำระเงินด้วย QR Code
🇹🇭 ภาษาไทย
🇬🇧 English
QR codes make accepting payments incredibly easy — customers just scan with their phone and pay instantly. There are two main approaches: Stripe Payment Links (for worldwide credit card payments) and PromptPay QR (for domestic Thai bank transfers).
How QR Scan Payments Work — QR ชำระเงินทำงานอย่างไร
Stripe Payment Link QR:
เว็บแสดง QR code
สแกนด้วยกล้องโทรศัพท์
กรอกบัตรแล้วจ่าย
PromptPay QR (Thailand):
เว็บแสดง QR พร้อมเพย์
สแกนด้วยแอปธนาคาร
โอนทันที ฟรี!
QR Code = URL in a Picture — QR Code = URL ในรูปภาพ
QR code คือ URL ที่เข้ารหัสเป็นรูปภาพ เมื่อลูกค้า
A QR code is a URL encoded as an image. When customers scan it with their phone, it opens that URL — for Stripe it opens a checkout page, for PromptPay it opens the banking app with transfer details pre-filled.
Method A: Stripe Payment Link QR — QR จาก Stripe Payment Link
🇹🇭 ภาษาไทย
Stripe
🇬🇧 English
Stripe Payment Links create a payment URL with zero code. Convert that URL into a QR code and customers can scan to pay with credit card instantly.
1 Create a Payment Link — สร้าง Payment Link
🇹🇭 ภาษาไทย
- ไปที่ Stripe Dashboard → Payment Links
- กด Create payment link
- เลือก
product และตั้งราคา - กด Create link
- คัดลอก URL เช่น
https://buy.stripe.com/abc123
🇬🇧 English
- Go to Stripe Dashboard → Payment Links
- Click Create payment link
- Select your product and set the price
- Click Create link
- Copy the URL, e.g.,
https://buy.stripe.com/abc123
2 Generate a QR Code — สร้าง QR Code
🇹🇭 ภาษาไทย
ใช้
🇬🇧 English
Use the QRCode.js library to generate QR codes directly in your webpage. No server needed — it runs entirely in the browser:
No Code Alternative — ทางเลือกไม่ต้องเขียนโค้ด
ถ้าไม่อยากเขียนโค้ด Stripe Dashboard มีปุ่มดาวน์โหลด QR code ให้เลยตรง Payment Link — ดาวน์โหลดเป็นรูปภาพแล้วใส่ในเว็บไซต์ด้วย <img> tag
If you don't want to code, the Stripe Dashboard has a QR code download button right on the Payment Link page — download the image and add it to your site with an <img> tag.
Method B: PromptPay QR — QR พร้อมเพย์ (ประเทศไทย)
🇹🇭 ภาษาไทย
🇬🇧 English
PromptPay is Thailand's national money transfer system. Anyone with a Thai banking app can scan a PromptPay QR code to transfer money instantly — with zero fees! Perfect for selling within Thailand.
1 Generate PromptPay QR in JavaScript — สร้าง QR พร้อมเพย์ด้วย JavaScript
🇹🇭 ภาษาไทย
ใช้
🇬🇧 English
Use the promptpay-qr library to generate a valid PromptPay QR code following the Bank of Thailand's EMVCo standard:
PromptPay ID Options — ตัวเลือก PromptPay ID
| ID Type / ประเภท | Format / รูปแบบ | Example / ตัวอย่าง |
|---|---|---|
| 10 digits | 0812345678 | |
| 13 digits | 1234567890123 | |
| 13 digits | 0123456789012 | |
| 15 digits | 012345678901234 |
2 Dynamic Amount Input — ใส่จำนวนเงินแบบไดนามิก
🇹🇭 ภาษาไทย
ให้ลูกค้ากรอกจำนวนเงินเอง แล้วสร้าง QR code ใหม่ทันที:
🇬🇧 English
Let customers enter their own amount and generate a fresh QR code instantly:
Stripe QR vs PromptPay QR — เปรียบเทียบ
| Feature / ฟีเจอร์ | Stripe Payment Link QR | PromptPay QR |
|---|---|---|
| Payment method / วิธีชำระ | Credit/debit cards worldwide | Thai bank transfer — โอนผ่านธนาคารไทย |
| Fees / ค่าธรรมเนียม | 2.9% + $0.30 | Free — ฟรี |
| Coverage / ครอบคลุม | Global — ทั่วโลก | Thailand only — ประเทศไทยเท่านั้น |
| Automatic via Stripe — อัตโนมัติ | Manual check — ต้องตรวจสอบเอง | |
| Server needed / ต้องมีเซิร์ฟเวอร์ | No | No |
| Best for / เหมาะสำหรับ | International customers | Thai customers — ลูกค้าคนไทย |
Use both! Show PromptPay for Thai customers and Stripe for international ones.
ใช้ทั้งสองอย่าง! แสดง PromptPay สำหรับลูกค้าคนไทย และ Stripe สำหรับลูกค้าต่างชาติ
Print Your QR Code — พิมพ์ QR Code ของคุณ
QR codes ไม่ได้ใช้แค่ในเว็บไซต์เท่านั้น — พิมพ์ลงบนนามบัตร ใบปลิว เมนูอาหาร หรือป้ายร้าน ลูกค้าสแกนแล้วจ่ายเงินได้ทันที!
QR codes aren't just for websites — print them on business cards, flyers, restaurant menus, or shop signs. Customers scan and pay instantly!
QR Payment Phrases — วลี QR ชำระเงิน
Glossary — อภิธานศัพท์
🇹🇭 ภาษาไทย
คำศัพท์สำคัญทั้งหมดในบทเรียนนี้ กดคำภาษาอังกฤษเพื่อฟังการออกเสียง
🇬🇧 English
All key terms from this tutorial. Click the English terms to hear pronunciation.
ที่เก็บไฟล์โปรเจกต์บน GitHub เหมือนโฟลเดอร์ในคลาวด์สำหรับโค้ดของคุณ
การทำให้เว็บไซต์ใช้งานได้บนอินเทอร์เน็ต เมื่อดีพลอย โค้ดของคุณจะออนไลน์
บริการที่เก็บไฟล์เว็บไซต์และส่งให้ผู้เยี่ยมชม GitHub Pages เป็นโฮสติ้งฟรี
ที่อยู่ที่คนพิมพ์เพื่อเข้าเว็บไซต์ (เช่น mysite.com) ซื้อได้หรือใช้ที่อยู่ github.io ฟรี
แปลงชื่อโดเมน (mysite.com) เป็นที่อยู่ IP ที่คอมพิวเตอร์เข้าใจ เหมือนสมุดโทรศัพท์ของอินเทอร์เน็ต
เครือข่ายเซิร์ฟเวอร์ทั่วโลกที่แคชเว็บไซต์ของคุณ ผู้เยี่ยมชมจะได้รับบริการจากตำแหน่งที่ใกล้ที่สุด
การเข้ารหัสที่ทำให้เว็บไซต์ใช้ HTTPS (ไอคอนแม่กุญแจ) ป้องกันข้อมูลระหว่างผู้เยี่ยมชมกับเว็บไซต์
เวอร์ชันปลอดภัยของ HTTP เว็บที่มี HTTPS แสดงแม่กุญแจในเบราว์เซอร์ จำเป็นสำหรับเบราว์เซอร์สมัยใหม่
เว็บไซต์ที่ทำจากไฟล์ HTML, CSS และ JavaScript คงที่ ไม่มีการประมวลผลฝั่งเซิร์ฟเวอร์ เร็วและโฮสต์ฟรีได้ง่าย
การบันทึกชุดการเปลี่ยนแปลงไปยัง repository เหมือนกด "บันทึก" แต่มีคำอธิบายว่าเปลี่ยนอะไร
การอัปโหลดคอมมิตในเครื่องไปยัง GitHub หลังจากพุช การเปลี่ยนแปลงจะอยู่บน GitHub และเว็บไซต์อัปเดต
สำเนาแยกของโค้ดสำหรับทำการเปลี่ยนแปลงโดยไม่กระทบเวอร์ชันหลัก ค่าเริ่มต้นเรียกว่า "main"
เซิร์ฟเวอร์ที่บอกอินเทอร์เน็ตว่าจะหาโดเมนของคุณได้ที่ไหน การเปลี่ยนเป็นของ Cloudflare ให้พวกเขาจัดการ DNS
สำเนาที่เก็บไว้ของไฟล์เว็บไซต์ แคช CDN ส่งเนื้อหาเร็วกว่าเพราะข้อมูลอยู่ใกล้แล้ว
การโจมตีที่ท่วมเว็บไซต์ด้วยทราฟฟิกปลอมเพื่อทำให้ออฟไลน์ แผนฟรีของ Cloudflare รวมการป้องกัน DDoS
ปริมาณข้อมูลที่ส่งระหว่างเว็บไซต์กับผู้เยี่ยมชม ผู้เยี่ยมชมยิ่งมาก = ใช้แบนด์วิดท์ยิ่งมาก
เวลาที่การเปลี่ยนแปลง DNS ใช้ในการแพร่กระจายทั่วอินเทอร์เน็ต ปกติ 1-24 ชั่วโมงหลังเปลี่ยน nameservers
บริษัทที่คุณซื้อชื่อโดเมน ตัวอย่าง: Cloudflare Registrar, Namecheap, Porkbun
แพลตฟอร์มประมวลผลการชำระเงินที่ให้คุณรับบัตรเครดิตบนเว็บไซต์ ใช้งานกับเว็บ static ได้ผ่าน Stripe Checkout
หน้าชำระเงินสำเร็จรูปที่ Stripe โฮสต์ให้ เว็บไซต์ของคุณเปลี่ยนเส้นทางลูกค้าไปที่นั่น — ไม่ต้องมีเซิร์ฟเวอร์
รหัสลับที่ยืนยันตัวตนแอปของคุณกับบริการ Stripe มีคีย์เผยแพร่ได้ (ปลอดภัยในเบราว์เซอร์) และคีย์ลับ (ฝั่งเซิร์ฟเวอร์เท่านั้น)
โค้ดที่รันบนคลาวด์โดยไม่ต้องจัดการเซิร์ฟเวอร์ Cloudflare Workers ให้ 100,000 requests ฟรีต่อวัน
การแจ้งเตือนอัตโนมัติที่ส่งจากบริการหนึ่งไปอีกบริการเมื่อเกิดเหตุการณ์ Stripe ส่ง webhooks เมื่อชำระเงินสำเร็จหรือล้มเหลว
มาตรฐานความปลอดภัยสำหรับจัดการข้อมูลบัตรเครดิต Stripe Checkout จัดการ PCI compliance ให้ — คุณไม่ต้องสัมผัสหมายเลขบัตร
ค่าการตั้งค่าที่เก็บนอกโค้ด ใช้เพื่อเก็บความลับเช่น API keys อย่างปลอดภัย ตั้งค่าผ่าน Wrangler สำหรับ Cloudflare Workers
บาร์โค้ดสี่เหลี่ยมที่เก็บข้อมูลเช่น URL หรือข้อมูลการชำระเงิน โทรศัพท์สแกน QR code ด้วยกล้องเพื่อเปิดลิงก์หรือชำระเงิน
ระบบโอนเงินทันทีของประเทศไทย เชื่อมกับหมายเลขโทรศัพท์หรือบัตรประชาชน ใช้ฟรี รองรับทุกธนาคารไทย
URL ที่สร้างโดย Stripe เปิดหน้าชำระเงินที่โฮสต์ไว้ ไม่ต้องเขียนโค้ด — แค่แชร์ลิงก์หรือแปลงเป็น QR code
มาตรฐานสากลสำหรับการชำระเงินด้วย QR code พร้อมเพย์ใช้รูปแบบ EMVCo ทำให้แอปธนาคารไทยทุกแอปอ่านได้