PayPal PHP SDK - 在发票中设置税金

I'm trying to insert a tax in this example https://github.com/paypal/PayPal-PHP-SDK/blob/master/sample/invoice/CreateInvoice.php using the setTax function and I always get an error. Could you help me? Thank you in advance.

I have updated the sample code for create invoice to include tax into each item. You can read more about the specifics on tax in developer docs. As you can see, the tax field is present inside invoice_item. You can follow the sample code as shown below. To checkout the complete sample, visit here.

// #### Tax Item
// You could provide Tax information to each item.
$tax = new \PayPal\Api\Tax();
$tax->setPercent(1)->setName("Local Tax on Sutures");
$items[0]->setTax($tax);

Now, if you run the samples in your local machine, and run SendInvoice, you would see the tax included in the response.

enter image description here

The invoice would look something like this:

enter image description here