Skip to content

Commit

Permalink
add closePaymentV2 and pspNotifyPaymentV2
Browse files Browse the repository at this point in the history
  • Loading branch information
esposimo committed Apr 28, 2024
1 parent 0db2a33 commit 7956dff
Show file tree
Hide file tree
Showing 60 changed files with 4,222 additions and 79 deletions.
16 changes: 16 additions & 0 deletions src/mock_crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,29 @@
$a->run();


$a = new \pagopa\crawler\paymentlist\req\closePaymentV2(new \DateTime('2024-03-10'), 'closePayment-v2', 'REQ', $redis_cache);
$a->run();


$a = new \pagopa\crawler\paymentlist\resp\closePaymentV2(new \DateTime('2024-03-10'), 'closePayment-v2', 'RESP', $redis_cache);
$a->run();



$a = new \pagopa\crawler\paymentlist\req\pspNotifyPayment(new \DateTime('2024-03-10'), 'pspNotifyPayment', 'REQ', $redis_cache);
$a->run();

$a = new \pagopa\crawler\paymentlist\resp\pspNotifyPayment(new \DateTime('2024-03-10'), 'pspNotifyPayment', 'RESP', $redis_cache);
$a->run();


$a = new \pagopa\crawler\paymentlist\req\pspNotifyPaymentV2(new \DateTime('2024-03-10'), 'pspNotifyPaymentV2', 'REQ', $redis_cache);
$a->run();

$a = new \pagopa\crawler\paymentlist\resp\pspNotifyPaymentV2(new \DateTime('2024-03-10'), 'pspNotifyPaymentV2', 'RESP', $redis_cache);
$a->run();


$a = new \pagopa\crawler\paymentlist\req\pspInviaCarrelloRPT(new DateTime('2024-03-10'), 'pspInviaCarrelloRPT', 'REQ', $redis_cache);
$a->run();

Expand Down
220 changes: 219 additions & 1 deletion src/mock_insert.php

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions src/sql/05_2024_insert_data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,15 @@ INSERT INTO mapped_events(tipo_evento,sotto_tipo_evento ,fk_event) values
('nodoInviaRT' , 'REQ' , 17),
('nodoInviaRT' , 'RESP', 18),
('paaInviaRT' , 'REQ' , 19),
('paaInviaRT' , 'RESP', 20);
('paaInviaRT' , 'RESP', 20),
('activateIOPayment' , 'REQ' , 21),
('activateIOPayment' , 'RESP', 22),
('activatePaymentNoticeV2' , 'REQ' , 23),
('activatePaymentNoticeV2' , 'RESP', 24);
('activatePaymentNoticeV2' , 'RESP', 24),
('pspNotifyPaymentV2' , 'REQ' , 25),
('pspNotifyPaymentV2' , 'RESP', 26),
('closePayment-v2' , 'REQ' , 27),
('closePayment-v2' , 'RESP', 28);

insert into mapped_payment_methods (tipoversamento, descrizione) values
('CC', 'Carta di Credito'),
Expand Down
2 changes: 1 addition & 1 deletion src/src/crawler/events/AbstractEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ public function isValidPayload(): bool
}
if ($this->typePayload == 'json')
{
json_decode($payload);
return $this->getMethodInterface()->isValidPayload();
return json_last_error() === JSON_ERROR_NONE;
}
return false;
Expand Down
172 changes: 172 additions & 0 deletions src/src/crawler/events/req/closePaymentV2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
<?php

namespace pagopa\crawler\events\req;

use pagopa\crawler\events\AbstractEvent;
use pagopa\crawler\MapEvents;
use pagopa\crawler\methods\MethodInterface;
use pagopa\database\sherlock\Transaction;
use pagopa\database\sherlock\TransactionDetails;
use pagopa\database\sherlock\Workflow;
use pagopa\crawler\methods\req\closePaymentV2 as Payload;

class closePaymentV2 extends AbstractEvent
{

protected Payload $method;


protected bool $isCart = true;


public function __construct(array $eventData)
{
parent::__construct($eventData);
$this->method = new Payload($this->data['payload']);
}
/**
* @inheritDoc
*/
public function getIuvs(): array|null
{
$value = $this->getIuv();
return (is_null($value)) ? $this->getMethodInterface()->getIuvs() : array($value);
}

/**
* @inheritDoc
*/
public function getPaEmittenti(): array|null
{
$value = $this->getPaEmittente();
return (is_null($value)) ? $this->getMethodInterface()->getPaEmittenti() : array($value);
}

/**
* @inheritDoc
*/
public function getCcps(): array|null
{
$value = $this->getCcp();
return (is_null($value)) ? $this->getMethodInterface()->getCcps() : array($value);
}

/**
* @inheritDoc
*/
public function transaction(int $index = 0): Transaction|null
{
return null;
}

public function transactionDetails(int $transfer, int $index = 0): TransactionDetails|null
{
return null;
}

public function workflowEvent(int $index = 0): Workflow|null
{
$workflow = new Workflow($this->getInsertedTimestamp());
$workflow->setNewColumnValue('date_event', $this->getInsertedTimestamp()->format('Y-m-d'));
$workflow->setEventTimestamp($this->getInsertedTimestamp());
$workflow->setEventId($this->getUniqueId());
$workflow->setFkTipoEvento(MapEvents::getMethodId($this->getTipoEvento(), $this->getSottoTipoEvento()));

$id_psp = $this->getPsp();
$stazione = $this->getStazione();
$canale = $this->getCanale();

if (!is_null($id_psp))
{
$workflow->setPsp($id_psp);
}
if (!is_null($stazione))
{
$workflow->setStazione($stazione);
}
if (!is_null($canale))
{
$workflow->setCanale($canale);
}
if (!is_null($this->getMethodInterface()->outcome()))
{
$workflow->setOutcomeEvent($this->getMethodInterface()->outcome());
}

return $workflow;
}

/**
* @inheritDoc
*/
public function getMethodInterface(): Payload
{
return $this->method;
}

/**
* @inheritDoc
*/
public function getPaymentsCount(): int|null
{
return $this->getMethodInterface()->getPaymentsCount();
}

/**
* @inheritDoc
*/
public function getTransferCount(int $index = 0): int|null
{
return null;
}

/**
* @inheritDoc
*/
public function getCacheKeyPayment(): string
{
$session = $this->getSessionIdOriginal();
return base64_encode(sprintf('sessionOriginal_%s', $session));
}

/**
* @inheritDoc
*/
public function getCacheKeyAttempt(): string
{
$session = $this->getSessionIdOriginal();
return base64_encode(sprintf('sessionOriginal_%s', $session));
}

/**
* @inheritDoc
*/
public function isFaultEvent(): bool
{
return false;
}

/**
* @inheritDoc
*/
public function getFaultCode(): string|null
{
return null;
}

/**
* @inheritDoc
*/
public function getFaultString(): string|null
{
return null;
}

/**
* @inheritDoc
*/
public function getFaultDescription(): string|null
{
return null;
}
}
165 changes: 165 additions & 0 deletions src/src/crawler/events/req/pspNotifyPaymentV2.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
<?php

namespace pagopa\crawler\events\req;

use pagopa\crawler\events\AbstractEvent;
use pagopa\crawler\MapEvents;
use pagopa\crawler\methods\MethodInterface;
use pagopa\database\sherlock\Transaction;
use pagopa\database\sherlock\TransactionDetails;
use pagopa\database\sherlock\Workflow;
use pagopa\crawler\methods\req\pspNotifyPaymentV2 as Payload;

class pspNotifyPaymentV2 extends AbstractEvent
{

protected Payload $method;


public function __construct(array $eventData)
{
parent::__construct($eventData);
$this->method = new Payload($this->data['payload']);
}
/**
* @inheritDoc
*/
public function getIuvs(): array|null
{
$value = $this->getMethodInterface()->getIuvs();
return (is_null($value)) ? null : $value;
}

/**
* @inheritDoc
*/
public function getPaEmittenti(): array|null
{
$value = $this->getMethodInterface()->getPaEmittenti();
return (is_null($value)) ? null : $value;
}

/**
* @inheritDoc
*/
public function getCcps(): array|null
{
$value = $this->getMethodInterface()->getCcps();
return (is_null($value)) ? null : $value;
}

/**
* @inheritDoc
*/
public function transaction(int $index = 0): Transaction|null
{
return null;
}

public function transactionDetails(int $transfer, int $index = 0): TransactionDetails|null
{
return null;
}

public function workflowEvent(int $index = 0): Workflow|null
{
$workflow = new Workflow($this->getInsertedTimestamp());
$workflow->setNewColumnValue('date_event', $this->getInsertedTimestamp()->format('Y-m-d'));
$workflow->setEventTimestamp($this->getInsertedTimestamp());
$workflow->setEventId($this->getUniqueId());
$workflow->setFkTipoEvento(MapEvents::getMethodId($this->getTipoEvento(), $this->getSottoTipoEvento()));

$id_psp = $this->getPsp();
$stazione = $this->getStazione();
$canale = $this->getCanale();

if (!is_null($id_psp))
{
$workflow->setPsp($id_psp);
}
if (!is_null($stazione))
{
$workflow->setStazione($stazione);
}
if (!is_null($canale))
{
$workflow->setCanale($canale);
}

return $workflow;
}

/**
* @inheritDoc
*/
public function getMethodInterface(): Payload
{
return $this->method;
}

/**
* @inheritDoc
*/
public function getPaymentsCount(): int|null
{
return $this->getMethodInterface()->getPaymentsCount();
}

/**
* @inheritDoc
*/
public function getTransferCount(int $index = 0): int|null
{
return $this->getMethodInterface()->getTransferCount($index);
}

/**
* @inheritDoc
*/
public function getCacheKeyPayment(int $index = 0): string
{
$session = $this->getSessionIdOriginal();
return base64_encode(sprintf('sessionOriginal_%s', $session));
}

/**
* @inheritDoc
*/
public function getCacheKeyAttempt(int $index = 0): string
{
$session = $this->getSessionIdOriginal();
return base64_encode(sprintf('sessionOriginal_%s', $session));
}

/**
* @inheritDoc
*/
public function isFaultEvent(): bool
{
return false;
}

/**
* @inheritDoc
*/
public function getFaultCode(): string|null
{
return null;
}

/**
* @inheritDoc
*/
public function getFaultString(): string|null
{
return null;
}

/**
* @inheritDoc
*/
public function getFaultDescription(): string|null
{
return null;
}
}
Loading

0 comments on commit 7956dff

Please sign in to comment.