0
例如,如果我故意讓卡片拒絕,我會看到錯誤頁面。像這樣: 而不是一個錯誤頁面我想用閃光燈來通知。我有下面的代碼,但爲什麼我沒有使用閃存提醒?當條紋驗證失敗時爲什麼我沒有顯示閃光燈?
class ChargesController < ApplicationController
def new
end
def create
# Amount in cents
@amount = 100
# Get the credit card details submitted by the form
customer = Stripe::Customer.create(
:email => params[:email],
:source => params[:stripeToken]
)
# Create the charge on Stripe's servers - this will charge the user's card
begin
Stripe::Charge.create(
:amount => @amount,
:currency => 'usd',
:customer => customer.id,
:description => 'Example charge custom form'
)
current_user.subscribed = true
current_user.stripe_id = customer.id
current_user.expiry_date = Date.today + 30.days
current_user.save
flash[:success] = "Thank you for subscribing. Your account has been unlocked."
redirect_to root_path
rescue Stripe::CardError => e
flash[:error] = e.message
redirect_to root_path
end
end
end
我不認爲這會改變什麼,除非我失去了一些東西! –
你試過了嗎?如果所有其他的'救援'都沒有做任何事情,'救援=>'應該抓住一些東西。 –