3

I'm implementing a stripe checkout system.

Every time i try to call checkout view i have a weird javascript error: IntegrationError: SKUs for Checkout require a name attribute.

In dashboard the button for checkout integration is greyed out.

Any clues on how to pass the name in the creation of the SKU?

Here is my PHP for posting a SKU via stripe api curl call:

$sku = [
        'active' => 'true',
        'inventory' => ['type' => 'infinite', 'value' => null],
        "currency" => "eur",
        "price" => $price,
        "product" => $stripe_product_id
    ];
André Castro
  • 1,527
  • 6
  • 33
  • 60

2 Answers2

3

After many combinations, and deep analysis of stripe API, find the answer i was looking for.

Products Creation:

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

SKU creation:

$sku = [
        'product' => $stripe_product_id,
        "attributes" => [
            "name" => $name,
        ],
        "price" => $price,
        "currency" => "eur",
        "inventory" => [
            "type" => "infinite",
        ],
        "active" => "true",
    ];
André Castro
  • 1,527
  • 6
  • 33
  • 60
  • I can't figure out how to pass name attribute. I'm working with Laravel PHP, session code is in PHP and redirectToCheckout is in JS. – Shariq Shaikh Feb 28 '20 at 10:36
1

The name value lives inside the attributes on the SKU object. You can set attributes[name] when creating or updating the SKU. For example:

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

taintedzodiac
  • 2,658
  • 1
  • 18
  • 16
  • When i use 'attributes' => ['name' => 'my_name'], STRIPE API returns.......... 'error' => [ 'message' => 'Unknown attributes specified: name', 'param' => 'attributes', 'type' => 'invalid_request_error' ] – André Castro May 22 '19 at 07:56
  • In stripe api docs its written about attributes: A dictionary of attributes and values for the attributes defined by the product. If, for example, a product’s attributes are ["size", "gender"], a valid SKU has the following dictionary of attributes: {"size": "Medium", "gender": "Unisex"}. – André Castro May 22 '19 at 08:00
  • The above explanation does not mention 'name' as a valid attribute for creating SKUS using the api endpoint. – André Castro May 22 '19 at 08:00
  • @AndréCastro Could you elaborate on what the issue ended up being? Per your other answer, it appears you succeeded in setting the SKU's name in this manner. – taintedzodiac May 23 '19 at 13:11