Site icon บริษัท โค๊ดบี จำกัด

Stripe Webhook รวม Event พื้นฐานที่จำเป็น

&NewLine;<h2 class&equals;"wp-block-heading">Stripe Webhook&colon; ทำความเข้าใจและรวม Event ที่ควรใช้<&sol;h2>&NewLine;&NewLine;&NewLine;&NewLine;<h3 class&equals;"wp-block-heading">Stripe Webhook คืออะไร&quest;<&sol;h3>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph"><strong>Webhook<&sol;strong> คือกลไกที่ Stripe ใช้ในการแจ้งเตือนระบบของคุณเมื่อมีเหตุการณ์บางอย่างเกิดขึ้นในบัญชี Stripe ของคุณ เช่น มีการชำระเงินสำเร็จ&comma; การยกเลิกการสมัครสมาชิก&comma; หรือการคืนเงิน ฯลฯ<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">Webhook จะช่วยให้ระบบของคุณ <strong>ตอบสนองแบบอัตโนมัติ<&sol;strong> ต่อเหตุการณ์เหล่านี้โดยไม่ต้องเรียก API ตลอดเวลา ทำให้ระบบทันสมัยและมีประสิทธิภาพมากขึ้น<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<hr class&equals;"wp-block-separator has-alpha-channel-opacity"&sol;>&NewLine;&NewLine;&NewLine;&NewLine;<h2 class&equals;"wp-block-heading">การใช้งาน Stripe Webhook เบื้องต้น<&sol;h2>&NewLine;&NewLine;&NewLine;&NewLine;<ol class&equals;"wp-block-list">&NewLine;<li><strong>กำหนด Endpoint<&sol;strong> บนฝั่งเซิร์ฟเวอร์ของคุณ เช่น <code>https&colon;&sol;&sol;yourdomain&period;com&sol;webhook<&sol;code><&sol;li>&NewLine;&NewLine;&NewLine;&NewLine;<li>ไปที่ <strong>Stripe Dashboard<&sol;strong> &srarr; <strong>Developers > Webhooks<&sol;strong><&sol;li>&NewLine;&NewLine;&NewLine;&NewLine;<li>เพิ่ม Endpoint แล้วเลือก <strong>Event<&sol;strong> ที่ต้องการให้ Stripe แจ้ง<&sol;li>&NewLine;&NewLine;&NewLine;&NewLine;<li>ตรวจสอบ <code>signature<&sol;code> เพื่อความปลอดภัย &lpar;Stripe จะส่ง <code>Stripe-Signature<&sol;code> header มาให้&rpar;<&sol;li>&NewLine;<&sol;ol>&NewLine;&NewLine;&NewLine;&NewLine;<hr class&equals;"wp-block-separator has-alpha-channel-opacity"&sol;>&NewLine;&NewLine;&NewLine;&NewLine;<h2 class&equals;"wp-block-heading">Event ที่ควรตั้งรับใน Stripe Webhook<&sol;h2>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">นี่คือ Event สำคัญที่ควรใช้สำหรับระบบทั่วไป โดยแบ่งตามหมวด&colon;<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<hr class&equals;"wp-block-separator has-alpha-channel-opacity"&sol;>&NewLine;&NewLine;&NewLine;&NewLine;<h3 class&equals;"wp-block-heading">🔹 <strong>การชำระเงิน &lpar;Payments&rpar;<&sol;strong><&sol;h3>&NewLine;&NewLine;&NewLine;&NewLine;<figure class&equals;"wp-block-table"><table class&equals;"has-fixed-layout"><thead><tr><th>Event<&sol;th><th>คำอธิบาย<&sol;th><&sol;tr><&sol;thead><tbody><tr><td><code>payment&lowbar;intent&period;succeeded<&sol;code><&sol;td><td>การชำระเงินสำเร็จ<&sol;td><&sol;tr><tr><td><code>payment&lowbar;intent&period;payment&lowbar;failed<&sol;code><&sol;td><td>การชำระเงินล้มเหลว<&sol;td><&sol;tr><tr><td><code>charge&period;succeeded<&sol;code><&sol;td><td>ยืนยันการหักเงินจากบัตรสำเร็จ &lpar;ใช้กับระบบเก่า&rpar;<&sol;td><&sol;tr><tr><td><code>charge&period;refunded<&sol;code><&sol;td><td>การคืนเงินเกิดขึ้น<&sol;td><&sol;tr><&sol;tbody><&sol;table><&sol;figure>&NewLine;&NewLine;&NewLine;&NewLine;<hr class&equals;"wp-block-separator has-alpha-channel-opacity"&sol;>&NewLine;&NewLine;&NewLine;&NewLine;<h3 class&equals;"wp-block-heading">🔹 <strong>การสมัครสมาชิก &lpar;Subscriptions&rpar;<&sol;strong><&sol;h3>&NewLine;&NewLine;&NewLine;&NewLine;<figure class&equals;"wp-block-table"><table class&equals;"has-fixed-layout"><thead><tr><th>Event<&sol;th><th>คำอธิบาย<&sol;th><&sol;tr><&sol;thead><tbody><tr><td><code>customer&period;subscription&period;created<&sol;code><&sol;td><td>มีการสร้าง subscription ใหม่<&sol;td><&sol;tr><tr><td><code>customer&period;subscription&period;updated<&sol;code><&sol;td><td>มีการเปลี่ยนแปลง &lpar;เปลี่ยน plan&comma; ปรับราคา&rpar;<&sol;td><&sol;tr><tr><td><code>customer&period;subscription&period;deleted<&sol;code><&sol;td><td>Subscription ถูกยกเลิก<&sol;td><&sol;tr><tr><td><code>invoice&period;payment&lowbar;succeeded<&sol;code><&sol;td><td>ลูกค้าจ่ายค่าสมาชิกสำเร็จ<&sol;td><&sol;tr><tr><td><code>invoice&period;payment&lowbar;failed<&sol;code><&sol;td><td>ลูกค้าชำระไม่ผ่าน &lpar;อาจต้องแจ้งเตือน&rpar;<&sol;td><&sol;tr><&sol;tbody><&sol;table><&sol;figure>&NewLine;&NewLine;&NewLine;&NewLine;<hr class&equals;"wp-block-separator has-alpha-channel-opacity"&sol;>&NewLine;&NewLine;&NewLine;&NewLine;<h3 class&equals;"wp-block-heading">🔹 <strong>ลูกค้า &lpar;Customer&rpar;<&sol;strong><&sol;h3>&NewLine;&NewLine;&NewLine;&NewLine;<figure class&equals;"wp-block-table"><table class&equals;"has-fixed-layout"><thead><tr><th>Event<&sol;th><th>คำอธิบาย<&sol;th><&sol;tr><&sol;thead><tbody><tr><td><code>customer&period;created<&sol;code><&sol;td><td>มีการสร้างบัญชีลูกค้าใหม่<&sol;td><&sol;tr><tr><td><code>customer&period;updated<&sol;code><&sol;td><td>ข้อมูลลูกค้าถูกแก้ไข<&sol;td><&sol;tr><tr><td><code>customer&period;deleted<&sol;code><&sol;td><td>ลูกค้าถูกลบออก<&sol;td><&sol;tr><&sol;tbody><&sol;table><&sol;figure>&NewLine;&NewLine;&NewLine;&NewLine;<hr class&equals;"wp-block-separator has-alpha-channel-opacity"&sol;>&NewLine;&NewLine;&NewLine;&NewLine;<h3 class&equals;"wp-block-heading">🔹 <strong>ใบแจ้งหนี้ &lpar;Invoices&rpar;<&sol;strong><&sol;h3>&NewLine;&NewLine;&NewLine;&NewLine;<figure class&equals;"wp-block-table"><table class&equals;"has-fixed-layout"><thead><tr><th>Event<&sol;th><th>คำอธิบาย<&sol;th><&sol;tr><&sol;thead><tbody><tr><td><code>invoice&period;created<&sol;code><&sol;td><td>ใบแจ้งหนี้ถูกสร้างขึ้น<&sol;td><&sol;tr><tr><td><code>invoice&period;finalized<&sol;code><&sol;td><td>ใบแจ้งหนี้ถูกล็อกและพร้อมชำระเงิน<&sol;td><&sol;tr><tr><td><code>invoice&period;payment&lowbar;action&lowbar;required<&sol;code><&sol;td><td>การชำระเงินต้องการการกระทำเพิ่มเติมจากลูกค้า<&sol;td><&sol;tr><&sol;tbody><&sol;table><&sol;figure>&NewLine;&NewLine;&NewLine;&NewLine;<h2 class&equals;"wp-block-heading">ข้อควรระวัง<&sol;h2>&NewLine;&NewLine;&NewLine;&NewLine;<ul class&equals;"wp-block-list">&NewLine;<li><strong>ตรวจสอบ Signature ทุกครั้ง<&sol;strong> เพื่อป้องกัน Webhook ปลอม<&sol;li>&NewLine;&NewLine;&NewLine;&NewLine;<li>อย่าเชื่อข้อมูลจาก Webhook โดยตรง ให้ใช้เพื่อ <strong>แจ้งเตือนแล้วค่อยดึงข้อมูลจาก API<&sol;strong> เพื่อความแม่นยำ<&sol;li>&NewLine;&NewLine;&NewLine;&NewLine;<li>ทดสอบ Webhook ด้วย <code>Stripe CLI<&sol;code> หรือ Dashboard ก่อนใช้งานจริง<&sol;li>&NewLine;<&sol;ul>&NewLine;&NewLine;&NewLine;&NewLine;<hr class&equals;"wp-block-separator has-alpha-channel-opacity"&sol;>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph">Stripe Webhook เป็นเครื่องมือที่จำเป็นสำหรับระบบที่ต้องติดตามสถานะการเงินแบบเรียลไทม์ โดย Event สำคัญที่ควรตั้งมีทั้งด้านการชำระเงิน&comma; ใบแจ้งหนี้&comma; การสมัครสมาชิก และข้อมูลลูกค้า การตั้งค่า Webhook อย่างถูกต้องจะช่วยให้ระบบของคุณมีความแม่นยำและอัตโนมัติมากขึ้น<&sol;p>&NewLine;&NewLine;&NewLine;&NewLine;<p class&equals;"wp-block-paragraph"><&sol;p>&NewLine;

Exit mobile version