条纹结帐将不接受元数据

时间:2019-04-18 10:26:56

标签: php stripe-payments

我已经集成了Stripe Checkout(最新版本),并且需要发送其他数据,以便我可以协调以后的Webhook。

条带拒绝元数据并出现以下错误

Fatal error: Uncaught exception 'Stripe\Error\InvalidRequest' with message 'Received unknown parameter: metadata' 

我部分编辑的代码如下:

$object = \Stripe\Checkout\Session::create([
    'success_url' => 'www/payment_processor.php?action=success',
    'cancel_url' => 'www/payment_processor.php?action=cancel',
    'payment_method_types' => ['card'],
    'customer_email' => $email,
    'metadata' => ['user_id' => $user_id],
    'line_items' => [[
        'amount' => $amount,
        'currency' => $currency,
        'name' => 'Purchase',
        'description' => $description,
        'quantity' => 1,
    ]]
]);

我希望元数据能够被Webhook接受并返回,如Stripe documentation中所述。

8 个答案:

答案 0 :(得分:5)

对于仍然遇到此问题的任何人,即使使用 2020-08-27 API,仅放置 client_reference_idmetadata 参数对我也不起作用。

使用元数据添加 payment_intent_data 是让它为我工作的原因。您可以尝试添加以下代码:

'payment_intent_data'=>['metadata' => ["order_id" => $orderID, "type" => "myProduct"],

答案 1 :(得分:3)

您可以做到

/usr/local/bin/pod install

答案 2 :(得分:2)

截至2020年10月,会话对象具有元数据。

答案 3 :(得分:1)

链接文档的第一句话指出:

  

可更新的Stripe对象(包括帐户,费用,客户,PaymentIntent,退款,订阅和转账)具有元数据参数。

您没有创建任何一个,而是创建了一个会话

答案 4 :(得分:0)

Stripe Session对象不接受metadata作为参数。 See here了解详细信息。

您问题中的reference you give是针对接受元数据的Stripe Charge 对象。

答案 5 :(得分:0)

其他答案正确的是,会话对象上不存在metadataclient_reference_id是替代方法,但必须唯一,并且必须是字符串。

如果您只希望元数据显示在Stripe仪表板上的购买中,请在创建会话时使用payment_intent_data属性。这样,您就可以将元数据附加到会话期间进行的购买中。 Relevant documentation here

答案 6 :(得分:0)

您不能将元数据附加到Session,但是可以将元数据附加到将在会话中创建的payment_intentsetup_intent。 / p>

请参见the documentation,将其作为payment_intent_data.metadata传递。

请注意,条带warns you不能将敏感数据放入metadata中,因此,如果要存储客户端名称等,最好将其放在唯一键下的数据库中,然后将密钥作为client_reference_id传递。

答案 7 :(得分:0)

如果您像我一样,遇到需要将一些信息(例如客户ID,订单ID等)捆绑到条带上的情况。有一个名为 payment_intent_data 的参数,它是一个关联数组。在payment_intent_data中,您有一个名为 description 的属性,可用于嵌入一些其他信息。当您在条带上进行csv付款导出时,您在此处放置的描述将显示在描述字段上。

https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-description

              $stripe_session = \Stripe\Checkout\Session::create([
              'submit_type' => 'pay',
              'billing_address_collection' => 'required',
              'customer' => $customer,            
              'client_reference_id' => $customer ,
              'payment_intent_data'=>['description' =>'This is my description'],
              'payment_method_types' => ['card'],
              'line_items' => [[
                'name' => $event->title,
                'description' => $description/*This description does not go on csv export, it's more or less cosmetic */,               
                'amount' => ($fee),
                'currency' => 'gbp',
                'quantity' => 1,
              ]],
              'success_url' => 'example.com',
              'cancel_url' => 'example.com',
            ]);