Skip to content

Commit 880509d

Browse files
committed
SP-983 PSR-1 and PSR-2 cleanup
1 parent 3c7cff0 commit 880509d

File tree

2 files changed

+32
-28
lines changed

2 files changed

+32
-28
lines changed

modules/gateways/bitpaycheckout.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,7 @@ function ($table) {
8080
* @return array
8181
*/
8282

83-
if (!function_exists('bitpaycheckout_config'))
84-
{
83+
if (!function_exists('bitpaycheckout_config')) {
8584
function bitpaycheckout_config()
8685
{
8786
return array(
@@ -119,7 +118,7 @@ function bitpaycheckout_config()
119118
'Type' => 'dropdown',
120119
'Options' => 'Modal,Redirect',
121120
'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>',
122-
),
121+
),
123122
);
124123
}
125124
}
@@ -137,7 +136,9 @@ function bitpaycheckout_link($config_params)
137136
$curpage = basename($_SERVER["SCRIPT_FILENAME"]);
138137

139138
$curpage = str_replace("/", "", $curpage);
140-
if ($curpage != 'viewinvoice.php'): return;endif;
139+
if ($curpage != 'viewinvoice.php') {
140+
return;
141+
}
141142
?>
142143
<script src="https://bitpay.com/bitpay.min.js" type="text/javascript"></script>
143144
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
@@ -273,7 +274,7 @@ function redirectURL($url){
273274
}, false);
274275
function showModal(){
275276
//show the modal
276-
<?php if ($bitpay_checkout_endpoint == 'Test'): ?>
277+
<?php if ($bitpay_checkout_endpoint == 'Test') : ?>
277278
bitpay.enableTestMode()
278279
<?php endif;?>
279280
bitpay.showInvoice('<?php echo $basicInvoice->getId(); ?>');

modules/gateways/bitpaycheckout/callback/bitpaycheckout_ipn.php

+26-23
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020

2121
use WHMCS\Database\Capsule;
22+
2223
// Require libraries needed for gateway module functions.
2324
require_once '../../../../init.php';
2425
require_once '../../../../includes/gatewayfunctions.php';
@@ -31,7 +32,8 @@
3132
define("TEST_URL", 'https://test.bitpay.com/invoices/');
3233
define("PROD_URL", 'https://bitpay.com/invoices/');
3334

34-
function checkInvoiceStatus($url) {
35+
function checkInvoiceStatus($url)
36+
{
3537
$ch = curl_init();
3638
curl_setopt($ch, CURLOPT_URL, $url);
3739
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
@@ -47,10 +49,10 @@ function checkInvoiceStatus($url) {
4749
$file = 'bitpay.txt';
4850
$err = "bitpay_err.txt";
4951

50-
file_put_contents($file,"===========INCOMING IPN=========================",FILE_APPEND);
51-
file_put_contents($file,date('d.m.Y H:i:s'),FILE_APPEND);
52-
file_put_contents($file,print_r($response, true),FILE_APPEND);
53-
file_put_contents($file,"===========END OF IPN===========================",FILE_APPEND);
52+
file_put_contents($file, "===========INCOMING IPN=========================", FILE_APPEND);
53+
file_put_contents($file, date('d.m.Y H:i:s'), FILE_APPEND);
54+
file_put_contents($file, print_r($response, true), FILE_APPEND);
55+
file_put_contents($file, "===========END OF IPN===========================", FILE_APPEND);
5456

5557
$order_status = $data['status'];
5658
$order_invoice = $data['id'];
@@ -93,16 +95,16 @@ function checkInvoiceStatus($url) {
9395
['transaction_id', '=', $order_invoice],
9496
])
9597
->update($update);
96-
} catch (Exception $e ) {
97-
file_put_contents($file,$e,FILE_APPEND);
98+
} catch (Exception $e) {
99+
file_put_contents($file, $e, FILE_APPEND);
98100
}
99101

100102
addInvoicePayment(
101-
$orderid,
102-
$order_invoice,
103-
$price,
104-
0,
105-
'bitpaycheckout'
103+
$orderid,
104+
$order_invoice,
105+
$price,
106+
0,
107+
'bitpaycheckout'
106108
);
107109
break;
108110

@@ -118,8 +120,8 @@ function checkInvoiceStatus($url) {
118120
['paymentmethod', '=', 'bitpaycheckout'],
119121
])
120122
->update($update);
121-
} catch (Exception $e ) {
122-
file_put_contents($file,$e,FILE_APPEND);
123+
} catch (Exception $e) {
124+
file_put_contents($file, $e, FILE_APPEND);
123125
}
124126

125127
#update the bitpay_invoice table
@@ -132,8 +134,8 @@ function checkInvoiceStatus($url) {
132134
['transaction_id', '=', $order_invoice],
133135
])
134136
->update($update);
135-
} catch (Exception $e ) {
136-
file_put_contents($file,$e,FILE_APPEND);
137+
} catch (Exception $e) {
138+
file_put_contents($file, $e, FILE_APPEND);
137139
}
138140
break;
139141

@@ -145,8 +147,8 @@ function checkInvoiceStatus($url) {
145147
Capsule::table($table)
146148
->where('transaction_id', '=', $order_invoice)
147149
->delete();
148-
} catch (Exception $e ) {
149-
file_put_contents($file,$e,FILE_APPEND);
150+
} catch (Exception $e) {
151+
file_put_contents($file, $e, FILE_APPEND);
150152
}
151153
break;
152154

@@ -163,8 +165,8 @@ function checkInvoiceStatus($url) {
163165
['paymentmethod', '=', 'bitpaycheckout'],
164166
])
165167
->update($update);
166-
} catch (Exception $e ) {
167-
file_put_contents($file,$e,FILE_APPEND);
168+
} catch (Exception $e) {
169+
file_put_contents($file, $e, FILE_APPEND);
168170
}
169171

170172
#update the bitpay invoice table
@@ -177,11 +179,12 @@ function checkInvoiceStatus($url) {
177179
['transaction_id', '=', $order_invoice],
178180
])
179181
->update($update);
180-
} catch (Exception $e ) {
181-
file_put_contents($file,$e,FILE_APPEND);
182+
} catch (Exception $e) {
183+
file_put_contents($file, $e, FILE_APPEND);
182184
}
183185
break;
184186
}
185187
}
186-
http_response_code(200);
188+
189+
http_response_code(200);
187190
}

0 commit comments

Comments
 (0)