我在向方形结帐api交易添加税项时遇到问题。其他所有东西都在起作用,但是我不能使税收部分起作用。如果有人可以发布几行相关的php代码,在项目或订单级别增加税收,将不胜感激。预先谢谢你。
答案 0 :(得分:0)
以下是一个PHP Checkout请求的示例,该请求创建了5.00美元的费用,并在订单级别收取10%的税(50美分):
$checkout_api = new \SquareConnect\Api\CheckoutApi();
$request_body = new \SquareConnect\Model\CreateCheckoutRequest(
[
"idempotency_key" => uniqid(),
"order" => [
"line_items" => [
[
"name" => "Test Payment",
"quantity" => "1",
"base_price_money" => [
"amount" => 500,
"currency" => "USD"
]
]],
"taxes" => [
[
"name" => "This is so taxing",
"type" => "ADDITIVE",
"percentage" => "10"
]
]
]
]
);
$response = $checkout_api->createCheckout($location_id, $request_body);
如果要在项目级别添加它,只需将taxes
数组移到line_items
对象内部。例如2件商品,一件含税,一件不含税:
$checkout_api = new \SquareConnect\Api\CheckoutApi();
$request_body = new \SquareConnect\Model\CreateCheckoutRequest(
[
"idempotency_key" => uniqid(),
"order" => [
"line_items" => [
[
"name" => "Test Payment",
"quantity" => "1",
"base_price_money" => [
"amount" => 500,
"currency" => "USD"
],
"taxes" => [
[
"name" => "This is so taxing",
"type" => "ADDITIVE",
"percentage" => "10"
]
]
],
[
"name" => "Test Payment Without Tax",
"quantity" => "1",
"base_price_money" => [
"amount" => 500,
"currency" => "USD"
]
]],
]
]
);
$response = $checkout_api->createCheckout($location_id, $request_body);