Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
credit_card_controller
# app/controllers/api/v1/credit_cards_controller.rb
module Api
module V1
class CreditCardsController < Api::V1::ApiController
helper_method :shop
def index
service = StripeService.new(shop)
@card = service.credit_card_info
@customer = service.customer
end
def create
StripeService.new(shop).add_card(token_id, email, customer_name) if token_id
head :no_content
end
def update
begin
StripeService.new(shop).update_credit_card(token_id)
rescue StripeService::StripeException => ex
return render_not_found(ex.message)
end
head :no_content
end
private
def shop
@shop ||= current_shop
end
def token_json
params[:token]
end
def token_id
token_json['id']
end
def email
token_json['email']
end
def customer_name
token_json['name']
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.