merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

test_merchant_kyc.sh (3932B)


      1 #!/bin/bash
      2 # This file is part of TALER
      3 # Copyright (C) 2014-2023 Taler Systems SA
      4 #
      5 # TALER is free software; you can redistribute it and/or modify
      6 # it under the terms of the GNU General Public License as
      7 # published by the Free Software Foundation; either version 3, or
      8 # (at your option) any later version.
      9 #
     10 # TALER is distributed in the hope that it will be useful, but
     11 # WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 # GNU General Public License for more details.
     14 #
     15 # You should have received a copy of the GNU General Public
     16 # License along with TALER; see the file COPYING.  If not, see
     17 # <http://www.gnu.org/licenses/>
     18 #
     19 set -eu
     20 
     21 . setup.sh
     22 
     23 
     24 # Launch system.
     25 setup \
     26     -c "test_template.conf" \
     27     -mef \
     28     -r "merchant-exchange-default" \
     29     -u "exchange-account-2"
     30 LAST_RESPONSE=$(mktemp -p "${TMPDIR:-/tmp}" test_response.conf-XXXXXX)
     31 
     32 echo -n "Configuring a merchant admin instance ..."
     33 
     34 STATUS=$(curl -H "Content-Type: application/json" -X POST \
     35     -H 'Authorization: Bearer secret-token:super_secret' \
     36     http://localhost:9966/management/instances \
     37     -d '{"auth":{"method":"external"},"id":"admin","name":"default","user_type":"business","address":{},"jurisdiction":{},"use_stefan":true,"default_wire_transfer_delay":{"d_us" : 50000000},"default_pay_delay":{"d_us": 60000000}}' \
     38     -w "%{http_code}" -s -o /dev/null)
     39 
     40 if [ "$STATUS" != "204" ]
     41 then
     42     exit_fail "Expected 204 ok, instance created. got: $STATUS"
     43 fi
     44 
     45 STATUS=$(curl -H "Content-Type: application/json" -X POST \
     46     -H 'Authorization: Bearer secret-token:super_secret' \
     47     http://localhost:9966/private/accounts \
     48     -d '{"payto_uri":"payto://x-taler-bank/localhost:8082/43?receiver-name=user43"}' \
     49     -w "%{http_code}" -s -o /dev/null)
     50 
     51 
     52 if [ "$STATUS" != "200" ]
     53 then
     54     exit_fail "Expected 200 OK. Got: $STATUS"
     55 fi
     56 
     57 STATUS=$(curl -H "Content-Type: application/json" -X POST \
     58     -H 'Authorization: Bearer secret-token:super_secret' \
     59     http://localhost:9966/private/accounts \
     60     -d '{"payto_uri":"payto://x-taler-bank/localhost:8082/44?receiver-name=user44"}' \
     61     -w "%{http_code}" -s -o /dev/null)
     62 
     63 
     64 if [ "$STATUS" != "200" ]
     65 then
     66     exit_fail "Expected 200 OK. Got: $STATUS"
     67 fi
     68 
     69 echo " OK"
     70 
     71 echo -n "Check the instance exists ..."
     72 
     73 STATUS=$(curl -H "Content-Type: application/json" -X GET \
     74     http://localhost:9966/private/ \
     75     -w "%{http_code}" -s -o /dev/null)
     76 
     77 if [ "$STATUS" != "200" ]
     78 then
     79     exit_fail "Expected 200 ok, instance exists. got: $STATUS"
     80 fi
     81 
     82 echo " OK"
     83 
     84 RANDOM_IMG='data:image/png;base64,abcdefg'
     85 
     86 #
     87 # CREATE AN ORDER WITHOUT TOKEN
     88 #
     89 
     90 echo -n "Creating order without TOKEN..."
     91 STATUS=$(curl 'http://localhost:9966/private/orders' \
     92     -d '{"create_token":false,"order":{"amount":"TESTKUDOS:7","summary":"3","products":[{"description":"desct","image":"'"$RANDOM_IMG"'","price":"TESTKUDOS:1","taxes":[],"unit":"u","quantity":1}]}}' \
     93     -w "%{http_code}" -s -o "$LAST_RESPONSE")
     94 
     95 if [ "$STATUS" != "200" ]
     96 then
     97     echo "Should respond 200 OK, order created. got: $STATUS"
     98     jq < "$LAST_RESPONSE"
     99     exit 1
    100 fi
    101 
    102 ORDER_ID=$(jq -r .order_id < "$LAST_RESPONSE")
    103 TOKEN=$(jq -r .token < "$LAST_RESPONSE")
    104 
    105 if [ "$TOKEN" != "null" ]
    106 then
    107     exit_fail "Token should be null, got: $TOKEN"
    108 fi
    109 
    110 echo "OK"
    111 
    112 echo -n "Checking created order without TOKEN..."
    113 
    114 STATUS=$(curl http://localhost:9966/orders/$ORDER_ID \
    115     -w "%{http_code}" -s -o "$LAST_RESPONSE")
    116 
    117 PAY_URI=$(jq -r .taler_pay_uri < "$LAST_RESPONSE")
    118 
    119 if [ "$PAY_URI" == "null" ]
    120 then
    121     cat "$LAST_RESPONSE"
    122     exit_fail "Expected a taler_pay_uri. Got: $PAY_URI"
    123 fi
    124 echo "OK"
    125 
    126 
    127 echo -n "Getting information about KYC ..."
    128 
    129 STATUS=$(curl -H "Content-Type: application/json" -X GET \
    130     http://localhost:9966/private/kyc \
    131     -w "%{http_code}" -s -o /dev/null)
    132 
    133 if [ "$STATUS" != "200" ]
    134 then
    135     exit_fail "Expected 200. got: $STATUS"
    136 fi
    137 
    138 echo " OK"
    139 
    140 exit 0