2019-07-30 21:29:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2020-06-12 20:03:43 +00:00
|
|
|
# License: AGPL-3.0-or-later WITH WTO-AP-3.0-or-later
|
|
|
|
# Full license explanation at https://github.com/houdiniproject/houdini/blob/master/LICENSE
|
2018-03-25 17:30:42 +00:00
|
|
|
require 'stripe'
|
|
|
|
require 'calculate/calculate_fees'
|
|
|
|
|
|
|
|
module StripeUtils
|
2019-07-30 21:29:24 +00:00
|
|
|
# Get the verification status from a stripe object
|
|
|
|
# Some of our accounts seem to be marked 'Unverified,' but have no
|
|
|
|
# fields_needed set and have transfers_enabled set to true. So for our system,
|
|
|
|
# that practically means they are verified.
|
|
|
|
def self.get_verification_status(stripe_acct)
|
|
|
|
return 'verified' if stripe_acct.transfers_enabled
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
stripe_acct.legal_entity.verification.status
|
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
def self.create_transfer(net_amount, stripe_account_id, currency)
|
|
|
|
Stripe::Transfer.create({
|
|
|
|
amount: net_amount,
|
2020-06-10 22:31:47 +00:00
|
|
|
currency: currency || Houdini.intl.currencies[0],
|
2019-07-30 21:29:24 +00:00
|
|
|
recipient: 'self'
|
|
|
|
},
|
|
|
|
stripe_account: stripe_account_id)
|
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
def self.create_refund(stripe_charge, amount, reason)
|
|
|
|
stripe_charge.refunds.create(
|
|
|
|
amount: amount,
|
|
|
|
refund_application_fee: true,
|
|
|
|
reverse_transfer: true,
|
|
|
|
reason: reason
|
|
|
|
)
|
|
|
|
end
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|