条纹定期付款,但每 3 或 6 个月一次

Stripe Recurring Payments but every 3 or 6 months

我是 Stripe 新手 PHP Laravel。对于不是 1 个月而是 3 个月或 6 个月的计费周期,是否可以在 Laravel Stripe 中定期付款?因为我不熟悉这个术语,任何人都可以给我发送正确的文档吗?我已经检查了 Stripe 中的周期,但我认为这不是我需要的。

在 belling-> products 下的 stripe 仪表板上创建新产品,例如 prod-1,添加定价计划,例如 plan-1(stripe 将为此计划生成 ID)到该产品(prod-1),同时添加计费间隔下的定价计划 select 或自定义您想要的间隔。

现在开始 laravel 应用程序方面的工作。我会推荐使用 Laravel 收银台。

运行作曲家composer require laravel/cashier

更新您的用户迁移 Table:

 Schema::table('users', function ($table) {
    $table->string('stripe_id')->nullable()->collation('utf8mb4_bin');
    $table->string('card_brand')->nullable();
    $table->string('card_last_four', 4)->nullable();
    $table->timestamp('trial_ends_at')->nullable();
});

Schema::create('subscriptions', function ($table) {
    $table->increments('id');
    $table->unsignedInteger('user_id');
    $table->string('name');
    $table->string('stripe_id')->collation('utf8mb4_bin');
    $table->string('stripe_plan');
    $table->integer('quantity');
    $table->timestamp('trial_ends_at')->nullable();
    $table->timestamp('ends_at')->nullable();
    $table->timestamps();
});

更新您的用户模型:

use Laravel\Cashier\Billable;

class User extends Authenticatable
{
    use Billable;
}

在你的控制器中。 MyController.php:

use Cartalyst\Stripe\Laravel\Facades\Stripe;
use Cartalyst\Stripe\Exception\CardErrorException;
use Session;
use Auth;

public function store(Request $request)
{

    $token = $_POST['stripeToken'];
    $user = Auth::user();

    try {

        $user->newSubscription('prod-1', 'ID of plan-1')->create($token);

        Session::flash('success', 'You are now a premium member');
        return redirect()->back();

    } catch (CardErrorException $e) {
        return back()->withErrors('Error!'.  $e->getMessage());
    }


}

在您看来:

<form action="{{ route('subscribe')}}" method="POST">
  <script
    src="https://checkout.stripe.com/checkout.js" class="stripe-button"
    data-key="pk_test_0000000000000000000" // Your api key
    data-image="/images/marketplace.png" // You can change this image to your image
    data-name="My App Name"
    data-description="Subscription for 1 weekly box"
    data-amount="2000" //the price is in cents 2000 = 20.00
    data-label="Sign Me Up!">
  </script>
</form>

创建路线:

Route::POST('subscription', 'MyController@store')->name('susbcribe');

如果有效请告诉我。