【问题标题】:Stripe - SKUS without a name are not supported by checkoutStripe - 结帐不支持没有名称的 SKUS
【发布时间】:2019-05-21 14:12:28
【问题描述】:

我正在实施条带结帐系统。

每次我尝试调用结帐视图时,我都会遇到一个奇怪的 javascript 错误: IntegrationError: Checkout 的 SKU 需要 name 属性。

在仪表板中,用于结帐集成的按钮显示为灰色。

在创建SKU时如何传递名称有什么线索吗?

这是我通过条带 api curl 调用发布 SKU 的 PHP:

$sku = [
        'active' => 'true',
        'inventory' => ['type' => 'infinite', 'value' => null],
        "currency" => "eur",
        "price" => $price,
        "product" => $stripe_product_id
    ];

【问题讨论】:

    标签: php stripe-payments sku


    【解决方案1】:

    经过多次组合,以及对stripe API的深入分析,找到了我一直在寻找的答案。

    产品创建:

    $pacoteSMS = [
            'name' => $name,
            'type' => 'good',
            'active' => 'true',
            'description' => $description,
            "attributes" => [
                "name"
            ],
        ];
    

    SKU 创建:

    $sku = [
            'product' => $stripe_product_id,
            "attributes" => [
                "name" => $name,
            ],
            "price" => $price,
            "currency" => "eur",
            "inventory" => [
                "type" => "infinite",
            ],
            "active" => "true",
        ];
    

    【讨论】:

    • 我不知道如何传递名称属性。我正在使用 Laravel PHP,会话代码在 PHP 中,redirectToCheckout 在 JS 中。
    【解决方案2】:

    name 值位于 SKU 对象的 attributes 内。您可以在创建或更新 SKU 时设置attributes[name]。例如:

    'attributes' => ['name' => 'the name'],

    【讨论】:

    • 当我使用 'attributes' => ['name' => 'my_name'],STRIPE API 返回.....'error' => ['message' = > '未知属性指定:名称', 'param' => 'attributes', 'type' => 'invalid_request_error' ]
    • 在 stripe api 文档中,它写了关于属性的内容:产品定义的属性的属性和值的字典。例如,如果产品的属性为 ["size", "gender"],则有效 SKU 具有以下属性字典:{"size": "Medium", "gender": "Unisex"}。
    • 上述解释没有提到'name'作为使用api端点创建SKUS的有效属性。
    • @AndréCastro 您能否详细说明问题的最终结果?根据您的其他答案,您似乎成功地以这种方式设置了 SKU 的名称。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-23
    • 2012-03-03
    • 2014-10-24
    • 1970-01-01
    相关资源
    最近更新 更多