-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ASW-500 merge release-3.5.0 into adyen/develop
- Loading branch information
Showing
74 changed files
with
3,070 additions
and
220 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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AdyenPayment\AdyenApi\HttpClient; | ||
|
||
use Adyen\Client; | ||
use Shopware\Models\Shop\Shop; | ||
|
||
interface ClientFactoryInterface | ||
{ | ||
public function provide(Shop $shop): Client; | ||
} |
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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AdyenPayment\AdyenApi\HttpClient; | ||
|
||
use Adyen\Client; | ||
use Shopware\Models\Shop\Shop; | ||
|
||
interface ClientMemoiseInterface | ||
{ | ||
public function lookup(Shop $shop): Client; | ||
} |
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,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AdyenPayment\AdyenApi\HttpClient; | ||
|
||
use Symfony\Component\Validator\ConstraintViolationList; | ||
|
||
interface ConfigValidatorInterface | ||
{ | ||
public function validate(int $shopId): ConstraintViolationList; | ||
} |
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,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AdyenPayment\AdyenApi\Model; | ||
|
||
final class ApiResponse | ||
{ | ||
private bool $success; | ||
private string $message; | ||
|
||
private function __construct(bool $success, string $message) | ||
{ | ||
$this->success = $success; | ||
$this->message = $message; | ||
} | ||
|
||
public static function create(bool $success, string $message): self | ||
{ | ||
return new self($success, $message); | ||
} | ||
|
||
public static function empty(): self | ||
{ | ||
return new self(false, 'Customer number not found.'); | ||
} | ||
|
||
public function isSuccess(): bool | ||
{ | ||
return $this->success; | ||
} | ||
|
||
public function message(): string | ||
{ | ||
return $this->message; | ||
} | ||
} |
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,55 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AdyenPayment\AdyenApi\Recurring; | ||
|
||
use AdyenPayment\AdyenApi\Model\ApiResponse; | ||
use AdyenPayment\AdyenApi\TransportFactoryInterface; | ||
use AdyenPayment\Session\CustomerNumberProviderInterface; | ||
use Shopware\Models\Shop\Shop; | ||
|
||
final class DisableTokenRequestHandler implements DisableTokenRequestHandlerInterface | ||
{ | ||
private TransportFactoryInterface $transportFactory; | ||
private CustomerNumberProviderInterface $customerNumberProvider; | ||
|
||
public function __construct( | ||
TransportFactoryInterface $transportFactory, | ||
CustomerNumberProviderInterface $customerNumberProvider | ||
) { | ||
$this->transportFactory = $transportFactory; | ||
$this->customerNumberProvider = $customerNumberProvider; | ||
} | ||
|
||
public function disableToken(string $recurringTokenId, Shop $shop): ApiResponse | ||
{ | ||
$customerNumber = ($this->customerNumberProvider)(); | ||
if ('' === $customerNumber) { | ||
return ApiResponse::empty(); | ||
} | ||
$recurringTransport = $this->transportFactory->recurring($shop); | ||
|
||
$payload = [ | ||
'shopperReference' => $customerNumber, | ||
'recurringDetailReference' => $recurringTokenId, | ||
]; | ||
|
||
$result = $recurringTransport->disable($payload); | ||
|
||
$response = (string) ($result['response'] ?? ''); | ||
$resultMessage = (string) ($result['message'] ?? ''); | ||
$isSuccessfullyDisabled = $this->isSuccessfullyDisabled($response); | ||
|
||
return ApiResponse::create($isSuccessfullyDisabled, $resultMessage); | ||
} | ||
|
||
private function isSuccessfullyDisabled(string $response): bool | ||
{ | ||
if (false === mb_strpos($response, 'successfully-disabled')) { | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
AdyenApi/Recurring/DisableTokenRequestHandlerInterface.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,13 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AdyenPayment\AdyenApi\Recurring; | ||
|
||
use AdyenPayment\AdyenApi\Model\ApiResponse; | ||
use Shopware\Models\Shop\Shop; | ||
|
||
interface DisableTokenRequestHandlerInterface | ||
{ | ||
public function disableToken(string $recurringTokenId, Shop $shop): ApiResponse; | ||
} |
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 | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AdyenPayment\AdyenApi; | ||
|
||
use Adyen\Service\Checkout; | ||
use Adyen\Service\Recurring; | ||
use AdyenPayment\AdyenApi\HttpClient\ClientFactoryInterface; | ||
use Shopware\Models\Shop\Shop; | ||
|
||
final class TransportFactory implements TransportFactoryInterface | ||
{ | ||
private ClientFactoryInterface $apiFactory; | ||
|
||
public function __construct(ClientFactoryInterface $apiFactory) | ||
{ | ||
$this->apiFactory = $apiFactory; | ||
} | ||
|
||
public function recurring(Shop $shop): Recurring | ||
{ | ||
return new Recurring( | ||
$this->apiFactory->provide($shop) | ||
); | ||
} | ||
|
||
public function checkout(Shop $shop): Checkout | ||
{ | ||
return new Checkout( | ||
$this->apiFactory->provide($shop) | ||
); | ||
} | ||
} |
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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace AdyenPayment\AdyenApi; | ||
|
||
use Adyen\Service\Checkout; | ||
use Adyen\Service\Recurring; | ||
use Shopware\Models\Shop\Shop; | ||
|
||
interface TransportFactoryInterface | ||
{ | ||
public function recurring(Shop $shop): Recurring; | ||
public function checkout(Shop $shop): Checkout; | ||
} |
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.