税费
创建税费报价
在支付前,根据客户的地址和税号为 Stripe Billing 订阅计算税费报价
POST
/
taxes
/
quote
创建税费报价
curl --request POST \
--url https://api-sandbox.y.uno/v1/taxes/quote \
--header 'Content-Type: application/json' \
--header 'PUBLIC-API-KEY: <public-api-key>' \
--data '
{
"account_id": "<your_account_id>",
"external_subscription": {
"customer_id": "cus_RplXYZ",
"items": [
{
"price": "price_1QwAbc",
"quantity": 1
}
]
},
"address": {
"country": "US",
"postal_code": "10001"
},
"tax_information": {
"business": false
}
}
'import requests
url = "https://api-sandbox.y.uno/v1/taxes/quote"
payload = {
"account_id": "<your_account_id>",
"external_subscription": {
"customer_id": "cus_RplXYZ",
"items": [
{
"price": "price_1QwAbc",
"quantity": 1
}
]
},
"address": {
"country": "US",
"postal_code": "10001"
},
"tax_information": { "business": False }
}
headers = {
"PUBLIC-API-KEY": "<public-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'PUBLIC-API-KEY': '<public-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
account_id: '<your_account_id>',
external_subscription: {customer_id: 'cus_RplXYZ', items: [{price: 'price_1QwAbc', quantity: 1}]},
address: {country: 'US', postal_code: '10001'},
tax_information: {business: false}
})
};
fetch('https://api-sandbox.y.uno/v1/taxes/quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-sandbox.y.uno/v1/taxes/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'account_id' => '<your_account_id>',
'external_subscription' => [
'customer_id' => 'cus_RplXYZ',
'items' => [
[
'price' => 'price_1QwAbc',
'quantity' => 1
]
]
],
'address' => [
'country' => 'US',
'postal_code' => '10001'
],
'tax_information' => [
'business' => false
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"PUBLIC-API-KEY: <public-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-sandbox.y.uno/v1/taxes/quote"
payload := strings.NewReader("{\n \"account_id\": \"<your_account_id>\",\n \"external_subscription\": {\n \"customer_id\": \"cus_RplXYZ\",\n \"items\": [\n {\n \"price\": \"price_1QwAbc\",\n \"quantity\": 1\n }\n ]\n },\n \"address\": {\n \"country\": \"US\",\n \"postal_code\": \"10001\"\n },\n \"tax_information\": {\n \"business\": false\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("PUBLIC-API-KEY", "<public-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-sandbox.y.uno/v1/taxes/quote")
.header("PUBLIC-API-KEY", "<public-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"account_id\": \"<your_account_id>\",\n \"external_subscription\": {\n \"customer_id\": \"cus_RplXYZ\",\n \"items\": [\n {\n \"price\": \"price_1QwAbc\",\n \"quantity\": 1\n }\n ]\n },\n \"address\": {\n \"country\": \"US\",\n \"postal_code\": \"10001\"\n },\n \"tax_information\": {\n \"business\": false\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.y.uno/v1/taxes/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["PUBLIC-API-KEY"] = '<public-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"account_id\": \"<your_account_id>\",\n \"external_subscription\": {\n \"customer_id\": \"cus_RplXYZ\",\n \"items\": [\n {\n \"price\": \"price_1QwAbc\",\n \"quantity\": 1\n }\n ]\n },\n \"address\": {\n \"country\": \"US\",\n \"postal_code\": \"10001\"\n },\n \"tax_information\": {\n \"business\": false\n }\n}"
response = http.request(request)
puts response.read_body{
"tax_quote_id": "txq_2a8a493dcc5c4230b4cf8d9359fd200a",
"status": "TAX_APPLIED",
"currency": "USD",
"subtotal": 29,
"tax": 2.57,
"total": 31.57,
"lines": [
{
"type": "sales_tax",
"jurisdiction": "NY",
"percentage": 8.875,
"taxable_amount": 29,
"value": 2.57
}
]
}{
"code": "INVALID_REQUEST",
"messages": [
"address.postal_code is required for US."
]
}{
"code": "PRODUCT_NOT_ENABLED",
"messages": [
"..."
]
}根据客户的账单地址(如为企业,还包括其税号),为 Stripe Billing 订阅的首次支付计算税费报价。该报价使用 Stripe Tax 以及您 Stripe 账户中的税务登记。请参阅 本地价格和税费。
按组织启用税费征收按组织启用,并且需要您已完成 Stripe Billing onboarding 且 Stripe Tax 处于启用状态。请联系您的大客户经理(KAM)启用。
- 每当国家、邮政编码或税号发生变化时,请重新报价。报价的有效期为 30 分钟。
- 美国和加拿大需要提供邮政编码。其他国家只需提供国家。
- 收取
total,并将报价的每一行放在支付的additional_data.order.taxes中发送,同时附带source: YUNO_TAX_QUOTE和tax_quote_id(tax_base为该行的taxable_amount)。支付已批准后,Yuno 会在 Stripe 中创建订阅,其首张发票包含相同的税费。 - 不适用任何税费时,
status为NO_TAX(no_tax_reason说明原因,例如对于拥有有效税号的企业为REVERSE_CHARGE,或者在您的 Stripe 账户没有税务登记时为NOT_SUBJECT_TO_TAX)。
请求头
请求体
application/json
此页面对您有帮助吗?
⌘I
创建税费报价
curl --request POST \
--url https://api-sandbox.y.uno/v1/taxes/quote \
--header 'Content-Type: application/json' \
--header 'PUBLIC-API-KEY: <public-api-key>' \
--data '
{
"account_id": "<your_account_id>",
"external_subscription": {
"customer_id": "cus_RplXYZ",
"items": [
{
"price": "price_1QwAbc",
"quantity": 1
}
]
},
"address": {
"country": "US",
"postal_code": "10001"
},
"tax_information": {
"business": false
}
}
'import requests
url = "https://api-sandbox.y.uno/v1/taxes/quote"
payload = {
"account_id": "<your_account_id>",
"external_subscription": {
"customer_id": "cus_RplXYZ",
"items": [
{
"price": "price_1QwAbc",
"quantity": 1
}
]
},
"address": {
"country": "US",
"postal_code": "10001"
},
"tax_information": { "business": False }
}
headers = {
"PUBLIC-API-KEY": "<public-api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'PUBLIC-API-KEY': '<public-api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
account_id: '<your_account_id>',
external_subscription: {customer_id: 'cus_RplXYZ', items: [{price: 'price_1QwAbc', quantity: 1}]},
address: {country: 'US', postal_code: '10001'},
tax_information: {business: false}
})
};
fetch('https://api-sandbox.y.uno/v1/taxes/quote', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api-sandbox.y.uno/v1/taxes/quote",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'account_id' => '<your_account_id>',
'external_subscription' => [
'customer_id' => 'cus_RplXYZ',
'items' => [
[
'price' => 'price_1QwAbc',
'quantity' => 1
]
]
],
'address' => [
'country' => 'US',
'postal_code' => '10001'
],
'tax_information' => [
'business' => false
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"PUBLIC-API-KEY: <public-api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-sandbox.y.uno/v1/taxes/quote"
payload := strings.NewReader("{\n \"account_id\": \"<your_account_id>\",\n \"external_subscription\": {\n \"customer_id\": \"cus_RplXYZ\",\n \"items\": [\n {\n \"price\": \"price_1QwAbc\",\n \"quantity\": 1\n }\n ]\n },\n \"address\": {\n \"country\": \"US\",\n \"postal_code\": \"10001\"\n },\n \"tax_information\": {\n \"business\": false\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("PUBLIC-API-KEY", "<public-api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api-sandbox.y.uno/v1/taxes/quote")
.header("PUBLIC-API-KEY", "<public-api-key>")
.header("Content-Type", "application/json")
.body("{\n \"account_id\": \"<your_account_id>\",\n \"external_subscription\": {\n \"customer_id\": \"cus_RplXYZ\",\n \"items\": [\n {\n \"price\": \"price_1QwAbc\",\n \"quantity\": 1\n }\n ]\n },\n \"address\": {\n \"country\": \"US\",\n \"postal_code\": \"10001\"\n },\n \"tax_information\": {\n \"business\": false\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api-sandbox.y.uno/v1/taxes/quote")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["PUBLIC-API-KEY"] = '<public-api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"account_id\": \"<your_account_id>\",\n \"external_subscription\": {\n \"customer_id\": \"cus_RplXYZ\",\n \"items\": [\n {\n \"price\": \"price_1QwAbc\",\n \"quantity\": 1\n }\n ]\n },\n \"address\": {\n \"country\": \"US\",\n \"postal_code\": \"10001\"\n },\n \"tax_information\": {\n \"business\": false\n }\n}"
response = http.request(request)
puts response.read_body{
"tax_quote_id": "txq_2a8a493dcc5c4230b4cf8d9359fd200a",
"status": "TAX_APPLIED",
"currency": "USD",
"subtotal": 29,
"tax": 2.57,
"total": 31.57,
"lines": [
{
"type": "sales_tax",
"jurisdiction": "NY",
"percentage": 8.875,
"taxable_amount": 29,
"value": 2.57
}
]
}{
"code": "INVALID_REQUEST",
"messages": [
"address.postal_code is required for US."
]
}{
"code": "PRODUCT_NOT_ENABLED",
"messages": [
"..."
]
}