kilbot / WooCommerce-POS

:bangbang: All development now at https://github.com/wcpos.
http://wcpos.com
GNU General Public License v3.0
353 stars 125 forks source link

Failed payment gateway causes a new order on retry #51

Closed codewise-nicolas closed 9 years ago

codewise-nicolas commented 9 years ago

I believe the failure of a payment is currently not being handled. Every time create_order() is called a NEW order is created.

The code should try and resume the existing order, if one exists.

Temp solution, in your payment gateway if a failure occurs delete the post: wp_delete_post( $order_id );

ghost commented 9 years ago

Is this a POS "feature"? I see the same with iDEAL payments in a non-POS site which sometimes fail when the order is placed. When a retry of the transaction takes place, I see a new order number. I haven't figured out if the order is copied to the new number or that a new order is created and filled with the same data.

Egbert Jan NL

codewise-nicolas schreef op 9-3-2015 om 23:00:

I believe the failure of a payment is currently not being handled. Every time create_order() is called a NEW order is created.

The code should try and resume the existing order, if one exists.

Temp solution, in your payment gateway if a failure occurs delete the post: wp_delete_post( $order_id );

— Reply to this email directly or view it on GitHub https://github.com/kilbot/WooCommerce-POS/issues/51.

codewise-nicolas commented 9 years ago

It would be a feature to start a new order on every checkout, IF the "new checkout" wasnt a re-try of a failed one that just happened.

I did find the problem code in file woocommerce-pos/public/includes/class-pos-checkout.php line 41 to 89 create_order() function. You will notice that there is a commented out section near the end to rollback on a payment failure, but thats a database rollback if transactions where enabled. Line 59 inserts a new post every time.

For comparison, woocommerce/includes/class-wc-checkout.php line 193+ function create_order() it hanldes resuming an order_id

kilbot commented 9 years ago

WooCommerce POS allows editing orders via the REST API in version 0.4-beta.

kilbot commented 9 years ago

I'm closing this issue as it should be fixed in 0.4. Leave a comment if you experience any problems and I'll reopen.