Last active
March 6, 2017 21:14
-
-
Save iCreateJB/63baa20ae7b6ac69ace2713dfe4479f0 to your computer and use it in GitHub Desktop.
Consolidated Interface to payment services
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BraintreePayment | |
class << self | |
def cancel_plan! | |
end | |
def charge! | |
end | |
def fetch_customer! | |
end | |
def list | |
end | |
def skip_event? | |
end | |
def update_customer! | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PaymentService | |
include BraintreePayment | |
include StripePayment | |
class << self | |
def create(provider:, user_id:, token:, plan:) | |
service(provider: provider).charge!(user_id: user_id, token: token, plan: plan) | |
end | |
def list(provider:) | |
service(provider: provider).list | |
end | |
def process_event!(event:, provider:) | |
service(provier: provider).process!(event: event) | |
end | |
protected | |
def service(provider:) | |
raise if provider.blank? | |
provider.to_s.classify.constantize | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StripePayment | |
class << self | |
def cancel_plan! | |
end | |
def charge! | |
end | |
def fetch_customer! | |
end | |
def list | |
end | |
def skip_event? | |
end | |
def update_customer! | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment