Skip to content

Commit

Permalink
SP-983 PSR-1 and PSR-2 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bobbrodie committed Jun 19, 2024
1 parent 3c7cff0 commit 880509d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 28 deletions.
11 changes: 6 additions & 5 deletions modules/gateways/bitpaycheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,7 @@ function ($table) {
* @return array
*/

if (!function_exists('bitpaycheckout_config'))
{
if (!function_exists('bitpaycheckout_config')) {
function bitpaycheckout_config()
{
return array(
Expand Down Expand Up @@ -119,7 +118,7 @@ function bitpaycheckout_config()
'Type' => 'dropdown',
'Options' => 'Modal,Redirect',
'Description' => 'Select <b>Modal</b> to keep the user on the invoice page, or <b>Redirect</b> to have them view the invoice at BitPay.com, and be redirected after payment.<br>',
),
),
);
}
}
Expand All @@ -137,7 +136,9 @@ function bitpaycheckout_link($config_params)
$curpage = basename($_SERVER["SCRIPT_FILENAME"]);

$curpage = str_replace("/", "", $curpage);
if ($curpage != 'viewinvoice.php'): return;endif;
if ($curpage != 'viewinvoice.php') {
return;
}
?>
<script src="https://bitpay.com/bitpay.min.js" type="text/javascript"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
Expand Down Expand Up @@ -273,7 +274,7 @@ function redirectURL($url){
}, false);
function showModal(){
//show the modal
<?php if ($bitpay_checkout_endpoint == 'Test'): ?>
<?php if ($bitpay_checkout_endpoint == 'Test') : ?>
bitpay.enableTestMode()
<?php endif;?>
bitpay.showInvoice('<?php echo $basicInvoice->getId(); ?>');
Expand Down
49 changes: 26 additions & 23 deletions modules/gateways/bitpaycheckout/callback/bitpaycheckout_ipn.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

use WHMCS\Database\Capsule;

// Require libraries needed for gateway module functions.
require_once '../../../../init.php';
require_once '../../../../includes/gatewayfunctions.php';
Expand All @@ -31,7 +32,8 @@
define("TEST_URL", 'https://test.bitpay.com/invoices/');
define("PROD_URL", 'https://bitpay.com/invoices/');

function checkInvoiceStatus($url) {
function checkInvoiceStatus($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
Expand All @@ -47,10 +49,10 @@ function checkInvoiceStatus($url) {
$file = 'bitpay.txt';
$err = "bitpay_err.txt";

file_put_contents($file,"===========INCOMING IPN=========================",FILE_APPEND);
file_put_contents($file,date('d.m.Y H:i:s'),FILE_APPEND);
file_put_contents($file,print_r($response, true),FILE_APPEND);
file_put_contents($file,"===========END OF IPN===========================",FILE_APPEND);
file_put_contents($file, "===========INCOMING IPN=========================", FILE_APPEND);
file_put_contents($file, date('d.m.Y H:i:s'), FILE_APPEND);
file_put_contents($file, print_r($response, true), FILE_APPEND);
file_put_contents($file, "===========END OF IPN===========================", FILE_APPEND);

$order_status = $data['status'];
$order_invoice = $data['id'];
Expand Down Expand Up @@ -93,16 +95,16 @@ function checkInvoiceStatus($url) {
['transaction_id', '=', $order_invoice],
])
->update($update);
} catch (Exception $e ) {
file_put_contents($file,$e,FILE_APPEND);
} catch (Exception $e) {
file_put_contents($file, $e, FILE_APPEND);
}

addInvoicePayment(
$orderid,
$order_invoice,
$price,
0,
'bitpaycheckout'
$orderid,
$order_invoice,
$price,
0,
'bitpaycheckout'
);
break;

Expand All @@ -118,8 +120,8 @@ function checkInvoiceStatus($url) {
['paymentmethod', '=', 'bitpaycheckout'],
])
->update($update);
} catch (Exception $e ) {
file_put_contents($file,$e,FILE_APPEND);
} catch (Exception $e) {
file_put_contents($file, $e, FILE_APPEND);
}

#update the bitpay_invoice table
Expand All @@ -132,8 +134,8 @@ function checkInvoiceStatus($url) {
['transaction_id', '=', $order_invoice],
])
->update($update);
} catch (Exception $e ) {
file_put_contents($file,$e,FILE_APPEND);
} catch (Exception $e) {
file_put_contents($file, $e, FILE_APPEND);
}
break;

Expand All @@ -145,8 +147,8 @@ function checkInvoiceStatus($url) {
Capsule::table($table)
->where('transaction_id', '=', $order_invoice)
->delete();
} catch (Exception $e ) {
file_put_contents($file,$e,FILE_APPEND);
} catch (Exception $e) {
file_put_contents($file, $e, FILE_APPEND);
}
break;

Expand All @@ -163,8 +165,8 @@ function checkInvoiceStatus($url) {
['paymentmethod', '=', 'bitpaycheckout'],
])
->update($update);
} catch (Exception $e ) {
file_put_contents($file,$e,FILE_APPEND);
} catch (Exception $e) {
file_put_contents($file, $e, FILE_APPEND);
}

#update the bitpay invoice table
Expand All @@ -177,11 +179,12 @@ function checkInvoiceStatus($url) {
['transaction_id', '=', $order_invoice],
])
->update($update);
} catch (Exception $e ) {
file_put_contents($file,$e,FILE_APPEND);
} catch (Exception $e) {
file_put_contents($file, $e, FILE_APPEND);
}
break;
}
}
http_response_code(200);

http_response_code(200);
}

0 comments on commit 880509d

Please sign in to comment.