public function AvataxLib::transactionsVoid in Drupal Commerce Connector for AvaTax 8
Voids a transaction for the given order.
Parameters
\Drupal\commerce_order\Entity\OrderInterface $order: The order.
Overrides AvataxLibInterface::transactionsVoid
File
- src/
AvataxLib.php, line 156
Class
- AvataxLib
- The AvaTax integration library.
Namespace
Drupal\commerce_avataxCode
public function transactionsVoid(OrderInterface $order) {
$store = $order
->getStore();
// Attempt to get company code for specific store, otherwise, fallback to
// the company code configured in the settings.
if ($store
->get('avatax_company_code')
->isEmpty()) {
$company_code = $this->config
->get('company_code');
}
else {
$company_code = $store
->get('avatax_company_code')->value;
}
$transaction_code = 'DC-' . $order
->uuid();
return $this
->doRequest('POST', "api/v2/companies/{$company_code}/transactions/{$transaction_code}/void", [
'json' => [
'code' => 'DocVoided',
],
]);
}