Vote up!
Vote down!

Is there a way to prevent payment transaction from being saved ? (ex. out of stock)

Say for example the user is on his way to checkout :
- the user chooses a payment method, one that redirects to an external gateway ;
- the user stays on that external page for some time ;
- A business rule makes the order's content expire meanwhile ;
- therefore the payment, even if authorized must not be accepted.

Is there a way to reject the payment transaction ? a hook or a rule's action maybe ?

Asked by: redben
on June 21, 2013

1 Answer

Vote up!
Vote down!

Unfortunately, there isn't a good way to support this, because we can't control what the user does once they've already redirected. The best thing to do would be to place a hold on the stock set to expire after a certain amount of time - perhaps even a couple hours unless you're moving product very fast. But still, if the customer completes payment remotely, it's gonna get reported, and you'll just have to deal with it.

I'd establish a process along the lines of detect if the stock dropped below 0, and if so send a back order e-mail or else automate some way to void the transaction and notify the customer that their product has dropped out of stock. In fact, perhaps what you should do is simply authorize the transaction and wait until you confirm their payment to capture it so you don't have to issue a refund, just void an authorization.

Ryan Szrama
Answer by: Ryan Szrama
Posted: Jun 21, 2013


Ok I get it thanks ! Any chance to see a hook_commerce_payment_authorize_transaction($order, $transaction) in future versions ?

- redben on July 19, 2013