{"record":{"id":"74f56180218fc251","repo":"antiwork/gumroad","slug":"the-product-was-just-released-refresh-the-page-to","errorCode":null,"errorMessage":"The product was just released. Refresh the page to purchase it.","messagePattern":"The product was just released\\. Refresh the page to purchase it\\.","errorType":"exception","errorClass":"Purchase::PurchaseInvalid","httpStatus":null,"severity":"error","filePath":"app/services/purchase/create_service.rb","lineNumber":520,"sourceCode":"        is_gift_receiver_purchase: true\n      )\n      giftee_purchase = build_purchase(giftee_purchase_params)\n      giftee_purchase.purchaser = giftee_purchaser\n      giftee_purchase.gift_received = gift\n      giftee_purchase.process!\n      raise Purchase::PurchaseInvalid, giftee_purchase.errors.full_messages[0] if giftee_purchase.errors.present?\n    end\n\n    def giftee_purchaser\n      @_giftee_purchaser ||= gift_params[:giftee_id].present? ? User.alive.find_by_external_id(gift_params[:giftee_id]) : User.alive.by_email(gift_params[:giftee_email]).last\n    end\n\n    def giftee_email\n      giftee_purchaser&.email || gift_params[:giftee_email]\n    end\n\n    def build_preorder(locked_rate: nil)\n      raise Purchase::PurchaseInvalid, \"The product was just released. Refresh the page to purchase it.\" unless product.is_in_preorder_state?\n\n      self.preorder = product.preorder_link.build_preorder(purchase)\n      if purchase.is_part_of_combined_charge?\n        purchase.prepare_for_charge!(locked_rate:)\n      else\n        preorder.authorize!(locked_rate:)\n        error_message = preorder.errors.full_messages[0]\n        if purchase.is_test_purchase?\n          preorder.mark_test_authorization_successful!\n        elsif error_message.present?\n          raise Purchase::PurchaseInvalid, error_message\n        elsif purchase.requires_sca?\n          # Leave the preorder in `in_progress` state until the the required UI action is completed.\n          # Check back later to see if it has been completed. If not, transition to a failed state.\n          FailAbandonedPurchaseWorker.perform_in(ChargeProcessor::TIME_TO_COMPLETE_SCA, purchase.id)\n        else\n          preorder.mark_authorization_successful!\n        end","sourceCodeStart":502,"sourceCodeEnd":538,"githubUrl":"https://github.com/antiwork/gumroad/blob/afeacbd394069a1cbf0c6c50ee8e900925050370/app/services/purchase/create_service.rb#L502-L538","documentation":"build_preorder runs when the purchase is flagged is_preorder_authorization, but it first asserts product.is_in_preorder_state?. If the product was just released, the assertion fails and the buyer is told to refresh - the pre-order authorization path no longer applies and a normal purchase must be made instead.","triggerScenarios":"Checkout was loaded while the product was a pre-order (is_preorder_authorization true in the submitted params), but by submit time product.is_in_preorder_state? is false - the classic race between release and submit. A separate guard (line 75) covers the inverse tampered case.","commonSituations":"Stale tabs from before a product release; integrations caching preorder state; seller releasing the product while buyers are mid-checkout.","solutions":["Refresh the page and complete a normal purchase - the release flow takes over.","Integrators: re-check product.is_in_preorder_state? immediately before submit and switch to the normal purchase flow on mismatch.","Handle this raise by restarting checkout, never by resubmitting identical preorder params."],"exampleFix":"# before: preorder params submitted after release\nparams[:purchase][:is_preorder_authorization] = true # product no longer in preorder state\n\n# after: reconcile the flag with live product state\nparams[:purchase][:is_preorder_authorization] = product.is_in_preorder_state?","handlingStrategy":"validation","validationCode":"params[:purchase][:is_preorder_authorization] = product.is_in_preorder_state? if params[:purchase][:is_preorder_authorization]","typeGuard":"def preorder_flow_current?(params, product)\n  !params[:purchase][:is_preorder_authorization] || product.is_in_preorder_state?\nend","tryCatchPattern":"begin\n  Purchase::CreateService.new(product:, params:, buyer:).perform\nrescue Purchase::PurchaseInvalid => e\n  # product was released mid-checkout: restart checkout in normal purchase mode\n  redirect_to_checkout if e.message == 'The product was just released. Refresh the page to purchase it.'\nend","preventionTips":["Re-check product.is_in_preorder_state? immediately before submit and switch flows on mismatch.","Treat release events as checkout-invalidating for in-flight pre-order sessions."],"tags":["preorder","stale-state","race-condition","checkout","gumroad"],"backgroundTag":"preorder-state-conflict","analyzedSha":"afeacbd394069a1cbf0c6c50ee8e900925050370","analyzedAt":"2026-08-21T17:58:52.159Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}