Skip to content

Commit

Permalink
Comply to WPCS
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperstrongBE committed Nov 18, 2024
1 parent dac4d76 commit b6ca786
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 56 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
=== XPR Checkout: Webauth payment gateway ===
=== XPRCheckout - WebAuth Gateway for Woocommerce ===
Requires at least: 6.0
Tested up to: 6.6.1
Tested up to: 6.7
Requires PHP: 7.0
Stable tag: ##VERSION_TAG##
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

# XPR Checkout: Webauth payment gateway
# XPRCheckout - WebAuth Gateway for Woocommerce
*A WebAuth-Enabled Gateway for WooCommerce*

## The basic scope

This plugin provides a payment gateway for WooCommerce that enables users to pay for their purchases using any cryptocurrency available in the WebAuth wallet. With this feature, users can enjoy a seamless and secure shopping experience, thank Proton, as they can easily pay for their purchases using their preferred digital currency.

XPR Checkout, through a hassle-free configuration, provides additional features to help store owners manage payment reconciliation, withdrawal, and refund inside the WooCommerce regular flow also driven by Webauth authentification.
XPR Checkout, through a hassle-free configuration, provides additional features to help store owners manage payment reconciliation, withdrawal, and refund inside the WooCommerce regular flow also driven by Webauth authentication.

Overall, this plugin helps to expand the use of cryptocurrencies through the proton chain in e-commerce, making it easier and more convenient for users to use their digital assets for online shopping.

Expand Down Expand Up @@ -65,7 +65,7 @@ Register a store to allow payment and multi-balance storage (for different token
Remove a store from the store list, but keep the balance stored.

- **Refund by the store owner (pay.refund)**
Allow the refund of payment by flaging flag the payment as “REFUNDED”.
Allow the refund of payment by flagging flag the payment as “REFUNDED”.
- **No more Withdraw of payments by the store owner (bal.claim)**
No need to withdraw payment are directly transferred to the store owner through the @xprckechout smart contract.

Expand Down
4 changes: 2 additions & 2 deletions includes/controllers/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public function mutateOrdersColumnsHeader($columns)
foreach ($columns as $column_name => $column_info) {
$new_columns[$column_name] = $column_info;
if ('order_status' === $column_name) {
$new_columns['transactionId'] = __('Transaction', 'xprcheckout'); // title
$new_columns['net'] = __('Mainnet/testnet', 'xprcheckout'); // title
$new_columns['transactionId'] = __('Transaction', 'xprcheckout_gateway'); // title
$new_columns['net'] = __('Mainnet/testnet', 'xprcheckout_gateway'); // title
}
}
return $new_columns;
Expand Down
4 changes: 2 additions & 2 deletions includes/controllers/Refund.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function registerMetabox()
{
add_meta_box(
'woocommerce-xprcheckout-payment',
__('XPRCheckout payment', 'xprcheckout'),
__('XPRCheckout payment', 'xprcheckout_gateway'),
[$this, 'renderMetabox'],
'shop_order',
'advanced',
Expand Down Expand Up @@ -100,7 +100,7 @@ public function renderMetabox($post)
$baseConfig['orderStatus']= $order->get_status();
$baseConfig['orderStatus']= $order->get_status();
?>
window.pluginConfig = <?php echo json_encode(array_merge($baseConfig,$adminConfig)); ?>;
window.pluginConfig = <?php echo wp_json_encode(array_merge($baseConfig,$adminConfig)); ?>;
</script>
<div id="xpr-refund"></div>
<?php
Expand Down
7 changes: 2 additions & 5 deletions includes/rpc/TokensPricesRPC.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function ($matches) {
$data_array = json_decode($json_data, true);

if ($data_array === null && json_last_error() !== JSON_ERROR_NONE) {
die('JSON Decode Error: ' . json_last_error_msg());
return null;
}

// Use the data
Expand All @@ -81,7 +81,7 @@ function ($matches) {

if (isset($prices[0])) {
$mergedToken = array_merge($prices[0], $tokenBase);
// Update database
//phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching,
$wpdb->query($wpdb->prepare(
"INSERT INTO wp_%1s (symbol,contract,token_precision,rate)
VALUES (%s,%s,%d,%.12f)
Expand All @@ -105,9 +105,6 @@ function ($matches) {
}));

} catch (Exception $e) {
error_log('JSON Processing Error: ' . $e->getMessage());
error_log('JSON Error Code: ' . json_last_error());
error_log('JSON Error Message: ' . json_last_error_msg());
return null;
}
}
Expand Down
4 changes: 2 additions & 2 deletions includes/templates/template-payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
<?php wp_head() ?>
<script type='text/javascript'>

window.pluginConfig = <?php echo json_encode($baseConfig); ?>;
window.pluginConfig = <?php echo wp_json_encode($baseConfig); ?>;

</script>
<?php $g->payment_scripts(); ?>
</head>
<body class="<?php echo join(" ",get_body_class()) ?>">
<body class="<?php echo esc_html(join(" ",get_body_class())) ?>">


<div style='max-width:1040px;margin:0 auto' >
Expand Down
67 changes: 28 additions & 39 deletions includes/woocommerce/gateway/xprcheckout-gateway.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
<?php

use xprcheckout\config\Config;
use xprcheckout\i18n\Translations;


/**
* Class XPRCheckoutGateway
*
* Extends WooCommerce Payment Gateway to provide Webauth functionality.
*/
class XPRCheckoutGateway extends WC_Payment_Gateway
{

/**
* XPRCheckoutGateway constructor.
*
* Set up the gateway's properties and initializes settings.
*/
public function __construct()
{

Expand Down Expand Up @@ -51,9 +40,9 @@ protected function setup_properties()
{
$this->id = 'xprcheckout';
$this->icon = apply_filters('woocommerce_cod_icon', '');
$this->title = __('XPR Checkout', 'xprcheckout');
$this->method_title = __('XPR Checkout', 'xprcheckout');
$this->method_description = __('Provides a Webauth wallet Payment Gateway for your customer.', 'xprcheckout');
$this->title = __('XPR Checkout', 'xprcheckout_gateway');
$this->method_title = __('XPR Checkout', 'xprcheckout_gateway');
$this->method_description = __('Provides a Webauth wallet Payment Gateway for your customer.', 'xprcheckout_gateway');
$this->has_fields = false;
}

Expand All @@ -64,75 +53,75 @@ public function init_form_fields()
{
$this->form_fields = array(
'enabled' => array(
'title' => __('Enable/Disable', 'xprcheckout'),
'title' => __('Enable/Disable', 'xprcheckout_gateway'),
'type' => 'checkbox',
'label' => __('Enable Webauth Payment', 'xprcheckout'),
'label' => __('Enable Webauth Payment', 'xprcheckout_gateway'),
'default' => 'yes'
),
'network' => array(
'title' => __('Select network', 'xprcheckout'),
'title' => __('Select network', 'xprcheckout_gateway'),
'type' => 'select',
'options' => [
'mainnet' => 'Mainnet',
'testnet' => 'Testnet',
],
'label' => __('Select network', 'xprcheckout'),
'label' => __('Select network', 'xprcheckout_gateway'),
'default' => 'testnet',
'value'
),
'registered' => array(
'title' => __('Register store ', 'xprcheckout'),
'title' => __('Register store ', 'xprcheckout_gateway'),
'type' => 'xprcheckout_register',
'description' => __('Register you store nearby the smart contract', 'xprcheckout'),
'description' => __('Register you store nearby the smart contract', 'xprcheckout_gateway'),
'desc_tip' => true,
),
'title' => array(
'title' => __('Title', 'xprcheckout'),
'title' => __('Title', 'xprcheckout_gateway'),
'type' => 'text',
'default' => 'Pay with WebAuth',
'description' => __('This controls the title which the user sees during checkout.', 'xprcheckout'),
'description' => __('This controls the title which the user sees during checkout.', 'xprcheckout_gateway'),
'desc_tip' => true,
),
'description' => array(
'title' => __('Description', 'xprcheckout'),
'title' => __('Description', 'xprcheckout_gateway'),
'type' => 'textarea',
'description' => __('This controls the title which the user sees during checkout.', 'xprcheckout'),
'default' => __('Pay securely with with multiple crypto currencies through WebAuth with zero gas fee', 'xprcheckout'),
'description' => __('This controls the title which the user sees during checkout.', 'xprcheckout_gateway'),
'default' => __('Pay securely with with multiple crypto currencies through WebAuth with zero gas fee', 'xprcheckout_gateway'),
'desc_tip' => true,
),

'wallet' => array(
'title' => __('Mainnet account', 'xprcheckout'),
'title' => __('Mainnet account', 'xprcheckout_gateway'),
'type' => 'hidden',
'description' => __('Set the destination account on mainnet where pay token will be paid. <b>Used only when "Use testnet" option is disabled</b>', 'xprcheckout'),
'description' => __('Set the destination account on mainnet where pay token will be paid. <b>Used only when "Use testnet" option is disabled</b>', 'xprcheckout_gateway'),
'desc_tip' => true,
),

'appName' => array(
'title' => __('dApp Name', 'xprcheckout'),
'title' => __('dApp Name', 'xprcheckout_gateway'),
'type' => 'text',
'description' => __('The application name displayed in the webauth modal', 'xprcheckout'),
'default' => __('My awesome store', 'xprcheckout'),
'description' => __('The application name displayed in the webauth modal', 'xprcheckout_gateway'),
'default' => __('My awesome store', 'xprcheckout_gateway'),
'desc_tip' => true,
),
/*'appLogo' => array(
'title' => __('dApp Logo', 'xprcheckout'),
'title' => __('dApp Logo', 'xprcheckout_gateway'),
'type' => 'text',
'description' => __('The application logo displayed in the webauth modal', 'xprcheckout'),
'description' => __('The application logo displayed in the webauth modal', 'xprcheckout_gateway'),
'desc_tip' => true,
),*/
'allowedTokens' => array(
'title' => __('Allowed Tokens', 'xprcheckout'),
'title' => __('Allowed Tokens', 'xprcheckout_gateway'),
'type' => 'text',
'description' => __('Accepted tokens as payment for transfer, will be displayed in the payments process flow. Specify a uppercase only, coma separated, tokens list', 'xprcheckout'),
'default' => __('XPR,XUSDC', 'xprcheckout'),
'description' => __('Accepted tokens as payment for transfer, will be displayed in the payments process flow. Specify a uppercase only, coma separated, tokens list', 'xprcheckout_gateway'),
'default' => __('XPR,XUSDC', 'xprcheckout_gateway'),
'desc_tip' => true,
),
'currencyApi' => array(
'title' => __('Free api key ', 'xprcheckout'),
'title' => __('Free api key ', 'xprcheckout_gateway'),
'type' => 'text',
'description' => __('We provide limited one. You can register yours for free <a target="_blank" style="text-decoration:underline" href="https://app.freecurrencyapi.com/register">here</a>.', 'xprcheckout'),
'description' => __('We provide limited one. You can register yours for free <a target="_blank" style="text-decoration:underline" href="https://app.freecurrencyapi.com/register">here</a>.', 'xprcheckout_gateway'),
'desc_tip' => false,
),
);
Expand Down Expand Up @@ -274,7 +263,7 @@ public function generate_xprcheckout_register_html($key, $data)
$baseConfig['walletInputSelector']= "#woocommerce_xprcheckout_wallet";

?>
window.pluginConfig = <?php echo json_encode($baseConfig); ?>;
window.pluginConfig = <?php echo wp_json_encode($baseConfig); ?>;
</script>

<tr valign="top">
Expand Down Expand Up @@ -345,7 +334,7 @@ public function generate_hidden_html($key, $data)

function xprcheckout_redirect_on_new_order($order) {

if(WC()->session->chosen_payment_method == 'xprcheckout'){
if(WC()->session->chosen_payment_method == 'xprcheckout_gateway'){
$this->xprcheckout_redirect_to_payment_page();

}
Expand Down
2 changes: 1 addition & 1 deletion xprcheckout_gateway.php → xprcheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Author: Rémy Chauveau AKA Rockerone
* Author URI: rockerone.io
* Version: ##VERSION_TAG##
* slug: xprcheckout
* slug: xprcheckout_gateway
* Text Domain: xprcheckout_gateway
* Domain Path: /i18n/languages/
* License: GPLv2 or later
Expand Down

0 comments on commit b6ca786

Please sign in to comment.