- Issue created by @smokris
- Issue was unassigned.
- Status changed to Needs review
about 1 year ago 1:33am 8 October 2023 - last update
about 1 year ago 38 pass - Status changed to Needs work
about 1 year ago 4:46pm 10 October 2023 - πΊπΈUnited States rszrama
Ahh, I see - the field is indeed optional. However, let's use this ticket to solve this for both the Card Element and the Payment Element. Note that in either case, we also need to ensure the payment method entity created in Drupal Commerce is set to non-reusable when this "none" option is selected.
Additionally, as a slight clarification to the option, given the name of the field, let's make this the third option, not the first, with a key of
single_use
and label of, "Single use: the payment method will not be made available for subsequent transactions".Good find! I was actually wondering about that message myself when testing other issues just now. π
- πΊπ¦Ukraine marchuk.vitaliy Rivne, UA
vmarchuk β made their first commit to this issueβs fork.
- Merge request !56Issue #3392413: Add the option to not setup payment methods for future usage β (Merged) created by Unnamed author
- last update
about 1 year ago 20 pass, 2 fail - πΊπ¦Ukraine marchuk.vitaliy Rivne, UA
I've opened MR with the initial work for both payment gateways. But it still requires some additional work and testing. We need to figure out if we need to create a remote payment method if None (or Single use) is selected and attach it to the remote client or not.
- πΊπ¦Ukraine marchuk.vitaliy Rivne, UA
After some research, I see the following.
For the Stripe Card Element, this works perfectly - the PaymentIntent succeeded and the payment method was attached to the customer with no "Set up for future use" options.
For the Stripe Payment Element, it still doesn't work - the PaymentIntent succeeded but I get an error "This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again.". This means that we want to attach the payment method to the customer after the paymentIntent has used it, so this should happen before that. In our case, it is impossible because it does not exist.So basically when we use the setup_future_usage parameter, the paymentIntent automatically attaches the payment method to the customer, but in case it is empty or missing, we need to attach it to the customer manually. In the case of the Stripe Payment Element, the payment method will be created after the paymentIntent is confirmed, but at this point, we cannot attach it to the customer because it has already been used by the paymentIntent.
I'm open to discussion if anyone is also interested in this issue.
- last update
about 1 year ago 20 pass, 2 fail - last update
about 1 year ago 20 pass, 2 fail 40:53 38:46 Running- last update
about 1 year ago 38 pass - Status changed to Needs review
about 1 year ago 7:37am 17 November 2023 - πΊπ¦Ukraine marchuk.vitaliy Rivne, UA
From my comment β¨ Add the option to not setup payment methods for future usage Fixed we cannot attach a payment method to the customer after the paymentIntent is confirmed but we can skip attaching a payment method to the customer. But in this case, the Stripe dashboard on the customer page won't show the payment method (is that a big deal?). Otherwise, for the Stripe Card Element, the payment method will be there.
This seems to be the only way we can use the Stripe Payment element. - Status changed to RTBC
11 months ago 1:56pm 7 January 2024 - π¨π³China skyredwang Shanghai
https://www.drupal.org/project/commerce_stripe/issues/3392413#mr56-note2... β¨ Add the option to not setup payment methods for future usage Fixed works, I can see the new option "Single use: the payment method will not be made available for subsequent transactions" under Stripe Payment Element payment gateway. When choosing it, I can see single-use payment methods showing up, although they don't actually work, that's new issues.
Can we get this in first, so follow up issues can fix additional problems.
- Status changed to Needs review
11 months ago 3:28pm 7 January 2024 - π¨π³China skyredwang Shanghai
I brought the latest changes from 8.1-1.x to this MR.
However, I temporarily removed the changes to
Stripe.php
In #3, @rszrama wanted to add this third option for Card Element. But, Card Element uses Stripe Card Element (Stripe.php) gateway, which doesn't have on-session and off-session configurations.
@vmarchuk made this 3rd option available to Card Element by using the configuration from Stripe Review Pane. Programming wise, add a condition or dependency on routing makes
Stripe.php
less robust, as routing isn't always safe assumption. Personally, I think if we want the Card Element to have this configuration, then we want to add this configuration to its gateway. The configuration for Stripe Review Pane serves as an option to override in the checkout process.What do you think?
- Status changed to Needs work
11 months ago 10:13am 8 January 2024 - π¨π³China skyredwang Shanghai
Here is one more thing we have to deal with: when a payment succeeded, we have the logic to create a customer and attach the payment method in both
Stripe.php
andStripePaymentElement.php
.However, when we set
setup_future_usage: null
to make/allow single-use payment method. We cannot create the customer and attach the single-use payment method. Otherwise, Stripe API will return:400 invalid_request_error This PaymentMethod was previously used without being attached to a Customer or was detached from a Customer, and may not be used again.
This is documented here https://stripe.com/docs/payments/payment-methods#usage
Single-use payment methods (for example, some kinds of bank transfers) canβt be attached to customers because theyβre consumed after a payment attempt.
So, depending on the gateway, we will conditionally attach the payment method that just completed.
- Status changed to Needs review
11 months ago 11:26am 8 January 2024 - π¨π³China skyredwang Shanghai
In https://www.drupal.org/project/commerce_stripe/issues/3392413#mr56-note2... β¨ Add the option to not setup payment methods for future usage Fixed , I added a condition.
- π¦πΉAustria agoradesign
Coming from #3403745-4: Why is stripe-php still stuck on version 7 and Stripe API on 2019-12-03? What does it imply? β , I've tried this patch (latest MR) and it solved our problem :-)
- π«π·France nicolas bouteille
Hi there,
I'd like to add some info to the mix that needs to be taken into account about setup_future_usage:
π Do not set setup_future_usage off_session again for already stored payment methods to avoid multiple mandates creation Active - πΊπΈUnited States loze Los Angeles
The MR needs to be rebased, its no longer applying for me.
- πΊπ¦Ukraine marchuk.vitaliy Rivne, UA
Rebased patch with the latest changes from 8.x-1.x.
+ tested changes locally and everything works as expected.
@skyredwang
I just don't know why we need a new test in tests/src/FunctionalJavascript/CheckoutTest.php since all the tests were written for the Stripe Card Element, but as part of this issue, we are only making changes for the Stripe Payment Element. - First commit to issue fork.
-
TomTech β
committed 85463717 on 8.x-1.x authored by
vmarchuk β
Issue #3392413 by vmarchuk, skyredwang, smokris, rszrama, loze, Nicolas...
-
TomTech β
committed 85463717 on 8.x-1.x authored by
vmarchuk β
- Status changed to Fixed
5 months ago 8:07am 8 July 2024 - Assigned to TomTech
Automatically closed - issue fixed for 2 weeks with no activity.