Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def execute_purchase
- if credit_card_needed? or paypal_order?
- authorize_payment!
- end
- Product.connection.execute "savepoint quantity_update"
- product.decrement_quantity(self.quantity, self.product_style, self.product_size)
- rescue ActiveRecord::StatementInvalid => e
- Product.connection.execute "rollback to quantity_update"
- if e.message =~ /quantity_check/
- raise FulfillmentError, "not enough in stock"
- else
- raise
- end
- rescue StandardError => e
- errors.add_to_base e.message
- raise e
- end
Add Comment
Please, Sign In to add comment