Class: Pay::Stripe::Merchant
- Inherits:
-
Merchant
- Object
- ApplicationRecord
- Merchant
- Pay::Stripe::Merchant
- Defined in:
- app/models/pay/stripe/merchant.rb
Instance Method Summary collapse
- #account ⇒ Object
- #account_link(refresh_url:, return_url:, type: "account_onboarding", **options) ⇒ Object
- #create_account(**options) ⇒ Object
-
#login_link(**options) ⇒ Object
A single-use login link for Express accounts to access their Stripe dashboard.
-
#transfer(amount:, currency: "usd", **options) ⇒ Object
Transfer money from the platform to this connected account stripe.com/docs/connect/charges-transfers#transfer-availability.
Methods inherited from Merchant
Instance Method Details
#account ⇒ Object
20 21 22 23 24 |
# File 'app/models/pay/stripe/merchant.rb', line 20 def account ::Stripe::Account.retrieve(processor_id) rescue ::Stripe::StripeError => e raise Pay::Stripe::Error, e end |
#account_link(refresh_url:, return_url:, type: "account_onboarding", **options) ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'app/models/pay/stripe/merchant.rb', line 26 def account_link(refresh_url:, return_url:, type: "account_onboarding", **) ::Stripe::AccountLink.create({ account: processor_id, refresh_url: refresh_url, return_url: return_url, type: type }.merge()) 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 create_account(**) defaults = { type: "express", capabilities: { card_payments: {requested: true}, transfers: {requested: true} } } stripe_account = ::Stripe::Account.create(defaults.merge()) update(processor_id: stripe_account.id) stripe_account rescue ::Stripe::StripeError => e raise Pay::Stripe::Error, e end |
#login_link(**options) ⇒ Object
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 login_link(**) ::Stripe::Account.create_login_link(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", **) ::Stripe::Transfer.create({ amount: amount, currency: currency, destination: processor_id }.merge()) rescue ::Stripe::StripeError => e raise Pay::Stripe::Error, e end |