AI Powered SaaS: Stripe + Auth + Billing + Deploy · บทเรียน

บัญชี Stripe และคีย์ API

ตั้งค่าบัญชีนักพัฒนา Stripe และกำหนดค่าคีย์ API สำหรับแอปพลิเคชันอย่างปลอดภัย

บทเรียน 1 จาก 411 ขั้นตอน

บัญชี Stripe และคีย์ API เป็นบทเรียน AI Powered SaaS: Stripe + Auth + Billing + Deploy ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน AI Powered SaaS: Stripe + Auth + Billing + Deploy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส AI Powered SaaS: Stripe + Auth + Billing + Deploy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Welcome to Stripe Payments

Welcome to the world of secure online payments! In this lesson, we'll kickstart our journey by setting up your Stripe developer account and understanding the essential API keys.

Stripe is a powerful platform that allows businesses to accept payments over the internet. It handles everything from processing credit cards to managing subscriptions, making it a cornerstone for many SaaS applications.

Signing Up for Stripe

Before we can integrate Stripe into our application, we need an account. It's free to sign up and explore the developer features.

  • Visit the official Stripe website.
  • Click on 'Sign Up' or 'Start now'.
  • Provide your email, name, and create a password.
  • Confirm your email address.

Once registered, you'll gain access to the Stripe Dashboard, which is your central hub for managing payments and configurations.

Navigating Your Dashboard

The Stripe Dashboard is where you'll manage your payment operations. Take a moment to familiarize yourself with its layout.

Key areas include:

  • Home: An overview of your recent activity and balance.
  • Payments: View and manage all transactions.
  • Customers: Manage your customer profiles.
  • Developers: Access API keys, webhooks, and logs (this is where we'll spend a lot of time!).

You can switch between 'Test mode' and 'Live mode' easily, which is crucial for development.

Understanding API Keys

API keys are like digital passwords that allow your application to securely communicate with Stripe's services. They tell Stripe who is making the request and grant permission to perform actions like creating charges or managing customers.

Stripe uses two main types of API keys:

  • Publishable keys
  • Secret keys

Each serves a distinct purpose and has different security requirements.

Publishable vs. Secret Keys

It's vital to understand the difference between these two key types:

  • Publishable Key (e.g., pk_test_...): This key is safe to embed in your client-side code (e.g., JavaScript in your website or mobile app). It's used to collect payment information securely and create tokens. It cannot be used to make charges directly.
  • Secret Key (e.g., sk_test_...): This key must NEVER be exposed in client-side code. It grants full access to your Stripe account's API and can be used to create charges, process refunds, and manage subscriptions. It should only be used on your server.

Locating Your API Keys

You can find your API keys in the Stripe Dashboard:

  1. Log in to your Stripe account.
  2. Navigate to the 'Developers' section in the left sidebar.
  3. Click on 'API keys'.

Here you'll see both your 'Publishable key' and 'Secret key' for both test and live modes. You can also generate new secret keys or revoke existing ones for security reasons.

Test Mode & Live Mode

Stripe provides two environments: 'Test mode' and 'Live mode'.

  • Test Mode: Use test API keys to simulate transactions without moving real money. This is perfect for development and debugging.
  • Live Mode: Use live API keys to process actual payments with real customers.

Always ensure you're using the correct keys for the environment you're working in. You can toggle between modes in the Dashboard and your API requests.

API Key Security Best Practices

Protecting your secret keys is paramount to prevent unauthorized access to your Stripe account.

  • Never hardcode secret keys: Store them as environment variables or in a secure configuration service.
  • Do not commit to version control: Exclude configuration files containing secret keys from Git repositories (e.g., using .gitignore).
  • Rotate keys regularly: Periodically generate new secret keys and update them in your application.
  • Restrict access: Limit who has access to your production secret keys.

Loading Keys in Your App

Here's a simple Python example showing how your application might load Stripe API keys securely from environment variables. This keeps sensitive information out of your codebase.

import os

# In a real application, these keys
# would be loaded from environment variables
# or a secure configuration management system.

# Attempt to get the publishable key
stripe_publishable_key = os.getenv("STRIPE_PUBLISHABLE_KEY")

# Attempt to get the secret key
stripe_secret_key = os.getenv("STRIPE_SECRET_KEY")

print("Stripe Key Loading Status:")
if stripe_publishable_key:
    print("  Publishable key detected.")
else:
    print("  Publishable key NOT found!")

if stripe_secret_key:
    print("  Secret key detected.")
else:
    print("  Secret key NOT found!")

Quick Key Knowledge Check

You're building a checkout page for your SaaS app. Which type of Stripe API key should you use directly in your client-side JavaScript code to securely collect payment details?

Recap: Account & Keys

In this lesson, we've laid the groundwork for integrating Stripe. You learned how to:

  • Set up your free Stripe developer account.
  • Navigate the essential parts of the Stripe Dashboard.
  • Distinguish between Publishable and Secret API keys.
  • Locate your keys and understand 'Test' vs. 'Live' modes.
  • Implement crucial security practices for handling API keys.

Understanding these fundamentals is key to building a secure and functional payment system. Next, we'll dive into defining products and prices!

เริ่มต้นได้ฟรี

เรียนรู้ AI Powered SaaS: Stripe + Auth + Billing + Deploy ด้วย AI tutor — ฟรี

เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป

คอร์ส
12
บทเรียน
48

คำถามที่พบบ่อย

บทเรียน “บัญชี Stripe และคีย์ API” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “บัญชี Stripe และคีย์ API” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส AI Powered SaaS: Stripe + Auth + Billing + Deploy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส AI Powered SaaS: Stripe + Auth + Billing + Deploy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “บัญชี Stripe และคีย์ API”

ตั้งค่าบัญชีนักพัฒนา Stripe และกำหนดค่าคีย์ API สำหรับแอปพลิเคชันอย่างปลอดภัย คุณปฏิบัติ AI Powered SaaS: Stripe + Auth + Billing + Deploy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน AI Powered SaaS: Stripe + Auth + Billing + Deploy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน AI Powered SaaS: Stripe + Auth + Billing + Deploy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน

บทเรียน “บัญชี Stripe และคีย์ API” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน AI Powered SaaS: Stripe + Auth + Billing + Deploy นี้ได้ไหม

ได้ บทเรียน AI Powered SaaS: Stripe + Auth + Billing + Deploy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. บัญชี Stripe และคีย์ API
  2. การสร้างผลิตภัณฑ์และราคา
  3. การนำเซสชันชำระเงินมาใช้
  4. การจัดการเงินคืนและข้อพิพาท
← กลับไปที่ AI Powered SaaS: Stripe + Auth + Billing + Deploy