omise / examples

Examples for implementing Omise Libraries
GNU General Public License v2.0
16 stars 50 forks source link

[WIP] Rails demo #6

Closed fred closed 1 year ago

fred commented 9 years ago

Rails demo application with Token and Charge creation

robinclart commented 9 years 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
fred commented 9 years ago

cool, I will add that functionality soon.

robinclart commented 9 years ago

OK great :smile:

robinclart commented 9 years ago

Will you do it in this PR or you want this merged first and do a new one later?

fred commented 9 years ago

I'll do in this PR since I might change the database structure.