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

programmatically capturing/voiding authorized payments (506) #590

Closed
Sirvijver opened this issue Apr 13, 2022 · 4 comments · Fixed by #1262
Closed

programmatically capturing/voiding authorized payments (506) #590

Sirvijver opened this issue Apr 13, 2022 · 4 comments · Fixed by #1262
Labels
enhancement New feature or request parity
Milestone

Comments

@Sirvijver
Copy link
Collaborator

Multiple users and third-party developers are asking us how they can capture authorized orders.
Right now, it’s only possible through order actions, which is not ideal.

(linked to thread: #234 (comment))

@Sirvijver Sirvijver added enhancement New feature or request parity labels Apr 13, 2022
@JStockton-Kishmish
Copy link

I believe this is the issue that is currently blocking one of my clients from adopting this plugin - just want to confirm that I'm right and I don't have to submit a new issue.

We have some customizations that require being able to void authorizations based on a status change (through the woocommerce_order_status_<status_transition_to> action) as well as when an order is covered 100% by a gift card.

If I'm understanding this issue correctly - you'd provide some way of doing this (e.g. $paypal_payments->void_authorization($order_id);); if so then that would resolve our problem.

Let me know if I'm misunderstanding and I'll submit a new issue, otherwise thank you in advanced for your support!

P.S. I did see that the work around is to register a new module and have it do whatever we need it to so we may go that route, but obviously an official solution is preferable.

@InpsydeNiklas
Copy link
Member

Correct, the long-term goal is to provide an easy-to-use method for programmatically capturing/voiding/refunding payments since these actions currently only can be performed through the WooCommerce or PayPal GUI. As mentioned above, the filter to create a custom module essentially allows you to modify the entire plugin behavior already. But depending on what you want to achieve, we understand that a "classic solution" would be desired for routine tasks such as handling payments. So a regular hook/filter will eventually cover these tasks.

One way is to do the same thing as the action is by retrieving 'wcgateway.processor.authorized-payments' from the container.

@JStockton-Kishmish
Copy link

Perfect, thanks for the confirmation and the feedback!

My use case is more surrounding voiding the authorization rather than capturing it so, depending on what my client decides / how urgent the switch is, it looks like for voids the service I will be hooking up to is: api.endpoint.payments and using it similar to the RefundProcessor::process() method. Does that sound like the right move or is there a better service to use for that purpose?

The only thing that stops me from just triggering it with wc_refund_payment() (which seems to go through that method) is that I don't want it to set the order status to refunded.

@JStockton-Kishmish
Copy link

My client had me move forward with this; as I started going through and getting my work arounds in-place, I found a simpler solution that would allow any voids to be done using wc_refund_payment() without any unwanted side-effects.

As I mentioned above, the only issue I had was that the order status was being set to "refunded". If it could be filtered, then it provides everything I need.

I've submitted PR #681 with the above change made. I'm going to hotfix this on my client site, but if you could review it for the mainline, I'd greatly appreciate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request parity
Projects
None yet
4 participants