File: /var/www/selfanalyse/wp-content/plugins/psychometrics/api/psy_functions.php
<?php
function invoice($type,$txn_type, $ref_id, $order_id, $amount, $txn_id,$user_id, $user_name, $email, $user_address, $user_state, $date)
{
//include("../../../../wp-config.php");
global $wpdb;
$PSY_INVOICE = $wpdb->prefix . PSY_INVOICE;
$date = date('Y-m-d H:i:s');
$insertInvoice = "INSERT into $PSY_INVOICE set type_extn='$txn_type', type='$type',type_id='$ref_id', order_amount='$amount', order_id='$order_id', transaction_id='$txn_id', user_id='$user_id', name='$user_name', email='$email',address='$user_address',state_id='$user_state', txn_date='$date', issue_date='$date'";
$invoiceInsert = $wpdb->query($insertInvoice);
}
// to save data from different platform to specific database to handle all transaction
function getPaymentInvoice($from_domain, $if_vendor, $transaction_type, $payment_for, $payment_type, $order_id, $product_mrp, $gst_rate, $gepl_amount, $discount_amount, $net_amount, $customer_name, $customer_address, $customer_mobile, $customer_email, $customer_gst_name, $customer_gstin, $customer_state_id, $customer_state_code, $customer_state_name,$year_extn, $transaction_id1, $transaction_id2, $transaction_date, $ref_name1, $ref_id1, $ref_name2, $ref_id2, $ref_name3, $ref_id3)
{
$cipher = "aes-256-cbc";
$encryption_key = "unbox-enc2022";
$apiData = array("from_domain" => $from_domain, "if_vendor" => $if_vendor, "transaction_type" => $transaction_type, "payment_for" => $payment_for, "payment_type" => $payment_type, "order_id" => $order_id, "product_mrp" => $product_mrp, "gst_rate" => $gst_rate, "gepl_amount" => $gepl_amount, "discount_amount" => $discount_amount, "net_amount" => $net_amount, "customer_name" => $customer_name, "customer_address" => $customer_address, "customer_mobile" => $customer_mobile, "customer_email" => $customer_email, "customer_gst_name" => $customer_gst_name, "customer_gstin" => $customer_gstin, "customer_state_id" => $customer_state_id, "customer_state_code" => $customer_state_code, "customer_state_name" => $customer_state_name, "year_extn" => $year_extn, "transaction_id1" => $transaction_id1, "transaction_id2" => $transaction_id2, "transaction_date" => $transaction_date, "ref_name1" => $ref_name1, "ref_id1" => $ref_id1, "ref_name2" => $ref_name2, "ref_id2" => $ref_id2, "ref_name3" => $ref_name3, "ref_id3" => $ref_id3);
$jsonEncodeData = json_encode($apiData);
$base64EncodeData = base64_encode($jsonEncodeData);
$finalEncryptedData = openssl_encrypt($base64EncodeData, $cipher, $encryption_key);
// API URL to send data
$url = 'https://unboxcatalysts.com/api/all-platform-payment.php';
// curl initiate
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $finalEncryptedData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute curl and assign returned data
$apiDataJsonResponse = curl_exec($ch);
// Close curl
curl_close($ch);
return $apiDataJsonResponse;
}
?>