Skip to content

Commit

Permalink
Merge pull request #4 from shellrent/hotfix/endtoendid
Browse files Browse the repository at this point in the history
EndToEndId and SiaCode in Live environment must be omitted if empty
  • Loading branch information
svdigital-development authored Apr 8, 2021
2 parents 6833c0b + 2bcbaea commit 735e1f7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/IntesaSanPaoloClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 735e1f7

Please sign in to comment.