[Payment request] Order pay via the UI#16790
Merged
GSadee merged 59 commits intoSylius:payment-requestfrom Sep 23, 2024
Merged
Conversation
Bunnyshell Preview Environment deletedAvailable commands:
|
diimpp
reviewed
Aug 28, 2024
src/Sylius/Bundle/ShopBundle/Provider/PaymentRequestPayResponseProvider.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/Provider/PaymentRequestPayResponseProvider.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/Provider/PayumPayResponseProvider.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/Provider/PayumPayResponseProvider.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/Provider/PaymentRequestPayResponseProvider.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/Provider/PayumPayResponseProvider.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/Provider/PayumPayResponseProvider.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/Provider/PayumPayResponseProvider.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/Resources/config/services/providers.xml
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/PaymentRequest/CommandProvider/ActionsCommandProvider.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/PaymentRequest/Provider/HttpResponseProviderInterface.php
Show resolved
Hide resolved
src/Sylius/Bundle/CoreBundle/PaymentRequest/Provider/ActionsHttpResponseProvider.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/Provider/PaymentRequestAfterPayResponseProvider.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/Provider/PayumPayResponseProvider.php
Outdated
Show resolved
Hide resolved
src/Sylius/Bundle/ShopBundle/Provider/NoPaymentPayResponseProvider.php
Outdated
Show resolved
Hide resolved
085d460 to
c799166
Compare
b5e1057 to
50c5c2e
Compare
… ShopBundle controller action # Conflicts: # UPGRADE-2.0.md # Conflicts: # src/Sylius/Bundle/PayumBundle/Controller/PayumController.php # src/Sylius/Bundle/PayumBundle/Resources/config/services/controller.xml
Co-authored-by: Jan Góralski <jan.wojciech.goralski@gmail.com>
Co-authored-by: Dmitri Perunov <diimpp@gmail.com>
Co-authored-by: Dmitri Perunov <diimpp@gmail.com>
Co-authored-by: Dmitri Perunov <diimpp@gmail.com>
Co-authored-by: Jan Góralski <jan.wojciech.goralski@gmail.com>
11fdcd8 to
ac94a19
Compare
Wojdylak
approved these changes
Sep 23, 2024
| $paymentRequest = $this->paymentRequestFactory->create($payment, $paymentMethod); | ||
| $paymentRequest->setAction($addPaymentRequest->action); | ||
| $paymentRequest->setPayload($addPaymentRequest->payload); | ||
| $paymentRequest->setAction($addPaymentRequest->action ?? $this->defaultActionProvider->getAction($paymentRequest)); |
Member
There was a problem hiding this comment.
Maybe we should create a SerializerContextBuilder to set the default value in the AddPaymentRequest command.
Contributor
Author
There was a problem hiding this comment.
I'm ok with this idea for the API part, but what about the UI :
?
src/Sylius/Bundle/CoreBundle/Resources/config/services/order_pay.xml
Outdated
Show resolved
Hide resolved
Co-authored-by: Karol <33687392+Wojdylak@users.noreply.github.com>
GSadee
approved these changes
Sep 23, 2024
| $this->client->executeCustomRequest($request); | ||
| } | ||
|
|
||
| public function putPaymentRequest(string $paymentRequestUri, array $payload = []): void |
Member
There was a problem hiding this comment.
Suggested change
| public function putPaymentRequest(string $paymentRequestUri, array $payload = []): void | |
| private function putPaymentRequest(string $paymentRequestUri, array $payload = []): void |
Comment on lines
+79
to
+81
| $request->setContent([ | ||
| 'payload' => $payload, | ||
| ]); |
Member
There was a problem hiding this comment.
Suggested change
| $request->setContent([ | |
| 'payload' => $payload, | |
| ]); | |
| $request->setContent(['payload' => $payload]); |
Member
There was a problem hiding this comment.
I would be for splitting this controller into two files, per action
Comment on lines
+34
to
+36
| $url = $this->orderPayFinalUrlProvider->getUrl(null); | ||
|
|
||
| return new RedirectResponse($url); |
Member
There was a problem hiding this comment.
Suggested change
| $url = $this->orderPayFinalUrlProvider->getUrl(null); | |
| return new RedirectResponse($url); | |
| return new RedirectResponse($$this->orderPayFinalUrlProvider->getUrl(null)); |
Comment on lines
+43
to
+44
| $payment = $this->paymentToPayResolver->getLastPayment($order); | ||
| return null === $payment; |
Member
There was a problem hiding this comment.
Suggested change
| $payment = $this->paymentToPayResolver->getLastPayment($order); | |
| return null === $payment; | |
| $payment = $this->paymentToPayResolver->getLastPayment($order); | |
| return null === $payment; |
| RequestConfiguration $requestConfiguration, | ||
| OrderInterface $order | ||
| ): bool { | ||
|
|
|
|
||
| $gatewayName = $gatewayConfig->getGatewayName() ?? ''; | ||
|
|
||
| return isset($this->payum->getGateways()[$gatewayName]); |
Member
There was a problem hiding this comment.
Suggested change
| return isset($this->payum->getGateways()[$gatewayName]); | |
| return isset($this->payum->getGateways()[$gatewayName]); |
| ) { | ||
| } | ||
|
|
||
| protected function getHttpResponseProviderIndex(PaymentRequestInterface $paymentRequest): string { |
Member
There was a problem hiding this comment.
Suggested change
| protected function getHttpResponseProviderIndex(PaymentRequestInterface $paymentRequest): string { | |
| protected function getHttpResponseProviderIndex(PaymentRequestInterface $paymentRequest): string | |
| { |
| <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> | ||
| <services> | ||
|
|
||
| <service abstract="true" id="Sylius\Bundle\CoreBundle\OrderPay\Provider\AfterPayUrlProvider" class="Sylius\Bundle\CoreBundle\OrderPay\Provider\AfterPayUrlProvider"> |
Member
There was a problem hiding this comment.
I would be for not using an FQCN as services' ids
Suggested change
| <service abstract="true" id="Sylius\Bundle\CoreBundle\OrderPay\Provider\AfterPayUrlProvider" class="Sylius\Bundle\CoreBundle\OrderPay\Provider\AfterPayUrlProvider"> | |
| <service abstract="true" id="sylius.order_pay.provider.after_pay_url" class="Sylius\Bundle\CoreBundle\OrderPay\Provider\AfterPayUrlProvider"> |
6 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR will allow
PaymentRequestto be used through the UI (not the API), the goal is to allow developper to create HTTP response they need to handle any Payment Method. SyliusPayumBundle controller actions will be preserved to avoid any changes for existing Payum gateways.Basic payment flow
--- title: Customer paying an order --- flowchart TD A[sylius_shop_checkout_complete] B[sylius_shop_order_pay] subgraph Payment Provider C[External portal or custom page] end D[sylius_shop_order_after_pay] E[sylius_shop_order_thank_you] F[sylius_shop_order_show] A --> B B --> C C --> D D -- OK --> E D -- KO --> F F -- Choose another payment method or retry --> BWhat is the current (Sylius 1.*) URLs flow
--- title: Sylius 1.* - Customer paying an order --- flowchart TD A[sylius_shop_checkout_complete] --> B[sylius_shop_order_pay] subgraph Payum C[payum_capture_do] D{External URL or custom page} end E[sylius_shop_order_after_pay] subgraph Payum after capture F[Payum Status & ResolveNextRoute ] end G[sylius_shop_order_thank_you] H[sylius_shop_order_show] B -- No payment --> G B --> C C <--> D D --> E C --> E E --> F F -- KO --> H F -- OK --> G H -- Choose another payment method or retry --> BWhat this PR is aiming to do
--- title: Sylius 2.* - Customer paying an order --- flowchart TD A[sylius_shop_checkout_complete] B[sylius_shop_order_pay] subgraph No payment C[No payment processing] end subgraph Payum D[Keep existing Payum beforeCapture processing] end subgraph Payment Request E[Payment Request processing] F[Http Response processing] end G[sylius_shop_order_after_pay] subgraph Payum after pay H[Keep existing afterCapture processing] end subgraph Payment request after pay I[Payment request processing] J[Http response processing] end A --> B B --> C & D & E G --> H & I C --> K D --> G E --> F F --> G I --> J H -- OK --> K H -- KO --> L J -- OK --> K J -- KO --> L L -- Choose another payment method or retry --> B K[sylius_shop_order_thank_you] L[sylius_shop_order_show]Order pay phase
sylius.controller.payum::prepareCaptureActiondispatch action content into several services.sylius.controller.shop.order_pay::payActionto replace the previous SyliusPayumBundle controller action.PaymentRequestorderPay HTTP Response.After pay phase
sylius.controller.payum::afterCaptureActiondispatch action content into several services.sylius.controller.shop.order_pay::afterPayActionto replace the previous SyliusPayumBundle controller action.PaymentRequestafterPay HTTP Response.Global