'The "client_reference_id" argument is not passed

I use Stripe Checkout (Stripe version 2016-07-06) and I want to recover a personalized data thanks to the argument "client_reference_id" but in the JSON I do not find it while I have the amount or e-mail by example. I am in the test environment. Can you help me please ? thank you in advance

$session = \Stripe\Checkout\Session::create([
  'client_reference_id' =>'TEST',
  'customer_email'       => '[email protected]',
  'payment_method_types' => ['card'],
  'line_items' => [[
    'name'        => 'My purchase',
    'amount'      => '1000',
    'currency'    => 'eur',
    'quantity'    => 1,
  ]],
  'success_url'   => 'https://www.loremipsum.fr',
  'cancel_url'    => 'https://www.loremipsum.fr',
]);


Solution 1:[1]

For Rails it works like this:

class CheckoutController < ApplicationController

def create

cart = Cart.find(params[:id])
session = Stripe::Checkout::Session.create({
    payment_method_types: ['card'],
    line_items: [{
        description: "Your product description",
        name: "Name",
        amount: 1999,
        currency: 'eur',
        quantity: 1,
    }],
    
    client_reference_id: cart.id,
    mode: 'payment',
    success_url: root_url,
    cancel_url: root_url,
})

redirect_to session.url, allow_other_host: true

end

end

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 antoniolulee