I require some functionality similar to how a daily voucher site might work. Say I have 10 of the same item available, users can select to buy 1 of the items and the payment is authorised.

After a set period lets say 24 hours. if all 10 items are bought I then want to capture the payments, if less than all 10 are bought the payments are not captured.

Is there any way this could be achieved?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rszrama’s picture

Status: Active » Fixed

There's nothing within the PayPal module that's going to directly assist you. It's possible using the Stock module to limit the amount of inventory for a product. It's also possible using Rules or a direct hook to take some action when the stock level reaches 0 (i.e. the last order completes or the product is saved with a stock of 0). There is no ready-made action for capturing an authorization on an order, though, so you'd need to code that yourself.

What the module will do for you is allow you to let users checkout with authorization only transactions and then use the API in the module to submit the capture requests after the fact. I'd also make sure your module voided authorizations at the end of the day if enough deals weren't bought to complete the sale for everyone.

timdiacon’s picture

Ryan,

Thanks for the reply. The approach you describe using stock, rules and authorising payment is exactly where I'm at right now. As you point out the bit where the module doesn't currently help me is capturing the payment once the stock level reaches 0.

In an ideal world there would be rules actions to both capture all authorised payments of a product and also void all authorised payments of a product.

It seems your saying that is technically possible using the API so I'll have a crack at seeing if I can create those.

Tim

timdiacon’s picture

Category: support » feature

Having had a dig around the module code this is above my ability. Recategorising as a feature request.

I would happily sponsor this module to get the feature included or pay a bounty to any other developers who were able to patch it.

rszrama’s picture

It would probably be better to follow this issue in the main Commerce queue: #1820356: Rule to capture from a previous authorization empty

timdiacon’s picture

Ryan,

Thanks for pointing me there. Having dug around I now have this working using the patches for WPP and Payment by tmsimont.

These patches seem pretty common sense to me it would be great to get these rolled into the Commerce and Commerce_PayPal modules respectively?

Tim

rszrama’s picture

When the code is fully reviewed / good to go we'll get 'em in. : )

timdiacon’s picture

That's awesome Ryan thanks for your help on this.

One last thing. When it comes to voiding an authorised payment which you no longer want to capture is simply deleting the order sufficient or should you ideally make some kind of call on the api?

rszrama’s picture

It's not sufficient, actually - there is no sort of automated void, though it'd be a simple leap from authorization to that.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

timdiacon’s picture

Version: 7.x-1.0 » 7.x-2.2
Status: Closed (fixed) » Active

Re-opening this thread as having updated to latest version of Commerce PayPal noticed the authorise via Rule is still not catered for. Also previous patches no longer work with latest versions of modules.

Any ideas if this could get implemented soon, it's mission critical for me - happy to sponsor.

rszrama’s picture

It's still more or less just being tracked through that other issue. I'll talk to a couple folks and see if they're interested in doing the work freelance. Cool if they just comment in here to follow-up?

timdiacon’s picture

sorry I might not have re-activated the most appropriate thread here. The code to implement the functionality had all been written and worked through tmsimont's patches. They were just never merged and unfortunately can't be applied to the latest versions of the modules.

Anyone able to help update the patches please feel free to post in here :-)

rszrama’s picture

He had a patch somewhere specifically for WPP? Is that in another issue in this queue or something we can post in here perhaps?

timdiacon’s picture

This was the original WPP patch. The description is...

Moved admin capture submit callback into a re-useable function called commerce_paypal_wpp_capture so other code, e.g. a payment rule callback, can capture a previously-authorized payment