Skip to content

Commit

Permalink
less code ni paymentlist
Browse files Browse the repository at this point in the history
  • Loading branch information
esposimo committed Apr 13, 2024
1 parent c73ed52 commit 277c7d1
Show file tree
Hide file tree
Showing 14 changed files with 34 additions and 450 deletions.
14 changes: 13 additions & 1 deletion src/src/crawler/AbstractEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,23 @@ public function getPayload(): string|null
return $this->getColumn('payload');
}

public function getPaEmittente(int $index = 0): string|null
{
$column = $this->getColumn('iddominio');
if ($index > 0)
{
// se sto chiedendo una PA interna al payload , chiedo al metodo
return $this->getMethodInterface()->getPaEmittente($index);
}
// altrimenti se $column è vuoto, chiedo al metodo con $index=0, altrimenti restituisco column (che esiste a questo punto)
return (empty($column)) ? $this->getMethodInterface()->getPaEmittente(0) : $column;
}


/**
* @inheritDoc
*/
abstract public function getPaEmittente(int $index = 0): string|null;
//abstract public function getPaEmittente(int $index = 0): string|null;

/**
* @inheritDoc
Expand Down
25 changes: 21 additions & 4 deletions src/src/crawler/paymentlist/AbstractPaymentList.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,24 @@ abstract public function isValidPayment(int $index = 0): bool;
*/
abstract public function isAttempt(int $index = 0): bool;


/**
* @inheritDoc
*/
abstract public function isAttemptInCache(int $index = 0): bool;
public function isAttemptInCache(int $index = 0): bool
{
$key = $this->getEvent()->getCacheKeyAttempt();
return $this->hasInCache($key);
}

/**
* @inheritDoc
*/
abstract public function isPaymentInCache(int $index = 0): bool;
public function isPaymentInCache(int $index = 0): bool
{
$key = $this->getEvent()->getCacheKeyPayment();
return $this->hasInCache($key);
}

/**
* @inheritDoc
Expand All @@ -266,15 +275,23 @@ public function isEnableSearch(): bool
{
return $this->search_on_db;
}

/**
* @inheritDoc
*/
abstract public function runRejectedEvent(string $message = null): TransactionRe;
public function runRejectedEvent(string $message = null): TransactionRe
{
return $this->getEvent()->getEventRowInstance()->reject($message)->update();

}

/**
* @inheritDoc
*/
abstract public function runCompleteEvent(string $message = null): TransactionRe;
public function runCompleteEvent(string $message = null): TransactionRe
{
return $this->getEvent()->getEventRowInstance()->loaded($message)->update();
}


public function runAnalysisSingleEvent() : void
Expand Down
45 changes: 0 additions & 45 deletions src/src/crawler/paymentlist/req/activatePaymentNotice.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,51 +39,6 @@ public function isAttempt(int $index = 0): bool
return ($this->getEvent()->getIuv(0) && $this->getEvent()->getPaEmittente(0) && $this->getEvent()->getPaymentToken(0));
}

/**
* @inheritDoc
*/
public function isAttemptInCache(int $index = 0): bool
{
$date = $this->getEvent()->getInsertedTimestamp()->format('Ymd');
$iuv = $this->getEvent()->getIuv(0);
$pa = $this->getEvent()->getPaEmittente(0);
$token = $this->getEvent()->getPaymentToken(0);
$key = base64_encode(sprintf('attempt_%s_%s_%s', $iuv, $pa, $token));
$cache_key = $this->getEvent()->getCacheKeyAttempt();
return $this->hasInCache($cache_key);
}

/**
* @inheritDoc
*/
public function isPaymentInCache(int $index = 0): bool
{
$date = $this->getEvent()->getInsertedTimestamp()->format('Ymd');
$iuv = $this->getEvent()->getIuv($index);
$pa = $this->getEvent()->getPaEmittente($index);
$key = base64_encode(sprintf('payment_%s_%s', $iuv, $pa));
$cache_key = $this->getEvent()->getCacheKeyPayment();
return $this->hasInCache($cache_key);
}

/**
* @inheritDoc
*/
public function runRejectedEvent(string $message = null): TransactionRe
{
return $this->getEvent()->getEventRowInstance()->reject($message)->update();

}

/**
* @inheritDoc
*/
public function runCompleteEvent(string $message = null): TransactionRe
{
return $this->getEvent()->getEventRowInstance()->loaded($message)->update();
}


public function createTransaction(int $index = 0) : array|null
{
// devo creare la transazione e il workflow
Expand Down
35 changes: 0 additions & 35 deletions src/src/crawler/paymentlist/req/nodoInviaCarrelloRPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,6 @@ public function isAttempt(int $index = 0): bool
{
return !is_null($this->getEvent()->getSessionIdOriginal());
}

/**
* @inheritDoc
*/
public function isAttemptInCache(int $index = 0): bool
{
$key = $this->getEvent()->getCacheKeyAttempt();
return $this->hasInCache($key);
}

/**
* @inheritDoc
*/
public function isPaymentInCache(int $index = 0): bool
{
$key = $this->getEvent()->getCacheKeyPayment();
return $this->hasInCache($key);
}

/**
* @inheritDoc
*/
Expand All @@ -69,22 +50,6 @@ public function isFoundOnDb(int $index = 0): bool
return !is_null(Transaction::searchByPayment($iuv, $pa));
}

/**
* @inheritDoc
*/
public function runRejectedEvent(string $message = null): TransactionRe
{
return $this->getEvent()->getEventRowInstance()->reject($message)->update();
}

/**
* @inheritDoc
*/
public function runCompleteEvent(string $message = null): TransactionRe
{
return $this->getEvent()->getEventRowInstance()->loaded($message)->update();
}

public function createTransaction(int $index = 0) : array|null
{
$iuv = $this->getEvent()->getIuv($index);
Expand Down
36 changes: 0 additions & 36 deletions src/src/crawler/paymentlist/req/nodoInviaRPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,42 +37,6 @@ public function isAttempt(int $index = 0): bool
return ($this->getEvent()->getIuv(0) && $this->getEvent()->getPaEmittente(0) && $this->getEvent()->getCcp(0));
}

/**
* @inheritDoc
*/
public function isAttemptInCache(int $index = 0): bool
{
// una nodoInviaRPT è in cache con attempt_* se c'è stata già una attivazione con nodoAttivaRPT
// una nodoInviaRPT non è in cache con attempt_* se non c'è stata una attivazione con nodoAttivaRPT
$key = $this->getEvent()->getCacheKeyAttempt();
return $this->hasInCache($key);
}

/**
* @inheritDoc
*/
public function isPaymentInCache(int $index = 0): bool
{
$key = $this->getEvent()->getCacheKeyPayment();
return $this->hasInCache($key);
}

/**
* @inheritDoc
*/
public function runRejectedEvent(string $message = null): TransactionRe
{
return $this->getEvent()->getEventRowInstance()->reject($message)->update();
}

/**
* @inheritDoc
*/
public function runCompleteEvent(string $message = null): TransactionRe
{
return $this->getEvent()->getEventRowInstance()->loaded($message)->update();
}

public function updateDetails(CacheObject $cache, int $index = 0): array|null
{
// qui aggiungo i versamenti della RPT
Expand Down
35 changes: 0 additions & 35 deletions src/src/crawler/paymentlist/req/pspInviaCarrelloRPT.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,41 +35,6 @@ public function isAttempt(int $index = 0): bool
{
return !is_null($this->getEvent()->getSessionIdOriginal());
}

/**
* @inheritDoc
*/
public function isAttemptInCache(int $index = 0): bool
{
$key = $this->getEvent()->getCacheKeyAttempt();
return $this->hasInCache($key);
}

/**
* @inheritDoc
*/
public function isPaymentInCache(int $index = 0): bool
{
$key = $this->getEvent()->getCacheKeyAttempt();
return $this->hasInCache($key);
}

/**
* @inheritDoc
*/
public function runRejectedEvent(string $message = null): TransactionRe
{
return $this->getEvent()->getEventRowInstance()->reject($message)->update();
}

/**
* @inheritDoc
*/
public function runCompleteEvent(string $message = null): TransactionRe
{
return $this->getEvent()->getEventRowInstance()->loaded($message)->update();
}

public function updateTransaction(CacheObject $cache, int $index = 0): array|null
{
$id = $cache->getId();
Expand Down
48 changes: 0 additions & 48 deletions src/src/crawler/paymentlist/req/pspInviaCarrelloRPTCarte.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,54 +37,6 @@ public function isAttempt(int $index = 0): bool
return !is_null($this->getEvent()->getSessionIdOriginal());
}

/**
* @inheritDoc
*/
public function isAttemptInCache(int $index = 0): bool
{
// se sono valorizzate le colonne
$key = $this->getEvent()->getCacheKeyAttempt();
$iuv = $this->getEvent()->getColumn('iuv');
$pa_emittente = $this->getEvent()->getColumn('iddominio');
$token = $this->getEvent()->getColumn('ccp');
if (($iuv) && ($pa_emittente) && ($token))
{
$key = base64_encode(sprintf('attempt_%s_%s_%s', $iuv, $pa_emittente, $token));
}
return $this->hasInCache($key);
}

/**
* @inheritDoc
*/
public function isPaymentInCache(int $index = 0): bool
{
$key = $this->getEvent()->getCacheKeyAttempt();
$iuv = $this->getEvent()->getColumn('iuv');
$pa_emittente = $this->getEvent()->getColumn('iddominio');
$token = $this->getEvent()->getColumn('ccp');
if (($iuv) && ($pa_emittente) && ($token))
{
$key = base64_encode(sprintf('attempt_%s_%s_%s', $iuv, $pa_emittente, $token));
}
return $this->hasInCache($key);
}

/**
* @inheritDoc
*/
public function runRejectedEvent(string $message = null): TransactionRe
{
return $this->getEvent()->getEventRowInstance()->reject($message)->update();
}

/**
* @inheritDoc
*/
public function runCompleteEvent(string $message = null): TransactionRe
{
return $this->getEvent()->getEventRowInstance()->loaded($message)->update();
}

public function updateTransaction(CacheObject $cache, int $index = 0): array|null
{
Expand Down
35 changes: 0 additions & 35 deletions src/src/crawler/paymentlist/req/sendPaymentOutcome.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,41 +40,6 @@ public function isAttempt(int $index = 0): bool
return ($this->getEvent()->getIuv(0) && $this->getEvent()->getPaEmittente(0) && $token);
}

/**
* @inheritDoc
*/
public function isAttemptInCache(int $index = 0): bool
{
$cache_key = $this->getEvent()->getCacheKeyAttempt();
return $this->hasInCache($cache_key);
}

/**
* @inheritDoc
*/
public function isPaymentInCache(int $index = 0): bool
{
$cache_key = $this->getEvent()->getCacheKeyPayment();
return $this->hasInCache($cache_key);
}

/**
* @inheritDoc
*/
public function runRejectedEvent(string $message = null): TransactionRe
{
return $this->getEvent()->getEventRowInstance()->reject($message)->update();
}

/**
* @inheritDoc
*/
public function runCompleteEvent(string $message = null): TransactionRe
{
return $this->getEvent()->getEventRowInstance()->loaded($message)->update();
}


public function updateTransaction(CacheObject $cache, int $index = 0): array|null
{
if ((!$this->getEvent()->isValidPayload()) || ($cache->getEsito()))
Expand Down
Loading

0 comments on commit 277c7d1

Please sign in to comment.