source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/user/affiliated_products.rb
Ruby
mit
8,966
main
290
# frozen_string_literal: true module User::AffiliatedProducts extend ActiveSupport::Concern def directly_affiliated_products(alive: true) scope = Link.with_direct_affiliates scope = scope.merge(DirectAffiliate.alive).alive if alive scope.for_affiliate_user(id) end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/user/direct_affiliates.rb
Ruby
mit
8,966
main
206
# frozen_string_literal: true module User::DirectAffiliates extend ActiveSupport::Concern included do has_many :direct_affiliates, foreign_key: :seller_id, class_name: "DirectAffiliate" end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/user/followers.rb
Ruby
mit
8,966
main
869
# frozen_string_literal: true module User::Followers extend ActiveSupport::Concern included do has_many :followers, foreign_key: "followed_id" end def follower_by_email(email) Follower.active.find_by(followed_id: id, email:) end def followed_by?(email) follower_by_email(email).present? end...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/user/email_normalization.rb
Ruby
mit
8,966
main
1,170
# frozen_string_literal: true module User::EmailNormalization extend ActiveSupport::Concern GMAIL_DOMAINS = %w[gmail.com googlemail.com].freeze ABUSIVE_RISK_STATES = %w[ suspended_for_fraud suspended_for_tos_violation flagged_for_fraud flagged_for_tos_violation ].freeze class_methods do def nor...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/user/comments.rb
Ruby
mit
8,966
main
261
# frozen_string_literal: true module User::Comments extend ActiveSupport::Concern def add_payout_note(content:) comments.create!( content:, author_id: GUMROAD_ADMIN_ID, comment_type: Comment::COMMENT_TYPE_PAYOUT_NOTE ) end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/user/low_balance_fraud_check.rb
Ruby
mit
8,966
main
3,995
# frozen_string_literal: true module User::LowBalanceFraudCheck extend ActiveSupport::Concern LOW_BALANCE_THRESHOLD = -100_00 # USD -100 private_constant :LOW_BALANCE_THRESHOLD HIGH_BALANCE_THRESHOLD = 100_00 # USD 100 private_constant :HIGH_BALANCE_THRESHOLD LOW_BALANCE_PROBATION_WAIT_TIME = 2.months ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/installment/searchable.rb
Ruby
mit
8,966
main
2,128
# frozen_string_literal: true module Installment::Searchable extend ActiveSupport::Concern included do include Elasticsearch::Model include SearchIndexModelCommon include ElasticsearchModelAsyncCallbacks index_name "installments" settings number_of_shards: 1, number_of_replicas: 0, index: { ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/affiliate/sorting.rb
Ruby
mit
8,966
main
1,350
# frozen_string_literal: true module Affiliate::Sorting extend ActiveSupport::Concern SORT_KEYS = ["affiliate_user_name", "products", "fee_percent", "volume_cents"] SORT_KEYS.each do |key| const_set(key.upcase, key) end class_methods do def sorted_by(key: nil, direction: nil) direction = dir...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/affiliate/audience_member.rb
Ruby
mit
8,966
main
2,500
# frozen_string_literal: true module Affiliate::AudienceMember extend ActiveSupport::Concern included do after_save :update_audience_member_details after_destroy :remove_from_audience_member_details end def update_audience_member_with_added_product(product_or_id) return unless persisted? && type ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/affiliate/basis_points_validations.rb
Ruby
mit
8,966
main
619
# frozen_string_literal: true module Affiliate::BasisPointsValidations extend ActiveSupport::Concern MIN_AFFILIATE_BASIS_POINTS = 100 # 1% MAX_AFFILIATE_BASIS_POINTS = 7500 # 75% included do private def affiliate_basis_points_must_fall_in_an_acceptable_range return if affiliate_basis_points...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/affiliate/cookies.rb
Ruby
mit
8,966
main
1,149
# frozen_string_literal: true module Affiliate::Cookies extend ActiveSupport::Concern AFFILIATE_COOKIE_NAME_PREFIX = "_gumroad_affiliate_id_" class_methods do def by_cookies(cookies) in_order_of(:id, ids_from_cookies(cookies)) end def ids_from_cookies(cookies) cookies .sort_by ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/affiliate/destination_url_validations.rb
Ruby
mit
8,966
main
417
# frozen_string_literal: true module Affiliate::DestinationUrlValidations extend ActiveSupport::Concern included do validate :destination_url_validation private def destination_url_validation return if destination_url.blank? errors.add(:base, "The destination url you entered is inv...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/upsell/sorting.rb
Ruby
mit
8,966
main
808
# frozen_string_literal: true module Upsell::Sorting extend ActiveSupport::Concern SORT_KEYS = ["name", "revenue", "uses", "status"] SORT_KEYS.each do |key| const_set(key.upcase, key) end class_methods do def sorted_by(key: nil, direction: nil) direction = direction == "desc" ? "desc" : "asc...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/follower/audience_member.rb
Ruby
mit
8,966
main
1,148
# frozen_string_literal: true module Follower::AudienceMember extend ActiveSupport::Concern included do after_save :update_audience_member_details after_destroy :remove_from_audience_member_details end def should_be_audience_member? confirmed_at.present? && EmailFormatValidator.valid?(email) en...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/balance/refund_eligibility_underwriter.rb
Ruby
mit
8,966
main
810
# frozen_string_literal: true module Balance::RefundEligibilityUnderwriter extend ActiveSupport::Concern included do after_commit :update_seller_refund_eligibility end private def update_seller_refund_eligibility return if user_id.blank? return unless anticipate_refund_eligibility_changes...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/balance/searchable.rb
Ruby
mit
8,966
main
1,290
# frozen_string_literal: true module Balance::Searchable extend ActiveSupport::Concern included do include Elasticsearch::Model include SearchIndexModelCommon include ElasticsearchModelAsyncCallbacks index_name "balances" settings number_of_shards: 1, number_of_replicas: 0 mapping dynam...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/offer_code/sorting.rb
Ruby
mit
8,966
main
850
# frozen_string_literal: true module OfferCode::Sorting extend ActiveSupport::Concern SORT_KEYS = ["name", "revenue", "uses", "term"] SORT_KEYS.each do |key| const_set(key.upcase, key) end class_methods do def sorted_by(key: nil, direction: nil) direction = direction == "desc" ? "desc" : "as...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/payment/failure_reason.rb
Ruby
mit
8,966
main
7,170
# frozen_string_literal: true module Payment::FailureReason extend ActiveSupport::Concern CANNOT_PAY = "cannot_pay" DEBIT_CARD_LIMIT = "debit_card_limit" INSUFFICIENT_FUNDS = "insufficient_funds" PAYPAL_MASS_PAY = { "PAYPAL 1000" => "Unknown error", "PAYPAL 1001" => "Receiver's account is invalid",...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/video_file/has_thumbnail.rb
Ruby
mit
8,966
main
934
# frozen_string_literal: true module VideoFile::HasThumbnail extend ActiveSupport::Concern THUMBNAIL_SUPPORTED_CONTENT_TYPES = /jpeg|gif|png|jpg/i THUMBNAIL_MAXIMUM_SIZE = 5.megabytes included do has_one_attached :thumbnail do |attachable| attachable.variant :preview, resize_to_limit: [1280, 720], ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/purchase/dispute_win_credits.rb
Ruby
mit
8,966
main
2,706
# frozen_string_literal: true module Purchase::DisputeWinCredits extend ActiveSupport::Concern def create_credit_for_dispute_won_for_affiliate!(flow_of_funds, amount_cents: 0) return if affiliate_credit_cents == 0 || amount_cents == 0 affiliate_issued_amount = BalanceTransaction::Amount.create_issued_amo...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/purchase/searchable.rb
Ruby
mit
8,966
main
15,209
# frozen_string_literal: true module Purchase::Searchable extend ActiveSupport::Concern included do include Elasticsearch::Model include ElasticsearchModelAsyncCallbacks include SearchIndexModelCommon include RelatedPurchaseCallbacks index_name "purchases" settings number_of_shards: 1, n...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/purchase/custom_fields.rb
Ruby
mit
8,966
main
318
# frozen_string_literal: true module Purchase::CustomFields extend ActiveSupport::Concern included do has_many :purchase_custom_fields, dependent: :destroy end def custom_fields purchase_custom_fields.map do |field| { name: field.name, value: field.value, type: field.type } end end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/purchase/receipt.rb
Ruby
mit
8,966
main
1,698
# frozen_string_literal: true module Purchase::Receipt extend ActiveSupport::Concern included do has_many :email_infos has_many :installments, through: :email_infos has_one :receipt_email_info_from_purchase, -> { order(id: :desc) }, class_name: "CustomerEmailInfo" end def receipt_email_info ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/purchase/charge_events_handler.rb
Ruby
mit
8,966
main
4,916
# frozen_string_literal: true module Purchase::ChargeEventsHandler extend ActiveSupport::Concern class_methods do def handle_charge_event(event) logger.info("Charge event: #{event.to_h.to_json}") chargeable = Charge::Chargeable.find_by_stripe_event(event) if chargeable.nil? ErrorNo...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/purchase/blockable.rb
Ruby
mit
8,966
main
15,544
# frozen_string_literal: true module Purchase::Blockable extend ActiveSupport::Concern included do include AttributeBlockable attr_blockable :browser_guid attr_blockable :ip_address attr_blockable :email attr_blockable :paypal_email, object_type: :email attr_blockable :gifter_email, objec...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/purchase/audience_member.rb
Ruby
mit
8,966
main
2,118
# frozen_string_literal: true module Purchase::AudienceMember extend ActiveSupport::Concern included do after_save :update_audience_member_details after_destroy :remove_from_audience_member_details end def should_be_audience_member? result = can_contact? result &= purchase_state.in?(%w[succes...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/purchase/creator_analytics_callbacks.rb
Ruby
mit
8,966
main
809
# frozen_string_literal: true module Purchase::CreatorAnalyticsCallbacks extend ActiveSupport::Concern included do after_commit :update_creator_analytics_cache, on: :update def update_creator_analytics_cache(force: false) return if !force && !%w[chargeback_date flags purchase_state stripe_refunded]...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/purchase/recommended.rb
Ruby
mit
8,966
main
974
# frozen_string_literal: true module Purchase::Recommended extend ActiveSupport::Concern def handle_recommended_purchase return unless successful? || preorder_authorization_successful? || is_free_trial_purchase? return if RecommendedPurchaseInfo.where(purchase_id: id).present? if RecommendationType.i...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/purchase/reportable.rb
Ruby
mit
8,966
main
1,414
# frozen_string_literal: true module Purchase::Reportable extend ActiveSupport::Concern def price_cents_net_of_refunds net_of_refunds_cents(:price_cents, :amount_cents) end def fee_cents_net_of_refunds net_of_refunds_cents(:fee_cents, :fee_cents) end def tax_cents_net_of_refunds net_of_refun...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/concerns/purchase/paypal.rb
Ruby
mit
8,966
main
1,161
# frozen_string_literal: true module Purchase::Paypal extend ActiveSupport::Concern included do scope :paypal, -> { where(charge_processor_id: PaypalChargeProcessor.charge_processor_id) } scope :paypal_orders, -> { where.not(paypal_order_id: nil) } scope :unsuccessful_paypal_orders, lambda { |created_...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/mailer_info/delivery_method.rb
Ruby
mit
8,966
main
1,292
# frozen_string_literal: true module MailerInfo::DeliveryMethod extend self include Kernel DOMAIN_GUMROAD = :gumroad DOMAIN_FOLLOWERS = :followers DOMAIN_CREATORS = :creators DOMAIN_CUSTOMERS = :customers DOMAINS = [DOMAIN_GUMROAD, DOMAIN_FOLLOWERS, DOMAIN_CREATORS, DOMAIN_CUSTOMERS] def options(do...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/mailer_info/encryption.rb
Ruby
mit
8,966
main
1,388
# frozen_string_literal: true module MailerInfo::Encryption extend self include Kernel def encrypt(value) return value if value.nil? cipher = OpenSSL::Cipher.new("aes-256-cbc") cipher.encrypt key_version = current_key_version cipher.key = derive_key(key_version) iv = cipher.random_iv ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/mailer_info/router.rb
Ruby
mit
8,966
main
3,517
# frozen_string_literal: true module MailerInfo::Router extend self include Kernel def determine_email_provider(domain) raise ArgumentError, "Invalid domain: #{domain}" unless MailerInfo::DeliveryMethod::DOMAINS.include?(domain) return MailerInfo::EMAIL_PROVIDER_SENDGRID if Feature.inactive?(:resend) ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/mailer_info/header_builder.rb
Ruby
mit
8,966
main
5,221
# frozen_string_literal: true require "openssl" class MailerInfo::HeaderBuilder attr_reader :mailer_class, :email_provider attr_reader :mailer_args attr_reader :mailer_method def self.perform(mailer_class:, mailer_method:, mailer_args:, email_provider:) new(mailer_class:, mailer_method:, mailer_args:, ema...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/models/admin/sales_report.rb
Ruby
mit
8,966
main
2,361
# frozen_string_literal: true class Admin::SalesReport include ActiveModel::Model YYYY_MM_DD_FORMAT = /\A\d{4}-\d{2}-\d{2}\z/ INVALID_DATE_FORMAT_MESSAGE = "Invalid date format. Please use YYYY-MM-DD format" ACCESSORS = %i[country_code start_date end_date sales_type].freeze attr_accessor(*ACCESSORS) ACCE...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/channels/user_channel.rb
Ruby
mit
8,966
main
830
# frozen_string_literal: true class UserChannel < ApplicationCable::Channel LATEST_COMMUNITY_INFO_TYPE = "latest_community_info" def subscribed return reject unless current_user.present? stream_for "user_#{current_user.external_id}" end def receive(data) case data["type"] when LATEST_COMMUNIT...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/channels/community_channel.rb
Ruby
mit
8,966
main
655
# frozen_string_literal: true class CommunityChannel < ApplicationCable::Channel CREATE_CHAT_MESSAGE_TYPE = "create_chat_message" UPDATE_CHAT_MESSAGE_TYPE = "update_chat_message" DELETE_CHAT_MESSAGE_TYPE = "delete_chat_message" def subscribed return reject unless params[:community_id].present? return ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/channels/application_cable/connection.rb
Ruby
mit
8,966
main
1,209
# frozen_string_literal: true module ApplicationCable class Connection < ActionCable::Connection::Base rescue_from StandardError, with: :report_error delegate :session, to: :request identified_by :current_user def connect self.current_user = impersonated_user end private def i...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/sales_tax/sales_tax_calculator.rb
Ruby
mit
8,966
main
10,837
# frozen_string_literal: true require_relative "../../../lib/utilities/geo_ip" class SalesTaxCalculator attr_accessor :tax_rate, :product, :price_cents, :shipping_cents, :quantity, :buyer_location, :buyer_vat_id, :state, :is_us_taxable_state, :is_ca_taxable, :is_quebec def initialize(product:, price_cents:, ship...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/sales_tax/sales_tax_calculation.rb
Ruby
mit
8,966
main
1,815
# frozen_string_literal: true class SalesTaxCalculation attr_reader :price_cents, :tax_cents, :zip_tax_rate, :business_vat_status, :used_taxjar, :gumroad_is_mpf, :taxjar_info, :is_quebec def initialize(price_cents:, tax_cents:, zip_tax_rate:, business_vat_status: nil, used_taxjar: false, gumroad_is_mpf: false, ta...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/sales_tax/taxjar/taxjar_errors.rb
Ruby
mit
8,966
main
506
# frozen_string_literal: true module TaxjarErrors CLIENT = [Taxjar::Error::BadRequest, Taxjar::Error::Unauthorized, Taxjar::Error::Forbidden, Taxjar::Error::NotFound, Taxjar::Error::MethodNotAllowed, Taxjar::Error::NotAcceptable, Taxjar::Error::Gone, Taxjar::Error::UnprocessableEn...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/sales_tax/taxjar/taxjar_api.rb
Ruby
mit
8,966
main
2,921
# frozen_string_literal: true class TaxjarApi def initialize @client = Taxjar::Client.new(api_key: TAXJAR_API_KEY, headers: { "x-api-version" => "2022-01-24" }, api_url: TAXJAR_ENDPOINT) @cache = Redis::Namespace.new(:taxjar_calculations, redis: $redis) end # Returns nil if there's an error calling TaxJ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/card_data_handling/card_data_handling_error.rb
Ruby
mit
8,966
main
1,030
# frozen_string_literal: true # CardDataHandlingError is an error from the front-end when the card data was being handled and failed for some reason. class CardDataHandlingError attr_reader :card_error_code, :error_message # Public: Initialize the error with an error message and card error code. If the card error...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/card_data_handling/card_data_handling_mode.rb
Ruby
mit
8,966
main
541
# frozen_string_literal: true module CardDataHandlingMode TOKENIZE_VIA_STRIPEJS = "stripejs.0" VALID_MODES = { TOKENIZE_VIA_STRIPEJS => StripeChargeProcessor.charge_processor_id }.freeze module_function def is_valid(card_data_handling_mode) return false if card_data_handling_mode.nil? card_dat...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/currency.rb
Ruby
mit
8,966
main
1,557
# frozen_string_literal: true module Currency # These currencies can be used as account's default currency and to set product prices, # along with creating Stripe Connect accounts and making payouts. CURRENCY_CHOICES.each do |currency_type, _currency_hash| const_set(currency_type.upcase, currency_type.downca...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/reports/deferred_refunds_reports.rb
Ruby
mit
8,966
main
2,078
# frozen_string_literal: true module DeferredRefundsReports def self.deferred_refunds_report(month, year) json = { "Purchases" => [] } range = DateTime.new(year, month)...DateTime.new(year, month).end_of_month refunded_purchase_ids = Refund.where(created_at: range).pluck(:purchase_id) deferred_refun...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/reports/funds_received_reports.rb
Ruby
mit
8,966
main
2,191
# frozen_string_literal: true module FundsReceivedReports def self.funds_received_report(month, year) json = {} range = DateTime.new(year, month)...DateTime.new(year, month).end_of_month successful_purchases = Purchase.successful.not_fully_refunded.not_chargedback_or_chargedback_reversed.where(created_a...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/reports/stripe_currency_balances_report.rb
Ruby
mit
8,966
main
836
# frozen_string_literal: true module StripeCurrencyBalancesReport extend CurrencyHelper def self.stripe_currency_balances_report currency_balances = {} stripe_balance = Stripe::Balance.retrieve stripe_balance.available.sort_by { _1["currency"] }.each do |balance| currency_balances[balance["cur...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/utilities/stripe_metadata.rb
Ruby
mit
8,966
main
1,080
# frozen_string_literal: false module StripeMetadata STRIPE_METADATA_VALUE_MAX_LENGTH = 500 STRIPE_METADATA_MAX_KEYS_LENGTH = 50 private_constant :STRIPE_METADATA_VALUE_MAX_LENGTH # Public: Builds a hash to be included in Stripe metadata that lists the items passed in, separated by the # separator and sp...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/utilities/braintree_exceptions.rb
Ruby
mit
8,966
main
245
# frozen_string_literal: true module BraintreeExceptions UNAVAILABLE = [Braintree::ServiceUnavailableError, Braintree::SSLCertificateError, Braintree::ServerError, Braintree::UnexpectedError, *INTERNET_EXCEPTIONS].freeze end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/utilities/stripe_url.rb
Ruby
mit
8,966
main
788
# frozen_string_literal: true module StripeUrl def self.dashboard_url(account_id: nil) [base_url(account_id:), "dashboard"].join("/") end def self.event_url(event_id, account_id: nil) [base_url(account_id:), "events", event_id].join("/") end def self.transfer_url(transfer_id, account_id: nil) [...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/events/stripe/stripe_event_handler.rb
Ruby
mit
8,966
main
3,580
# frozen_string_literal: true class StripeEventHandler attr_accessor :params # See full list of events at https://stripe.com/docs/api/events/types ALL_HANDLED_EVENTS = %w{account.application.deauthorized account.updated capability.updated payout. charge. capital. radar. payment_intent.payment_failed}.freeze #...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/events/paypal/paypal_event_handler.rb
Ruby
mit
8,966
main
2,596
# frozen_string_literal: true class PaypalEventHandler attr_accessor :paypal_event IGNORED_TRANSACTION_TYPES = %w[express_checkout cart mp_signup mp_notification mp_cancel].freeze private_constant :IGNORED_TRANSACTION_TYPES def initialize(paypal_event) self.paypal_event = paypal_event end def sched...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/events/paypal/paypal_webhook_verifier.rb
Ruby
mit
8,966
main
2,662
# frozen_string_literal: true class PaypalWebhookVerifier include HTTParty base_uri PAYPAL_REST_ENDPOINT REQUIRED_HEADERS = %w[ HTTP_PAYPAL_TRANSMISSION_ID HTTP_PAYPAL_TRANSMISSION_SIG HTTP_PAYPAL_CERT_URL HTTP_PAYPAL_AUTH_ALGO HTTP_PAYPAL_TRANSMISSION_TIME ].freeze def initialize(head...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/events/paypal/paypal_event_type.rb
Ruby
mit
8,966
main
1,547
# frozen_string_literal: true class PaypalEventType CUSTOMER_DISPUTE_CREATED = "CUSTOMER.DISPUTE.CREATED" CUSTOMER_DISPUTE_RESOLVED = "CUSTOMER.DISPUTE.RESOLVED" PAYMENT_CAPTURE_COMPLETED = "PAYMENT.CAPTURE.COMPLETED" PAYMENT_CAPTURE_DENIED = "PAYMENT.CAPTURE.DENIED" PAYMENT_CAPTURE_REVERSED = "PAYMENT.CAPTU...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/merchant_registration/user_compliance_info_field_property.rb
Ruby
mit
8,966
main
2,906
# frozen_string_literal: true # Information about the fields stored in UserComplianceInfo, such as min/max lengths, etc. module UserComplianceInfoFieldProperty LENGTH = "length" FILTER = "filter" PROPERTIES = { Compliance::Countries::USA.alpha2 => { UserComplianceInfoFields::Individual::TAX_ID => { LE...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/merchant_registration/user_compliance_info_fields.rb
Ruby
mit
8,966
main
3,985
# frozen_string_literal: true # Fields that can be requested in a UserComplianceInfoRequest. # Some fields map onto the UserComplianceInfo model, while others do not. module UserComplianceInfoFields # The following fields are attributes of UserComplianceInfo and can be referenced # in requests for user compliance ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/merchant_registration/errors/merchant_registration_user_not_ready_error.rb
Ruby
mit
8,966
main
211
# frozen_string_literal: true class MerchantRegistrationUserNotReadyError < GumroadRuntimeError def initialize(user_id, message_why_not_ready) super("User #{user_id} #{message_why_not_ready}.") end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/merchant_registration/errors/merchant_registration_user_already_has_account_error.rb
Ruby
mit
8,966
main
268
# frozen_string_literal: true class MerchantRegistrationUserAlreadyHasAccountError < GumroadRuntimeError def initialize(user_id, charge_processor_id) super("User #{user_id} already has a merchant account for charge processor #{charge_processor_id}.") end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/merchant_registration/implementations/stripe/stripe_merchant_account_manager.rb
Ruby
mit
8,966
main
43,736
# frozen_string_literal: true module StripeMerchantAccountManager REQUESTED_CAPABILITIES = %w(card_payments transfers) CROSS_BORDER_PAYOUTS_ONLY_CAPABILITIES = %w(transfers) COUNTRIES_SUPPORTED_BY_STRIPE_CONNECT = ["Australia", "Austria", "Belgium", "Brazil", "Bulgaria", "Canada", "Croatia", ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/merchant_registration/implementations/stripe/stripe_user_compliance_info_field_map.rb
Ruby
mit
8,966
main
3,894
# frozen_string_literal: true module StripeUserComplianceInfoFieldMap MAP_STRIPE_FIELD_TO_INTERNAL_FIELD = { "business_type" => UserComplianceInfoFields::IS_BUSINESS, "individual.first_name" => UserComplianceInfoFields::Individual::FIRST_NAME, "individual.last_name" => UserComplianceInfoFields::Individu...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/merchant_registration/implementations/paypal/paypal_merchant_account_manager.rb
Ruby
mit
8,966
main
9,117
# frozen_string_literal: true class PaypalMerchantAccountManager attr_reader :response # Ref: https://developer.paypal.com/docs/api/reference/country-codes/#paypal-commerce-platform-availability COUNTRY_CODES_NOT_SUPPORTED_BY_PCP = [ Compliance::Countries::DZA, Compliance::Countries::BRA, Compliance...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/integrations/paypal_partner_rest_credentials.rb
Ruby
mit
8,966
main
1,599
# frozen_string_literal: true class PaypalPartnerRestCredentials REDIS_KEY_STORAGE_NS = Redis::Namespace.new(:paypal_partner_rest_auth_token, redis: $redis) TOKEN_KEY = "token_header" API_RETRY_TIMEOUT_IN_SECONDS = 2 # Number of seconds before the API request is retried on failure API_MAX_TRIES ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/integrations/paypal_integration_rest_api.rb
Ruby
mit
8,966
main
2,116
# frozen_string_literal: true class PaypalIntegrationRestApi include HTTParty base_uri PAYPAL_REST_ENDPOINT attr_reader :merchant, :response, :options def initialize(merchant, options = {}) @merchant = merchant @options = options end # Create a partner (Gumroad) referral for the given merchant...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/setup_intent.rb
Ruby
mit
8,966
main
210
# frozen_string_literal: true class SetupIntent attr_accessor :id, :setup_intent, :client_secret def succeeded? true end def requires_action? false end def canceled? false end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/charge_intent.rb
Ruby
mit
8,966
main
728
# frozen_string_literal: true # Represents the user's intent to pay. The intent may succeed immediately (resulting in a charge) # or require additional confirmation from the user (such as 3D Secure). # # This is mainly a wrapper around Stripe's PaymentIntent API: https://stripe.com/docs/payments/payment-intents # # Fo...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/holder_of_funds.rb
Ruby
mit
8,966
main
247
# frozen_string_literal: true # Describe where funds collected by creating a charge at a charge processor # are held until they are paid out to the creator. module HolderOfFunds GUMROAD = "gumroad" STRIPE = "stripe" CREATOR = "creator" end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/chargeable_visual.rb
Ruby
mit
8,966
main
854
# frozen_string_literal: true module ChargeableVisual module_function DEFAULT_FORMAT = "**** **** **** %s" LENGTH_TO_FORMAT = Hash.new(DEFAULT_FORMAT).merge( 16 => DEFAULT_FORMAT, 15 => "**** ****** *%s", 14 => "**** ****** %s" ) def is_cc_visual(visual) !(visual =~ /^[*\s\d]+$/).nil? end...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/charge_event.rb
Ruby
mit
8,966
main
1,660
# frozen_string_literal: true class ChargeEvent # An informational event that requires no action from a financial point of view. TYPE_INFORMATIONAL = :info # A dispute has been formalized and has financial consequences, funds have been withdrawn to cover the dispute. TYPE_DISPUTE_FORMALIZED = :dispute_formaliz...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/chargeable.rb
Ruby
mit
8,966
main
2,553
# frozen_string_literal: true # Public: A chargeable contains multiple internal chargeables that are mapped to charge processor implementations. # Externally to the charging module the application interacts with the Chargeable only but internally to the individual # chargeables associated with each charge processor ar...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/flow_of_funds.rb
Ruby
mit
8,966
main
2,357
# frozen_string_literal: true class FlowOfFunds class Amount attr_accessor :currency, :cents def initialize(currency:, cents:) @currency = currency @cents = cents end def to_h { currenty: currency, cents: } end end attr_accessor :issued_amount, :sett...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/base_processor_charge.rb
Ruby
mit
8,966
main
731
# frozen_string_literal: true class BaseProcessorCharge attr_accessor :charge_processor_id, :id, :status, :refunded, :disputed, :fee, :fee_currency, :card_fingerprint, :card_instance_id, :card_last4, :card_number_length, :card_expiry_month, :card_expiry_year, :card_zip_code, ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/charge_processor.rb
Ruby
mit
8,966
main
13,330
# frozen_string_literal: true module ChargeProcessor # Time user has to complete Strong Customer Authentication (enter an OTP, confirm purchase via bank app, etc). Sensible default, not dictated by a payment processor. TIME_TO_COMPLETE_SCA = 15.minutes NOTIFICATION_CHARGE_EVENT = "charge_event.charge_processor....
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/stripe/stripe_chargeable_payment_method.rb
Ruby
mit
8,966
main
3,824
# frozen_string_literal: true class StripeChargeablePaymentMethod include StripeErrorHandler attr_reader :payment_method_id, :stripe_setup_intent_id, :stripe_payment_intent_id def initialize(payment_method_id, customer_id: nil, stripe_setup_intent_id: nil, stripe_payment_inten...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/stripe/stripe_charge_radar_processor.rb
Ruby
mit
8,966
main
2,315
# frozen_string_literal: true # Sample Stripe event: # { # "id": "evt_0O8n7L9e1RjUNIyY90W7gkV3", # "object": "event", # "api_version": "2020-08-27", # "created": 1699116878, # "data": { # "object": { # "id": "issfr_0O8n7K9e1RjUNIyYmTbvMMLa", # "object": "radar.early_fraud_warning", # "a...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/stripe/stripe_chargeable_token.rb
Ruby
mit
8,966
main
2,838
# frozen_string_literal: true # Public: Chargeable representing pre-tokenized data using Stripe. class StripeChargeableToken include StripeErrorHandler attr_reader :payment_method_id def initialize(token, zip_code, product_permalink:) @token_s = token @zip_code = zip_code @merchant_account = get_me...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/stripe/stripe_charge_processor.rb
Ruby
mit
8,966
main
53,013
# frozen_string_literal: true class StripeChargeProcessor include StripeErrorHandler extend CurrencyHelper DISPLAY_NAME = "Stripe" # https://stripe.com/docs/api/charges/object#charge_object-status VALID_TRANSACTION_STATUSES = %w(succeeded pending).freeze # https://stripe.com/docs/api/refunds/create#crea...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/stripe/stripe_setup_intent.rb
Ruby
mit
8,966
main
923
# frozen_string_literal: true # Creates a SetupIntent from Stripe::SetupIntent class StripeSetupIntent < SetupIntent delegate :id, :client_secret, to: :setup_intent def initialize(setup_intent) self.setup_intent = setup_intent validate_next_action end def succeeded? setup_intent.status == StripeI...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/stripe/stripe_card_type.rb
Ruby
mit
8,966
main
936
# frozen_string_literal: true class StripeCardType CARD_TYPES = { "Visa" => CardType::VISA, "American Express" => CardType::AMERICAN_EXPRESS, "MasterCard" => CardType::MASTERCARD, "Discover" => CardType::DISCOVER, "JCB" => CardType::JCB, "Diners Club" => CardType::DINERS_CLUB, "UnionPay" ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/stripe/stripe_chargeable_credit_card.rb
Ruby
mit
8,966
main
3,729
# frozen_string_literal: true # Public: Chargeable representing a card stored at Stripe. class StripeChargeableCreditCard include StripeErrorHandler attr_reader :fingerprint, :payment_method_id, :last4, :visual, :number_length, :expiry_month, :expiry_year, :zip_code, :card_type, :country, ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/stripe/stripe_charge_intent.rb
Ruby
mit
8,966
main
2,026
# frozen_string_literal: true # Creates a ChargeIntent from Stripe::PaymentIntent class StripeChargeIntent < ChargeIntent delegate :id, :client_secret, to: :payment_intent def initialize(payment_intent:, merchant_account: nil) self.payment_intent = payment_intent load_charge(payment_intent, merchant_acco...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/stripe/stripe_charge_refund.rb
Ruby
mit
8,966
main
4,983
# frozen_string_literal: true class StripeChargeRefund < ChargeRefund # Public: Create a ChargeRefund from a Stripe::Refund # # Inherits attr_accessor :charge_processor_id, :id, :charge_id, :flow_of_funds, :refund from ChargeRefund attr_reader :charge, :destination_payment_refund, :...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/stripe/stripe_charge.rb
Ruby
mit
8,966
main
6,904
# frozen_string_literal: true class StripeCharge < BaseProcessorCharge # Public: Create a BaseProcessorCharge from a Stripe::Charge and a Stripe::BalanceTransaction def initialize(stripe_charge, stripe_charge_balance_transaction, stripe_application_fee_balance_transaction, stripe_destination_payme...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/stripe/helpers/stripe_intent_status.rb
Ruby
mit
8,966
main
265
# frozen_string_literal: true class StripeIntentStatus SUCCESS = "succeeded" REQUIRES_CONFIRMATION = "requires_confirmation" REQUIRES_ACTION = "requires_action" PROCESSING = "processing" CANCELED = "canceled" ACTION_TYPE_USE_SDK = "use_stripe_sdk" end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/stripe/helpers/stripe_error_handler.rb
Ruby
mit
8,966
main
1,671
# frozen_string_literal: true module StripeErrorHandler private def with_stripe_error_handler yield rescue Stripe::InvalidRequestError => e raise ChargeProcessorInvalidRequestError.new(original_error: e) rescue Stripe::APIConnectionError, Stripe::APIError => e raise ChargeProcessorUnava...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/braintree/braintree_charge_processor.rb
Ruby
mit
8,966
main
8,698
# frozen_string_literal: true class BraintreeChargeProcessor DISPLAY_NAME = "Braintree" MAXIMUM_DESCRIPTOR_LENGTH = 18 PROCESSOR_UNSUPPORTED_PAYMENT_ACCOUNT_ERROR_CODE = "2071" PROCESSOR_UNSUPPORTED_PAYMENT_INSTRUMENT_ERROR_CODE = "2074" private_constant :MAXIMUM_DESCRIPTOR_LENGTH, :PROCESSOR_UNSUPPORTED...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/braintree/braintree_chargeable_nonce.rb
Ruby
mit
8,966
main
739
# frozen_string_literal: true class BraintreeChargeableNonce < BraintreeChargeableBase def initialize(nonce, zip_code) @nonce = nonce @zip_code = zip_code end def prepare! unless @paypal || @card @customer = Braintree::Customer.create!( credit_card: { payment_method_nonce: @n...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/braintree/braintree_chargeable_base.rb
Ruby
mit
8,966
main
1,792
# frozen_string_literal: true class BraintreeChargeableBase attr_accessor :braintree_device_data attr_reader :payment_method_id def charge_processor_id BraintreeChargeProcessor.charge_processor_id end def prepare! raise NotImplementedError end def funding_type nil end def fingerprint ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/braintree/braintree_charge.rb
Ruby
mit
8,966
main
3,041
# frozen_string_literal: true class BraintreeCharge < BaseProcessorCharge def initialize(braintree_charge, load_extra_details:) self.charge_processor_id = BraintreeChargeProcessor.charge_processor_id self.zip_check_result = nil self.id = braintree_charge.id self.status = braintree_charge.status.to_s....
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/braintree/braintree_chargeable_transient_customer.rb
Ruby
mit
8,966
main
2,484
# frozen_string_literal: true class BraintreeChargeableTransientCustomer < BraintreeChargeableBase TRANSIENT_CLIENT_TOKEN_VALIDITY_DURATION = 5.minutes attr_accessor :customer_id, :transient_customer_store_key def initialize(customer_id, transient_customer_store_key) @customer_id = customer_id @transie...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/braintree/braintree_card_type.rb
Ruby
mit
8,966
main
510
# frozen_string_literal: true class BraintreeCardType CARD_TYPES = { "Visa" => CardType::VISA, "American Express" => CardType::AMERICAN_EXPRESS, "MasterCard" => CardType::MASTERCARD, "Discover" => CardType::DISCOVER, "JCB" => CardType::JCB, "Diners Club" => CardType::DINERS_CLUB, CardType...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/braintree/braintree_charge_refund.rb
Ruby
mit
8,966
main
490
# frozen_string_literal: true class BraintreeChargeRefund < ChargeRefund def initialize(braintree_transaction) self.charge_processor_id = BraintreeChargeProcessor.charge_processor_id self.id = braintree_transaction.id self.charge_id = braintree_transaction.refunded_transaction_id currency = Currency...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/braintree/braintree_chargeable_credit_card.rb
Ruby
mit
8,966
main
945
# frozen_string_literal: true # Public: Chargeable representing a card stored at Braintree. class BraintreeChargeableCreditCard attr_reader :fingerprint, :last4, :number_length, :visual, :expiry_month, :expiry_year, :zip_code, :card_type, :country attr_reader :braintree_customer_id def initialize(reusable_token...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/paypal/paypal_rest_api.rb
Ruby
mit
8,966
main
7,729
# frozen_string_literal: true class PaypalRestApi include CurrencyHelper PAYPAL_INTENT_CAPTURE = "CAPTURE" def initialize paypal_environment = Rails.env.production? ? PayPal::LiveEnvironment.new(PAYPAL_PARTNER_CLIENT_ID, PAYPAL_PARTNER_CLIENT_SECRET) : ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/paypal/paypal_card_fingerprint.rb
Ruby
mit
8,966
main
277
# frozen_string_literal: true module PaypalCardFingerprint PAYPAL_FINGERPRINT_PREFIX = "paypal_" private_constant :PAYPAL_FINGERPRINT_PREFIX def self.build_paypal_fingerprint(email) return "#{PAYPAL_FINGERPRINT_PREFIX}#{email}" if email.present? nil end end
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/paypal/paypal_approved_order_chargeable.rb
Ruby
mit
8,966
main
564
# frozen_string_literal: true class PaypalApprovedOrderChargeable attr_reader :fingerprint, :last4, :number_length, :visual, :expiry_month, :expiry_year, :zip_code, :card_type, :country, :funding_type, :email def initialize(order_id, visual, country) @fingerprint = order_id @visual = visual ...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/paypal/paypal_charge_refund.rb
Ruby
mit
8,966
main
349
# frozen_string_literal: true class PaypalChargeRefund < ChargeRefund include CurrencyHelper def initialize(paypal_refund_response, charge_id) self.charge_processor_id = PaypalChargeProcessor.charge_processor_id self.id = paypal_refund_response.RefundTransactionID self.charge_id = charge_id self.f...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/paypal/paypal_charge_processor.rb
Ruby
mit
8,966
main
35,155
# frozen_string_literal: true class PaypalChargeProcessor extend PaypalApiResponse extend CurrencyHelper DISPLAY_NAME = "PayPal" MAXIMUM_DESCRIPTOR_LENGTH = 22 MAXIMUM_ITEM_NAME_LENGTH = 127 PAYPAL_VALID_CHARACTERS_REGEX = /[^A-Z0-9. ]/i private_constant :PAYPAL_VALID_CHARACTERS_REGEX DISPUTE_OUTC...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/paypal/paypal_chargeable.rb
Ruby
mit
8,966
main
706
# frozen_string_literal: true class PaypalChargeable attr_reader :billing_agreement_id, :fingerprint, :last4, :number_length, :visual, :expiry_month, :expiry_year, :zip_code, :card_type, :country, :funding_type, :email, :payment_method_id def initialize(billing_agreement_id, visual, country) @bi...
github
antiwork/gumroad
https://github.com/antiwork/gumroad
app/business/payments/charging/implementations/paypal/paypal_order_refund.rb
Ruby
mit
8,966
main
273
# frozen_string_literal: true class PaypalOrderRefund < ChargeRefund def initialize(response, capture_id) self.charge_processor_id = PaypalChargeProcessor.charge_processor_id self.charge_id = capture_id self.id = response.id @refund = response end end