如何从API获取Shopify订单的正确税金

时间:2012-11-20 14:16:42

标签: api shopify webhooks

我收到了Shopify网络订单/创建和订单的订单 需要存储适用于该订单的价格和税费。我看到了一些 Shopify首选项中允许我设置销售税的设置 每个送货目的地。 Shopify还允许我选择充电 运费税。我在订单上看到“tax_included”属性 (我认为所列出的价格是净值或总价)。 但它似乎没有说明运费是否含税。是 有没有办法从API中获取这些信息?

这是我在web-hook调用中传递的数据。我可以 进一步的API调用以获取信息(如果可用),但不能 在文档中找到所有内容。

我找到了这里记录的国家API:

http://api.shopify.com/country.html

所以我应该能够找到正确的税率 来自帐单邮寄地址province_code&的line_items COUNTRY_CODE。

但我找不到任何告诉我应该或不应该征税的事情 在航运公司收取费用。

如果实际提供税收会更方便 数据。它也应该更正确,因为有机会(但是 小的)税率在我得到之间发生了变化 回调并进一步要求提供税务信息。有办法吗? 让Shopify在网络钩子中提供这些信息吗?

另外,到目前为止,我还没有在tax_lines属性中获取数据 数据。我需要跳过这个箍吗?

回调中提供的数据示例:

{"note":"",
 "total_discounts":"0.00",
 "cancel_reason":null,
 "shipping_lines":
 [{"code":"International Shipping",
   "price":"25.00",
   "source":"shopify",
   "title":"International Shipping"}],
 "landing_site_ref":null,
 "discount_codes":[],
 "currency":"CAD",
 "buyer_accepts_marketing":true,
 "customer":
 {"last_order_name":null,
  "note":null,
  "last_name":"Test",
  "state":"disabled",
  "updated_at":"2012-11-20T08:05:07-05:00",
  "last_order_id":null,
  "orders_count":0,
  "total_spent":"0.00",
  "created_at":"2012-11-05T10:50:23-05:00",
  "email":"test@example.com",
  "first_name":"Test",
  "accepts_marketing":true,
  "id":101986160,
  "tags":""},
 "token":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
 "note_attributes":[],
 "gateway":"bogus",
 "cancelled_at":null,
 "name":"#1025",
 "processing_method":"direct",
 "updated_at":"2012-11-20T08:05:07-05:00",
 "payment_details":
 {"avs_result_code":null,
  "credit_card_bin":"1",
  "cvv_result_code":null,
  "credit_card_number":"XXXX-XXXX-XXXX-1",
  "credit_card_company":"Bogus"},
 "total_price":"44.00",
 "shipping_address":
 {"country":"United States",
  "last_name":"Test",
  "longitude":"-88.1632",
  "name":"Test Test",
  "address1":"Test",
  "province":"Alabama",
  "address2":"",
  "latitude":"30.3891",
  "city":"Test",
  "phone":"",
  "province_code":"AL",
  "first_name":"Test",
  "country_code":"US",
  "zip":"36523",
  "company":"Test"},
 "line_items":
 [{"variant_id":240781369,
   "quantity":1,
   "name":"product with stock code and shopify stock value",
   "properties":[],
   "title":"product with stock code and shopify stock value",
   "product_id":104741307,
   "variant_inventory_management":"shopify",
   "fulfillment_service":"manual",
   "sku":"some-stock-code",
   "variant_title":null,
   "requires_shipping":true,
   "price":"19.00",
   "vendor":"Shopify",
   "id":243081982,
   "grams":0,
   "fulfillment_status":null}],
 "closed_at":null,
 "billing_address":
 {"country":"United States",
  "last_name":"Test",
  "longitude":"-88.1632",
  "name":"Test Test",
  "address1":"Test",
  "province":"Alabama",
  "address2":"",
  "latitude":"30.3891",
  "city":"Test",
  "phone":"",
  "province_code":"AL",
  "first_name":"Test",
  "country_code":"US",
  "zip":"36523",
  "company":"Test"},
 "order_number":1025,
 "total_line_items_price":"19.00",
 "total_tax":"0.00",
 "tax_lines":[],
 "created_at":"2012-11-20T08:05:07-05:00",
 "landing_site":"\/",
 "fulfillments":[],
 "total_price_usd":"44.14",
 "financial_status":"authorized",
 "email":"test@example.com",
 "browser_ip":"1.2.3.4",
 "total_weight":0,
 "referring_site":"",
 "client_details":
 {"accept_language":"en-US,en;q=0.8",
  "browser_ip":"1.2.3.4",
  "session_hash":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "user_agent":"Mozilla\/5.0 (X11; Linux x86_64) AppleWebKit\/537.1 (KHTML, like Gecko) Chrome\/21.0.1180.89 Safari\/537.1"},
 "subtotal_price":"19.00",
 "number":25,
 "taxes_included":false,
 "id":148179898,
 "cart_token":"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
 "fulfillment_status":null}

1 个答案:

答案 0 :(得分:1)

假设对订单征税,所有税将显示在税行数组中。在测试中使用真实地址可能会更好。试试美国着名的地标或其他东西。

如果商店设置为对运费征税,金额将包含在订单的税行中。您可以通过查看Shop对象了解商店是否对运费征税。