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

Stripe payments 如何在条带中一次对多个项目收费?,stripe-payments,Stripe Payments,我在想办法让Stripe在一次充电中充电多个项目。我想它看起来会像这样: $totalitems = []; if ( $item1 == "true" ) { $currentitem = array( "amount" => 19999, "currency" => "usd", "description" => "Item 1", "customer" => $customer->id, ); array

我在想办法让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]);

这只会对阵列中的第一项充电。有一种方法可以一次对多个项目收费吗?

您不能用这种方法对多个项目收费。相反,您有几个选择:

  • 只需将您这边的物品加起来,并为总金额创建一笔费用
  • 对每一项单独收费
  • 使用

我建议使用第一种方法,您可以使用费用记录费用中包含的项目,供您参考。

您不能以这种方式对多个项目收费。相反,您有几个选择:

  • 只需将您这边的物品加起来,并为总金额创建一笔费用
  • 对每一项单独收费
  • 使用

我建议使用第一种方法,您可以使用费用记录费用中包含的项目,以供您自己参考。

在current Stripe checkout.session.create中,您可以在line\u 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 checkout.session.create中,您可以在行\项属性中添加多个项:

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的Orders API可能会有点限制或麻烦,因为您必须提前定义所有产品和价格。您是否介意激发您为什么建议第一种方法?好吧,与其他方法相比,快速连续收取多笔费用可能会导致某些银行标记某些交易;使用Stripe的Orders API可能会有点限制或麻烦,因为您必须提前定义所有产品和价格。为什么它旁边有一点胖零?把你的票投好,先生。这就是我的解决方案。如果我第一次看到这个的话,我可以省下1.5天的头痛。谢谢你,RalphTheWonderLlama。是的,我记得那头痛。组织良好的文档,但只是这些人们反复做的小的基本事情,通过示例展示时应该非常清楚。祝你建店好运。为什么旁边有一点胖零呢?把你的票投好,先生。这就是我的解决方案。如果我第一次看到这个的话,我可以省下1.5天的头痛。谢谢你,RalphTheWonderLlama。是的,我记得那头痛。组织良好的文档,但只是这些人们反复做的小的基本事情,通过示例展示时应该非常清楚。祝你建造商店好运。