Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,14 @@ require 'smoothcode'

SmoothCodeAuth.new(request_hmac, client_secret).webhook_request?(webhook_data) # returns True if the request is valid
```

* `gdpr_webhook_request?(webhook_data)` - This method verifies if the webhook request is coming from `SmoothCode`
```ruby
require 'smoothcode'

# SmoothCode sends hmac in the Authorization Header of the request
# It is hmac of the shop id signed by your App Client Secret

SmoothCodeAuth.new(request_hmac, client_secret).gdpr_webhook_request?(webhook_data) # returns True if the request is valid
```
***
7 changes: 7 additions & 0 deletions lib/smoothcode/auth.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,11 @@ def webhook_request?(webhook_data)

generate_hmac(@client_secret, webhook_id.to_s) == @request_hmac
end

def gdpr_webhook_request?(webhook_data)
webhook_data = webhook_data.transform_keys(&:to_sym)
shop_id = webhook_data[:shop_id]

generate_hmac(@client_secret, shop_id.to_s) == @request_hmac
end
end
2 changes: 1 addition & 1 deletion smoothcode.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'smoothcode'
s.version = '0.0.3'
s.version = '0.0.4'
s.summary = 'Ruby client to interact with SmoothCode'
s.description = 'Ruby client to interact with SmoothCode'
s.authors = ['SmoothCode']
Expand Down