From 6a60003b2429624397736f1131b084e21e1d2eb2 Mon Sep 17 00:00:00 2001
From: Patrick
Date: Mon, 24 Jun 2024 12:05:10 -0400
Subject: [PATCH] SP-986: Update comments formatting
---
modules/gateways/bitpaycheckout.php | 21 ++++++++-----------
.../callback/bitpaycheckout_ipn.php | 20 +++++++++---------
2 files changed, 19 insertions(+), 22 deletions(-)
diff --git a/modules/gateways/bitpaycheckout.php b/modules/gateways/bitpaycheckout.php
index 87adab0..69011f6 100644
--- a/modules/gateways/bitpaycheckout.php
+++ b/modules/gateways/bitpaycheckout.php
@@ -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');
@@ -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/
*
@@ -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') {
@@ -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
@@ -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();
@@ -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;
diff --git a/modules/gateways/bitpaycheckout/callback/bitpaycheckout_ipn.php b/modules/gateways/bitpaycheckout/callback/bitpaycheckout_ipn.php
index e67b797..eac9ec4 100644
--- a/modules/gateways/bitpaycheckout/callback/bitpaycheckout_ipn.php
+++ b/modules/gateways/bitpaycheckout/callback/bitpaycheckout_ipn.php
@@ -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([
@@ -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 {
@@ -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 {
@@ -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 {
@@ -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)
@@ -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
@@ -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 {