首页 > 解决方案 > Stripe - 结帐不支持没有名称的 SKUS

问题描述

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

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

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

关于如何在创建 SKU 时传递名称的任何线索?

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

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

标签: phpstripe-paymentssku

解决方案


经过多次组合,以及对条带 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",
    ];

推荐阅读