小编Hir*_*ara的帖子

Laravel Cashier paymentMethods() 返回始终为空的对象结果

  • 收银台版本:^10.5
  • Laravel 版本:^6.0
  • PHP 版本:7.3.5
  • 数据库驱动程序和版本:

描述:

paymentMethods() 总是用空对象检索数组。

public function userAllPaymentMethods(Request $request)
    {
        $user = User::find(5);
        $paymentMethod = $user->paymentMethods();
        return response($paymentMethod);
    }
Run Code Online (Sandbox Code Playgroud)

结果:https : //www.screencast.com/t/aqenaud77A

也使用 Stripe PaymentMethod lib 它的工作原理。

public function userAllPaymentMethods(Request $request)
    {
        $user = User::find(5);
        \Stripe\Stripe::setApiKey('{{KEY}}');
        $paymentMethod = \Stripe\PaymentMethod::all([
            'customer' =>  $user->stripe_id,
            'type' => 'card',
        ]);

        return response($paymentMethod);
    }
Run Code Online (Sandbox Code Playgroud)

结果:https :
//www.screencast.com/t/X14ane7WyqS

GitHub:这里

php stripe-payments laravel-5 laravel-cashier

2
推荐指数
1
解决办法
1214
查看次数

标签 统计

laravel-5 ×1

laravel-cashier ×1

php ×1

stripe-payments ×1