定制 celtyvsk/cashier-connect 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

celtyvsk/cashier-connect

Composer 安装命令:

composer require celtyvsk/cashier-connect

包简介

Laravel Cashier Connect add support for Stripe Connect to Laravel Cashier.

README 文档

README

Laravel Cashier Connect add support for Stripe Connect Subscription to laravel Cashier (based on v10.7.1).

Documentation

  1. Install the package
composer require "oixan/cashier-connect"
  1. Follow the instructions of cashier in the official guide The installations process is the same.

  2. Add the Trait to User model use Billable from use Laravel\CashierConnect\Billable

Create your .env file

You will need to set the Stripe Testing Secret env variable before your vendor/bin/phpunit call in order to run the Cashier Connect tests:

STRIPE_SECRET=<your Stripe secret>

Please note that due to the fact that actual API requests against Stripe are being made, these tests take a few minutes to run.

How this package work.

All the default cashier methods remain the same if not direct support by CashierConnect.

This package assume you created yours Stripe Accounts directly or through API then assign the Account id to user->stripe_account_id.

Every user can be a customers or an Stripe Account.

Basic Method Added to User model

$user = user from db or wathever;
$user->getStripeAccount(); // Check if every cashier call will go to Stripe Account
$user->setStripeAccount($userAccount); // Pass a User instance then every cashier call will go to Stripe Account
$user->unsetStripeAccount; // Remove the userAccount, cashier will work with default setting.
$user->pauseStripeAccount // Pause the userAccount, cashier will work with default setting.
$user->resumeStripeAccount  // Resume the previous userAccount, cashier call will go to Stripe Account

*** IMPORTANT *** any further call after setStripeAccount() will be direct to Stripe Account so remember to call unsetStripeAccount() if needed.

Methods Supported (Version 0.3.0).

The setStripeAccount($userAccount) method make every subsequent call goes from your Platform to Stripe Account passed like parameter. If you need to change the userAccount or pause the StripeAccount call see the previous section.

Creating Subscriptions

   $user->setStripeAccount($userAccount)->newSubscription('main', 'plan_id')->create("pm_card_visa");

Add user detail

$user->newSubscription('main', 'monthly')->create($token, [
  'email' => $email,
]);

Checking Subscription Status

if ($user->subscribed('main')) {
   //
}

Subscribe to plan

if ($user->subscribedToPlan('monthly', 'main')) {
  //
}

Reccuring check

if ($user->subscription('main')->recurring()) {
  //
}

Cancelled Subscription Status

if ($user->subscription('main')->cancelled()) {
  //
}

if ($user->subscription('main')->onGracePeriod()) {
  //
}

if ($user->subscription('main')->ended()) {
  //
}

Changing Plans

$user->subscription('main')->swap('provider-plan-id');

Subscription Quantity

$user->subscription('main')->incrementQuantity();

// Add five to the subscription's current quantity...
$user->subscription('main')->incrementQuantity(5);

$user->subscription('main')->decrementQuantity();

// Subtract five to the subscription's current quantity...
$user->subscription('main')->decrementQuantity(5);

Subscription Ancor Date

$user->newSubscription('main', 'premium')
     ->anchorBillingCycleOn( Carbon::parse('first day of next month'))
     ->create($token);

Subscription Trials

$user->newSubscription('main', 'monthly')
            ->trialDays(10)
            ->create($token);

$user->newSubscription('main', 'monthly')
        ->trialUntil(Carbon::now()->addDays(10))
        ->create($token);

$user->onTrial('main')

$user->subscription('main')->onTrial()

Cancelling Subscriptions

$user->subscription('main')->cancel();

if ($user->subscription('main')->onGracePeriod()) {
    //
}

$user->subscription('main')->cancelNow();

Resume Subscriptions

$user->subscription('main')->resume();

*All cashier methods not in list are not tested to work with Stripe Account

More.

If you want set an application fee set on user model

public function applicationFeePercent()
{
    return 40;
}

The Web hook from stripe connect have different secret key. Set

services.stripe.webhook.connect_secret

to allow cashier connect to accept webhook from stripe connect.

License

Laravel Cashier Connect is open-sourced software licensed under the MIT license.

celtyvsk/cashier-connect 适用场景与选型建议

celtyvsk/cashier-connect 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 04 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「stripe」 「laravel」 「billing」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 celtyvsk/cashier-connect 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 celtyvsk/cashier-connect 我们能提供哪些服务?
定制开发 / 二次开发

基于 celtyvsk/cashier-connect 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 7
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-04-03