docs/support.md
This document contains various administrative operations for Gumroad. To use, run these commands in the production console.
PayoutUsersService.new(
date_string: "2025-4-18",
processor_type: "PAYPAL",
user_ids: User.find_by(email: "[email protected]").id
).process
PayoutUsersService.new(
date_string: "2025-4-18",
processor_type: "STRIPE",
user_ids: User.find_by(email: "[email protected]").id
).process
User.find_by(email: '[email protected]').update!(payouts_paused_internally: false)
User.find_by(email: '[email protected]').update!(payment_address: "[email protected]")
User.find_by(email: '[email protected]').update!(can_connect_stripe: true)
Check unpaid balance up to specific dates to find the closest amount to what you want to pay out:
User.find_by(email: '[email protected]').unpaid_balance_cents_up_to_date("2025-4-23")
User.find_by(email: '[email protected]').unpaid_balance_cents_up_to_date("2025-4-22")
User.find_by(email: '[email protected]').unpaid_balance_cents_up_to_date("2025-4-21")
User.find_by(email: '[email protected]').unpaid_balance_cents_up_to_date("2025-4-20")
Once you've identified the appropriate date, issue a payout up to that date:
PayoutUsersService.new(
date_string: "2025-4-20", # Use the date that gives the closest amount to what you want to pay out
processor_type: "STRIPE",
user_ids: User.find_by(email: "[email protected]").id
).process
User.find_by(email: '[email protected]').payments.select(:id, :created_at, :processor, :amount_cents, :currency, :state).last(5)
User.find_by(email: '[email protected]').payments.failed.last(2)
If it has not been triggered on Stripe/PayPal, can just mark it as failed:
Payment.find(PAYMENT_ID).mark_failed!
Or using payment external ID:
Payment.find_by_external_id("abcdefghijklmno==").mark_failed!
Payment.find(PAYMENT_ID).mark_returned!
Or using payment external ID:
Payment.find_by_external_id("abcdefghijklmno==").mark_returned!
User.find_by(email: "[email protected]").paypal_connect_account.paypal_account_details["primary_email"]
PaypalIntegrationRestApi.new(nil, authorization_header: PaypalPartnerRestCredentials.new.auth_token).get_merchant_account_by_merchant_id("MERCHANT_ID")["primary_email"]
User.find_by(email: '[email protected]').sales.successful.where(email: '[email protected]').pluck(:id, :created_at, :stripe_transaction_id, :total_transaction_cents)
Purchase.successful.where(email: '[email protected]').select(:id, :created_at, :stripe_transaction_id, :total_transaction_cents).last(25)
Purchase.find(purchase_id).refund!(refunding_user_id: GUMROAD_ADMIN_ID)
Purchase.find_by_external_id(purchase_external_id).refund!(refunding_user_id: GUMROAD_ADMIN_ID)
Charge.find_by_external_id("abcdefghijklmno==").purchases
User.find_by_username("<username>").links.f("<permalink>").mark_undeleted!
product = Link.find_by_unique_permalink("<username>.gumroad.com/l/abcde")
product.update!(custom_receipt: nil)
product = Link.find_by(email: '[email protected]', custom_permalink: 'customname')
product.update!(custom_receipt: nil)
Alternative method:
user = User.find_by(email: '[email protected]')
product = user.links.find_by(unique_permalink: 'PERMALINK')
product.update!(custom_receipt: nil)
user = User.find_by(email: '[email protected]')
product = user.links.find_by(unique_permalink: 'PERMALINK')
product.update(purchase_type: :buy_only)
u = User.find_by(email: '[email protected]')
u.update!(refunds_disabled: false)
Get the current email:
User.find_by(email: "[email protected]").alive_cart.email
Remove the email:
User.find_by(email: "[email protected]").alive_cart.update!(email: nil)
User.find_by(email: "[email protected]").financial_annual_report_url_for(year: 2024)
User.find_by(email: '[email protected]').id
user = User.find_by(email: '[email protected]')
# or
user = User.find_by(id: USER_ID)
user.confirm
user = User.find_by(email: "[email protected]")
if user.present?
Purchase.where(email: user.email, purchaser_id: nil).update_all(purchaser_id: user.id)
else
# Handle case when user doesn't exist
puts "No user found with email: [email protected]"
end
email = "[email protected]"
purchases = Purchase.successful
.where(email: email)
.not_is_gift_sender_purchase
.not_is_bundle_product_purchase
purchases.find_each do |purchase|
purchase.resend_receipt
end
Subscription.find(SUBSCRIPTION_ID).user_requested_cancellation_at
User.find_by_email("[email protected]").links.each do |product|
product.subscriptions.active.each do |subscription|
subscription.cancel!(by_admin: true)
end
end