【问题标题】:Laravel Cashier Single Charge does it is suitable for this taskLaravel Cashier Single Charge 是否适合这个任务
【发布时间】:2021-04-10 07:26:09
【问题描述】:

每当客户想要进行我系统中提供的计算时,我想向他收取 1 欧元的费用。每次客户想要再次进行计算时,他都必须再次支付 1 欧元。 Laravel Cashier 单笔收费是否适合这样的任务,还是我应该选择一个简单的 Stripe SDK?

【问题讨论】:

    标签: laravel laravel-cashier


    【解决方案1】:

    是的,您可以使用 Cashier 包做到这一点。

    首先,用户应设置付款方式。

    return view('update-payment-method', [
        'intent' => $user->createSetupIntent()
    ]);
    

    然后在你看来:

    <input id="card-holder-name" type="text">
    
    <!-- Stripe Elements Placeholder -->
    <div id="card-element"></div>
    
    <button id="card-button" data-secret="{{ $intent->client_secret }}">
        Update Payment Method
    </button>
    

    然后,您可以在每次要进行计算时向用户收费。

    // The amount is in cents. 100 = 1 euro
    $stripeCharge = $user->charge(
      100, $user->defaultPaymentMethod()
    );
    

    You can view the docs for more details.

    【讨论】:

      猜你喜欢
      • 2020-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-31
      • 2011-05-26
      • 1970-01-01
      • 2019-05-30
      • 1970-01-01
      相关资源
      最近更新 更多