/home/desid573/public_html/gcdriver/payment
NameSizeModeActions
assets/-0755rm
pdd/-0755rm
xero/-0755rm
approved.php15130644editdlrm
checktime.php14360644editdlrm
driverCheck.php7940644editdlrm
error_log247610644editdlrm
index.php347530644editdlrm
thankyou.php125480644editdlrm
tokenUpdate.php55280644editdlrm
updatetoken.php36960644editdlrm
Edit: /home/desid573/public_html/gcdriver/payment/thankyou.php (12548B)
setHost("https://connect.squareupsandbox.com"); $api_config->setAccessToken($access_token); $api_client = new \SquareConnect\ApiClient($api_config); $customersApi = new SquareConnect\Api\CustomersApi($api_client); $tokencheck = ""; ?> Payment - Processed
setAmount($charge); $amountMoney->setCurrency("AUD"); $body->setSourceId($nonce); $body->setAmountMoney($amountMoney); # Every payment you process with the SDK must have a unique idempotency key. # If you're unsure whether a particular payment succeeded, you can reattempt # it with the same idempotency key without worrying about double charging # the buyer. $body->setIdempotencyKey($reference); try { $result = $payments_api->createPayment($body); if($result["payment"]["status"] == "COMPLETED") { $res["cardID"] = $cardID; $res["status"] = "OK"; $res["message"] = ""; } else { $res["cardID"] = ""; $res["status"] = "error"; $res["message"] = "Error Processing Payment"; } } catch (\SquareConnect\ApiException $e) { error_log("Exception when calling PaymentsApi->createPayment:".$e->getResponseBody()); } } else if ($_POST['payment_type'] == 'token') { $apiInstance = new SquareConnect\Api\PaymentsApi($api_client); $body = new \SquareConnect\Model\CreatePaymentRequest(); // Set your customer_id and customer_card_id $body->setSourceId($_POST["token"]); $body->setCustomerId($_POST["cust_id"]); // Set the payment information $body->setIdempotencyKey($reference); $body->setAutocomplete(true); $body->setReferenceId($reference); // Set the charge amount to 10 USD $chargeAmount = new SquareConnect\Model\Money(); $chargeAmount->setAmount($charge); $chargeAmount->setCurrency("AUD"); $body->setAmountMoney($chargeAmount); //make the call try { $result = $apiInstance->createPayment($body); error_log($result); if($result["payment"]["status"] == "COMPLETED") { $res["cardID"] = $cardID; $res["status"] = "OK"; $res["message"] = ""; } else { $res["cardID"] = ""; $res["status"] = "error"; $res["message"] = "Error Processing Card on File Payment"; } } catch (Exception $e) { error_log('Exception when calling PaymentsApi->createPayment: '.$e->getMessage()); } } if ($res["status"] == "OK") { //$paymentCode = "1cb7bb21-739d-480d-909d-fe564b0e2df8"; $sql = "UPDATE booking SET payment_eway = '".$charge."' WHERE reference = '".$reference."'"; $response = $conn->query($sql); echo "

Transaction Approved

"; echo "

Refresh

"; if(!$response) { error_log("payment add to database error ".$conn->error); } } else { die("Error".$res["message"]); } $amount = floatval($_POST['amount']); $reference = ($_POST['reference'] != '') ? $_POST['reference'] : $_POST['reference']; $invname = $_POST['invname']; $paidby = $_POST['payment_type']; $invdesc = $_POST['invdesc']; $invmessage = "Invoice Issued
Name $invname
Type $type
Email $email
Amount $amount
Paid By $paidby
Reference $reference
Description $invdesc"; send_mail('booking@perthdesignateddrivers.com.au', 'invoice@perthdesignateddrivers.com.au', 'New Invoice For '.$invname ,$invmessage); $amountArray["total"] = $amount; if($_POST['levy'] != "0") { $amountArray["levy"] = $_POST['levy']; } if($_POST['tollAmount'] != "0") { error_log("fired tolls"); $amountArray["tolls"] = $_POST['tollAmount']; } $query1 = "SELECT ".$spatulaID.", driver FROM ".$table." WHERE reference='".$reference."'"; $result = mysqli_query($conn, $query1); $row = mysqli_fetch_assoc($result); $spat_ref = $row[$spatulaID]; $driver_name = $row['driver']; $query1 = "SELECT id FROM desid573_eway_codes.drivers WHERE driver='".$driver_name."'"; $result = mysqli_query($conn, $query1); $row = mysqli_fetch_assoc($result); $driver_id = $row['id']; $invnamed = mysqli_real_escape_string($conn, $invname); $invdescd = mysqli_real_escape_string($conn, str_replace("&","", $invdesc)); $query1 = "INSERT INTO invoices (id, reference, tokenid, invname, amount, tollAmount, email, transactionid, date_created, type, paidby, invdesc, driver) VALUES (NULL,'" . $reference . "','" . $tokencustomerid . "','" . $invnamed . "','" . $amountArray["total"] . "','" . $amountArray["tolls"] . "','" . $email . "','" . $transactionid . "','" . date('Y-m-d H:i:s') . "','" . $type . "','" . $paidby . "','" . $invdescd . "','" . $driver_name . "')"; $success = mysqli_query($conn, $query1); if (!$success) { die("Couldn't enter data: ".$conn->error); } if($type == "GA") { $query1 = "SELECT cid FROM booking WHERE reference='".$reference."'"; $result = mysqli_query($conn, $query1); $row = mysqli_fetch_assoc($result); $cid = $row['cid']; if($_REQUEST["referral"] != "none") { $query1 = "UPDATE `credits` SET `reference` = '".$reference."', `is_used` = 1, `date_used` = NOW() WHERE `customer_id`='".$cid."' AND `is_used` = 0"; $result = mysqli_query($conn, $query1); $query1 = "UPDATE `referal_claim` SET `reference_claimed` = '".$reference."', `date_last_claimed` = NOW() WHERE `customer_id`='".$cid."'"; $result = mysqli_query($conn, $query1); } $query1 = "SELECT promo_code, promo_used FROM customers WHERE id='".$cid."' "; $result = mysqli_query($conn, $query1); $row = mysqli_fetch_assoc($result); $promo_code = $row['promo_code']; $is_used = $row['promo_used']; $is_used = $is_used + 1; if($promo_code != ""){ $query1 = "UPDATE `".$dbname."`.`customers` SET `promo_code` = '', promo_used = '".$is_used."' WHERE `id`='".$cid."'"; $result = mysqli_query($conn, $query1); if(substr($_REQUEST['promo_code'], 0, 2) === "RF"){ $sql = "UPDATE `".$dbname."`.`referrals` where `code` = '".$promo_code."' and `refered_id` = '".$cid."' SET `reference` = '".$reference."', `date_used` = NOW()"; $result = $conn->query($sql); if(!$result) { error_log($conn->error); } } } } if (!$success) { die("Couldnt enter invoice data: ".$conn->error); } else { date_default_timezone_set('Australia/Perth'); $date = date("c"); $tollDesc = ""; if($amountArray["tolls"] != null) { $result = mysqli_query($conn, "SELECT * FROM toll_estimates WHERE reference='".$reference."'"); if(!$result) { error_log($conn->error); } else { if($result->num_rows > 0) { $row = mysqli_fetch_assoc($result); $tollDesc = $row['description']; } } } error_log(json_encode($amountArray, true)); $invoiceDetails = submitInvoice($invnamed, $date, $invdescd, $amountArray, $reference, $type, $tollDesc, $email); error_log(json_encode($invoiceDetails, true)); if($invoiceDetails != "") { $sql = "UPDATE ".$table." SET xero_inv = '".$invoiceDetails['invoiceNumber']."' WHERE reference = '".$reference."' "; $response = $conn->query($sql); if(!$response) { error_log("xero update database error ".$conn->error); } if($paymentCode != "") { $totalAmount = $amountArray["total"] + $amountArray["tolls"]; error_log("totalAmount = ".$totalAmount); submitPayment($invoiceDetails['invoiceID'], $paymentCode, $date, $totalAmount, $reference); } $totalAmount = $amountArray["total"] + $amountArray["tolls"]; addToSheets($reference, $invoiceDetails['invoiceNumber'][0], $totalAmount); } else { addToSheets($reference, "", $amountArray["total"] + $amountArray["tolls"]); } } if($spat_ref != "") { require("../vromo.php"); $url = "https://api.fleeteng.com.au/v2/graph/role/jobs/$spat_ref/dispatches?access_token=".$vromo; $curlObj = curl_init(); curl_setopt($curlObj, CURLOPT_URL, "$url"); curl_setopt($curlObj, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlObj, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($curlObj, CURLOPT_HEADER, 0); curl_setopt($curlObj, CURLOPT_HTTPHEADER, array('Content-type:application/json')); curl_setopt($curlObj, CURLOPT_POST, 1); curl_setopt($curlObj, CURLOPT_POSTFIELDS, '[{"vehicle":{"id":' . $driver_id . '},"type":"closed"}]'); $response = curl_exec($curlObj); error_log($response); curl_close($curlObj); } $message = "Type $type
Referecence $reference
"; header('Location: https://desidrivers.com.au/payment/approved.php'); die(); ?>