跳到主要内容

结账

Checkout API 用于在店铺前台开启结账会话,并返回顾客要跳转到的结账地址。主题有两个场景会用到它:商品页的立即购买按钮,把单个商品直接带进结账、不经过购物车;订单页的去支付按钮,为顾客未付款的订单重新开启支付。

下面的示例带了 X-CSRF-Token 请求头,取值方式见身份要求。本页的请求体都是 JSON,Content-Type 设为 application/json

所有 Ajax API 请求应使用多语言 URL,以便为访客提供一致的体验。

创建结账会话

POST /{locale}/api/checkout/order

为一组 variant 创建结账会话。响应返回本页其他 endpoint 所需的 order_token,以及顾客要跳转到的 checkout_url

请求示例

const data = {
line_items: [
{
product_id: '14a309ec-b966-4cf9-a9bb-33baa821fdbc',
variant_id: 'fff360dd-6457-466a-98b3-16878bacef5b',
quantity: 1
}
],
refer_info: {
source: 'buy_now'
}
};

fetch(window.SHOPLAZZA.routes.root + '/api/checkout/order', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': getCsrfToken()
},
body: JSON.stringify(data)
})
.then((response) => response.json())
.then((data) => {
// do something...
});

请求参数

    line_items object[]

    要结账的 variant 列表。

  • Array [
  • product_idstring

    variant 所属商品的 id。

    variant_idstring

    variant 的 id。

    quantitynumber

    variant 的数量。

  • ]
  • refer_info object

    请求来源信息。包含 source 属性,取值为 add_to_cartbuy_nowcart

    sourcestring

响应

    statestring

    请求结果标识,success0 表示请求成功。

    messagestring

    响应返回的结果说明。

    errorsundefined[]

    请求失败时返回的错误列表。

    data object

    响应数据主体。

    order_tokenstring

    标识该订单的 token。

    checkout_urlstring

    订单结账页的相对地址。

    prices object

    订单的金额明细。

    total_pricestring

    应用折扣后购物车的总价。

    subtotal_pricestring

    折扣前所有行项目价格的总和。

    shipping_pricestring

    订单的运费。

    tax_pricestring

    订单的税费。

    discount_pricestring

    订单的折扣总额。

    discount_line_item_pricestring

    已应用折扣的折后总价。

    discount_code_pricestring

    优惠码带来的折扣金额。

    currency_codestring

    订单的货币代码,例如 USD

    discount_applicationsundefined[]

    该对象已应用的折扣。

    items object[]

    购物车中的行项目列表。

  • Array [
  • barcodestring

    款式的条形码。

    compare_at_pricestring

    划线价。

    cost_pricestring

    款式的成本价。

    customboolean

    该行项目是否为自定义商品。

    discount_applicationsundefined[]

    该对象已应用的折扣。

    discount_totalstring

    折扣总额。

    final_line_pricestring

    应用行级折扣后,该行项目所有商品的合计价格。

    idstring

    行项目的 ID。

    image object

    行项目所属款式的图片。

    altstring

    图片的替代文本。

    heightnumber

    图片高度(像素)。

    pathstring

    图片文件在图床上的路径。

    srcstring

    图片的地址。

    widthnumber

    图片宽度(像素)。

    line_pricestring

    应用折扣前,该行项目所有商品的合计价格。

    mixed_wholesaleboolean

    是否支持混批。

    notestring

    行项目的备注。

    options object[]

    行项目所属款式的属性取值。

  • Array [
  • namestring

    商品属性名称,例如 Color

    valuestring

    该商品属性被选中的取值。

  • ]
  • pricestring

    行项目单件商品的价格。

    product_handlestring

    商品的 handle。

    product_idstring

    商品 ID。

    product_tagsundefined[]

    商品的标签。

    product_titlestring

    商品名称。

    product_urlstring

    商品页的相对地址。

    propertiesstring

    行项目上记录的自定义属性。

    quantitynumber

    商品数量。

    requires_shippingboolean

    是否需要物流配送。

    skustring

    款式的 SKU,用于库存管理。

    spustring

    商品的 SPU(标准产品单元)。

    tax_codestring
    tax_pricestring

    行项目的税费。

    tax_ratestring

    适用的税率。

    taxableboolean

    是否需要计税。

    trunk_pricestring

    行项目的主干价格。

    variant_idstring

    款式 ID。

    variant_titlestring

    款式标题,例如 Blue, Size M

    vendorstring

    商品的供应商。

    vendor_urlstring

    商品供应商的链接。

    weightstring

    款式的重量。

    weight_unitstring

    重量单位,例如 kg

    wholesale_price object[]

    批发价梯度列表。

  • Array [
  • min_quantitynumber

    该批发价梯度要求的最小数量。

    pricestring

    该批发价梯度的单价。

  • ]
  • totalstring

    行项目的总价。

    tax_linesundefined[]

    订单的税费明细。

    final_pricestring

    应用行级折扣后,该行项目单件商品的价格。

    is_free_giftboolean

    该商品是否为赠品。

    excluded_tax_sub_totalstring
    lengthnumber

    该行项目包裹的长度。

    widthnumber

    该行项目包裹的宽度。

    heightnumber

    该行项目包裹的高度。

    dimension_unitstring

    包裹尺寸的单位。

    hs_codestring

    用于报关的 HS 编码。

    origin_country_codestring

    商品原产国的代码。

    origin_pricestring
    duty_pricestring

    行项目的关税费用。

    product_typestring

    商品类型。

  • ]
  • keystring

    与订单 ID 一起用于打开结账页的 key。

    line_items object[]

    行项目列表。

  • Array [
  • barcodestring

    款式的条形码。

    compare_at_pricestring

    划线价。

    cost_pricestring

    款式的成本价。

    customboolean

    该行项目是否为自定义商品。

    discount_applicationsundefined[]

    该对象已应用的折扣。

    discount_totalstring

    折扣总额。

    final_line_pricestring

    应用行级折扣后,该行项目所有商品的合计价格。

    idstring

    行项目的 ID。

    image object

    行项目所属款式的图片。

    altstring

    图片的替代文本。

    heightnumber

    图片高度(像素)。

    pathstring

    图片文件在图床上的路径。

    srcstring

    图片的地址。

    widthnumber

    图片宽度(像素)。

    line_pricestring

    应用折扣前,该行项目所有商品的合计价格。

    mixed_wholesaleboolean

    是否支持混批。

    notestring

    行项目的备注。

    options object[]

    行项目所属款式的属性取值。

  • Array [
  • namestring

    商品属性名称,例如 Color

    valuestring

    该商品属性被选中的取值。

  • ]
  • pricestring

    行项目单件商品的价格。

    product_handlestring

    商品的 handle。

    product_idstring

    商品 ID。

    product_tagsundefined[]

    商品的标签。

    product_titlestring

    商品名称。

    product_urlstring

    商品页的相对地址。

    propertiesstring

    行项目上记录的自定义属性。

    quantitynumber

    商品数量。

    requires_shippingboolean

    是否需要物流配送。

    skustring

    款式的 SKU,用于库存管理。

    spustring

    商品的 SPU(标准产品单元)。

    tax_codestring
    tax_pricestring

    行项目的税费。

    tax_ratestring

    适用的税率。

    taxableboolean

    是否需要计税。

    trunk_pricestring

    行项目的主干价格。

    variant_idstring

    款式 ID。

    variant_titlestring

    款式标题,例如 Blue, Size M

    vendorstring

    商品的供应商。

    vendor_urlstring

    商品供应商的链接。

    weightstring

    款式的重量。

    weight_unitstring

    重量单位,例如 kg

    wholesale_price object[]

    批发价梯度列表。

  • Array [
  • min_quantitynumber

    该批发价梯度要求的最小数量。

    pricestring

    该批发价梯度的单价。

  • ]
  • totalstring

    行项目的总价。

    tax_linesundefined[]

    订单的税费明细。

    final_pricestring

    应用行级折扣后,该行项目单件商品的价格。

    is_free_giftboolean

    该商品是否为赠品。

    excluded_tax_sub_totalstring
    lengthnumber

    该行项目包裹的长度。

    widthnumber

    该行项目包裹的宽度。

    heightnumber

    该行项目包裹的高度。

    dimension_unitstring

    包裹尺寸的单位。

    hs_codestring

    用于报关的 HS 编码。

    origin_country_codestring

    商品原产国的代码。

    origin_pricestring
    duty_pricestring

    行项目的关税费用。

    product_typestring

    商品类型。

  • ]
  • invalid_line_itemsundefined[]

    未能计入订单的行项目。

    redirect_urlstring

    顾客应被跳转到的地址。

获取结账会话

GET /{locale}/api/checkout/order/{order_id}

获取结账会话的当前状态,order_id 取结账地址里的 order token。

请求示例

fetch(window.SHOPLAZZA.routes.root + '/api/checkout/order/2446407200000000000000')
.then((response) => response.json())
.then((data) => {
// do something...
});

请求参数

    order_idstring

    创建结账会话时返回的 order token。

响应

    data object

    响应数据主体。

    idstring

    订单的 ID。

    refer_info object

    顾客访问来源信息。

    address_checkboolean
    client_idstring
    countrystring
    customer_sessionstring
    domainstring
    fbcstring
    fbpstring
    inventory_deductionstring
    ipstring

    访客的 IP 地址。

    segstring
    session_idstring
    sourcestring
    user_agentstring
    order_nostring

    订单号。

    create_timestring

    订单创建时间,与 create_at 相同。

    placed_atstring可空

    订单支付时间。

    statusstring

    订单状态,例如 openedplacedfinished

    financial_statusstring

    订单的支付状态,例如 waitingpaid

    fulfillment_statusstring

    发货状态,例如 waitingshippedfinished

    post_sale_statusstring可空

    订单的售后状态。

    email_statusstring

    订单召回邮件的状态,waiting 待发送,send 已发送。

    notestring可空

    商家为订单添加的备注。

    cancel_reasonstring可空

    订单的取消原因。

    discount_codestring

    订单使用的优惠码。

    customer_notestring

    顾客在结账时填写的备注。

    currency_codestring

    订单的货币代码,例如 USD

    shipping_address_editableboolean

    收货地址是否仍可修改。

    config object

    订单的配置信息。

    page_typestring

    结账页的版式,例如 three_step

    requires_shippingboolean

    是否需要物流配送。

    checkout_business_typenumber
    product_tax_includedboolean

    商品价格是否含税。

    checkout_template_typenumber
    market_setting object

    订单适用的市场设置。

    primary_market_langstring

    店铺主市场的语言代码。

    market_langstring

    市场使用的语言代码。

    market_idstring

    订单所属市场的 ID。

    market_currencystring

    市场使用的货币代码。

    market_currency_symbol object

    市场货币的符号信息。

    codestring

    货币代码,例如 USD

    valstring

    货币符号,例如 $

    leftstring

    显示在金额左侧的内容。

    rightstring

    显示在金额右侧的内容。

    market_base_currencystring

    市场的基准货币代码。

    market_base_currency_symbol object

    市场基准货币的符号信息。

    codestring

    货币代码,例如 USD

    valstring

    货币符号,例如 $

    leftstring

    显示在金额左侧的内容。

    rightstring

    显示在金额右侧的内容。

    primary_market_idstring

    店铺主市场的 ID。

    primary_market_currencystring

    店铺主市场的货币代码。

    primary_market_currency_symbol object

    店铺主市场货币的符号信息。

    codestring

    货币代码,例如 USD

    valstring

    货币符号,例如 $

    leftstring

    显示在金额左侧的内容。

    rightstring

    显示在金额右侧的内容。

    market_price_setting object
    local_currency_enabledboolean
    custom_rate_enabledboolean
    custom_ratenumber
    ratenumber
    back_ratenumber
    actual_ratenumber
    base_to_localnumber
    local_to_basenumber
    adjustnumber
    price_round_enabledboolean
    market_countrystring

    市场所属国家的代码。

    discount_applicationsundefined[]

    该对象已应用的折扣。

    canceled_atstring可空

    订单取消时间。

    fail_codestring可空
    shipping_lineundefined[]

    订单所选的物流方案。

    customer object

    顾客详情。

    idstring

    顾客的 ID。

    emailstring

    顾客的邮箱地址。

    first_namestring

    顾客或收件人的名。

    last_namestring

    顾客或收件人的姓。

    phonestring

    顾客的电话号码。

    tagsundefined[]

    对象上的标签。

    subscribedboolean

    顾客是否订阅了营销信息。

    namestring

    顾客的全名。

    notestring可空

    对象上的备注。

    contactstring

    顾客的联系方式,邮箱或电话号码。

    contact_typestring

    联系方式类型,邮箱或电话。

    created_atstring

    创建时间(ISO-8601 格式)。

    registeredboolean

    顾客是否已注册账号。

    registered_atstring

    顾客完成注册的时间。

    sourcestring

    顾客数据的来源。

    free_taxstring可空

    顾客是否享有税收豁免。

    location_idstring
    customer_extra_info object

    顾客的附加统计信息。

    finished_order_countnumber

    顾客已完成的订单数。

    finished_order_totalstring

    顾客已完成订单的总金额。

    countrystring
    country_codestring
    provincestring

    地址所在省或州。

    province_codestring

    省或州的代码。

    currency_codestring

    订单的货币代码,例如 USD

    purchase_product_countnumber

    顾客已购买的商品件数。

    store_customer_idstring
    customer_rolestring可空
    extstring可空
    first_order_atstring

    顾客首次下单时间。

    last_order_atstring

    顾客最后一次下单时间。

    shipping_address object

    订单的收货地址。

    idstring

    地址的 ID。

    first_namestring

    顾客或收件人的名。

    last_namestring

    顾客或收件人的姓。

    emailstring

    与该地址关联的邮箱。

    phonestring可空

    与该地址关联的电话号码。

    country_codestring

    地址所在国家的 ISO 代码。

    countrystring

    地址所在国家的名称。

    province_codestring

    省或州的代码。

    provincestring

    地址所在省或州。

    areastring可空

    地址所在区域。

    citystring

    地址所在城市。

    addressstring

    收件人的详细地址。

    address1string可空

    详细地址第一行。

    zipstring

    邮政编码。

    extra_infostring可空
    companystring可空

    地址的公司名称。

    phone_area_codestring

    电话号码的区号。

    latitudestring可空

    地址的纬度。

    longitudestring可空

    地址的经度。

    sourcestring可空
    tagsstring可空

    对象上的标签。

    billing_addressstring可空

    订单的账单地址。

    line_items object[]

    行项目列表。

  • Array [
  • idstring

    行项目的 ID。

    product_titlestring

    商品名称。

    product_idstring

    商品 ID。

    product_handlestring

    商品的 handle。

    variant_idstring

    款式 ID。

    variant_titlestring

    款式标题,例如 Blue, Size M

    quantitynumber

    商品数量。

    fulfillment_statusstring

    发货状态,例如 waitingshippedfinished

    notestring

    行项目的备注。

    image object

    行项目所属款式的图片。

    altstring

    图片的替代文本。

    heightnumber

    图片高度(像素)。

    pathstring

    图片文件在图床上的路径。

    srcstring

    图片的地址。

    widthnumber

    图片宽度(像素)。

    compare_at_pricestring

    划线价。

    pricestring

    行项目单件商品的价格。

    totalstring

    行项目的总价。

    skustring

    款式的 SKU,用于库存管理。

    weightstring

    款式的重量。

    weight_unitstring

    重量单位,例如 kg

    taxableboolean

    是否需要计税。

    requires_shippingboolean

    是否需要物流配送。

    options object[]

    行项目所属款式的属性取值。

  • Array [
  • namestring

    商品属性名称,例如 Color

    valuestring

    该商品属性被选中的取值。

  • ]
  • vendorstring

    商品的供应商。

    product_urlstring

    商品页的相对地址。

    propertiesstring

    行项目上记录的自定义属性。

    barcodestring

    款式的条形码。

    product_spustring

    商品的 SPU。

    product_vendor_urlstring

    商品供应商的链接。

    product_tagsundefined[]

    商品的标签。

    discount_applicationsundefined[]

    该对象已应用的折扣。

    tax_codestring
    tax_ratestring

    适用的税率。

    tax_pricestring

    行项目的税费。

    wholesale_price object[]

    批发价梯度列表。

  • Array [
  • pricestring

    该批发价梯度的单价。

    min_quantitynumber

    该批发价梯度要求的最小数量。

  • ]
  • mixed_wholesaleboolean

    是否支持混批。

    item_pricestring
    cost_pricestring

    款式的成本价。

    customboolean

    该行项目是否为自定义商品。

    trunk_pricestring

    行项目的主干价格。

    main_currency_prices object

    订单金额换算成店铺主货币后的结果。

    compare_at_pricestring

    划线价。

    pricestring

    换算成店铺主货币后的单价。

    totalstring

    换算成店铺主货币后的总额。

    tax_pricestring

    行项目的税费。

    item_pricestring
    cost_pricestring

    款式的成本价。

    trunk_pricestring

    行项目的主干价格。

    actual_ratestring

    换算所用的汇率。

    fixed_discount_totalstring
    excluded_tax_sub_totalstring
    tax_linesundefined[]

    订单的税费明细。

    lengthnumber

    该行项目包裹的长度。

    widthnumber

    该行项目包裹的宽度。

    heightnumber

    该行项目包裹的高度。

    dimension_unitstring

    包裹尺寸的单位。

    commissionstring
    origin_country_codestring

    商品原产国的代码。

    hs_codestring

    用于报关的 HS 编码。

    created_bystring
    origin_pricestring
    duty_pricestring

    行项目的关税费用。

    line_pricestring

    应用折扣前,该行项目所有商品的合计价格。

    discount_totalstring

    折扣总额。

    final_line_pricestring

    应用行级折扣后,该行项目所有商品的合计价格。

    final_pricestring

    应用行级折扣后,该行项目单件商品的价格。

  • ]
  • payment_linestring可空

    订单的支付详情。

    testboolean

    是否为测试订单。

    order_status_urlstring

    订单状态页的相对地址。

    order_keystring

    与订单 ID 一起用于访问订单的 key。

    yet_paymentstring

    订单尚未支付的金额。

    refundstring

    订单的退款金额。

    installment_feestring

    订单的分期手续费。

    paid_totalstring

    订单已支付的总金额。

    updated_timestring

    订单最后更新时间。

    checkout_idstring
    tax_typenumber
    applied_gift_cardsundefined[]

    订单已使用的礼品卡。

    payment_linesundefined[]

    订单的支付记录列表。

    checkout_urlstring

    订单结账页的相对地址。

    finished_atstring可空

    订单完成时间。

    fulfillmentsundefined[]

    订单的物流记录列表。

    identifier_extrastring
    main_currency_prices object

    订单金额换算成店铺主货币后的结果。

    sub_totalstring

    应用订单级折扣前,所有行项目价格的总和。

    shipping_totalstring

    订单的运费总额。

    tax_totalstring

    订单的税费总额。

    discount_totalstring

    折扣总额。

    totalstring

    换算成店铺主货币后的总额。

    total_tip_receivedstring

    订单收到的小费总额。

    refund_totalstring

    订单的退款总额。

    actual_ratestring

    换算所用的汇率。

    shipping_line_detailstring可空
    order_typenumber

    订单类型,0 为普通订单,1 为礼品卡订单。

    shipping_tax_typenumber
    product_tax_includedboolean

    商品价格是否含税。

    translationsundefined[]
    location_line object

    商家仓库地址。

    idstring

    地址的 ID。

    location_idstring

    仓库 ID。

    location_namestring

    仓库名称。

    first_namestring

    顾客或收件人的名。

    last_namestring

    顾客或收件人的姓。

    phonestring

    与该地址关联的电话号码。

    emailstring

    与该地址关联的邮箱。

    countrystring

    地址所在国家的名称。

    country_codestring

    地址所在国家的 ISO 代码。

    provincestring

    地址所在省或州。

    province_codestring

    省或州的代码。

    areastring

    地址所在区域。

    citystring

    地址所在城市。

    addressstring

    收件人的详细地址。

    address1string

    详细地址第一行。

    companystring

    地址的公司名称。

    latitudestring

    地址的纬度。

    longitudestring

    地址的经度。

    zipstring

    邮政编码。

    phone_area_codestring

    电话号码的区号。

    extra_infostring
    additional_totalstring

    订单的附加费用总额。

    additional_pricesundefined[]

    附加费用明细。

    tax_lines object

    订单的税费明细。

    sales_tax_linesundefined[]
    locale_zonestring
    tagsundefined[]

    对象上的标签。

    order_customer object

    订单上记录的顾客信息。

    origin_idstring
    first_namestring

    顾客或收件人的名。

    last_namestring

    顾客或收件人的姓。

    emailstring

    顾客的邮箱地址。

    phonestring

    顾客的电话号码。

    customer_rolestring
    extundefined[]
    duty_totalstring

    订单的关税税费总额。

    mail_send_configundefined[]
    custom_fieldsundefined[]
    already_payment_linesundefined[]
    additional_rules object[]
  • Array [
  • idstring
    namestring
    input_typenumber
    descriptionstring
    enablenumber
    show_typestring
    show_rules object[]
  • Array [
  • fieldstring
    rulesundefined[]
  • ]
  • requirenumber
    validatesundefined[]
    enumsundefined[]
  • ]
  • checkout_settings object

    店铺的结账设置。

    customer_authoritystring
    checkout_page_typestring

    结账页的版式,例如 three_step

    lineitems_validateboolean
    discount_showstring
    discount_show_v2string[]
    reduction_show object
    singlestring[]
    two_stepstring[]
    three_stepstring[]
    zip_checkstring
    zip_check_v2string
    zip_format_checkstring
    zip_check_config object
    GBnumber
    USnumber
    BRnumber
    MXnumber
    CLnumber
    COnumber
    DEnumber
    KRnumber
    ROnumber
    zip_check_config_v2 object
    AEnumber
    BHnumber
    KWnumber
    OMnumber
    QAnumber
    SAnumber
    order_timeoutnumber
    inventory_deductionstring
    shipping_cpf object
    config_info object
    config_default object
    lengthstring
    typestring
    config_br object
    lengthstring
    typestring
    is_show_countries object
    cpf_cnpj object
    titlestring
    country_codesstring
    is_filledboolean
    countriesstring可空
    format_checkboolean
    rut object
    titlestring
    country_codesstring
    is_filledboolean
    countriesstring可空
    format_checkboolean
    other object
    titlestring
    is_filledboolean
    countriesundefined[]
    format_checkboolean
    countriesundefined[]
    is_showboolean
    instructionstring
    address_setting object
    namestring

    地址表单中姓名字段的排布方式。

    emailstring

    地址表单中邮箱字段的展示设置。

    phonestring

    地址表单中电话字段的展示设置。

    companystring

    地址表单中公司字段的展示设置,例如 hidden

    addressstring

    地址表单中详细地址字段的展示设置。

    address1string

    地址表单中详细地址字段的展示设置。

    name_requirementstring

    姓名字段中哪一项必填,例如 last_name

    contact_detailsstring

    地址表单收集联系方式的方式。

    auto_completestring
    doorplate_format_checkstring
    forced_zip_checkstring[]
    identification_info object
    default object
    countriesstring可空
    format_checkboolean
    is_filledboolean
    rules object[]
  • Array [
  • country_codestring
    namestring
    regexpstring
    example_valstring
  • ]
  • shipping_method_display_stylestring
    address_settings object

    地址表单的配置。

    namestring

    地址表单中姓名字段的排布方式。

    emailstring

    地址表单中邮箱字段的展示设置。

    phonestring

    地址表单中电话字段的展示设置。

    companystring

    地址表单中公司字段的展示设置,例如 hidden

    addressstring

    地址表单中详细地址字段的展示设置。

    address1string

    地址表单中详细地址字段的展示设置。

    name_requirementstring

    姓名字段中哪一项必填,例如 last_name

    contact_detailsstring

    地址表单收集联系方式的方式。

    customer_info object

    结账时填写的联系信息。

    emailstring

    顾客的邮箱地址。

    first_namestring

    顾客或收件人的名。

    last_namestring

    顾客或收件人的姓。

    phonestring

    顾客的电话号码。

    payment_settings object

    结账页可用的支付设置。

    settings object
    dynamic_config object
    paypal_js_sdk_urlstring
    express_checkout_config object
    express_channelsundefined[]
    express_account_infosundefined[]
    express_theme_configsundefined[]
    scmstring
    unified_user_idstring
    fallback_reasonstring
    request_idstring
    ec_legacy_apple_pay_block_store_idsstring[]
    ec_legacy_google_pay_block_store_idsstring[]
    ec_legacy_spz_paypal_store_idsundefined[]
    express_checkout_config object
    express_account_infosundefined[]
    express_channelsundefined[]
    express_theme_configsundefined[]
    payment_icon_resourcesundefined[]
    payment_resourcesundefined[]
    paypal_accountundefined[]
    paypal_account_typestring
    paypal_creditcard_enabledboolean
    paypal_express_enabledboolean
    paypal_shipment_enabledboolean
    support_channelsstring[]
    order_tokenstring

    标识该订单的 token。

    currency_symbolstring

    订单的货币符号。

    currency_symbol_posstring

    货币符号的位置,leftright

    payment_duestring

    订单尚未支付的金额。

    all_tax_totalstring

    订单所有税费的合计。

    prices object

    订单的金额明细。

    subtotal_pricestring

    折扣前所有行项目价格的总和。

    shipping_pricestring

    订单的运费。

    tax_pricestring

    订单的税费。

    discount_code_pricestring

    优惠码带来的折扣金额。

    discount_pricestring

    订单的折扣总额。

    total_pricestring

    应用折扣后购物车的总价。

    shipping_tax_totalstring

    订单的运费税总额。

    discount_line_item_pricestring

    已应用折扣的折后总价。

    total_tip_receivedstring

    订单收到的小费总额。

    discount_shipping_pricestring

    运费上的折扣金额。

    discount_sub_totalstring

    折扣后的小计金额。

    gift_card_pricestring

    礼品卡抵扣的金额。

    paid_totalstring

    订单已支付的总金额。

    payment_duestring

    订单尚未支付的金额。

    all_tax_totalstring

    订单所有税费的合计。

    payment_discount_totalstring

    支付方式带来的折扣金额。

    additional_totalstring

    订单的附加费用总额。

    duty_totalstring

    订单的关税税费总额。

    except_notification object

    完成订单时出现的异常信息。

    codestring

    异常代码,例如 total_price_changed

    ip_address object

    根据顾客 IP 解析出的位置信息。

    country_codestring

    根据顾客 IP 解析出的国家代码。

    province_namestring

    根据顾客 IP 解析出的省份名称。

    country_namestring

    根据顾客 IP 解析出的国家名称。

    citystring

    地址所在城市。

    ipstring

    访客的 IP 地址。

    policy_titlesundefined[]

    结账页展示的店铺条款标题。

    checkout_page_typestring

    结账页的版式,例如 three_step

    stepstring

    结账流程当前所处的步骤。

    statestring

    请求结果标识,success0 表示请求成功。

    messagestring

    响应返回的结果说明。

    errorsundefined[]

    请求失败时返回的错误列表。

保存结账会话的配送地址

POST /{locale}/api/checkout/order/presave

在支付前把配送地址存到会话上,以便按该地址计算运费和税费。

请求示例

const data = {
order_token: '2446407200000000000000',
shipping_address: {
first_name: 'Jane',
last_name: 'Doe',
address: '123 Main St',
city: 'Los Angeles',
country: 'United States',
country_code: 'US',
province: 'California',
province_code: 'CA',
zip: '90001',
}
};

fetch(window.SHOPLAZZA.routes.root + '/api/checkout/order/presave', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': getCsrfToken()
},
body: JSON.stringify(data)
})
.then((response) => response.json())
.then((data) => {
// do something...
});

请求参数

    order_tokenstring

    结账会话的 order token。

    shipping_address object

    要存到会话上的配送地址。

    first_namestring
    last_namestring
    phonestring
    emailstring
    countrystring
    country_codestring
    areastring
    addressstring
    address1string
    companystring
    provincestring
    province_codestring
    citystring
    zipstring

响应

    datastring可空

    响应数据主体。

    statestring

    请求结果标识,success0 表示请求成功。

    messagestring

    响应返回的结果说明。

    errorsundefined[]

    请求失败时返回的错误列表。

重新开启未付款会话的结账

POST /{locale}/api/checkout/order/repay

对已创建但未支付的会话重新打开结账,并拿回它的结账地址。

请求示例

const data = { order_token: '2446407200000000000000' };

fetch(window.SHOPLAZZA.routes.root + '/api/checkout/order/repay', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': getCsrfToken()
},
body: JSON.stringify(data)
})
.then((response) => response.json())
.then((data) => {
// do something...
});

请求参数

    order_tokenstring

    结账会话的 order token。

响应

    data object

    响应数据主体。

    idstring

    订单的 ID。

    checkout_urlstring

    订单结账页的相对地址。

    statestring

    请求结果标识,success0 表示请求成功。

    messagestring

    响应返回的结果说明。

    errorsundefined[]

    请求失败时返回的错误列表。

提交结账会话去支付

POST /{locale}/api/checkout/order/complete

提交结账会话去支付,一并带上地址、联系方式、选定的配送与支付方式,以及会话算出的金额。

请求示例

GET /{locale}/api/checkout/order/{order_id} 读取 shipping_linepayment_lineprices,原样回传,服务端才会按会话相同的口径计价。

const data = {
order_token: '2446407200000000000000',
shipping_address: {
first_name: 'Jane',
last_name: 'Doe',
phone: '',
country: 'United States',
country_code: 'US',
area: '',
address: '456 Oak Ave',
address1: 'Apt 4',
company: '',
province: 'California',
province_code: 'US-CA',
city: 'Los Angeles',
zip: '90002'
},
billing_address: {
first_name: 'Jane',
last_name: 'Doe',
phone: '',
country: 'United States',
country_code: 'US',
area: '',
address: '456 Oak Ave',
address1: 'Apt 4',
company: '',
province: 'California',
province_code: 'US-CA',
city: 'Los Angeles',
zip: '90002'
},
use_shipping_address: '1',
customer_info: {
first_name: 'Jane',
last_name: 'Doe',
phone: '',
newsletter: 0,
note: '',
save_address: 0,
email_or_phone: '[email protected]'
},
shipping_line: {
id: 'd43bfac3-5f80-433d-b9ce-49a3d645cd5c',
name: 'Standard shipping',
desc: '',
delivery_method: 1,
shipping_price: '1.00',
discount_shipping_price: '1.00',
discounts: [],
is_free: false,
support_cod: 0,
location_id: '0',
plan_code: ''
},
payment_line: {
id: '59107222-a7a9-479a-a1f7-dd5d40015033',
name: 'bogus',
payment_channel: 'bogus',
payment_method: 'bogus_gateway',
payment_key: 'bogus',
status: 'open',
is_active: true
},
prices: {
subtotal_price: '1.00',
shipping_price: '0.00',
tax_price: '0.00',
discount_code_price: '0.00',
discount_price: '0.00',
total_price: '1.00',
shipping_tax_total: '0.00',
discount_line_item_price: '0.00',
total_tip_received: '0.00',
discount_shipping_price: '0.00',
discount_sub_total: '1.00',
gift_card_price: '0.00',
paid_total: '0.00',
payment_due: '1.00',
all_tax_total: '0.00',
payment_discount_total: '0.00',
additional_total: '0.00',
duty_total: '0.00'
},
risk_control_info: []
};

fetch(window.SHOPLAZZA.routes.root + '/api/checkout/order/complete', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': getCsrfToken()
},
body: JSON.stringify(data)
})
.then((response) => response.json())
.then((data) => {
// do something...
});

请求参数

    order_tokenstring

    结账会话的 order token。

    shipping_address object

    订单的配送地址。

    first_namestring
    last_namestring
    phonestring
    emailstring
    countrystring
    country_codestring
    areastring
    addressstring
    address1string
    companystring
    provincestring
    province_codestring
    citystring
    zipstring
    billing_address object

    订单的账单地址。

    first_namestring
    last_namestring
    phonestring
    emailstring
    countrystring
    country_codestring
    areastring
    addressstring
    address1string
    companystring
    provincestring
    province_codestring
    citystring
    zipstring
    use_shipping_addressstring

    账单地址是否与配送地址相同,取值 10

    customer_info object

    顾客的联系方式,以及是否订阅营销邮件、是否保存该地址。

    emailstring
    first_namestring
    last_namestring
    phonestring
    newsletternumber
    notestring
    save_addressnumber
    email_or_phonestring
    shipping_line object

    从会话中选定的配送方式,原样回传会话响应里的对象。

    idstring
    namestring
    descstring
    delivery_methodnumber
    shipping_pricestring
    discount_shipping_pricestring
    discountsarray
    is_freeboolean
    support_codnumber
    location_idstring
    plan_codestring
    payment_line object

    从会话中选定的支付方式,原样回传会话响应里的对象。

    idstring
    namestring
    payment_channelstring
    payment_methodstring
    payment_keystring
    statusstring
    is_activeboolean
    prices object

    会话算出的金额,原样回传会话响应里的对象。

    subtotal_pricestring
    shipping_pricestring
    tax_pricestring
    discount_code_pricestring
    discount_pricestring
    total_pricestring
    shipping_tax_totalstring
    discount_line_item_pricestring
    total_tip_receivedstring
    discount_shipping_pricestring
    discount_sub_totalstring
    gift_card_pricestring
    paid_totalstring
    payment_duestring
    all_tax_totalstring
    payment_discount_totalstring
    additional_totalstring
    duty_totalstring
    risk_control_infoarray

    为该订单采集的风控数据,没有采集时传空数组。

响应

    data object

    响应数据主体。

    except_notification object

    完成订单时出现的异常信息。

    codestring

    异常代码,例如 total_price_changed

    statestring

    请求结果标识,success0 表示请求成功。

    messagestring

    响应返回的结果说明。

    errorsundefined[]

    请求失败时返回的错误列表。