Class: Pay::Stripe::Merchant

Inherits:
Merchant show all
Defined in:
app/models/pay/stripe/merchant.rb

Instance Method Summary collapse

Methods inherited from Merchant

#onboarding_complete?

Instance Method Details

#accountObject



20
21
22
23
24
# File 'app/models/pay/stripe/merchant.rb', line 20

def 
  ::Stripe::Account.retrieve(processor_id)
rescue ::Stripe::StripeError => e
  raise Pay::Stripe::Error, e
end


26
27
28
29
30
31
32
33
34
35
# File 'app/models/pay/stripe/merchant.rb', line 26

def (refresh_url:, return_url:, type: "account_onboarding", **options)
  ::Stripe::AccountLink.create({
    account: processor_id,
    refresh_url: refresh_url,
    return_url: return_url,
    type: type
  }.merge(options))
rescue ::Stripe::StripeError => e
  raise Pay::Stripe::Error, e
end

#create_account(**options) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/models/pay/stripe/merchant.rb', line 4

def (**options)
  defaults = {
    type: "express",
    capabilities: {
      card_payments: {requested: true},
      transfers: {requested: true}
    }
  }

   = ::Stripe::Account.create(defaults.merge(options))
  update(processor_id: .id)
  
rescue ::Stripe::StripeError => e
  raise Pay::Stripe::Error, e
end

A single-use login link for Express accounts to access their Stripe dashboard



38
39
40
41
42
# File 'app/models/pay/stripe/merchant.rb', line 38

def (**options)
  ::Stripe::Account.(processor_id)
rescue ::Stripe::StripeError => e
  raise Pay::Stripe::Error, e
end

#transfer(amount:, currency: "usd", **options) ⇒ Object

Transfer money from the platform to this connected account stripe.com/docs/connect/charges-transfers#transfer-availability



46
47
48
49
50
51
52
53
54
# File 'app/models/pay/stripe/merchant.rb', line 46

def transfer(amount:, currency: "usd", **options)
  ::Stripe::Transfer.create({
    amount: amount,
    currency: currency,
    destination: processor_id
  }.merge(options))
rescue ::Stripe::StripeError => e
  raise Pay::Stripe::Error, e
end