# 4. Tax Calculation

# Brief Description

  • Swifood calculates the tax related information of the product by using the order price, service fee, discount type, discount amount and other information.

# HTTP Request Information

# Request URL

  • {domain}/open-api/order/tax/calculate

# Request Method

  • POST

# Request Header

Parameter Name Required Type Description
Content-Type Yes string application/json

# Request Body Parameters

Parameter Name Required Type Length Limit Example Description
appId Yes string - 45eebd745dcf0b5f6d6f9fcde28cd9fe8116a892 App id (provided by Swifood)
storeKey Yes string 100 CVIEIYUNHTS0 Store key (provided by Swifood)
param Yes string - - Request param content string
sign Yes string - RSA sign of param

# Param Parameters

Parameter Name Required Type Length Limit Example Description
totalAmount Yes integer 0 - 100000000 1000 Total order price after tax, Unit: cents
serviceFee No integer 0 - 10000000 100 Service charge
discountType No integer - 1 Discount type 1: PWD discount; 2: Promo discount; 4: SC discount
promoDiscountType No integer - 1 1. Whole order discount 2. Product discount
discountAmount No integer - 10 Promo discount amount (For promo discount, this parameter is filled)
deliveryFee No integer - 100 Delivery fee (required for takeout orders)
packingFee No integer - 100 Packing fee (required for takeout orders
productInfo No List 1 - 210 - Product info

# Product Info Param

Parameter Name Required Type Length Limit Example Description
productName Yes string 1 - 50 coffee Product name
price Yes integer 0 - 1000000 100 Unit price of product after tax, Unit: cents
quantity Yes integer 1 - 1000 1 Product quantity
discountAmount No integer 1 - 1000000 Product promo discount amount (This value is required when it is a Promo discount)

# Request body example

{
  "appId": "OpenTestAppId",
  "storeKey": "OpenTestStoreKey",
  "sign": "OpenTestSign",
  "param": "{\"productInfo\":[{\"productName\":\"item1\",\"price\":100,\"quantity\": 1},{\"productName\":\"item2\",\"price\":100,\"quantity\":1}],\"totalAmount\":200}"
}

# Response Example

# Code Refer to this list

# Response Parameters

Parameter Name Type Example Description
code int 10000 Status Code Refer to List
message string success Status Code Information
data string - Response Param
productAmount integer 100 Order price before tax
taxAmount integer - Order Tax amount
vatableSales integer - The total amount of product subject to tax before tax, excluding service fee
vatExemptSales integer - Pre-tax sales amount of duty-free product (PWD/SC discount product)
vatExemption integer - The amount of tax exempt
zeroRatedSales integer - Duty-free product amount
discountedAmount integer 80 Amount after order discount
productTaxInfo List - product tax info

# Product Tax Info Param

Parameter Name Type Length Limit Description
productName string 1 - 50 Product name
productAmount integer 1 - 1000000 Product price before tax
taxAmount integer - Product tax amount
vatableSales integer - The total amount of product subject to tax before tax, excluding service fee
vatExemptSales integer - Pre-tax sales amount of duty-free product (PWD/SC discount product)
vatExemption integer - The amount of tax exempt
zeroRatedSales integer - Duty-free product amount
{
  "code": 10000,
  "message": "success",
  "messageIn": "success",
  "data": {
    "productAmount": 100,
    "taxAmount": 0,
    "vatableSales": 0,
    "vatExemptSales": 100,
    "vatExemption": 12,
    "zeroRatedSales": 0,
    "productTaxInfo": [
      {
        "productName": "test11",
        "taxAmount": 0,
        "vatableSales": 0,
        "vatExemptSales": 99,
        "vatExemption": 12,
        "zeroRatedSales": 0
      },
      {
        "productName": "test12",
        "taxAmount": 0,
        "vatableSales": 0,
        "vatExemptSales": 1,
        "vatExemption": 0,
        "zeroRatedSales": 0
      }
    ]
  }
}

# Failed Response Example

{
    "code":21000,
    "message":"Service error, please contact administrator",
    "data":null
}