如何描述Stripe Checkout中的订单项?

发布于 2025-02-06 17:58:30 字数 1456 浏览 4 评论 0原文

这是我创建结帐函数的方式:

foreach($request->arrayOfObjects as $req) {
    array_push($lineItems, [
        'price' => $req['priceID'],
        'quantity' => (int) $req['quantity']
    ]);
}
    
if (Auth::check()) {
    $charge = $stripeClient->checkout->sessions->create([
        'payment_method_types' => [
            'card',
            'sepa_debit',
            'giropay',
            'sofort',
            'alipay'
        ],
        'success_url' => env('APP_URL').'/success',
        'cancel_url' => env('APP_URL').'/cancel',
        'shipping_address_collection' => [
            'allowed_countries' => ['DE'],
        ],
        'shipping_options' => [
            [
               'shipping_rate' => $request->lieferung ? env('SHIPPING_RATE_LIEFERUNG') : env('SHIPPING_RATE_ABHOLUNG')
            ],
        ],
        'line_items' => [$lineItems],
        'mode' => 'payment',
        'metadata' => [
            'lieferung' => $request->lieferung,
            'isCustomer' => true
        ],
        'allow_promotion_codes' => true,
        'customer' => Auth::user()->stripe_id
    ]);
}

但是它可以正常工作...但是,我想知道是否可以描述文章的测量值?

例如,我已经订购了10套包装的镶木地板经典,每个包装都有3m2的镶木地板。

我想在法案中看到它,就像:

第1001条 - 镶木地板经典(10倍软件包-3m2)

我发现可以提供元数据,但仅适用于全球结帐级别,而不是每个项目。

有什么办法做到这一点吗?

This is the way how I create checkout function:

foreach($request->arrayOfObjects as $req) {
    array_push($lineItems, [
        'price' => $req['priceID'],
        'quantity' => (int) $req['quantity']
    ]);
}
    
if (Auth::check()) {
    $charge = $stripeClient->checkout->sessions->create([
        'payment_method_types' => [
            'card',
            'sepa_debit',
            'giropay',
            'sofort',
            'alipay'
        ],
        'success_url' => env('APP_URL').'/success',
        'cancel_url' => env('APP_URL').'/cancel',
        'shipping_address_collection' => [
            'allowed_countries' => ['DE'],
        ],
        'shipping_options' => [
            [
               'shipping_rate' => $request->lieferung ? env('SHIPPING_RATE_LIEFERUNG') : env('SHIPPING_RATE_ABHOLUNG')
            ],
        ],
        'line_items' => [$lineItems],
        'mode' => 'payment',
        'metadata' => [
            'lieferung' => $request->lieferung,
            'isCustomer' => true
        ],
        'allow_promotion_codes' => true,
        'customer' => Auth::user()->stripe_id
    ]);
}

It works fine though... However, I'd like to know is there way to describe measurements of an article?

For example I have ordered 10 packages of Parquet Flooring Classic and each package has 3m2 of parquet.

I'd like to see it in the bill, like:

Article 1001 - Parquet Flooring Classic (10x Packages - 3m2 each)

I found that metadata could be provided but only for the global checkout level, not per item.

Is there any way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小糖芽 2025-02-13 17:58:30

can 使用条纹结帐提供每个项目的元数据。这是一个示例:

$charge = $stripeClient->checkout->sessions->create([
    ...
    'line_items' => [
        // item 1
        [
            'price_data' => [
                'product_data' => [
                    'name' => 'Item A',
                ],
                // 10.99 USD
                'currency' => 'usd',
                'unit_amount' => 1099,
            ],
            'quantity' => 3,
        ],
        // item 2
        [
            'price_data' => [
                'product_data' => [
                    'name' => 'Item B',
                ],
                // 5.49 USD
                'currency' => 'usd',
                'unit_amount' => 549,
            ],
            'quantity' => 2, 
        ],
    ],
    ...
]);

列表,

3 x Item A ....... 32.97 $ USD
2 x Item B ....... 10.98 $ USD

在结帐时,它将为您提供整洁的检查 以 Stripe API文档(单击所有可能的键以及它们的用途的'显示儿童属性'按钮。)

You can provide metadata per item using Stripe Checkout. Here's an example:

$charge = $stripeClient->checkout->sessions->create([
    ...
    'line_items' => [
        // item 1
        [
            'price_data' => [
                'product_data' => [
                    'name' => 'Item A',
                ],
                // 10.99 USD
                'currency' => 'usd',
                'unit_amount' => 1099,
            ],
            'quantity' => 3,
        ],
        // item 2
        [
            'price_data' => [
                'product_data' => [
                    'name' => 'Item B',
                ],
                // 5.49 USD
                'currency' => 'usd',
                'unit_amount' => 549,
            ],
            'quantity' => 2, 
        ],
    ],
    ...
]);

At checkout, it will give you a neat list of

3 x Item A ....... 32.97 $ USD
2 x Item B ....... 10.98 $ USD

Check all the information on line_items in The stripe API documentation (click on the 'show child attributes' button for all the possible keys and what they're for.)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文