Class: Pay::Stripe::Merchant
- Inherits:
-
Object
- Object
- Pay::Stripe::Merchant
- Defined in:
- lib/pay/stripe/merchant.rb
Instance Attribute Summary collapse
-
#pay_merchant ⇒ Object
readonly
Returns the value of attribute pay_merchant.
Instance Method Summary collapse
- #account ⇒ Object
- #account_link(refresh_url:, return_url:, type: "account_onboarding", **options) ⇒ Object
- #create_account(**options) ⇒ Object
-
#initialize(pay_merchant) ⇒ Merchant
constructor
A new instance of Merchant.
-
#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.
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_merchant ⇒ Object (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
#account ⇒ Object
29 30 31 32 33 |
# File 'lib/pay/stripe/merchant.rb', line 29 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
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/pay/stripe/merchant.rb', line 35 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
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pay/stripe/merchant.rb', line 13 def create_account(**) defaults = { type: "express", capabilities: { card_payments: {requested: true}, transfers: {requested: true} } } stripe_account = ::Stripe::Account.create(defaults.merge()) pay_merchant.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
47 48 49 50 51 |
# File 'lib/pay/stripe/merchant.rb', line 47 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
55 56 57 58 59 60 61 62 63 |
# File 'lib/pay/stripe/merchant.rb', line 55 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 |