Class: Pay::Stripe::Merchant

Inherits:
Object
  • Object
show all
Defined in:
lib/pay/stripe/merchant.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pay_merchant) ⇒ Merchant

Returns a new instance of Merchant.



9
10
11
# File 'lib/pay/stripe/merchant.rb', line 9

def initialize(pay_merchant)
  @pay_merchant = pay_merchant
end

Instance Attribute Details

#pay_merchantObject (readonly)

Returns the value of attribute pay_merchant.



4
5
6
# File 'lib/pay/stripe/merchant.rb', line 4

def pay_merchant
  @pay_merchant
end

Instance Method Details

#accountObject



29
30
31
32
33
# File 'lib/pay/stripe/merchant.rb', line 29

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


35
36
37
38
39
40
41
42
43
44
# File 'lib/pay/stripe/merchant.rb', line 35

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



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/pay/stripe/merchant.rb', line 13

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

   = ::Stripe::Account.create(defaults.merge(options))
  pay_merchant.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



47
48
49
50
51
# File 'lib/pay/stripe/merchant.rb', line 47

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



55
56
57
58
59
60
61
62
63
# File 'lib/pay/stripe/merchant.rb', line 55

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