Home > Software design >  How can i insert metadata details or expand new properties using stripe
How can i insert metadata details or expand new properties using stripe

Time:10-09

I just want to apply what the stripe's docs said about adding the Metadata property and then i can add everything and it can be displayed in the webhook, but i have tried to add the metadata , even to expand details but i didnt know how , this is the code :

$session = \Stripe\Checkout\Session::create([
    'success_url' => 'https://example.com/success',
  'cancel_url' => 'https://example.com/cancel',
  'payment_method_types' => ['card'],
  'line_items' => [
    [
      'price' => $price_id,
       'metadata' =>['prod_id' => ' TEST'], //// i want to store something like that
      'quantity' => 1,
    ],
  ],
  'mode' => 'payment',
  ]);

CodePudding user response:

You can add metadata to the object, but not inside the line-items array.

Add metadata like below

$session = \Stripe\Checkout\Session::create([
  'success_url' => 'https://example.com/success',
  'cancel_url' => 'https://example.com/cancel',
  'payment_method_types' => ['card'],
  'line_items' => [
    [
      'price' => $price_id,
      'quantity' => 1,
    ],
  ],
  'metadata' =>['prod_id' => ' TEST'], //// i want to store something like that
  'mode' => 'payment',
  ]);
  • Related