Skip to content

Instantly share code, notes, and snippets.

@xslim
Last active August 21, 2018 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xslim/cd637d126ca98e6a512215c1b1e0a71f to your computer and use it in GitHub Desktop.
Save xslim/cd637d126ca98e6a512215c1b1e0a71f to your computer and use it in GitHub Desktop.
#!/bin/bash
POIID=YOUR_TERMINAL_SERIAL_NUMBER
url=https://terminal-api-test.adyen.com/sync
apikey="YOUR_CHECKOUT_API_KEY"
SaleID="${USER}-${HOSTNAME}"
ServiceID=$(date +%m%d%H%M%S)
TransactionID=$RANDOM
TimeStamp=$(date -u +%FT%T+00:00)
Currency=EUR
RequestedAmount=10.00
cat > req.json << EOF
{
"SaleToPOIRequest": {
"MessageHeader": {
"ProtocolVersion":"3.0",
"MessageClass":"Service",
"MessageCategory":"Payment",
"MessageType":"Request",
"ServiceID":"$ServiceID",
"SaleID":"$SaleID",
"POIID":"$POIID"
},
"PaymentRequest": {
"SaleData": {
"SaleTransactionID": {
"TransactionID": "$TransactionID",
"TimeStamp": "$TimeStamp"
}
},
"PaymentTransaction": {
"AmountsReq": {
"Currency": "$Currency",
"RequestedAmount": $RequestedAmount
}
}
}
}
}
EOF
_has_cmd () { command -v "$1" >/dev/null 2>&1 ; }
# Run Curl
_has_cmd git || return
curl -sk --data-binary @req.json -H "Content-Type: application/json" -H "X-API-Key: $apikey" $url > resp.json
_has_cmd jq || return
jq . req.json
jq . resp.json
rm req.json resp.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment