나는 지불을 처리하기 위해 스트라이프를 사용하고 있습니다. 내가 트랜잭션 블록을 사용하고 있습니다 이유는 확인하는 것입니다 그 다음 성공하거나 전혀 없음 :트랜잭션 블록이 실패 할 경우 새 렌더링 방법은 무엇입니까?
- 지불 기록이
- 스트라이프 지불
한 가지 실행되는 DB에 기록됩니다 나는 일할 수 없다. rescue
블록이다. Story에게 의도하지 않게 거래를 실패하게하는 잘못된 신용 카드를 제공하고 있습니다. 실패 그러나, 그것은하지 않습니다 render :new
def create
manager = current_session.manager
plan = Plan.find params[:plan_id]
Payment.transaction do
Payment.create(
plan_id: params[:plan_id],
management_id: current_session.management.id
)
begin
stripe_customer = Stripe::Customer.retrieve(manager.payment_provider_customer_id) if manager.try(:payment_provider_customer_id).present?
if stripe_customer.present?
# do something here
else
stripe_customer = Stripe::Customer.create(
email: manager.email,
metadata: {
manager_id: manager.id
}
)
stripe_customer.cards.create(card: 'zzzzzzzzzzzz')
stripe_customer.subscriptions.create(plan: plan.payment_provider_plan_id)
end
rescue => error
# If any of the Stripe requests fail, then we must also rollback the payment transaction
puts "Error: #{error}"
raise ActiveRecord::Rollback
render :new
else
redirect_to root_path, notice: 'Thank you. Your payment is being processed.'
end
end
end
내가 오류는 다음과 같습니다
Missing template dashboard/payments/create, dashboard/application/create, application/create with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee, :slim]}
정지하여 템플릿을 만들 렌더링
요구하고있다 같은 '템플릿이 없습니다.'오류가 발생했습니다. 그것은 여전히 템플릿을 생성하려고 시도하고있는 것 같습니다. –
'puts' 문이 출력 되었습니까? –
Yeap, 확실 했어 –