小编zan*_*rsh的帖子

Laravel 收银员不会自动创建订阅

这是代码:

<?php

namespace App\Http\Controllers;

use Inertia\Inertia;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;

class BillingController extends Controller
{
    public function index(Request $request) {
        return Auth::user()
            ->newSubscription('default', 'price_#################')
            ->checkout();
    }
}
Run Code Online (Sandbox Code Playgroud)

它正确地将我重定向到 stripe 的结帐页面,它正确地处理付款并将我重定向回我的网站。我实际上可以在 stripe 面板中看到活动订阅,但我的网站帐户上没有活动订阅。

>>> User::first()->subscriptions;
=> Illuminate\Database\Eloquent\Collection {#4476
     all: [],
   }
>>> User::first()->subscribed('default');
=> false
Run Code Online (Sandbox Code Playgroud)

Laravel 文档中有一点说它会自动处理订阅关联(我猜是通过一种神奇的内部方法),但它不起作用。

Stripe 的 CLI 在我的付款操作中捕获了这些事件:

2021-10-19 23:34:16   --> charge.succeeded [evt_############]
2021-10-19 23:34:16   --> checkout.session.completed [evt_############]
2021-10-19 23:34:16   --> invoice.created [evt_############]
2021-10-19 23:34:16   --> invoice.finalized [evt_############]
2021-10-19 23:34:16   --> customer.subscription.created [evt_############]
2021-10-19 23:34:17   --> invoice.updated [evt_############] …
Run Code Online (Sandbox Code Playgroud)

php laravel stripe-payments laravel-cashier

5
推荐指数
1
解决办法
1354
查看次数

Angular 5 模型 httpClient 类型转换

我在配料.model.ts 中声明了一个模型

export class Ingredient {
 constructor(private name: string, public amount: number) {}

 getName() { return this.name }
}
Run Code Online (Sandbox Code Playgroud)

在配料.service.ts 中,如果我以这种方式获取它们:

httpClient.get<Ingredient>(url).subscribe(
 (igredient) => {
   console.log(igredient.getName());
 });
Run Code Online (Sandbox Code Playgroud)

它在控制台中给出错误,例如“属性 igrient 中没有方法 getName”。

另外,每当我尝试声明属性类型 Category[] 时,它都会失败,但 Array 似乎工作正常。

编辑: 我想提供更多信息。

给定 Igredient 模型和以下 JSON 结构:

{
 name: "Apple",
 amount: "5",
 created_at: "date",
}
Run Code Online (Sandbox Code Playgroud)

Igredient 构造函数甚至没有被调用,因此 GET 有效负载不会被解析。

httpclient models angular5

0
推荐指数
1
解决办法
4862
查看次数