-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.liquid
49 lines (40 loc) · 1.25 KB
/
example.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
---
slug: apis/stripe_webhooks/process
method: post
authorization_policies:
- validate_stripe_signature
---
{% comment %}
This is a comment that does not say much.
{% endcomment %}
{{ "hej ho" }}
{% assign variable = "value" %}
{% assign header = request.request.headers['HTTP_STRIPE_SIGNATURE'] | split: ',' %}
{% comment %}
{% query_graph 'get_request_headers', result_name: 'request' %}
{% endcomment %}
{% capture signature_json %}
{
{% assign json_key = "json_vlaue" %}
{% comment %}
{% for element in header %}
{% assign kv = element | split: '=' %}
"{{ kv[0] }}": "{{ kv[1] }}"{% if forloop.last != true %},{% endif %}
{% endfor %}
{% endcomment %}
}
{% endcapture %}
{% assign signature_hash = signature_json | to_hash %}
{% assign params_json = request.request.body %}
{% assign signed_payload = signature_hash.t | append: '.' | append: params_json %}
{% assign signature = signed_payload | compute_hmac: context.constants.stripe_webhook_secret %}
{% comment %}
{% if signature == signature_hash.v1 %}
{% if params.type == 'payout.paid' %}
{% include 'webhooks/payout_paid' %}
{% elsif params.type == 'customer.source.expiring' %}
{% include 'webhooks/card_expiring' %}
{% endif %}
{% endif %}
{% endcomment %}
{{ "page end" }}