스트라이프가있는 첫 번째 웹 후크를 설정하려고했습니다. article이 올바른 방법이지만 2 년 전인 것처럼 보입니다. 나는 그것이 구식이라고 생각하고 있습니다.레일 용 스트라이프 webhooks 4
여기 내 컨트롤러가 있습니다.
class StripewebhooksController < ApplicationController
# Set your secret key: remember to change this to your live secret key in production
# See your keys here https://manage.stripe.com/account
Stripe.api_key = "mytestapikey"
require 'json'
post '/stripewebhooks' do
data = JSON.parse request.body.read, :symbolize_names => true
p data
puts "Received event with ID: #{data[:id]} Type: #{data[:type]}"
# Retrieving the event from the Stripe API guarantees its authenticity
event = Stripe::Event.retrieve(data[:id])
# This will send receipts on succesful invoices
# You could also send emails on all charge.succeeded events
if event.type == 'invoice.payment_succeeded'
email_invoice_receipt(event.data.object)
end
end
end
올바른 방법일까요? 다음은 스트라이프 documentation입니다.
가장 좋은 방법은 코드를 실행하여 직접 확인하는 것입니다. – rb512