Я пытался настроить свой первый веб-сайт с полосой. Я нашел 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