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

[Split Checkout] Payments with non-3D cards need to be manually captured in the BO #8952

Closed
filipefurtad0 opened this issue Mar 2, 2022 · 9 comments · Fixed by #10089
Closed
Assignees
Labels
bug-s2 The bug is affecting any of the non-critical features described in S1 and there is no workaround.

Comments

@filipefurtad0
Copy link
Contributor

filipefurtad0 commented Mar 2, 2022

Description

Payments with non-3D cards need to be manually captured in the BO.
Despite manually capturing them they still appear as not-captured on the Stripe Dashboard.

Expected Behavior

  • Payments with non-3D cards should be automatically captured (provided the card is valid), both on the UI and on Stripe.
  • The button to manually capture credit card payments is displayed (when editing the order)

Actual Behaviour

  • Payments with non-3D cards are not automatically captured (provided the card is valid) in the UI, and remain uncaptured on Stripe
  • The button to manually capture credit card payments is displayed (when editing the order)

Steps to Reproduce

  1. Place an order with Stripe using a simple non-3D card, like the 4242424242...
  2. Notice the payment is not taken (seen on order confirmation and order edit)

Animated Gif/Screenshot

Peek 2022-03-02 16-18.gif

@filipefurtad0 filipefurtad0 changed the title [Stripe-SCA] Payments with non-3D cards need to be manually captured in the BO [Split Checkout] Payments with non-3D cards need to be manually captured in the BO Mar 2, 2022
@jibees jibees self-assigned this Mar 14, 2022
@jibees
Copy link
Contributor

jibees commented Mar 14, 2022

I'm not sure to manage to handle this one.
I guess @Matt-Yorkley could be the man for sure.

@BethanOFN
Copy link

I've currently taken UK testers off split checkout due to this issue - any rough timescale for a resolution?

@RachL RachL added the bug-s2 The bug is affecting any of the non-critical features described in S1 and there is no workaround. label May 6, 2022
@RachL
Copy link
Contributor

RachL commented May 6, 2022

@mkllnk do you have some room to look at it? George has already a pile of bug on his plate 😅

thanks @BethanOFN for the feedback! I will let you know as soon as it is fixed.

@filipefurtad0 filipefurtad0 mentioned this issue Jun 12, 2022
13 tasks
@RachL RachL added the priority We focus on this issue right now label Sep 6, 2022
@RachL RachL removed the priority We focus on this issue right now label Sep 27, 2022
@RachL RachL added the priority We focus on this issue right now label Oct 19, 2022
@RachL RachL removed the priority We focus on this issue right now label Oct 31, 2022
@drummer83 drummer83 mentioned this issue Nov 8, 2022
12 tasks
@filipefurtad0
Copy link
Contributor Author

Updated the description:

Despite manually capturing them they still appear as not-captured on the Stripe Dashboard.

I've checked this in the context of #10014 and in master: Manually capturing the payment on the backoffice marked the payment as captured on the Stripe Dashboard 👍

@abdellani abdellani self-assigned this Dec 1, 2022
@abdellani
Copy link
Member

Hi @filipefurtad0

I was unable to reproduce the issue locally.
Can you please check if I missed anything?
I integrated Stripe, and connected the producer.

This is how I create the payment method
image

I order a product and selected Stripe ASC as a payment method

image

Order confirmed
image

image

@drummer83
Copy link
Contributor

@abdellani On legacy checkout (your screenshot) this is working. You need to enable split checkout to reproduce the issue.

@abdellani
Copy link
Member

@drummer83
Can you please tell me where can I enable it?
I can't find it on /admin/general_settings/edit or /admin/payment_methods

@drummer83
Copy link
Contributor

drummer83 commented Dec 1, 2022

https://github.com/openfoodfoundation/openfoodnetwork/wiki/Feature-toggles

You need to log in as super admin and open /admin/feature-toggle.

EDIT: Updated the mentioned page.

@abdellani

@abdellani
Copy link
Member

After comparing the legacy checkout with the split checkout. I noticed that the payment_intent was created but processed in the split checkout.

image

In the legacy checkout controller, the submit request trigger a loop that keeps the order moving from one state to another unit it reaches the final state complete.
If I'm not wrong, The sequence of states is:
cart -> payment -> confirmation -> complete

Note: there are other order states, but it looks like they are not used in this context. For example: canceled or returned.
When the order reaches the state payment, we run the method to process the payment

  def checkout_workflow(shipping_method_id)
    while @order.state != "complete"
      if @order.state == "payment"
        update_payment_total
        return if redirect_to_payment_gateway

        return action_failed if @order.errors.any?
        return action_failed unless @order.process_payments!  # <<<<<<<<
      end

      next if OrderWorkflow.new(@order).next({ "shipping_method_id" => shipping_method_id })

      return action_failed
    end

    update_response
  end

In the split checkout, we don't need to use the same loop as every state is represented by a different view. The user controls the order transition from one state to another.

In the new context, we can't process the payment when the order is in the payment state. We need to wait for the user to confirm the order. In the PR, I suggest updating the confirm_order in the controller.

  def confirm_order
    return unless summary_step? && @order.confirmation?
    return unless validate_summary! && @order.errors.empty?

    @order.customer.touch :terms_and_conditions_accepted_at

    return true if redirect_to_payment_gateway

    @order.process_payments!
    @order.confirm!
    order_completion_reset @order
  end

I thought about adding process_payments before transitioning to complete in the state machine, but I was not sure if this will not create other issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-s2 The bug is affecting any of the non-critical features described in S1 and there is no workaround.
Projects
None yet
7 participants