examples icon indicating copy to clipboard operation
examples copied to clipboard

[WIP] Rails demo

Open fred opened this issue 10 years ago • 5 comments

Rails demo application with Token and Charge creation

fred avatar May 18 '15 10:05 fred

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

robinclart avatar May 18 '15 10:05 robinclart

cool, I will add that functionality soon.

fred avatar May 18 '15 10:05 fred

OK great :smile:

robinclart avatar May 18 '15 10:05 robinclart

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

robinclart avatar May 18 '15 10:05 robinclart

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

fred avatar May 18 '15 10:05 fred