diff --git a/modules/ppcp-api-client/src/Endpoint/PayUponInvoiceOrderEndpoint.php b/modules/ppcp-api-client/src/Endpoint/PayUponInvoiceOrderEndpoint.php index 23a330a67..91d1ba79a 100644 --- a/modules/ppcp-api-client/src/Endpoint/PayUponInvoiceOrderEndpoint.php +++ b/modules/ppcp-api-client/src/Endpoint/PayUponInvoiceOrderEndpoint.php @@ -111,6 +111,7 @@ class PayUponInvoiceOrderEndpoint { ), ); + $data = $this->ensure_tax( $data ); $data = $this->ensure_tax_rate( $data ); $data = $this->ensure_shipping( $data, $payment_source->to_array() ); @@ -196,6 +197,27 @@ class PayUponInvoiceOrderEndpoint { ); } + /** + * Ensures items contains tax. + * + * @param array $data The data. + * @return array + */ + private function ensure_tax( array $data ): array { + $items_count = count( $data['purchase_units'][0]['items'] ); + + for ( $i = 0; $i < $items_count; $i++ ) { + if ( ! isset( $data['purchase_units'][0]['items'][ $i ]['tax'] ) ) { + $data['purchase_units'][0]['items'][ $i ]['tax'] = array( + 'currency_code' => 'EUR', + 'value' => '0.00', + ); + } + } + + return $data; + } + /** * Ensures items contains tax rate. *