Module: CoinbaseCommerceClient::Webhook
- Defined in:
- lib/coinbase_commerce_client/webhooks.rb
Defined Under Namespace
Modules: WebhookSignature
Class Method Summary collapse
Class Method Details
.construct_event(payload, sig_header, secret) ⇒ Object
3 4 5 6 7 8 9 10 11 |
# File 'lib/coinbase_commerce_client/webhooks.rb', line 3 def self.construct_event(payload, sig_header, secret) data = JSON.parse(payload, symbolize_names: true) if data.key?(:event) WebhookSignature.verify_header(payload, sig_header, secret) CoinbaseCommerceClient::APIResources::Event.create_from(data[:event]) else raise CoinbaseCommerceClient::Errors::WebhookInvalidPayload.new("No event in payload", sig_header, http_body: payload) end end |