Skip to content
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

Handle Orders with Pending Payments #2478

Closed
solverat opened this issue Dec 12, 2023 · 3 comments
Closed

Handle Orders with Pending Payments #2478

solverat opened this issue Dec 12, 2023 · 3 comments

Comments

@solverat
Copy link
Contributor

Q A
Bug report? yes
Feature request? yes
BC Break report? no
RFC? no

If you're using an payment provider like stripe which allows klarna / sofort, the payment confirmation is a delayed process. In that case, the user will return to coreshop with a payment state of "processing" (PaymentInterface::STATE_PROCESSING). For coreshop, this state is not a "success" state:

if ($payment->getState() === PaymentInterface::STATE_COMPLETED ||
$payment->getState() === PaymentInterface::STATE_AUTHORIZED
) {
$request->setRouteName('coreshop_checkout_thank_you');
$request->setRouteParameters([
'_locale' => $order->getLocaleCode(),
'token' => $order->getToken(),
]);
return;
}
$request->setRouteName('coreshop_order_revise');

Which means, that a user retrieves the revise page which tells him, that the payment failed, and he needs to choose another payment.

What to do?

I. Improve Revise Page

In Sylius for example, they also render a similar thing to CoreShop's revise process:

src/Sylius/Bundle/ShopBundle/Resources/views/Order/show.html.twig

... but in a smarter way: If the payment state is in awaiting_payment state, they're showing a "Pay" button above the order. In my example, the payment would be "processed" so no payment button but a valid ("on-hold") summary page - so no confusion for the customer who's just successfully paid for the order.

image

II. Order Confirmation

The order should get confirmed, if a payment is in PaymentInterface::STATE_PROCESSING state.

Two checks to extend:

if ($payment->getState() === PaymentInterface::STATE_COMPLETED ||
$payment->getState() === PaymentInterface::STATE_AUTHORIZED
) {
$this->stateMachineApplier->apply($order, OrderTransitions::IDENTIFIER, OrderTransitions::TRANSITION_CONFIRM);

if ($value === PaymentInterface::STATE_COMPLETED ||
$value === PaymentInterface::STATE_AUTHORIZED
) {
$order = $payment->getOrder();
$this->confirmOrderState($order);

=> In my tests, the UpdateOrderStateExtension never triggered (see next section " Adjust Payment Bundles").

III. Resolve awaiting payment state in resolver

Same as here: Sylius/Sylius#11535

IV. Adjust Payment Bundles

Nothing to do in coreshop core, but I had to add an additional UpdatePaymentStateExtension extension (see section "Payment State not updating") otherwise the payment state won't get updated: coreshop/PayumStripeBundle#10

@dpfaffenbauer
Copy link
Member

I. Improve Revise Page

Sylius always shows a "order" detail page, where as we show either the confirmation page or a revise page. We cannot change how that is done now without a BC break or a feature flag. If we make processing a valid state and confirm the order, this part is not really necessary anway.

II. Order Confirmation

What are the possible side effects of this? We never had any issue before with that.

III. Resolve awaiting payment state in resolver

That is clearly the consequence and a must have when II is implemented.

IV. Adjust Payment Bundles

Looks rather like a issue in the Stripe Bundle?

@solverat
Copy link
Contributor Author

  1. Yes, I also thought about that. I don't see any issues, if we allow processing to enter the thank-you page (If the order gets canceled later on, notification rules take over to inform user or something like that
  2. I don't see any side effects. It's "just" a workflow dispatcher from "new" to "confirmed". Since we also show the thank-you page, a possible order-confirmation mail (which gets dispatched via "confirm") is valid
  3. ok
  4. yes, just like I said. :) I've had to implement a custom UpdatePaymentStateExtension.php, not sure why since CoreShop already comes with a UpdateOrderStateExtension - but it works.

PR?

@dpfaffenbauer
Copy link
Member

PR?

Yes, I don't see any side effect either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants