module JamRuby class AffiliatePaymentCharge < Charge #has_one :teacher_payment, class_name: "JamRuby::TeacherPayment", foreign_key: :affiliate_charge_id def distribution @distribution ||= teacher_payment.teacher_distribution end def max_retries 9999999 end def teacher @teacher ||= teacher_payment.teacher end def charged_user teacher end def do_charge # source will let you supply a token. But... how to get a token in this case? stripe_charge = Stripe::Charge.create( :amount => amount_in_cents, :currency => "usd", :customer => APP_CONFIG.stripe[:source_customer], :description => construct_description, :destination => teacher.teacher.stripe_account_id, :application_fee => fee_in_cents, ) stripe_charge end def do_send_notices #UserMailer.teacher_distribution_done(teacher_payment) end def do_send_unable_charge #UserMailer.teacher_distribution_fail(teacher_payment) end def construct_description #teacher_payment.teacher_distribution.description end end end