-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·142 lines (112 loc) · 4.56 KB
/
test.sh
File metadata and controls
executable file
·142 lines (112 loc) · 4.56 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
delay=1
set -e
base_url=http://localhost:8080
# get to /features
features_response=$(curl -sS -X 'GET' \
"$base_url/ALJAZ/fiatlink/1.0.0/features" \
-H 'accept: application/json')
echo $features_response | jq -r .
# get to /verify
verify_response=$(curl -sS -X 'GET' \
"$base_url/ALJAZ/fiatlink/1.0.0/verify" \
-H 'accept: application/json')
echo $verify_response | jq -r .
# post to /session
session_response=$(curl -sS -X 'POST' \
"$base_url/ALJAZ/fiatlink/1.0.0/session" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"app_id": "8ed13c2a-a8c6-4f0e-b43e-3fdbf1f094a6",
"node_pubkey": "0288037d3f0bdcfb240402b43b80cdc32e41528b3e2ebe05884aff507d71fca71a",
"session_id": "d7ef9a88-1ca1-4ac8-bc9e-da3d9824cdc5",
"signature": "rdfe8mi98o7am51jpocda1zp5d8scdu7rg65nn73fs6mb69t4byer9xned1hntkeq1pqdct9z5owx6bg58w5fmny6p5q783dce8ittjh"
}')
echo $session_response | jq -r .
session_id=$(echo $session_response | jq -r .session_id)
echo session_id $session_id
# post to /payment-options
payment_options_response=$(curl -sS -X 'POST' \
"$base_url/ALJAZ/fiatlink/1.0.0/payment-options" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"currency_code": "EUR",
"session_id": "'$session_id'"
}')
echo $payment_options_response | jq -r .
# post to /quote
quote_response=$(curl -sS -X 'POST' \
"$base_url/ALJAZ/fiatlink/1.0.0/quote" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"amount_fiat": 100,
"currency_id": 1,
"payment_option_id": 1,
"session_id": "d7ef9a88-1ca1-4ac8-bc9e-da3d9824cdc5"
}')
echo $quote_response | jq -r .
quote_id=$(echo $quote_response | jq -r .quote_id)
echo quote_id $quote_id
sleep ${delay}
#post to /order
order_response=$(curl -sS -X 'POST' \
"$base_url/ALJAZ/fiatlink/1.0.0/order" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"quote_id": "'$quote_id'",
"session_id": "d7ef9a88-1ca1-4ac8-bc9e-da3d9824cdc5",
"webhook_url": "https://webhook.example.com/"
}')
echo $order_response | jq -r .
echo $order_response | jq -r .order_status
#mark the order as settled
api_key=215b9e349fa918023654d6982a68e05d26beb851
store_id=6WGmyJNq1AvQD9n5JZipn1wSt4Nh86wwUv6xYSzEdtui
#invoice_id=$(python3 -c "import uuid; import base64; print(base64.urlsafe_b64encode(uuid.UUID('"${quote_id}"').bytes).decode('utf-8').rstrip('='))")
invoice_id=$(python3 -c "import uuid; import base64; quote_id='"${quote_id}"'; print(base64.urlsafe_b64encode(uuid.UUID(quote_id).bytes).decode('utf-8').rstrip('='))")
echo $invoice_id
python3 -c "from swagger_server.controllers.invoice_helper import convert_id_to_uuid; id='"$invoice_id"'; uuid = convert_id_to_uuid(id); print(uuid)"
echo invoice_id $invoice_id
echo invoice_id $invoice_id
curl -X POST https://signet.demo.btcpayserver.org/api/v1/stores/${store_id}/invoices/${invoice_id}/status -H 'Authorization: token 7275e951ef1e37d36e612fa28963602546155fab' -H 'Content-Type: application/json' -d '{"status": "Settled"}'
sleep 5
exit
# {"missingPermission":"btcpay.store.canmodifyinvoices","code":"missing-permission","message":"Insufficient API Permissions. Please use an API key with permission \"btcpay.store.canmodifyinvoices\". You can create an API key in your account's settings / Api Keys."}%
#post to /order-status after a few seconds seconds. order should be marked as paid now
sleep ${delay}
order_status_response=$(curl -sS -X 'POST' \
"$base_url/ALJAZ/fiatlink/1.0.0/order-status" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"order_id": "'$quote_id'",
"session_id": "d7ef9a88-1ca1-4ac8-bc9e-da3d9824cdc5"
}')
echo $order_status_response | jq
echo $order_status_response | jq -r '."'$quote_id'".order_status'
#post to /withdrawal
withdrawal_response=$(curl -sS -X 'POST' \
"$base_url/ALJAZ/fiatlink/1.0.0/withdrawal" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"failback_onchain": "bc1qcmu7kcwrndyke09zzyl0wv3dqxwlzqkma248kj",
"order_id": "'$quote_id'",
"session_id": "d7ef9a88-1ca1-4ac8-bc9e-da3d9824cdc5"
}')
echo $withdrawal_response | jq -r .
#post to /order-status after withdraw. should be finished
order_status_response=$(curl -sS -X 'POST' \
"$base_url/ALJAZ/fiatlink/1.0.0/order-status" \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"order_id": "'$quote_id'",
"session_id": "d7ef9a88-1ca1-4ac8-bc9e-da3d9824cdc5"
}')
echo $order_status_response | jq
echo $order_status_response | jq -r '."'$quote_id'".order_status'