diff options
-rwxr-xr-x | src/testing/test_merchant_order_creation.sh | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/testing/test_merchant_order_creation.sh b/src/testing/test_merchant_order_creation.sh index 175667b9..bf1c5d02 100755 --- a/src/testing/test_merchant_order_creation.sh +++ b/src/testing/test_merchant_order_creation.sh @@ -244,6 +244,46 @@ fi echo "OK" # +# CREATE TOKEN FAMILY AND V1 ORDER WITH CHOICES +# +echo -n "Creating token family..." +NOW=$(date +%s) +IN_A_YEAR=$((NOW + 31536000)) +STATUS=$(curl 'http://localhost:9966/private/tokenfamilies' \ + -d '{"slug":"test-sub","kind":"subscription","description":"Test token family","name":"Test Subscription","valid_after":{"t_s":'$NOW'},"valid_before":{"t_s":'$IN_A_YEAR'},"duration": {"d_us": 2592000000}}' \ + -w "%{http_code}" -s -o "$LAST_RESPONSE") + +if [ "$STATUS" != "204" ] +then + cat "$LAST_RESPONSE" >&2 + exit_fail "Expected 204, token family created. got: $STATUS" +fi + +echo -n "Creating v1 order with token family..." +STATUS=$(curl 'http://localhost:9966/private/orders' \ + -d '{"order":{"version":"1","amount":"TESTKUDOS:7","summary":"with_subscription","fulfillment_message":"Payed successfully","choices":[{"inputs":[{"kind":"token","count":1,"token_family_slug":"test-sub","valid_after":{"t_s":'$NOW'}}],"outputs":[{"kind":"token","count":1,"token_family_slug":"test-sub","valid_after":{"t_s":'$NOW'}}]}]}}' \ + -w "%{http_code}" -s -o "$LAST_RESPONSE") + +if [ "$STATUS" != "200" ] +then + cat "$LAST_RESPONSE" >&2 + exit_fail "Expected 200, order created. got: $STATUS" +fi + +ORDER_ID=$(jq -r .order_id < "$LAST_RESPONSE") +TOKEN=$(jq -r .token < "$LAST_RESPONSE") + +STATUS=$(curl http://localhost:9966/orders/"$ORDER_ID"/claim \ + -d '{"nonce":"","token":"'"$TOKEN"'"}' \ + -w "%{http_code}" -s -o "$LAST_RESPONSE") + +if [ "$STATUS" != "200" ] +then + cat "$LAST_RESPONSE" >&2 + exit_fail "Expected 200, order claimed. got: $STATUS" +fi + +# # CREATE ORDER WITH NON-INVENTORY AND CHECK # |