WP Simple Pay 文档

WP Simple Pay 的文档、参考资料和教程

如何使用受限的 API 密钥?

在大多数用例中,不需要使用受限的 Stripe API 密钥。通过“连接 Stripe”会自动创建一个 API 密钥,该密钥默认限制对某些 API 端点(例如创建其他账户)的访问。

一个“受限 API 密钥”允许您指定该 API 密钥可以读取和/或写入哪些 Stripe 资源。如果您的 Stripe 账户被多个集成使用,或者作为其他集成的“平台”,这会很有用。

如果您的 Stripe 账户未作为其他集成的平台,我们建议使用“连接 Stripe”自动创建的标准 API 密钥。

要创建受限密钥,请遵循“Stripe 提供的步骤”。创建密钥时,WP Simple Pay 所需的权限包括:

  • Apple Pay 域名: write(如果使用 Apple Pay)
  • Customers: write
  • Events: read
  • PaymentIntents: write
  • Products: write
  • SetupIntents: write(如果使用免费试用)
  • Checkout Sessions: write(如果使用 Stripe Checkout)
  • Coupons: write(如果使用优惠券)
  • Promotion Codes:write(如果使用优惠券)
  • Credit notes: read
  • Prices: write
  • Subscriptions:write(如果使用订阅)
  • Tax Rates:write(如果使用税率)
  • Webhook Endpoints:write(如果手动管理则为 none)
  • Tax Calculations & Transactions:write(如果使用自动纳税)

创建受限 API 密钥后,请通过WP Simple Pay → Settings → Stripe → Account断开与 Stripe 的连接(以移除之前的 API 密钥)。然后,将以下自定义代码段添加到 WordPress 的必须插件中,以告知 WP Simple Pay 使用您新的 API 密钥:

<?php
/**
 * mu-plugin: Stripe API Keys
 */

/**
 * Returns the Stripe Secret key.
 */
function get_secret_key( $key ) {
	return 'rk_live_123';
}
add_filter( 'simpay_stripe_api_secret_key', 'get_secret_key' );
add_filter( 'simpay_secret_key', 'get_secret_key' );

/**
 * Returns the Stripe Publishable key.
 */
function get_publishable_key( $key ) {
	return 'pk_live_123';
}
add_filter( 'simpay_stripe_api_publishable_key', 'get_publishable_key' );
add_filter( 'simpay_publishable_key', 'get_publishable_key' );

您也可以从在其他地方定义的 PHP 常量或环境变量加载这些值。

不应使用(也不支持)此技术根据使用的付款表单或其他变量将资金发送到不同的 Stripe 账户。

仍有疑问?我们随时为您服务!

最后修改时间:

立即开始接受付款

在您的WordPress网站上开始接受一次性付款、定期付款或捐赠。