Skip to content
Snippets Groups Projects
Commit e4534d83 authored by efalcy's avatar efalcy
Browse files

Merge branch 'hotline#191349_payfip_erreur_journal_pas_synchro_nanook' into 'master'

hotline#191349 : payfip fix error sigb batch

See merge request !4888
parents a40eaf0d 1c6fa0ff
Branches
Tags
1 merge request!4888hotline#191349 : payfip fix error sigb batch
Pipeline #28298 passed with stage
in 27 minutes and 33 seconds
- correctif #191349 : PAYFIP : problème de synchro avec nanook
\ No newline at end of file
......@@ -143,7 +143,7 @@ class Class_Batch_PayfipSigb extends Class_Batch_PayfipJob {
protected function _payments() : array {
return (new Storm_Model_Collection(Class_Payfip::findAllSigbUnknown()))
return (new Storm_Model_Collection(Class_Payfip::findAllSigbUnknownOrError()))
->reject(fn($model) => $model->isResultUnknown())
->getArrayCopy();
}
......
......@@ -61,6 +61,12 @@ class PayfipLoader extends Storm_Model_Loader {
}
public function findAllSigbUnknownOrError() : array {
return Class_Payfip::findAllBy(['sigb_status' => [Class_Payfip::SIGB_UNKNOWN,
Class_Payfip::SIGB_ERROR]]);
}
public function findAllSigbUnknownForUser( Class_Users $user) : array {
return Class_Payfip::findAllBy(['user_id' => $user->getId(),
'sigb_status' => Class_Payfip::SIGB_UNKNOWN]);
......@@ -159,11 +165,11 @@ class PayfipLoader extends Storm_Model_Loader {
public function refreshForUserAndIsIlsUpdated(Class_Users $user) : bool{
foreach(Class_Payfip::findAllResultUnknownForUser($user) as $payfip)
foreach(Class_Payfip::findAllResultUnknownForUser($user) as $payfip)
$payfip->refreshAndIsResultUnknown();
$updated = false;
foreach(Class_Payfip::needUpdateSigb($user) as $payfip) {
foreach(Class_Payfip::needUpdateSigb($user) as $payfip) {
$payfip->updateSigb();
$updated=true;
}
......@@ -344,7 +350,9 @@ class Class_Payfip extends Storm_Model_Abstract {
public function updateSigb() : self {
if ($this->isResultUnknown() || $this->isResultError() || !$this->isSigbStatusUnknown())
if ($this->isResultUnknown()
|| $this->isResultError()
|| $this->isSigbStatusOk())
return $this;
if (!$this->getUser()) {
......
......@@ -482,6 +482,49 @@ class PayfipBatchRefreshReturnPaidPaymentSigbErrorTest
class PayfipBatchRefreshReturnPaidPaymentSigbKOTest
extends PayfipBatchEnabledTestCase {
protected string $_response_file = 'recupererDetailPaiementSecurisePaid.xml';
protected function _prepareFixture() {
parent::_prepareFixture();
$this->fixture(Class_Payfip::class,
['id' => 2,
'type' => 'payfip-test',
'user_id' => 336,
'reference' => '098764321',
'amount' => 8839,
'id_op' => '99I88I',
'result' => Class_Payfip::RESULT_PAYED_BY_CB,
'sigb_status' => Class_Payfip::SIGB_ERROR,
]);
Class_Webservice_SIGB_Nanook_Service::shouldThrowError(false);
Class_AdminVar::set(Class_AdminVar_Payfip::ERROR_MAIL_RECIPIENT,'admin@mybib.fr');
$this->_nanook_client
->onPostData('EndPayment/patronId/336',
http_build_query(['totalAmount' => '88.39',
'paymentId' => '098764321',
'status' => 'Accepted',
'paymentType' => 'CB',
'paymentDate' => '',
'paymentInfo' => 'Référence commande : 098764321']))
->answerFile('endPaymentResponseSuccess.xml');
;
}
/** @test */
public function payfipLastErrorShouldBeEmpty() {
$this->assertEquals(1, Class_Payfip::find(2)->getSigbStatus());
}
}
class PayfipBatchRefreshReturnPaidPaymentSigbOKTest
extends PayfipBatchPayfipWebserviceReturnsOKTestCase {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment