diff --git a/src/IntesaSanPaoloClient.php b/src/IntesaSanPaoloClient.php index 6952880..a2a804e 100644 --- a/src/IntesaSanPaoloClient.php +++ b/src/IntesaSanPaoloClient.php @@ -356,6 +356,17 @@ public function simulateInstantPayment( PaymentExecution $payment ): PaymentSimu 'siaCode' => empty( $payment->getSiaCode() ) ? '' : $payment->getSiaCode(), ]; + /* Sandbox: endToEndId and siaCode must be present and empty; Live: if empty, they must be omitted */ + if( $this->Live ) { + if( empty( $data['endToEndId'] ) ) { + unset( $data['endToEndId'] ); + } + + if( empty( $data['siaCode'] ) ) { + unset( $data['siaCode'] ); + } + } + $paymentSimulationResponse = $this->request( 'POST', sprintf( '%s/payments/sct/instant/simulation', $this->getApiBaseUri() ), [], $data ); return new PaymentSimulated( $paymentSimulationResponse ); @@ -391,6 +402,17 @@ public function createInstantPayment( PaymentExecution $payment ): PaymentExecut $data['siaCode'] = ''; } + /* Sandbox: endToEndId and siaCode must be present and empty; Live: if empty, they must be omitted */ + if( $this->Live ) { + if( empty( $data['endToEndId'] ) ) { + unset( $data['endToEndId'] ); + } + + if( empty( $data['siaCode'] ) ) { + unset( $data['siaCode'] ); + } + } + $paymentExecutedResponse = $this->request( 'POST', sprintf( '%s/payments/sct/instant', $this->getApiBaseUri() ), [], $data ); return new PaymentExecuted( $paymentExecutedResponse );