Closed fred closed 1 year ago
Not sure I'd do it this way. Maybe better to implement this in term of what people usually are looking for. Something like an Order
that you have to pay.
order = @current_customer.new_order(amount_subunits: 100000, currency: "thb")
@card = if params[:save_card].present?
@current_customer.attach_card(params[:omise_token])
elsif params[:card_id].present?
@current_customer.find_card(params[:card_id])
end
if @card
order.pay_with_customer_card(@card.id)
else
order.pay_with_token(params[:omise_token])
end
if order.paid?
redirect_to thanks_url(order)
else
redirect_to checkout_url
end
cool, I will add that functionality soon.
OK great :smile:
Will you do it in this PR or you want this merged first and do a new one later?
I'll do in this PR since I might change the database structure.
Rails demo application with Token and Charge creation