Non-Secure Payments, all required parameters must be provided.transaction_type parameter must be set to PreAuth.Pre-Authorization.generate_hash_key() {
local total="$1"
local installment="$2"
local currency_code="$3"
local merchant_key="$4"
local invoice_id="$5"
local app_secret="$6"
local data="${total}|${installment}|${currency_code}|${merchant_key}|${invoice_id}"
local rand1
rand1=$(openssl rand -hex 16)
local iv
iv=$(printf "%s" "$rand1" | openssl sha1 | awk '{print $2}' | cut -c1-16)
local password
password=$(printf "%s" "$app_secret" | openssl sha1 | awk '{print $2}')
local rand2
rand2=$(openssl rand -hex 16)
local salt
salt=$(printf "%s" "$rand2" | openssl sha1 | awk '{print $2}' | cut -c1-4)
local salt_with_password
salt_with_password=$(printf "%s" "${password}${salt}" | openssl sha256 | awk '{print $2}' | cut -c1-32)
local key_hex
key_hex=$(printf "%s" "$salt_with_password" | xxd -p -c 256)
local iv_hex
iv_hex=$(printf "%s" "$iv" | xxd -p -c 256)
local encrypted_base64
encrypted_base64=$(printf "%s" "$data" | openssl enc -aes-256-cbc -K "$key_hex" -iv "$iv_hex" -base64)
local msg_encrypted_bundle="${iv}:${salt}:${encrypted_base64}"
msg_encrypted_bundle="${msg_encrypted_bundle//\//__}"
echo "$msg_encrypted_bundle"
}
#Parameters
total=""
installment=""
currency_code=""
merchant_key=""
invoice_id=""
app_secret=""
result=$(generate_hash_key "$total" "$installment" "$currency_code" "$merchant_key" "$invoice_id" "$app_secret")
echo "$result"{
"status_code": 100,
"status_description": "Payment process successful",
"data": {
"sipay_status": 1,
"order_no": "VP17743537462607531",
"order_id": "VP17743537462607531",
"invoice_id": "preauth-deneme12345",
"sipay_payment_method": 1,
"credit_card_no": "450803****4509",
"transaction_type": "Pre-Authorization",
"payment_status": 1,
"payment_method": 1,
"error_code": 100,
"error": "",
"auth_code": "P38522",
"merchant_commission": 0.1,
"user_commission": 0,
"merchant_commission_percentage": 2,
"merchant_commission_fixed": 0,
"installment": 1,
"amount": 5,
"payment_reason_code": "",
"payment_reason_code_detail": "",
"hash_key": "731092f9125b0a94:4678:3daVYe4QTo5HfV5n48E7Cb42u2LPIY0lpz+KP+ABA5aR0NxMKsBN11yuOx9IJtdR",
"original_bank_error_code": "",
"original_bank_error_description": "",
"host_reference_id": "608300512593"
}
}