如何使用受限的 API 密钥?
一个“受限 API 密钥”允许您指定该 API 密钥可以读取和/或写入哪些 Stripe 资源。如果您的 Stripe 账户被多个集成使用,或者作为其他集成的“平台”,这会很有用。
要创建受限密钥,请遵循“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 常量或环境变量加载这些值。
仍有疑问?我们随时为您服务!
最后修改时间: