-
Notifications
You must be signed in to change notification settings - Fork 0
Add SVEA deployment support to the WIX integration #68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 4 commits
71bc8a6
7f2cc84
d16d376
ef9a9a9
4393880
4285af1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ | |
| use SeQura\Core\BusinessLogic\CheckoutAPI\ExpressCheckout\Controller\ExpressCheckoutController; | ||
| use SeQura\Core\BusinessLogic\CheckoutAPI\Banners\BannerCheckoutController; | ||
| use SeQura\Core\BusinessLogic\CheckoutAPI\PaymentMethods\CachedPaymentMethodsController; | ||
| use SeQura\Core\BusinessLogic\CheckoutAPI\PaymentMethods\PaymentMethodsCheckoutController; | ||
| use SeQura\Core\BusinessLogic\CheckoutAPI\PromotionalWidgets\PromotionalWidgetsCheckoutController; | ||
| use SeQura\Core\BusinessLogic\CheckoutAPI\Solicitation\Controller\SolicitationController; | ||
|
|
||
|
|
@@ -60,6 +61,19 @@ public function cachedPaymentMethods(string $storeId): object | |
| ->beforeEachMethodOfService(CachedPaymentMethodsController::class); | ||
| } | ||
|
|
||
| /** | ||
| * @param string $storeId | ||
| * | ||
| * @return object | ||
| */ | ||
| public function paymentMethods(string $storeId): object | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming: the generic name went to the narrower feature.
An integrator picking
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new store-scoped endpoint provides no actual store isolation.
So in a multistore install, This contradicts
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Naming: the generic name went to the narrower feature.
An integrator picking |
||
| { | ||
| return Aspects | ||
| ::run(new ErrorHandlingAspect()) | ||
| ->andRun(new StoreContextAspect($storeId)) | ||
| ->beforeEachMethodOfService(PaymentMethodsCheckoutController::class); | ||
| } | ||
|
|
||
| /** | ||
| * @param string $storeId | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <?php | ||
|
|
||
| namespace SeQura\Core\BusinessLogic\CheckoutAPI\PaymentMethods; | ||
|
|
||
| use SeQura\Core\BusinessLogic\CheckoutAPI\PaymentMethods\Requests\PaymentMethodsInCategoriesRequest; | ||
| use SeQura\Core\BusinessLogic\CheckoutAPI\PaymentMethods\Responses\PaymentMethodsInCategoriesResponse; | ||
| use SeQura\Core\BusinessLogic\Domain\Order\Exceptions\OrderNotFoundException; | ||
| use SeQura\Core\BusinessLogic\Domain\Order\Service\OrderService; | ||
| use SeQura\Core\Infrastructure\Http\Exceptions\HttpRequestException; | ||
|
|
||
| /** | ||
| * Class PaymentMethodsCheckoutController. | ||
| * | ||
| * Storefront endpoint returning the payment methods of an already solicited order. It depends on OrderService | ||
| * alone, so integrations that solicit orders without configuring the checkout library can use it. | ||
| * | ||
| * @package SeQura\Core\BusinessLogic\CheckoutAPI\PaymentMethods | ||
| */ | ||
| class PaymentMethodsCheckoutController | ||
| { | ||
| /** | ||
| * @var OrderService | ||
| */ | ||
| protected $orderService; | ||
|
|
||
| /** | ||
| * @param OrderService $orderService | ||
| */ | ||
| public function __construct(OrderService $orderService) | ||
| { | ||
| $this->orderService = $orderService; | ||
| } | ||
|
|
||
| /** | ||
| * Returns the payment methods available for a solicited order, grouped in the categories SeQura returns them in. | ||
| * | ||
| * @param PaymentMethodsInCategoriesRequest $request | ||
| * | ||
| * @return PaymentMethodsInCategoriesResponse | ||
| * | ||
| * @throws HttpRequestException | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incomplete
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incomplete
|
||
| * @throws OrderNotFoundException | ||
| */ | ||
| public function getPaymentMethodsInCategories( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The endpoint's primary failure mode degrades to a generic unhandled error.
The 404 that
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The endpoint's primary failure mode degrades to a generic unhandled error.
The 404 that |
||
| PaymentMethodsInCategoriesRequest $request | ||
| ): PaymentMethodsInCategoriesResponse { | ||
| return new PaymentMethodsInCategoriesResponse( | ||
| $this->orderService->getAvailablePaymentMethodsInCategories($request->getOrderRef()) | ||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| <?php | ||
|
|
||
| namespace SeQura\Core\BusinessLogic\CheckoutAPI\PaymentMethods\Requests; | ||
|
|
||
| /** | ||
| * Class PaymentMethodsInCategoriesRequest. | ||
| * | ||
| * @package SeQura\Core\BusinessLogic\CheckoutAPI\PaymentMethods\Requests | ||
| */ | ||
| class PaymentMethodsInCategoriesRequest | ||
| { | ||
| /** | ||
| * @var string | ||
| */ | ||
| protected $orderRef; | ||
|
|
||
| /** | ||
| * @param string $orderRef Reference of the solicited order. | ||
| */ | ||
| public function __construct(string $orderRef) | ||
| { | ||
| $this->orderRef = $orderRef; | ||
| } | ||
|
|
||
| /** | ||
| * @return string | ||
| */ | ||
| public function getOrderRef(): string | ||
| { | ||
| return $this->orderRef; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| <?php | ||
|
|
||
| namespace SeQura\Core\BusinessLogic\CheckoutAPI\PaymentMethods\Responses; | ||
|
|
||
| use SeQura\Core\BusinessLogic\AdminAPI\Response\Response; | ||
| use SeQura\Core\BusinessLogic\Domain\PaymentMethod\Models\SeQuraPaymentMethod; | ||
| use SeQura\Core\BusinessLogic\Domain\PaymentMethod\Models\SeQuraPaymentMethodCategory; | ||
|
|
||
| /** | ||
| * Class PaymentMethodsInCategoriesResponse. | ||
| * | ||
| * @package SeQura\Core\BusinessLogic\CheckoutAPI\PaymentMethods\Responses | ||
| */ | ||
| class PaymentMethodsInCategoriesResponse extends Response | ||
| { | ||
| /** | ||
| * @var SeQuraPaymentMethodCategory[] | ||
| */ | ||
| protected $paymentMethodCategories; | ||
|
|
||
| /** | ||
| * @param SeQuraPaymentMethodCategory[] $paymentMethodCategories | ||
| */ | ||
| public function __construct(array $paymentMethodCategories) | ||
| { | ||
| $this->paymentMethodCategories = $paymentMethodCategories; | ||
| } | ||
|
|
||
| /** | ||
| * @return SeQuraPaymentMethodCategory[] | ||
| */ | ||
| public function getPaymentMethodCategories(): array | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Grep across
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Grep across |
||
| { | ||
| return $this->paymentMethodCategories; | ||
| } | ||
|
|
||
| /** | ||
| * Determines whether at least one category offers a payment method. Categories with no method are returned | ||
| * as well, so the presence of categories does not mean the buyer has anything to choose from. | ||
| * | ||
| * @return bool | ||
| */ | ||
| public function hasAvailablePaymentMethods(): bool | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On a failed call the facade returns Any storefront doing
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On a failed call the facade returns Any storefront doing |
||
| { | ||
| foreach ($this->paymentMethodCategories as $category) { | ||
| if (!empty($category->getMethods())) { | ||
| return true; | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * @inheritDoc | ||
| */ | ||
| public function toArray(): array | ||
| { | ||
| $categories = []; | ||
| foreach ($this->paymentMethodCategories as $category) { | ||
| $categories[] = [ | ||
| 'title' => $category->getTitle(), | ||
| 'description' => $category->getDescription(), | ||
| 'icon' => $category->getIcon(), | ||
| 'methods' => array_map(static function (SeQuraPaymentMethod $paymentMethod) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The public checkout payload delegates to the ORM persistence serializer.
The sibling Map the fields explicitly here, matching
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The public checkout payload delegates to the ORM persistence serializer.
The sibling Map the fields explicitly here, matching |
||
| return $paymentMethod->toArray(); | ||
| }, $category->getMethods()), | ||
| ]; | ||
| } | ||
|
|
||
| return $categories; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -252,14 +252,16 @@ private function removeAllDeploymentData(string $deploymentId): void | |
|
|
||
| // Removes country configurations connected to the deployment | ||
| $countryConfigurations = $this->countryConfigurationRepository->getCountryConfiguration(); | ||
| $newCountyConfigurations = []; | ||
| foreach ($countryConfigurations as $countryConfiguration) { | ||
| if (!\in_array($countryConfiguration->getMerchantId(), $merchantIds, true)) { | ||
| $newCountyConfigurations[] = $countryConfiguration; | ||
| if ($countryConfigurations) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Untested, unrelated to LIS-116, and only half-solves the stated problem. The guard does fix the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Untested, unrelated to LIS-116, and only half-solves the stated problem. The guard does fix the
|
||
| $newCountyConfigurations = []; | ||
| foreach ($countryConfigurations as $countryConfiguration) { | ||
| if (!\in_array($countryConfiguration->getMerchantId(), $merchantIds, true)) { | ||
| $newCountyConfigurations[] = $countryConfiguration; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| $this->countryConfigurationRepository->setCountryConfiguration($newCountyConfigurations); | ||
| $this->countryConfigurationRepository->setCountryConfiguration($newCountyConfigurations); | ||
| } | ||
|
|
||
| // Removes all payment methods connected to the deployment | ||
| foreach ($merchantIds as $merchantId) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -163,19 +163,22 @@ public function getAvailablePaymentMethods(SeQuraOrder $order): array | |
| } | ||
|
|
||
| /** | ||
| * Gets available payment methods for solicited order in categories. | ||
| * Gets available payment methods for solicited order in categories. The merchant the order was solicited for | ||
| * is taken from the stored order, so callers only need its reference. | ||
| * | ||
| * @param string $orderRef | ||
| * @param string $merchantId | ||
| * | ||
| * @return SeQuraPaymentMethodCategory[] | ||
| * | ||
| * @throws HttpRequestException | ||
| * @throws OrderNotFoundException | ||
| */ | ||
| public function getAvailablePaymentMethodsInCategories(string $orderRef, string $merchantId): array | ||
| public function getAvailablePaymentMethodsInCategories(string $orderRef): array | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Silent BC break for host integrations. This is a consumed library, and dropping It also now calls
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Silent BC break for host integrations. This is a consumed library, and dropping It also now calls |
||
| { | ||
| $order = $this->getSeQuraOrder($orderRef); | ||
|
|
||
| return $this->proxy->getAvailablePaymentMethodsInCategories( | ||
| new GetAvailablePaymentMethodsRequest($orderRef, $merchantId) | ||
| new GetAvailablePaymentMethodsRequest($orderRef, (string)$order->getMerchant()->getId()) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Note
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Note |
||
| ); | ||
| } | ||
|
|
||
|
|
@@ -319,8 +322,7 @@ public function createOrder(Webhook $webhook): string | |
| $updatedSeQuraOrder->setPaymentMethod( | ||
| $this->getOrderPaymentMethodInfo( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant repository read in the webhook hot path.
That is one extra SELECT per approved-order webhook, plus a new
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant repository read in the webhook hot path.
That is one extra SELECT per approved-order webhook, plus a new |
||
| $updatedSeQuraOrder->getReference(), | ||
| $webhook->getProductCode(), | ||
| (string)$updatedSeQuraOrder->getMerchant()->getId() | ||
| $webhook->getProductCode() | ||
| ) | ||
| ); | ||
|
|
||
|
|
@@ -477,21 +479,17 @@ public function getSeQuraOrder(string $orderReference): SeQuraOrder | |
| * | ||
| * @param string $orderReference | ||
| * @param string $paymentMethodId | ||
| * @param string $merchantId | ||
| * | ||
| * @return PaymentMethod|null | ||
| * | ||
| * @throws HttpRequestException | ||
| * @throws OrderNotFoundException | ||
| */ | ||
| private function getOrderPaymentMethodInfo( | ||
| string $orderReference, | ||
| string $paymentMethodId, | ||
| string $merchantId | ||
| string $paymentMethodId | ||
| ): ?PaymentMethod { | ||
| $methodCategories = $this->getAvailablePaymentMethodsInCategories( | ||
| $orderReference, | ||
| $merchantId | ||
| ); | ||
| $methodCategories = $this->getAvailablePaymentMethodsInCategories($orderReference); | ||
|
|
||
| foreach ($methodCategories as $category) { | ||
| foreach ($category->getMethods() as $method) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new store-scoped endpoint provides no actual store isolation.
StoreContextAspect($storeId)only constrains store-scoped repositories, andSeQuraOrderRepositoryis not one: it has noStoreContextandgetByOrderReference()filters onreferencealone (src/BusinessLogic/DataAccess/Order/Repositories/SeQuraOrderRepository.php).So in a multistore install,
CheckoutAPI::get()->paymentMethods('storeA')->getPaymentMethodsInCategories(new PaymentMethodsInCategoriesRequest($refFromStoreB))resolves store B's order and builds the authorized proxy from store B's merchant id.This contradicts
.claude/docs/codingStandard.md§8 ("Repositories are store-scoped: inject StoreContext, filter every query by storeId") andCLAUDE.md("Anything reading/writing per-store config must respect the active store"). The gap is pre-existing, but this PR is what turns it into a storefront-facing,$storeId-parameterised endpoint.