Skip to content

Commit

Permalink
add order info into dispatched events
Browse files Browse the repository at this point in the history
  • Loading branch information
nuryagdym committed May 22, 2024
1 parent fb51817 commit 1fe6820
Show file tree
Hide file tree
Showing 26 changed files with 234 additions and 75 deletions.
16 changes: 15 additions & 1 deletion src/Event/RequestDataPreparedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ class RequestDataPreparedEvent
/** @var array<string, mixed> */
private array $requestData;

/** @var array<string, mixed> */
private array $order;

private string $bank;

/** @var PosInterface::TX_TYPE_* */
Expand All @@ -32,17 +35,20 @@ class RequestDataPreparedEvent
* @param string $bank
* @param string $txType
* @param string $gatewayClass
* @param array<string, mixed> $order
*/
public function __construct(
array $requestData,
string $bank,
string $txType,
string $gatewayClass
string $gatewayClass,
array $order
) {
$this->requestData = $requestData;
$this->bank = $bank;
$this->txType = $txType;
$this->gatewayClass = $gatewayClass;
$this->order = $order;
}

/**
Expand All @@ -65,6 +71,14 @@ public function setRequestData(array $requestData): self
return $this;
}

/**
* @return array<string, mixed>
*/
public function getOrder(): array
{
return $this->order;
}

/**
* @return PosInterface::TX_TYPE_*
*/
Expand Down
21 changes: 14 additions & 7 deletions src/Gateways/AbstractGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ public function makeRegularPayment(array $order, CreditCardInterface $creditCard
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down Expand Up @@ -276,7 +277,8 @@ public function makeRegularPostPayment(array $order): PosInterface
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down Expand Up @@ -313,7 +315,8 @@ public function refund(array $order): PosInterface
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down Expand Up @@ -354,7 +357,8 @@ public function cancel(array $order): PosInterface
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down Expand Up @@ -395,7 +399,8 @@ public function status(array $order): PosInterface
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down Expand Up @@ -432,7 +437,8 @@ public function history(array $data): PosInterface
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$data
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down Expand Up @@ -469,7 +475,8 @@ public function orderHistory(array $order): PosInterface
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down
3 changes: 2 additions & 1 deletion src/Gateways/AkbankPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down
3 changes: 2 additions & 1 deletion src/Gateways/EstPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down
3 changes: 2 additions & 1 deletion src/Gateways/GarantiPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down
3 changes: 2 additions & 1 deletion src/Gateways/InterPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down
6 changes: 4 additions & 2 deletions src/Gateways/KuveytPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down Expand Up @@ -331,7 +332,8 @@ private function getCommon3DFormData(KuveytPosAccount $kuveytPosAccount, array $
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down
6 changes: 4 additions & 2 deletions src/Gateways/PayFlexCPV4Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public function make3DPayPayment(Request $request, array $order, string $txType)
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down Expand Up @@ -247,7 +248,8 @@ private function registerPayment(array $order, string $txType, string $paymentMo
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down
6 changes: 4 additions & 2 deletions src/Gateways/PayFlexV4Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down Expand Up @@ -222,7 +223,8 @@ private function sendEnrollmentRequest(array $order, CreditCardInterface $credit
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down
3 changes: 2 additions & 1 deletion src/Gateways/PayForPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down
9 changes: 6 additions & 3 deletions src/Gateways/PosNet.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down Expand Up @@ -111,7 +112,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down Expand Up @@ -250,7 +252,8 @@ private function getOosTransactionData(array $order, string $txType, CreditCardI
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down
3 changes: 2 additions & 1 deletion src/Gateways/PosNetV1Pos.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down
3 changes: 2 additions & 1 deletion src/Gateways/ToslaPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ private function registerPayment(array $order, string $paymentModel, string $txT
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down
6 changes: 4 additions & 2 deletions src/Gateways/VakifKatilimPos.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ public function make3DPayment(Request $request, array $order, string $txType, Cr
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down Expand Up @@ -202,7 +203,8 @@ private function sendEnrollmentRequest(KuveytPosAccount $kuveytPosAccount, array
$requestData,
$this->account->getBank(),
$txType,
\get_class($this)
\get_class($this),
$order
);
$this->eventDispatcher->dispatch($event);
if ($requestData !== $event->getRequestData()) {
Expand Down
Loading

0 comments on commit 1fe6820

Please sign in to comment.