Skip to content

Commit

Permalink
SP-986: Update comments formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
p-maguire committed Jun 24, 2024
1 parent 3e0256b commit 6a60003
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
21 changes: 9 additions & 12 deletions modules/gateways/bitpaycheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
* @license http://www.whmcs.com/license/ WHMCS Eula
*/

if (!defined("WHMCS")) {
die("This file cannot be accessed directly");
if (!defined('WHMCS')) {
die('This file cannot be accessed directly');
}

include_once(__DIR__ . DIRECTORY_SEPARATOR . 'bitpaycheckout'
require(__DIR__ . DIRECTORY_SEPARATOR . 'bitpaycheckout'
. DIRECTORY_SEPARATOR . 'vendor'
. DIRECTORY_SEPARATOR . 'autoload.php');

Expand Down Expand Up @@ -75,8 +75,6 @@ function ($table) {
* * radio
* * textarea
*
* Examples of each field type and their possible configuration parameters are
* provided in the sample function below.
*
* @see https://developers.whmcs.com/payment-gateways/configuration/
*
Expand Down Expand Up @@ -140,7 +138,7 @@ function bitpaycheckout_link($config_params)
}
$bitpay_checkout_mode = $config_params['bitpay_checkout_mode'];

$curpage = basename($_SERVER["SCRIPT_FILENAME"]);
$curpage = basename($_SERVER['SCRIPT_FILENAME']);

$curpage = str_replace("/", "", $curpage);
if ($curpage != 'viewinvoice.php') {
Expand Down Expand Up @@ -196,13 +194,12 @@ function bitpaycheckout_link($config_params)

$params->orderId = trim($invoiceId);
// @phpcs:ignore Generic.Files.LineLength.TooLong
$protocol = 'https://';
$params->notificationURL = $protocol . $_SERVER['SERVER_NAME']. $dir . '/modules/gateways/bitpaycheckout/callback/bitpaycheckout_ipn.php';
// @phpcs:ignore Generic.Files.LineLength.TooLong
$params->redirectURL = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$params->fullNotifications = true;

$protocol = 'https://';

// @phpcs:ignore Generic.Files.LineLength.TooLong
$notificationURL = $protocol . $_SERVER['SERVER_NAME'] . $dir . '/modules/gateways/bitpaycheckout/callback/bitpaycheckout_ipn.php';
// @phpcs:ignore Generic.Files.LineLength.TooLong
Expand Down Expand Up @@ -232,11 +229,11 @@ function bitpaycheckout_link($config_params)
$invoice->setBuyer($buyer);
$basicInvoice = $client->createInvoice($invoice, Facade::POS, false);

error_log("=======USER LOADED BITPAY CHECKOUT INVOICE=====");
error_log('=======USER LOADED BITPAY CHECKOUT INVOICE=====');
error_log(date('d.m.Y H:i:s'));
error_log("=======END OF INVOICE==========================");
error_log('=======END OF INVOICE==========================');

#insert into the database
// Insert into the database
$pdo = Capsule::connection()->getPdo();
$pdo->beginTransaction();

Expand Down Expand Up @@ -277,7 +274,7 @@ function redirectURL($url){

var payment_status = null;
var is_paid = false;
window.addEventListener("message", function(event) {
window.addEventListener('message', function(event) {
payment_status = event.data.status;
if(payment_status == 'paid' || payment_status == 'confirmed' || payment_status == 'complete'){
is_paid = true;
Expand Down
20 changes: 10 additions & 10 deletions modules/gateways/bitpaycheckout/callback/bitpaycheckout_ipn.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function checkInvoiceStatus($url)

$orderid = checkCbInvoiceID($invoiceStatus->data->orderId, 'bitpaycheckout');
$price = $invoiceStatus->data->price;
//first see if the ipn matches
// First see if the ipn matches
$trans_data = Capsule::table('_bitpay_checkout_transactions')
->select('order_id', 'transaction_id', 'transaction_status')
->where([
Expand All @@ -76,13 +76,13 @@ function checkInvoiceStatus($url)

if ($btn_id) {
switch ($data['status']) {
//complete, update invoice table to Paid
// Complete, update invoice table to Paid
case 'complete':
if ($transaction_status == $data['status']) {
exit();
}

//update the bitpay_invoice table
// Update the bitpay_invoice table
$table = '_bitpay_checkout_transactions';
$update = array('transaction_status' => 'complete', 'updated_at' => date('Y-m-d H:i:s'));
try {
Expand All @@ -105,9 +105,9 @@ function checkInvoiceStatus($url)
);
break;

//processing - put in Payment Pending
// Processing - put in Payment Pending
case 'paid':
//update the invoices table
// Update the invoices table
$table = 'tblinvoices';
$update = array("status" => 'Payment Pending','datepaid' => date('Y-m-d H:i:s'));
try {
Expand All @@ -121,7 +121,7 @@ function checkInvoiceStatus($url)
file_put_contents($file, $e, FILE_APPEND);
}

//update the bitpay_invoice table
// Update the bitpay_invoice table
$table = '_bitpay_checkout_transactions';
$update = array('transaction_status' => 'paid', 'updated_at' => date('Y-m-d H:i:s'));
try {
Expand All @@ -136,9 +136,9 @@ function checkInvoiceStatus($url)
}
break;

//expired, remove from transaction table, wont be in invoice table
// Expired, remove from transaction table, wont be in invoice table
case 'expired':
//delete any orphans
// Delete any orphans
$table = '_bitpay_checkout_transactions';
try {
Capsule::table($table)
Expand All @@ -149,7 +149,7 @@ function checkInvoiceStatus($url)
}
break;

//refunded, set invoice and bitpay transaction to refunded status
// Refunded, set invoice and bitpay transaction to refunded status
case 'pending':
if ($event['name'] == 'refund_pending') {
//update the invoices table
Expand All @@ -166,7 +166,7 @@ function checkInvoiceStatus($url)
file_put_contents($file, $e, FILE_APPEND);
}

//update the bitpay invoice table
// Update the bitpay invoice table
$table = '_bitpay_checkout_transactions';
$update = array('transaction_status' => 'refunded', 'updated_at' => date('Y-m-d H:i:s'));
try {
Expand Down

0 comments on commit 6a60003

Please sign in to comment.