##説明
Pay.jpという、クレジット決済のapiで、webhockを、受け取りたいが受け取れない。#webhockに、webhockのイベントを送っています。
##code
Ruby
1 2class WebhockController< ApplicationController 3 protect_from_forgery :except=>[:create] 4 5 def create 6 Payjp.api_key = '入力していま 7す。セキュリティー上非表示です。' 8 event = Payjp::Event.retrieve(params[:id]) 9 10 case event.type 11 when 'subscription.updated' 12 subscription = event.data.object 13 user = User.find_by(stripe_subscription_id: subscription.id) 14 user.update_subscription(subscription) 15 when 'subscription.created' 16 current_user.test 17 end 18 19 head :ok 20 end 21end
ruby
1post "webhock"=>"webhock#create"
##環境
Heroku
あなたの回答
tips
プレビュー