{"record":{"id":"fca51a6482db540b","repo":"antiwork/gumroad","slug":"you-cannot-gift-a-product-to-yourself-please-try","errorCode":null,"errorMessage":"You cannot gift a product to yourself. Please try gifting to another email.","messagePattern":"You cannot gift a product to yourself\\. Please try gifting to another email\\.","errorType":"exception","errorClass":"Purchase::PurchaseInvalid","httpStatus":null,"severity":"error","filePath":"app/services/purchase/create_service.rb","lineNumber":330,"sourceCode":"        end\n\n        purchase = result[:purchase] || restartable_subscription.original_purchase\n        self.purchase = purchase\n        Rails.logger.info(\"Subscription #{restartable_subscription.external_id} restarted during checkout for product #{product.id}\")\n        return purchase, nil\n      else\n        return nil, result[:error_message]\n      end\n    end\n\n    def create_gift\n      # A seller buying their own product can only ever be a test purchase, and test purchases were\n      # never built for gifts, so this case has to be rejected. The message names what the seller\n      # actually did and points at the supported way to give a product away, because the old wording\n      # (\"Test gift purchases have not been enabled yet.\") described an internal capability and read\n      # as a flag we could switch on for them, which generated support tickets asking us to do that.\n      raise Purchase::PurchaseInvalid, \"You can't gift your own product. To give it away for free, create a 100% off discount code under Checkout > Discounts and share the checkout link.\" if buyer == product.user\n      raise Purchase::PurchaseInvalid, \"You cannot gift a product to yourself. Please try gifting to another email.\" if giftee_email == purchase_params[:email]\n      raise Purchase::PurchaseInvalid, \"Gift purchases cannot be on installment plans.\" if params[:pay_in_installments]\n\n      if product.can_gift?\n        gift = product.gifts.build(giftee_email:, gift_note: gift_params[:gift_note], gifter_email: params[:purchase][:email], is_recipient_hidden: gift_params[:giftee_email].blank?)\n        error_message = gift.save ? nil : gift.errors.full_messages[0]\n        raise Purchase::PurchaseInvalid, error_message if error_message.present?\n\n        gift\n      else\n        error_message = product.user.gifting_disabled? ? \"The creator has disabled gifting for their products.\" : \"Gifting is not yet enabled for pre-orders.\"\n        raise Purchase::PurchaseInvalid, error_message\n      end\n    end\n\n    def validate_perceived_price\n      if purchase_params[:perceived_price_cents] && !Purchase::MAX_PRICE_RANGE.cover?(purchase_params[:perceived_price_cents])\n        raise Purchase::PurchaseInvalid, \"Purchase price is invalid. Please check the price.\"\n      end","sourceCodeStart":312,"sourceCodeEnd":348,"githubUrl":"https://github.com/antiwork/gumroad/blob/afeacbd394069a1cbf0c6c50ee8e900925050370/app/services/purchase/create_service.rb#L312-L348","documentation":"Raised when the gift recipient email equals the purchaser email (giftee_email == purchase_params[:email]). Gumroad's gift flow creates a second, recipient-side purchase, so gifting to yourself is rejected; giftee_email resolves from gift_params[:giftee_id]'s user or gift_params[:giftee_email].","triggerScenarios":"params[:gift][:giftee_email] (or the email of the user resolved by giftee_id) exactly equals params[:purchase][:email] on a gift checkout.","commonSituations":"Buyer types their own address into the recipient field by accident; browser autofill populating both email fields identically.","solutions":["Enter a different recipient email address.","If the buyer wants the product on their own account, complete a normal non-gift purchase.","Integrators: compare the two emails client-side and disable submit while they match."],"exampleFix":"# before: recipient field autofilled with the buyer's own address\ngift_params[:giftee_email] = purchase_params[:email]\n\n# after: block submission until the recipient differs\ngift_params[:giftee_email] = nil if gift_params[:giftee_email] == purchase_params[:email]","handlingStrategy":"validation","validationCode":"recipient = gift_params[:giftee_id].present? ? User.alive.find_by_external_id(gift_params[:giftee_id])&.email : gift_params[:giftee_email]\nparams.delete(:gift) if recipient == purchase_params[:email]","typeGuard":"def gift_to_self?(giftee_email, purchaser_email)\n  giftee_email.to_s.downcase == purchaser_email.to_s.downcase\nend","tryCatchPattern":"begin\n  Purchase::CreateService.new(product:, params:, buyer:).perform\nrescue Purchase::PurchaseInvalid => e\n  render_checkout_error(e.message) if e.message.start_with?('You cannot gift a product to yourself')\nend","preventionTips":["Compare recipient and purchaser emails client-side and disable submit while they match.","Beware autofill duplicating the buyer's email into the recipient field."],"tags":["gifting","email-validation","checkout","gumroad"],"backgroundTag":"gifting-not-allowed","analyzedSha":"afeacbd394069a1cbf0c6c50ee8e900925050370","analyzedAt":"2026-08-21T17:58:52.159Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}