asciisd/cashier-tap

Asciisd Cashier 提供了一个表达流畅的接口,用于访问 Tap 的订阅计费服务。

v2.1.1 2024-08-18 23:39 UTC

README

Latest Version on Packagist Software License Total Downloads Total Downloads

简介

Laravel Cashier-tap 提供了一个表达流畅的接口,用于访问 Tap 的公司订阅计费服务。它处理了您害怕编写的大多数样板订阅计费代码。除了基本的订阅管理外,Cashier 还可以处理优惠券、交换订阅、订阅“数量”、取消宽限期,甚至生成发票 PDF。

安装

1- 运行 composer required 命令

您可以通过 Composer 安装绑定。运行以下命令:

composer require asciisd/cashier-tap

2- 运行安装命令

此命令将安装 ServiceProviderConfigsviews

php artisan cashier:install

3- 运行发布命令

此命令将打包资产

php artisan cashier:publish

4- 运行迁移命令

通过运行迁移创建表

php artisan migrate

5- 添加 .env 参数

TAP_API_KEY=
TAP_WEBHOOK_SECRET= //use this key if you want tap to post the result back to your application

使用此包

尚未完成,您可以使用以下示例来使用此包:

Billable 特性添加到 User 模型

namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use Asciisd\Cashier\Billable;

class User extends Authenticatable {
   use Billable;
}

使用 pay() 方法

try{
    //allowed payment methods is ['src_kw.knet', 'src_all', 'src_card']
    $payment_method = 'src_card';
    $payment = $user->charge(10, $payment_method);

    $payment->url; // this will return payment link
} catch(\Asciisd\Cashier\Exceptions\PaymentActionRequired $exception) {
    $payment = $exception->payment;
}

return $payment->actionUrl();

支付完成后,您将被重定向到 /tap/receipt,您可以从配置文件中更改它以创建自己的处理器,因此请确保将此目录添加到 VerifyCsrfToken $except,如果您想使用 webhook,则还应将 tap/webhook 添加到 VerifyCsrfToken $except 方法

测试卡

贡献

感谢您考虑为 Cashier 贡献!

许可协议

Laravel Cashier-tap 是开源软件,采用 MIT 许可协议