# 创建包含指定购物车中所有商品的订单

用于客户端到服务器的集成。创建包含指定购物车中所有商品的订单，并为该订单生成支付令牌。创建后的订单状态为new。

客户端IP用于确定用户所在国家/地区，进而为订单应用对应的货币和可用支付方式。

如需在新窗口中打开支付UI，请使用以下链接：https://secure.xsolla.com/paystation4/?token={token}，其中{token}是收到的令牌。

如要进行测试，请使用以下URL：https://sandbox-secure.xsolla.com/paystation4/?token={token}`。

提示由于此方法会根据IP确定用户所在国家/地区，并为订单选择货币，因此请务必仅在客户端侧使用此方法，不要在服务器侧使用。从服务器侧使用此方法可能导致货币判断不准确，并影响支付收银台中可用的支付方式。

Endpoint: POST /v2/project/{project_id}/payment/cart/{cart_id}
Version: 2.0.0
Security: AuthForCart

## Path parameters:

  - `project_id` (integer, required)
    项目ID。您可以在发布商帐户的项目名称旁找到此参数；使用项目时，也可以在浏览器地址栏中找到此参数。URL格式如下：https://publisher.xsolla.com//projects/。
    Example: 44056

  - `cart_id` (string, required)
    购物车ID。
    Example: "custom_id"

## Request fields (application/json):

  - `currency` (string)
    订单价格币种。符合[ISO 4217](https://en.wikipedia.org/wiki/ISO_4217)标准的三位币种代码。关于[艾克索拉支持的币种](https://developers.xsolla.com/zh/doc/pay-station/references/supported-currencies/)的详细信息，请参阅文档。

  - `locale` (string)
    响应语言。

  - `sandbox` (boolean)
    在沙盒模式下创建订单。此选项仅适用于公司用户列表中指定的用户。

  - `settings` (object)
    用于为用户配置支付流程和支付UI的设置。

  - `settings.ui` (object)
    界面设置。

  - `settings.ui.theme` (string)
    支付UI主题。可以是63295a9a2e47fab76f7708e1（浅色主题（默认）），或63295aab2e47fab76f7708e3（深色主题）。您也可以[创建自定义主题](https://developers.xsolla.com/zh/doc/pay-station/features/ui-theme-customization/#pay_station_ui_theme_customization_in_token)，然后在此参数中传入其ID。
    Enum: "63295a9a2e47fab76f7708e1", "63295aab2e47fab76f7708e3"

  - `settings.ui.desktop` (object)
    桌面版的界面设置。

  - `settings.ui.desktop.header` (object)
    页眉设置。

  - `settings.ui.desktop.header.is_visible` (boolean)
    是否在支付UI中显示页眉。

  - `settings.ui.desktop.header.visible_logo` (boolean)
    如果为true，则在页眉中显示Logo。如需上传图片，请在[发布商帐户](https://publisher.xsolla.com/)中打开项目，并前往支付收银台>设置部分。

  - `settings.ui.desktop.header.visible_name` (boolean)
    是否在页眉中显示项目名称。

  - `settings.ui.desktop.header.visible_purchase` (boolean)
    是否在页眉中显示购买描述（purchase.description.value）。默认为true。

  - `settings.ui.desktop.header.type` (string)
    页眉的显示方式。可为compact（隐藏项目名称和用户ID）或normal（默认）。
    Enum: "compact", "normal"

  - `settings.ui.desktop.header.close_button` (boolean)
    是否在桌面端支付UI中显示关闭按钮。该按钮将关闭支付UI并将用户重定向到settings.return_url参数中指定的URL。默认为false。

  - `settings.ui.mode` (string)
    支付UI的界面模式。只能是user_account。请注意，页眉仅包含用户帐户的导航菜单，而没有用于选择产品或进行付款的任何选项。此模式仅适用于桌面端。
    Enum: "user_account"

  - `settings.ui.user_account` (object)
    用户帐户详细信息。

  - `settings.ui.user_account.payment_accounts` (object)
    我的支付帐户子菜单。

  - `settings.ui.user_account.payment_accounts.enable` (boolean, required)
    是否显示子菜单。默认为false。

  - `settings.ui.user_account.info` (object)
    我的帐户页面。

  - `settings.ui.user_account.info.enable` (boolean, required)
    是否显示子菜单。默认为false。

  - `settings.ui.user_account.info.order` (integer, required)
    子菜单在菜单中的位置。

  - `settings.ui.user_account.subscriptions` (object)
    管理订阅子菜单。

  - `settings.ui.user_account.subscriptions.enable` (boolean, required)
    是否显示子菜单。默认为false。

  - `settings.ui.user_account.subscriptions.order` (integer, required)
    子菜单在菜单中的位置。

  - `settings.ui.header` (object)

  - `settings.ui.header.visible_virtual_currency_balance` (boolean)
    此元素是否可在支付UI中隐藏。

  - `settings.ui.mobile` (object)

  - `settings.ui.mobile.header` (object)

  - `settings.ui.mobile.header.close_button` (boolean)
    是否在移动端支付UI中显示关闭按钮。该按钮将关闭支付UI并将用户重定向到settings.return_url参数中指定的URL。

  - `settings.ui.is_prevent_external_link_open` (boolean)
    是否禁用指向外部资源的重定向链接。点击外部链接时，会通过postMessage机制发送external-link-open事件。重定向链接地址通过url参数传递。

  - `settings.ui.is_payment_methods_list_mode` (boolean)
    打开支付UI时，是否显示用户所在国家/地区可用的支付方式列表。如果为false（默认），则显示settings.payment_method参数中传入的支付方式，或由[PayRank算法](https://developers.xsolla.com/zh/solutions/payments/payment-ui-management/top-payment-methods-management/)选择的支付方式。

  - `settings.ui.is_independent_windows` (boolean)
    是否将用户从嵌入式启动器浏览器(WebView)跳转到其默认浏览器进行购买。

  - `settings.ui.currency_format` (string)
    设置为code时，将在支付UI中显示三字母[ISO 4217](https://developers.xsolla.com/zh/doc/pay-station/references/supported-currencies/)币种代码。默认显示币种符号，而不是三字母币种代码。

  - `settings.ui.is_show_close_widget_warning` (boolean)
    关闭支付页面前，将鼠标悬停在×图标上时，是否显示关于交易处理中的警告。如果传入false或未传入该参数，则不显示警告。

  - `settings.ui.layout` (string)
    支付UI主要元素的位置。您可以在游戏内打开支付UI和/或交换订单信息和支付方式信息列的位置。详细信息请参阅[自定义说明](https://developers.xsolla.com/zh/doc/pay-station/features/ui-theme-customization/#pay_station_ui_theme_customization_layout)。
    Enum: "embed", "column_reverse", "embed_column_reverse"

  - `settings.ui.is_three_ds_independent_windows` (boolean)
    是否在新浏览器窗口中打开3-D Secure检查。如果您的配置强制执行内容安全政策(CSP)，请设置为true。

  - `settings.ui.is_cart_open_by_default` (boolean)
    打开移动版支付UI时购物车中商品列表的显示方式。如果为true，列表将以展开视图显示。如果为false（默认）或未传入该参数，列表将以折叠视图显示。

  - `settings.payment_method` (integer)
    支付方式ID。它决定收银台页面中的币种显示方式，因为某些支付方式可能仅支持特定币种。

  - `settings.return_url` (string)
    付款后将用户重定向到的页面。系统会自动将user_id、foreigninvoice、invoice_id和status参数添加到链接中。

  - `settings.redirect_policy` (object)

  - `settings.redirect_policy.redirect_conditions` (string)
    触发用户跳转到返回URL的支付状态。
    Enum: "none", "successful", "successful_or_canceled", "any"

  - `settings.redirect_policy.delay` (integer)
    用户自动跳转到返回URL前的延迟时间。

  - `settings.redirect_policy.status_for_manual_redirection` (string)
    触发显示跳转按钮的支付状态，点击该按钮会将用户重定向到返回URL。
    Enum: "none", "successful", "successful_or_canceled", "any"

  - `settings.redirect_policy.redirect_button_caption` (string)
    本地化的重定向按钮文字。
    Example: "Text button"

  - `custom_parameters` (object)
    项目特定参数。

## Response 200 fields (application/json):

  - `order_id` (integer)
    订单ID。

  - `token` (string)
    支付令牌。

## Response 422 fields (application/json):

  - `errorCode` (integer)
    Example: 1401

  - `statusCode` (integer)
    Example: 422

  - `errorMessage` (string)
    Example: "[0401-1401]: Invalid cart"


