跳转到正文
Senior IT Developer, Software Architect, AI master文档

← 所有指南

如何启用 Stripe 支付

访客在 Stripe 托管的页面上用银行卡付款。只有当 Stripe 通过 webhook 向您的网站确认付款后,预订才会被标记为已付款,因此 webhook 是必需的。

1 打开 Stripe Dashboard -> Developers -> API keys,复制 Publishable key(pk_…)和 Secret key(sk_…)。
2 进入“预订” -> “设置” -> “付款”,把两个密钥分别粘贴到 Stripe 可发布密钥 和 Stripe Secret Key,然后保存。
3 在 Stripe Dashboard 中打开 Developers -> Webhooks -> Add endpoint。
4 在 Endpoint URL 中粘贴“预订” -> “设置” -> “付款”中显示的 网络钩子 URL(https://您的网站/wp-json/vstrb/v1/payment/stripe/webhook)。
5 选择 checkout.session.completed;自动收取余额还需选择 payment_intent.succeeded,同步 Stripe 退款则选择 refund.updated。
6 保存该 endpoint,复制其 Signing secret(whsec_…),粘贴到插件设置中的 Stripe Webhook 秘密,然后保存。
7 在表单中显示付款方式:在“默认付款方式”中勾选“银行卡(Stripe)”,或在预订表单短代码中添加 enable_stripe="1"。
连接 Stripe(银行卡支付) – 视频为英文。

可选:填写 Stripe Success URL 和 Stripe Cancel URL,指定访客付款或取消后返回的页面。

测试模式和正式模式使用各自独立的 API 密钥和 webhook endpoint,其 signing secret 也不同。请先用 sk_test_… 密钥和测试 endpoint 测试,然后把这三个值全部换成正式环境的值。

网络钩子 URL 必须可通过 HTTPS 公开访问。如果 Stripe 中付款已完成但预订仍显示未付款,请在 Developers -> Webhooks -> 您的 endpoint 中查看失败的投递(signing secret 错误会返回 invalid_signature),并确认没有安全插件或防火墙拦截 /wp-json/。

如果希望已付款的预订自动确认,请在付款设置中启用“付款后自动确认预订”。访客也可以稍后在访客门户中选择 Stripe。银行卡信息由 Stripe 保存,插件从不保存。

[vstrb_booking_form unit="YOUR_ID" enable_stripe="1"]
https://example.com/wp-json/vstrb/v1/payment/stripe/webhook