1
나는 레일과 함께 Shopify 앱을 그리고 난이 있습니다작업에서 webhook 데이터에 액세스하려면 어떻게합니까? (Shopify 레일)
webhooks_controller.rb
module ShopifyApp
class WebhooksController < ActionController::Base
include ShopifyApp::WebhookVerification
class ShopifyApp::MissingWebhookJobError < StandardError; end
def receive
params.try(:permit!)
job_args = {shop_domain: shop_domain, webhook: webhook_params.to_h}
webhook_job_klass.perform_later(job_args)
head :no_content
end
private
def webhook_params
params.except(:controller, :action, :type)
end
def webhook_job_klass
"#{webhook_type.classify}Job".safe_constantize or raise ShopifyApp::MissingWebhookJobError
end
def webhook_type
params[:type]
end
end
end
orders_create_job.rb을
class OrdersCreateJob < ActiveJob::Base
def perform(shop_domain:, webhook:)
shop = Shop.find_by(shopify_domain: shop_domain)
shop.with_shopify_session do
#DATA GOES HERE
end
end
end
"#DATA GOES HERE"에서 "shipping_l"의 "title"과 같은 webhook의 변수를 가져올 수 있습니까? ines "?
어떻게하면됩니까?