gpt4 book ai didi

stripe-payments - 如何在 Stripe 中一次对多个项目收费?

转载 作者:行者123 更新时间:2023-12-05 08:41:12 26 4
gpt4 key购买 nike

我正在尝试找到一种方法让 Stripe 在一次收费中对多个项目收费。我认为它看起来像这样:

$totalitems = [];
if ( $item1 == "true" ) {
$currentitem = array(
"amount" => 19999,
"currency" => "usd",
"description" => "Item 1",
"customer" => $customer->id,
);
array_push($totalitems, $currentitem);
}

if ( $item2 == "true" ) {
$currentitem = array(
"amount" => 29999,
"currency" => "usd",
"description" => "Item 2",
"customer" => $customer->id,
);
array_push($totalitems, $currentitem);
}

$charge = \Stripe\Charge::create([$totalitems]);

这只对数组中的第一项收费。有没有办法一次为多个项目充电?

最佳答案

在当前的 Stripe checkout.session.create 中,您可以在 line_item 属性中添加多个项目:

line_items: [
// ONE ITEM

// {
// name: product.name,
// description: product.description,
// images: [product.image],
// amount: product.amount,
// currency: product.currency,
// quantity: validatedQuantity,
// },

// MULTIPLE ITEMS
{
name: 'F02',
images: [
'',
],
amount: '74900',
currency: 'sek',
quantity: 2,
},
{
name: 'F01',
images: [
'',
],
amount: '74900',
currency: 'sek',
quantity: 1,
},
],

关于stripe-payments - 如何在 Stripe 中一次对多个项目收费?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51584372/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com