Skip to content

Commit d345efe

Browse files
committed
SP-983 Address PHPCS warnings
1 parent 880509d commit d345efe

File tree

5 files changed

+27
-8
lines changed

5 files changed

+27
-8
lines changed

modules/gateways/bitpaycheckout.php

+20-6
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@
1919
die("This file cannot be accessed directly");
2020
}
2121

22-
include_once(__DIR__ . DIRECTORY_SEPARATOR . 'bitpaycheckout' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
23-
use BitPaySDK\PosClient;
22+
include_once(__DIR__ . DIRECTORY_SEPARATOR . 'bitpaycheckout'
23+
. DIRECTORY_SEPARATOR . 'vendor'
24+
. DIRECTORY_SEPARATOR . 'autoload.php');
25+
26+
use BitPaySDK\PosClient;
2427
use BitPaySDK\Model\Invoice\Invoice;
2528
use BitPaySDK\Model\Invoice\Buyer;
2629
use BitPaySDK\Model\Facade;
@@ -96,6 +99,7 @@ function bitpaycheckout_config()
9699
'Type' => 'text',
97100
'Size' => '25',
98101
'Default' => '',
102+
// @phpcs:ignore Generic.Files.LineLength.TooLong
99103
'Description' => 'Your <b>development</b> merchant token. <a href = "https://test.bitpay.com/dashboard/merchant/api-tokens" target = "_blank">Create one here</a> and <b>uncheck</b> `Require Authentication`.',
100104
),
101105
// a text field type allows for single line text input
@@ -104,19 +108,22 @@ function bitpaycheckout_config()
104108
'Type' => 'text',
105109
'Size' => '25',
106110
'Default' => '',
111+
// @phpcs:ignore Generic.Files.LineLength.TooLong
107112
'Description' => 'Your <b>production</b> merchant token. <a href = "https://bitpay.com/dashboard/merchant/api-tokens" target = "_blank">Create one here</a> and <b>uncheck</b> `Require Authentication`.',
108113
),
109114

110115
'bitpay_checkout_endpoint' => array(
111116
'FriendlyName' => 'Endpoint',
112117
'Type' => 'dropdown',
113118
'Options' => 'Test,Production',
119+
// @phpcs:ignore Generic.Files.LineLength.TooLong
114120
'Description' => 'Select <b>Test</b> for testing the plugin, <b>Production</b> when you are ready to go live.<br>',
115121
),
116122
'bitpay_checkout_mode' => array(
117123
'FriendlyName' => 'Payment UX',
118124
'Type' => 'dropdown',
119125
'Options' => 'Modal,Redirect',
126+
// @phpcs:ignore Generic.Files.LineLength.TooLong
120127
'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>',
121128
),
122129
);
@@ -147,7 +154,7 @@ function bitpaycheckout_link($config_params)
147154

148155
$client = new PosClient($bitpay_checkout_token, $bitpay_checkout_endpoint);
149156

150-
#check to make sure we don't already have a valid BitPay Invoice active
157+
// Check to make sure we don't already have a valid BitPay Invoice active
151158
$checkDup = Capsule::table('_bitpay_checkout_transactions')
152159
->select('transaction_id')
153160
->where('order_id', '=', $config_params['invoiceid'])
@@ -179,7 +186,7 @@ function bitpaycheckout_link($config_params)
179186
$moduleDisplayName = $config_params['name'];
180187
$moduleName = $config_params['paymentmethod'];
181188

182-
#BITPAY INVOICE DETAILS
189+
// BITPAY INVOICE DETAILS
183190
$params = new stdClass();
184191

185192
$dir = dirname($_SERVER['REQUEST_URI']);
@@ -188,13 +195,17 @@ function bitpaycheckout_link($config_params)
188195
}
189196

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

195204
$protocol = 'https://';
196205

206+
// @phpcs:ignore Generic.Files.LineLength.TooLong
197207
$notificationURL = $protocol . $_SERVER['SERVER_NAME'] . $dir . '/modules/gateways/bitpaycheckout/callback/bitpaycheckout_ipn.php';
208+
// @phpcs:ignore Generic.Files.LineLength.TooLong
198209
$redirectURL = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
199210

200211
$invoice = new Invoice($amount, $currencyCode);
@@ -231,6 +242,7 @@ function bitpaycheckout_link($config_params)
231242

232243
try {
233244
$statement = $pdo->prepare(
245+
// @phpcs:ignore Generic.Files.LineLength.TooLong
234246
'insert into _bitpay_checkout_transactions (order_id, transaction_id, transaction_status,created_at) values (:order_id, :transaction_id, :transaction_status,:created_at)'
235247
);
236248

@@ -250,8 +262,10 @@ function bitpaycheckout_link($config_params)
250262
}
251263

252264
if ($bitpay_checkout_mode == 'Modal') {
265+
// @phpcs:ignore Generic.Files.LineLength.TooLong
253266
$htmlOutput .= '<button name = "bitpay-payment" class = "btn btn-success btn-sm" onclick = "showModal(\'' . $basicInvoice->getId() . '\');return false;">' . $config_params['langpaynow'] . '</button>';
254267
} else {
268+
// @phpcs:ignore Generic.Files.LineLength.TooLong
255269
$htmlOutput .= '<button name = "bitpay-payment" class = "btn btn-success btn-sm" onclick = "redirectURL(\'' . $basicInvoice->getUrl(). '\');return false;">' . $config_params['langpaynow'] . '</button>';
256270
}
257271
?>
@@ -273,7 +287,7 @@ function redirectURL($url){
273287
}
274288
}, false);
275289
function showModal(){
276-
//show the modal
290+
// Show the modal
277291
<?php if ($bitpay_checkout_endpoint == 'Test') : ?>
278292
bitpay.enableTestMode()
279293
<?php endif;?>

modules/gateways/bitpaycheckout/callback/bitpaycheckout_ipn.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222

2323
// Require libraries needed for gateway module functions.
2424
require_once '../../../../init.php';
25-
require_once '../../../../includes/gatewayfunctions.php';
26-
require_once '../../../../includes/invoicefunctions.php';
25+
require_once ROOTDIR . "/includes/gatewayfunctions.php";
26+
require_once ROOTDIR . "/includes/invoicefunctions.php";
2727

2828
// Detect module name from filename.
2929
$gatewayModuleName = 'bitpaycheckout';
30+
3031
// Fetch gateway configuration parameters.
3132
$gatewayParams = getGatewayVariables($gatewayModuleName);
3233
define("TEST_URL", 'https://test.bitpay.com/invoices/');

phpcbf.phar

1.41 MB
Binary file not shown.

phpcs.phar

1.41 MB
Binary file not shown.

phpcs.xml

+4
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212
<file>modules/</file>
1313
<exclude-pattern>*/vendor/*</exclude-pattern>
1414

15+
<rule ref="PSR1.Files.SideEffects">
16+
<exclude name="PSR1.Files.SideEffects"/>
17+
</rule>
18+
1519
</ruleset>

0 commit comments

Comments
 (0)