tatter / stripe
Stripe SDK 集成到 CodeIgniter 4
资助包维护!
tattersoftware
paypal.me/tatter
Requires
- php: ^7.4 || ^8.0
- stripe/stripe-php: ^7.14 || ^8.0
Requires (Dev)
- codeigniter4/framework: ^4.1
- tatter/tools: ^2.0
This package is auto-updated.
Last update: 2024-09-17 17:26:03 UTC
README
Stripe SDK 集成到 CodeIgniter 4
快速开始
- 使用 Composer 安装:
> composer require tatter/stripe
- 设置环境密钥: .env >
stripe.apiKey
和stripe.apiSecret
- 加载服务:
$stripe = service('stripe');
描述
这是 Stripe PHP SDK 的 CodeIgniter 4 集成
安装
通过 Composer 轻松安装以利用 CodeIgniter 4 的自动加载功能,并始终保持最新状态
> composer require tatter/stripe
或者,通过下载源文件并将其添加到 app/Config/Autoload.php
中来手动安装。
配置
可以通过扩展其配置文件来改变库的默认行为。将 examples/Stripe.php 复制到 app/Config/,并遵循注释中的说明。如果 app/Config 中没有找到配置文件,则库将使用其自身的。
除了配置外,你必须在项目的根目录下的 .env 文件中设置你的 apiSecret
。API 密钥和密钥可在 Stripe 控制台 中找到。例如。
#--------------------------------------------------------------------
# STRIPE
#--------------------------------------------------------------------
stripe.apiKey = pk_test_6pRNASCoBOKtIshFeQd4XMUh
stripe.apiSecret = sk_test_BQokikJOvBiI2HlWgH4olfQ2
警告 确保你永远不会在仓库中包含凭证!
使用
加载 Stripe 服务
$stripe = service('stripe');
在此阶段,你已经有一个可工作的 StripeClient
,可以使用 Stripe API 文档 中描述的任何方法。请注意,API 端点具有版本特定性。有关如何使用示例配置文件来覆盖模块默认值以设置特定版本的说明,请参阅上面的 配置。