带有运费的条纹订单请求

Stripe Order request with shipping price

我想创建一个条带订单,但是当我将运费添加到数组时,出现以下错误:

响应正文

{
  "error": {
    "message": "Items of type `shipping` are not supported at order creation.",
    "param": "items[2]",
    "type": "invalid_request_error"
  }
}

请求POST正文

{
  "items": {
    "0": {
      "type": "sku",
      "parent": "sku_11111111111",
      "quantity": "1"
    },
    "1": {
      "type": "discount",
      "amount": "0",
      "currency": "GBP",
      "description": "No discount"
    },
    "2": {
      "type": "shipping",
      "amount": "30",
      "currency": "gbp",
      "description": "Shipping"
    }
  },
  "currency": "gbp",
  "shipping": {
    "name": "name lastname",
    "address": {
      "line1": "addres",
      "city": "city",
      "state": "pr",
      "country": "AM",
      "postal_code": "123"
    }
  },
  "email": "test@test.test",
  "metadata": {
    "payment_method": "visa"
  }
}

我也找到了 this,但我不明白 你的端点响应 部分

请务必首先注意 Orders API has been deprecated for some time and is not recommended for new integrations. Instead, I would suggest looking at Checkout 用于创建和履行客户订单。

对于订单,shipping docs explain that shipping is configured in your dashboard settingsprovidercallback 选项要求您配置运送信息的提供方式,“您的端点响应”部分解释了动态运送回调应如何响应 Stripe。

如果您使用的是 flat-rate 配置,则 order creation response will include one or more shipping_method options, and you can change which is being used by sending an update request to set the selected_shipping_method.