From aacc850c4deb51a7bb12f3911f3ed122d4923937 Mon Sep 17 00:00:00 2001 From: Tobia Zanarella Date: Fri, 10 Feb 2023 16:02:18 +0100 Subject: [PATCH 1/5] Started implementation of delayed payments --- src/DataSet/CurrencySet.php | 121 ++++++++++++++++++++++++++++++++ src/IntesaSanPaoloClient.php | 40 +++++++++++ src/Models/PaymentExecuted.php | 69 ++++++++++++++++++ src/Models/PaymentExecution.php | 49 +++++++++++++ 4 files changed, 279 insertions(+) create mode 100755 src/DataSet/CurrencySet.php diff --git a/src/DataSet/CurrencySet.php b/src/DataSet/CurrencySet.php new file mode 100755 index 0000000..b7b6ef8 --- /dev/null +++ b/src/DataSet/CurrencySet.php @@ -0,0 +1,121 @@ + $payment->getDebtorName(), + 'debtorIBAN' => $payment->getDebtorIban(), + 'creditorName' => $payment->getCreditorName(), + 'creditorIBAN' => $payment->getCreditorIban(), + 'amount' => $payment->getAmount(), + 'Currency' => $payment->getCurrency(), + 'paymentInformation' => $payment->getPaymentInformation(), + 'requestedExecutionDate'=> $payment->getRequestedExecutionDate()->format( 'd/m/Y' ), + 'endToEndId' => $payment->getEndToEndId(), + 'siaCode' => $payment->getSiaCode(), + 'simulationId' => $payment->getSimulationId(), + ]; + + if( $payment->getResubmit() ) { + $data['resubmit'] = true; + $data['resubmitId'] = $payment->getResubmitId(); + } + + /* 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'] ); + } + } + + $paymentExecutedResponse = $this->request( 'POST', sprintf( '%s/payments/sct', $this->getApiBaseUri() ), [], $data ); + + return new PaymentExecuted( $paymentExecutedResponse ); + } + + /** * Creates a new Instant Payment (SCT-Instant-Execution) * diff --git a/src/Models/PaymentExecuted.php b/src/Models/PaymentExecuted.php index 4c6fb32..65ba969 100644 --- a/src/Models/PaymentExecuted.php +++ b/src/Models/PaymentExecuted.php @@ -2,6 +2,7 @@ namespace Shellrent\OpenBanking\Models; +use DateTime; use stdClass; class PaymentExecuted extends GenericPaymentResult { @@ -16,6 +17,26 @@ class PaymentExecuted extends GenericPaymentResult { */ private $PaymentStatus; + /** + * @var float + */ + private $Commissions; + + /** + * @var DateTime + */ + private $SettlemenDate; + + /** + * @var DateTime + */ + private $RevokeDate; + + /** + * @var string + */ + private $RevokeTime; + /** @@ -29,6 +50,22 @@ protected function hydrateData( stdClass $data ) { $this->PaymentStatus = $payload->paymentStatus; $this->CustomerCro = $payload->customerCro; + + if( isset( $payload->commissioni ) ) { + $this->Commissions = $payload->commissioni; + } + + if( isset( $payload->settlemenDate ) ) { + $this->SettlemenDate = DateTime::createFromFormat( 'd/m/Y', $payload->settlemenDate ); + } + + if( isset( $payload->revokeDate ) ) { + $this->RevokeDate = DateTime::createFromFormat( 'd/m/Y', $payload->revokeDate ); + } + + if( isset( $payload->revokeTime ) ) { + $this->RevokeTime = $payload->revokeTime; + } } @@ -47,4 +84,36 @@ public function getCustomerCro(): ?string { public function getPaymentStatus(): ?string { return $this->PaymentStatus; } + + + /** + * @return float + */ + public function getCommissions(): ?float { + return $this->Commissions; + } + + + /** + * @return DateTime + */ + public function getSettlemenDate(): ?DateTime { + return $this->SettlemenDate; + } + + + /** + * @return DateTime + */ + public function getRevokeDate(): ?DateTime { + return $this->RevokeDate; + } + + + /** + * @return string + */ + public function getRevokeTime(): ?string { + return $this->RevokeTime; + } } diff --git a/src/Models/PaymentExecution.php b/src/Models/PaymentExecution.php index b399ccd..6a30124 100644 --- a/src/Models/PaymentExecution.php +++ b/src/Models/PaymentExecution.php @@ -2,6 +2,7 @@ namespace Shellrent\OpenBanking\Models; +use DateTime; use stdClass; class PaymentExecution extends GenericPayment { @@ -15,6 +16,16 @@ class PaymentExecution extends GenericPayment { */ private $Resubmit = false; + /** + * @var string + */ + private $Currency; + + /** + * @var DateTime + */ + private $RequestedExecutionDate; + /** @@ -62,4 +73,42 @@ public function setResubmit( bool $Resubmit ): self { return $this; } + + + /** + * @return string + */ + public function getCurrency(): string { + return $this->Currency; + } + + + /** + * @param string $Currency + * + * @return PaymentExecution + */ + public function setCurrency( string $Currency ): PaymentExecution { + $this->Currency = $Currency; + return $this; + } + + + /** + * @return DateTime + */ + public function getRequestedExecutionDate(): DateTime { + return $this->RequestedExecutionDate; + } + + + /** + * @param DateTime $RequestedExecutionDate + * + * @return PaymentExecution + */ + public function setRequestedExecutionDate( DateTime $RequestedExecutionDate ): PaymentExecution { + $this->RequestedExecutionDate = $RequestedExecutionDate; + return $this; + } } From 6ca6c820a1c2f43affa2cd7368d4583283afa26a Mon Sep 17 00:00:00 2001 From: Tobia Zanarella Date: Fri, 24 Feb 2023 16:15:35 +0100 Subject: [PATCH 2/5] Add methods to manage delayed payments --- src/IntesaSanPaoloClient.php | 184 ++++++++++++++++++++++-- src/Models/Collections/PaymentInfos.php | 23 ++- src/Models/DelayedPaymentRevoke.php | 58 ++++++++ src/Models/GenericModel.php | 8 +- src/Models/GenericPaymentData.php | 13 +- src/Models/GenericPaymentInfo.php | 8 +- src/Models/GenericPaymentResult.php | 18 ++- src/Models/PaymentExecuted.php | 19 ++- 8 files changed, 306 insertions(+), 25 deletions(-) create mode 100755 src/Models/DelayedPaymentRevoke.php diff --git a/src/IntesaSanPaoloClient.php b/src/IntesaSanPaoloClient.php index 13436a5..a83c749 100644 --- a/src/IntesaSanPaoloClient.php +++ b/src/IntesaSanPaoloClient.php @@ -4,6 +4,7 @@ use DateTime; use DateInterval; +use Shellrent\OpenBanking\Models\DelayedPaymentRevoke; use Shellrent\OpenBanking\Models\PaymentSimulated; use Shellrent\OpenBanking\Models\PaymentStatus; use stdClass; @@ -337,6 +338,44 @@ public function getTodayTransactions(): Transactions { } + /** + * Simulates an Instant Payment (SCT-Instant-Simulation) + * + * @param PaymentExecution $payment + * + * @return PaymentSimulated + */ + public function simulateDelayedPayment( PaymentExecution $payment ): PaymentSimulated { + $data = [ + 'debtorName' => $payment->getDebtorName(), + 'debtorIban' => $payment->getDebtorIban(), + 'creditorName' => $payment->getCreditorName(), + 'creditorIban' => $payment->getCreditorIban(), + 'amount' => $payment->getAmount(), + 'currency' => $payment->getCurrency(), + 'paymentInformation' => $payment->getPaymentInformation(), + 'requestedExecutionDate'=> $payment->getRequestedExecutionDate()->format( 'd/m/Y' ), + 'endToEndId' => empty( $payment->getEndToEndId() ) ? '' : $payment->getEndToEndId(), + 'categoryPurpose' => 'CASH', + ]; + + /* 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/bonsct/simulation', $this->getApiBaseUri() ), [], $data ); + + return new PaymentSimulated( $paymentSimulationResponse ); + } + + /** * Simulates an Instant Payment (SCT-Instant-Simulation) * @@ -382,24 +421,19 @@ public function simulateInstantPayment( PaymentExecution $payment ): PaymentSimu */ public function createDelayedPayment( PaymentExecution $payment ): PaymentExecuted { $data = [ + 'simulationId' => $payment->getSimulationId(), 'debtorName' => $payment->getDebtorName(), - 'debtorIBAN' => $payment->getDebtorIban(), + 'debtorIban' => $payment->getDebtorIban(), 'creditorName' => $payment->getCreditorName(), - 'creditorIBAN' => $payment->getCreditorIban(), + 'creditorIban' => $payment->getCreditorIban(), 'amount' => $payment->getAmount(), - 'Currency' => $payment->getCurrency(), + 'currency' => $payment->getCurrency(), 'paymentInformation' => $payment->getPaymentInformation(), 'requestedExecutionDate'=> $payment->getRequestedExecutionDate()->format( 'd/m/Y' ), 'endToEndId' => $payment->getEndToEndId(), - 'siaCode' => $payment->getSiaCode(), - 'simulationId' => $payment->getSimulationId(), + 'categoryPurpose' => 'CASH', ]; - if( $payment->getResubmit() ) { - $data['resubmit'] = true; - $data['resubmitId'] = $payment->getResubmitId(); - } - /* Sandbox: endToEndId and siaCode must be present and empty; Live: if empty, they must be omitted */ if( $this->Live ) { if( empty( $data['endToEndId'] ) ) { @@ -407,7 +441,7 @@ public function createDelayedPayment( PaymentExecution $payment ): PaymentExecut } } - $paymentExecutedResponse = $this->request( 'POST', sprintf( '%s/payments/sct', $this->getApiBaseUri() ), [], $data ); + $paymentExecutedResponse = $this->request( 'POST', sprintf( '%s/payments/bonsct', $this->getApiBaseUri() ), [], $data ); return new PaymentExecuted( $paymentExecutedResponse ); } @@ -459,6 +493,37 @@ public function createInstantPayment( PaymentExecution $payment ): PaymentExecut } + /** + * Retrieve the SCT payment's information about a specified IBAN and paymentId or customerCRO (BONSCT - Payment Status API) + * @param string $customerCro + * @param string|null $paymentId + * @return PaymentStatus + */ + public function getDelayedPaymentStatus( string $customerCro = null, string $paymentId = null ): PaymentStatus { + $params = []; + + $paramsOk = false; + + if( $customerCro ) { + $params['customerCRO'] = $customerCro; + $paramsOk = true; + } + + if( $paymentId ) { + $params['paymentId'] = $paymentId; + $paramsOk = true; + } + + if( !$paramsOk ) { + throw new Exception( 'A customer CRO or a Payment ID must be specified to retreive payment status' ); + } + + $paymentStatusResponse = $this->request( 'GET', sprintf( '%s/payments/bonsct/%s/history', $this->getApiBaseUri(), $this->Iban ), $params ); + + return new PaymentStatus( $paymentStatusResponse ); + } + + /** * Get the status of a payment (SCT Instant - Payment Status API) * @param string $orderId @@ -477,6 +542,74 @@ public function getPaymentStatus( string $orderId, string $paymentId = null ): P } + /** + * Retrieve the payments list for a specified IBAN, range of dates and payments direction. (BON SCT - Payments List API) + * + * @param DateTime $fromDate If null, defaults to "1 month ago" + * @param DateTime $toDate + * + * @return PaymentInfos + */ + public function getDelayedPaymentsList( DateTime $fromDate = null, DateTime $toDate = null ): PaymentInfos { + if( is_null( $fromDate ) ) { + $fromDate = new DateTime(); + $fromDate->modify( '-1 month' ); + } + + $params = [ + 'fromDate' => $fromDate->format( 'Ymd' ), + 'offset' => 0, + 'limit' => 100, + 'paymentDirection' => 'O', + ]; + + if( !is_null( $toDate ) ) { + $params['toDate'] = $toDate->format( 'Ymd' ); + } + + $url = sprintf( '%s/payments/bonsct/%s/list', $this->getApiBaseUri(), $this->Iban ); + + $payments = null; + + while( $url ) { + $paymentsResponse = $this->request( 'GET', $url, $params ); + + if( isset( $paymentsResponse->payload ) and isset( $paymentsResponse->payload->links ) and isset( $paymentsResponse->payload->links->next ) and !empty( $paymentsResponse->payload->links->next ) ) { + $uri = new Uri( $paymentsResponse->payload->links->next ); + parse_str( $uri->getQuery(), $params ); + + if( !isset( $params['paymentDirection'] ) ) { + $params['paymentDirection'] = 'O'; + } + + $url = $paymentsResponse->payload->links->next; + + /* URL next page on Sandbox is unreachable - it's a known bug */ + if( !$this->Live ) { + $url = str_replace( 'http://localhost:8081', sprintf( '%s/sandbox', $this->BaseUri ), $url ); + $url = str_replace( '/IT59R0306901001100000002110/', sprintf( '/%s/', $this->Iban ), $url ); + } + + } else { + $url = null; + } + + if( empty( $paymentsResponse->payload->paymentsResults ) ) { + $url = null; + } + + if( !$payments ) { + $payments = new PaymentInfos( $paymentsResponse ); + + } else { + $payments->addPayments( $paymentsResponse->payload->paymentsResults ); + } + } + + return $payments; + } + + /** * Get a list of the payments (SCT Instant - Payments List API) * @@ -543,4 +676,33 @@ public function getPaymentsList( DateTime $fromDate = null, DateTime $toDate = n return $payments; } + + + /** + * Try to Revoke the SCT payment specified by IBAN and paymentId or customerCRO (BON SCT - Revoke API) + * + */ + public function revokeDelayedPayment( string $customerCro = null, string $paymentId = null ) { + $params = []; + + $paramsOk = false; + + if( $customerCro ) { + $params['customerCRO'] = $customerCro; + $paramsOk = true; + } + + if( $paymentId ) { + $params['paymentId'] = $paymentId; + $paramsOk = true; + } + + if( !$paramsOk ) { + throw new Exception( 'A customer CRO or a Payment ID must be specified to retreive payment status' ); + } + + $paymentExecutedResponse = $this->request( 'GET', sprintf( '%s/payments/bonsct/%s/revoke', $this->getApiBaseUri(), $this->Iban ), $params ); + + return new DelayedPaymentRevoke( $paymentExecutedResponse ); + } } diff --git a/src/Models/Collections/PaymentInfos.php b/src/Models/Collections/PaymentInfos.php index 73895f9..d6b2585 100644 --- a/src/Models/Collections/PaymentInfos.php +++ b/src/Models/Collections/PaymentInfos.php @@ -6,6 +6,7 @@ use stdClass; use Shellrent\OpenBanking\Models\GenericModel; use Shellrent\OpenBanking\Models\PaymentInfo; +use Throwable; class PaymentInfos extends GenericModel implements ModelsCollectionInterface { /** @@ -45,10 +46,26 @@ protected function hydrateData( stdClass $data ) { $this->TotalPayments = (int)$payload->paymentsTotalCount; $this->PageSize = (int)$payload->pageSize; - $this->InquiryFromDate = new DateTime( $payload->inquiryFromDate ); - $this->InquiryToDate = new DateTime( $payload->inquiryToDate ); + try { + $this->InquiryFromDate = new DateTime( $payload->inquiryFromDate ); + + } catch( Throwable $exception ) { + $this->InquiryFromDate = DateTime::createFromFormat( 'd/m/Y', $payload->inquiryFromDate ); + } + + try { + $this->InquiryToDate = new DateTime( $payload->inquiryToDate ); + + } catch( Throwable $exception ) { + $this->InquiryToDate = DateTime::createFromFormat( 'd/m/Y', $payload->inquiryToDate ); + } - $this->addPayments( $payload->payments ); + if( isset( $payload->payments ) ) { + $this->addPayments( $payload->payments ); + + } elseif( isset( $payload->paymentsResults ) ) { + $this->addPayments( $payload->paymentsResults ); + } } diff --git a/src/Models/DelayedPaymentRevoke.php b/src/Models/DelayedPaymentRevoke.php new file mode 100755 index 0000000..2df2db7 --- /dev/null +++ b/src/Models/DelayedPaymentRevoke.php @@ -0,0 +1,58 @@ +PaymentId = (string)$data->payload->paymentId; + $this->CustomerCro = (string)$data->payload->customerCRO; + $this->Status = (string)$data->payload->status; + } + + + /** + * @return string + */ + public function getStatus(): ?string { + return $this->Status; + } + + + /** + * @return string + */ + public function getPaymentId(): ?string { + return $this->PaymentId; + } + + + /** + * @return string + */ + public function getCustomerCro(): ?string { + return $this->CustomerCro; + } +} diff --git a/src/Models/GenericModel.php b/src/Models/GenericModel.php index 1027086..eef5d0e 100644 --- a/src/Models/GenericModel.php +++ b/src/Models/GenericModel.php @@ -4,6 +4,7 @@ use DateTime; use stdClass; +use Throwable; abstract class GenericModel { @@ -38,7 +39,12 @@ public final function hydrate( stdClass $data ) { } if( isset( $payload->executionDate ) ) { - $this->ExecutionDate = new DateTime( $payload->executionDate ); + try { + $this->ExecutionDate = new DateTime( $payload->executionDate ); + + } catch( Throwable $exception ) { + $this->ExecutionDate = DateTime::createFromFormat( 'd/m/Y', $payload->executionDate ); + } } } diff --git a/src/Models/GenericPaymentData.php b/src/Models/GenericPaymentData.php index de70ae3..f183701 100644 --- a/src/Models/GenericPaymentData.php +++ b/src/Models/GenericPaymentData.php @@ -79,14 +79,21 @@ protected function hydrateData( stdClass $data ) { $this->setPaymentInformation( $data->paymentInformation ); } - $this->setAmount( $data->amount ); + if( isset( $data->amount ) ) { + $this->setAmount( $data->amount ); + } if( isset( $data->currency ) and !empty( $data->currency ) ) { $this->Currency = $data->currency; } - $this->UltimateDebtorName = $data->ultimateDebtorName; - $this->UltimateCreditorName = $data->ultimateCreditorName; + if( isset( $data->ultimateDebtorName ) ) { + $this->UltimateDebtorName = $data->ultimateDebtorName; + } + + if( isset( $data->ultimateCreditorName ) ) { + $this->UltimateCreditorName = $data->ultimateCreditorName; + } if( isset( $data->valueDate ) and !empty( $data->paymentInformation ) ) { $this->ValueDate = DateTime::createFromFormat( 'd/m/Y', $data->valueDate ); diff --git a/src/Models/GenericPaymentInfo.php b/src/Models/GenericPaymentInfo.php index f2573c8..2cd1053 100755 --- a/src/Models/GenericPaymentInfo.php +++ b/src/Models/GenericPaymentInfo.php @@ -19,7 +19,13 @@ abstract class GenericPaymentInfo extends GenericPaymentData { protected function hydrateData( stdClass $data ) { parent::hydrateData( $data ); - $this->Status = $data->status; + if( isset( $data->status ) ) { + $this->Status = $data->status; + } + + if( isset( $data->paymentStatus ) ) { + $this->Status = $data->paymentStatus; + } } diff --git a/src/Models/GenericPaymentResult.php b/src/Models/GenericPaymentResult.php index 150b295..a602f12 100755 --- a/src/Models/GenericPaymentResult.php +++ b/src/Models/GenericPaymentResult.php @@ -42,11 +42,21 @@ protected function hydrateData( stdClass $data ) { parent::hydrateData( $payload ); - $this->Date = new DateTime( $payload->date ); - $this->CategoryPurpose = $payload->categoryPurpose; + if( isset( $payload->date ) ) { + $this->Date = new DateTime( $payload->date ); + } - $this->DebtorBic = $payload->debtorBic; - $this->CreditorBic = $payload->creditorBic; + if( isset( $payload->categoryPurpose ) ) { + $this->CategoryPurpose = $payload->categoryPurpose; + } + + if( isset( $payload->debtorBic ) ) { + $this->DebtorBic = $payload->debtorBic; + } + + if( isset( $payload->creditorBic ) ) { + $this->CreditorBic = $payload->creditorBic; + } $this->TransactionStatusDescription = $payload->transactionStatusDescription; } diff --git a/src/Models/PaymentExecuted.php b/src/Models/PaymentExecuted.php index 65ba969..7ac2907 100644 --- a/src/Models/PaymentExecuted.php +++ b/src/Models/PaymentExecuted.php @@ -49,7 +49,14 @@ protected function hydrateData( stdClass $data ) { $payload = $data->payload; $this->PaymentStatus = $payload->paymentStatus; - $this->CustomerCro = $payload->customerCro; + + if( isset( $payload->customerCro ) ) { + $this->CustomerCro = $payload->customerCro; + + } elseif( isset( $payload->customerCRO ) ) { + $this->CustomerCro = $payload->customerCRO; + } + if( isset( $payload->commissioni ) ) { $this->Commissions = $payload->commissioni; @@ -60,7 +67,15 @@ protected function hydrateData( stdClass $data ) { } if( isset( $payload->revokeDate ) ) { - $this->RevokeDate = DateTime::createFromFormat( 'd/m/Y', $payload->revokeDate ); + $format = 'd/m/Y'; + $date = $payload->revokeDate; + + if( isset( $payload->revokeTime ) ) { + $format = sprintf( '%s H:i:s', $format ); + $date = sprintf( '%s %s', $date, $payload->revokeTime ); + } + + $this->RevokeDate = DateTime::createFromFormat( $format, $date ); } if( isset( $payload->revokeTime ) ) { From db6dc86e618c80b46498f70720098375bd3afda8 Mon Sep 17 00:00:00 2001 From: Tobia Zanarella Date: Mon, 27 Feb 2023 13:04:27 +0100 Subject: [PATCH 3/5] Added return type on revoke --- src/IntesaSanPaoloClient.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/IntesaSanPaoloClient.php b/src/IntesaSanPaoloClient.php index a83c749..d48412f 100644 --- a/src/IntesaSanPaoloClient.php +++ b/src/IntesaSanPaoloClient.php @@ -680,9 +680,9 @@ public function getPaymentsList( DateTime $fromDate = null, DateTime $toDate = n /** * Try to Revoke the SCT payment specified by IBAN and paymentId or customerCRO (BON SCT - Revoke API) - * + * @return DelayedPaymentRevoke */ - public function revokeDelayedPayment( string $customerCro = null, string $paymentId = null ) { + public function revokeDelayedPayment( string $customerCro = null, string $paymentId = null ): DelayedPaymentRevoke { $params = []; $paramsOk = false; From 4e35f0e4ac5ea329b5e7b29f8efd40f3ce3a8eaf Mon Sep 17 00:00:00 2001 From: Tobia Zanarella Date: Tue, 9 May 2023 10:45:48 +0200 Subject: [PATCH 4/5] Finalizzazione chiamate per bonifici ordinari --- composer.json | 2 +- src/IntesaSanPaoloClient.php | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 824420b..dad2c57 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ } ], "require": { - "php": "^7.3", + "php": "^8.0", "ext-json": "*", "php-http/guzzle7-adapter": "^1.0" }, diff --git a/src/IntesaSanPaoloClient.php b/src/IntesaSanPaoloClient.php index d48412f..9e25d29 100644 --- a/src/IntesaSanPaoloClient.php +++ b/src/IntesaSanPaoloClient.php @@ -84,6 +84,12 @@ class IntesaSanPaoloClient { */ private $MutualAuthenticationPrivateKey; + /** + * Forces a request to send a "Content-Type" header: "Content-Type: application/json" + * @var bool + */ + private $ForceContentJson = false; + /** @@ -173,6 +179,12 @@ private function request( string $method, string $url, array $queryParameters = RequestOptions::QUERY => $queryParameters, ]; + if( $this->ForceContentJson ) { + $this->ForceContentJson = false; + + $requestParams[RequestOptions::HEADERS]['Content-Type'] = 'application/json'; + } + if( !empty( $jsonBody ) ) { $requestParams[RequestOptions::JSON] = $jsonBody; @@ -518,6 +530,7 @@ public function getDelayedPaymentStatus( string $customerCro = null, string $pay throw new Exception( 'A customer CRO or a Payment ID must be specified to retreive payment status' ); } + $this->ForceContentJson = true; $paymentStatusResponse = $this->request( 'GET', sprintf( '%s/payments/bonsct/%s/history', $this->getApiBaseUri(), $this->Iban ), $params ); return new PaymentStatus( $paymentStatusResponse ); @@ -559,7 +572,7 @@ public function getDelayedPaymentsList( DateTime $fromDate = null, DateTime $toD $params = [ 'fromDate' => $fromDate->format( 'Ymd' ), 'offset' => 0, - 'limit' => 100, + 'limit' => 30, 'paymentDirection' => 'O', ]; @@ -572,6 +585,7 @@ public function getDelayedPaymentsList( DateTime $fromDate = null, DateTime $toD $payments = null; while( $url ) { + $this->ForceContentJson = true; $paymentsResponse = $this->request( 'GET', $url, $params ); if( isset( $paymentsResponse->payload ) and isset( $paymentsResponse->payload->links ) and isset( $paymentsResponse->payload->links->next ) and !empty( $paymentsResponse->payload->links->next ) ) { From ec13495f262f48731a169645a478f8c32fa69f38 Mon Sep 17 00:00:00 2001 From: Tobia Zanarella Date: Fri, 19 May 2023 11:56:47 +0200 Subject: [PATCH 5/5] Fix data read --- src/Models/GenericPaymentData.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/Models/GenericPaymentData.php b/src/Models/GenericPaymentData.php index f183701..272feb8 100644 --- a/src/Models/GenericPaymentData.php +++ b/src/Models/GenericPaymentData.php @@ -36,6 +36,11 @@ abstract class GenericPaymentData extends GenericPayment { */ protected $ValueDate; + /** + * @var \DateTime + */ + protected $SettlementDate; + /** @@ -65,6 +70,9 @@ protected function hydrateData( stdClass $data ) { if( isset( $data->debtorIBAN ) and !empty( $data->debtorIBAN ) ) { $this->setDebtorIban( $data->debtorIBAN ); + + } elseif( isset( $data->debtorIban ) and !empty( $data->debtorIban ) ) { + $this->setDebtorIban( $data->debtorIban ); } if( isset( $data->creditorName ) and !empty( $data->creditorName ) ) { @@ -73,6 +81,9 @@ protected function hydrateData( stdClass $data ) { if( isset( $data->creditorIBAN ) and !empty( $data->creditorIBAN ) ) { $this->setCreditorIban( $data->creditorIBAN ); + + } elseif( isset( $data->creditorIban ) and !empty( $data->creditorIban ) ) { + $this->setCreditorIban( $data->creditorIban ); } if( isset( $data->paymentInformation ) and !empty( $data->paymentInformation ) ) { @@ -95,10 +106,14 @@ protected function hydrateData( stdClass $data ) { $this->UltimateCreditorName = $data->ultimateCreditorName; } - if( isset( $data->valueDate ) and !empty( $data->paymentInformation ) ) { + if( isset( $data->valueDate ) and !empty( $data->valueDate ) ) { $this->ValueDate = DateTime::createFromFormat( 'd/m/Y', $data->valueDate ); } + if( isset( $data->settlementDate ) and !empty( $data->settlementDate ) ) { + $this->SettlementDate = DateTime::createFromFormat( 'd/m/Y', $data->settlementDate ); + } + if( isset( $data->resubmitId ) ) { $this->setResubmitId( $data->resubmitId ); } @@ -160,4 +175,12 @@ public function getUltimateCreditorName(): ?string { public function getValueDate(): ?DateTime { return $this->ValueDate; } + + + /** + * @return \DateTime + */ + public function getSettlementDate(): ?DateTime { + return $this->SettlementDate; + } }