-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ACP-2930: Added validation plugin for disconnection (#20)
- Loading branch information
1 parent
fd7b7d9
commit e5b61a0
Showing
29 changed files
with
491 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"The payment App cannot be disconnected when there are open orders. Open orders won’t be proceed automatically if you delete the App. Close the open orders to continue.","Die Zahlungs-App kann nicht getrennt werden, wenn offene Bestellungen vorliegen. Offene Bestellungen werden nicht automatisch abgeschlossen, wenn Sie die App löschen. Schließen Sie die offenen Bestellungen, um fortzufahren." | ||
"Please close any open orders and try again.","Bitte schließen Sie alle offenen Bestellungen und versuchen Sie es erneut." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"The payment App cannot be disconnected when there are open orders. Open orders won’t be proceed automatically if you delete the App. Close the open orders to continue.","The payment App cannot be disconnected when there are open orders. Open orders won’t be proceed automatically if you delete the App. Close the open orders to continue." | ||
"Please close any open orders and try again.","Please close any open orders and try again." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...e/AppPaymentBackendApi/Dependency/Facade/AppPaymentBackendApiToTranslatorFacadeBridge.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Spryker Suite. | ||
* For full license information, please view the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Spryker\Glue\AppPaymentBackendApi\Dependency\Facade; | ||
|
||
class AppPaymentBackendApiToTranslatorFacadeBridge implements AppPaymentBackendApiToTranslatorFacadeInterface | ||
{ | ||
/** | ||
* @var \Spryker\Zed\Translator\Business\TranslatorFacadeInterface | ||
*/ | ||
protected $translatorFacade; | ||
|
||
/** | ||
* @param \Spryker\Zed\Translator\Business\TranslatorFacadeInterface $translatorFacade | ||
*/ | ||
public function __construct($translatorFacade) | ||
{ | ||
$this->translatorFacade = $translatorFacade; | ||
} | ||
|
||
/** | ||
* @param array<mixed> $parameters | ||
* @param string|null $domain | ||
* @param string|null $locale | ||
*/ | ||
public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string | ||
{ | ||
return $this->translatorFacade->trans($id, $parameters, $domain, $locale); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...ppPaymentBackendApi/Dependency/Facade/AppPaymentBackendApiToTranslatorFacadeInterface.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Spryker Suite. | ||
* For full license information, please view the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Spryker\Glue\AppPaymentBackendApi\Dependency\Facade; | ||
|
||
interface AppPaymentBackendApiToTranslatorFacadeInterface | ||
{ | ||
/** | ||
* @param array<mixed> $parameters | ||
* @param string|null $domain | ||
* @param string|null $locale | ||
*/ | ||
public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string; | ||
} |
56 changes: 56 additions & 0 deletions
56
...ntBackendApi/Plugin/GlueApplication/PaymentConfirmDisconnectionRequestValidatorPlugin.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of the Spryker Suite. | ||
* For full license information, please view the LICENSE file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Spryker\Glue\AppPaymentBackendApi\Plugin\GlueApplication; | ||
|
||
use Generated\Shared\Transfer\GlueRequestTransfer; | ||
use Generated\Shared\Transfer\GlueRequestValidationTransfer; | ||
use Generated\Shared\Transfer\PaymentConditionsTransfer; | ||
use Generated\Shared\Transfer\PaymentCriteriaTransfer; | ||
use Spryker\Glue\AppKernel\Plugin\GlueApplication\AbstractConfirmDisconnectionRequestValidatorPlugin; | ||
use Spryker\Glue\AppPaymentBackendApi\AppPaymentBackendApiConfig; | ||
use Spryker\Zed\AppPayment\Business\Payment\Status\PaymentStatus; | ||
|
||
/** | ||
* @method \Spryker\Glue\AppPaymentBackendApi\AppPaymentBackendApiFactory getFactory() | ||
*/ | ||
class PaymentConfirmDisconnectionRequestValidatorPlugin extends AbstractConfirmDisconnectionRequestValidatorPlugin | ||
{ | ||
protected function validateDisconnectionRequest(GlueRequestTransfer $glueRequestTransfer, string $tenantIdentifier): GlueRequestValidationTransfer | ||
{ | ||
$paymentCollectionTransfer = $this->getFactory()->getAppPaymentFacade()->getPaymentCollection( | ||
(new PaymentCriteriaTransfer())->setPaymentConditions( | ||
(new PaymentConditionsTransfer()) | ||
->setTenantIdentifier($tenantIdentifier) | ||
->setExcludingStatuses([ | ||
PaymentStatus::STATUS_CANCELED, | ||
PaymentStatus::STATUS_CAPTURED, | ||
]), | ||
), | ||
); | ||
|
||
if ($paymentCollectionTransfer->getPayments()->count() === 0) { | ||
return (new GlueRequestValidationTransfer()) | ||
->setIsValid(true); | ||
} | ||
|
||
return $this->getFailedGlueRequestValidationTransfer( | ||
AppPaymentBackendApiConfig::ERROR_CODE_PAYMENT_DISCONNECTION_CANNOT_BE_PROCEEDED, | ||
$this->getFactory()->getTranslatorFacade()->trans('The payment App cannot be disconnected when there are open orders. Open orders won’t be proceed automatically if you delete the App. Close the open orders to continue.'), | ||
); | ||
} | ||
|
||
protected function getCancellationErrorCode(): string | ||
{ | ||
return AppPaymentBackendApiConfig::ERROR_CODE_PAYMENT_DISCONNECTION_FORBIDDEN; | ||
} | ||
|
||
protected function getCancellationErrorMessage(): string | ||
{ | ||
return $this->getFactory()->getTranslatorFacade()->trans('Please close any open orders and try again.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.