Skip to content

Commit

Permalink
Update 0.2.0
Browse files Browse the repository at this point in the history
- WooCommerce HPOS compatible
- Updated Skyverge version
- Included a ready to use plugin zip file in the project

** NOT (yet) WC Checkout/Cart Blocks compatible **
  • Loading branch information
cloudcogsio committed Nov 27, 2024
1 parent b1bc4db commit 7056209
Show file tree
Hide file tree
Showing 11 changed files with 148 additions and 148 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/composer.lock
/cc-woocommerce-gateway-powertranz.zip
/vendor/
/.idea
53 changes: 21 additions & 32 deletions cc-woocommerce-gateway-powertranz.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: WooCommerce Payment Gateway for First Atlantic Commerce (PowerTranz) 3DS2 (https://firstatlanticcommerce.com)
* Author: cloudcogs.io
* Author URI: https://www.cloudcogs.io/
* Version: 0.1.0
* Version: 0.2.0
* Text Domain: cc-woocommerce-gateway-powertranz
* Domain Path: /i18n/languages/
*
Expand All @@ -18,8 +18,8 @@
* @copyright Copyright (c) 2022, cloudcogs.io
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
*
* WC requires at least: 4.9.2
* WC tested up to: 6.9.2
* WC requires at least: 8.0
* WC tested up to: 9.4.2
*/

defined('ABSPATH') or exit;
Expand All @@ -42,17 +42,14 @@ class WC_PowerTranz_Loader
const MINIMUM_WC_VERSION = '4.9.2';

/** SkyVerge plugin framework version used by this plugin */
const FRAMEWORK_VERSION = '5.10.13';
const FRAMEWORK_VERSION = '5.15.1';

/** the plugin name, for displaying notices */
const PLUGIN_NAME = 'PowerTranz 3DS2 - WooCommerce Payment Gateway';


/** @var WC_PowerTranz_Loader single instance of this class */
private static $instance;

/** @var array the admin notices to add */
private $notices = array();
private array $notices = array();


/**
Expand All @@ -67,12 +64,10 @@ protected function __construct()

add_action('admin_init', array( $this, 'check_environment' ));
add_action('admin_init', array( $this, 'add_plugin_notices' ));

add_action('admin_notices', array( $this, 'admin_notices' ), 15);

add_filter('extra_plugin_headers', array( $this, 'add_documentation_header'));

// if the environment check fails, initialize the plugin
if ($this->is_environment_compatible()) {
add_action('plugins_loaded', array( $this, 'init_plugin' ));
}
Expand Down Expand Up @@ -166,8 +161,7 @@ private function load_framework()
*
* @return string
*/
public function get_framework_version_namespace()
{
public function get_framework_version_namespace(): string {

return 'v' . str_replace('.', '_', $this->get_framework_version());
}
Expand All @@ -180,8 +174,7 @@ public function get_framework_version_namespace()
*
* @return string
*/
public function get_framework_version()
{
public function get_framework_version(): string {

return self::FRAMEWORK_VERSION;
}
Expand Down Expand Up @@ -271,8 +264,7 @@ public function add_plugin_notices()
*
* @return bool
*/
private function plugins_compatible()
{
private function plugins_compatible(): bool {

return $this->is_wp_compatible() && $this->is_wc_compatible();
}
Expand All @@ -285,8 +277,7 @@ private function plugins_compatible()
*
* @return bool
*/
private function is_wp_compatible()
{
private function is_wp_compatible(): bool {

if (! self::MINIMUM_WP_VERSION) {
return true;
Expand All @@ -303,8 +294,7 @@ private function is_wp_compatible()
*
* @return bool
*/
private function is_wc_compatible()
{
private function is_wc_compatible(): bool {

if (! self::MINIMUM_WC_VERSION) {
return true;
Expand Down Expand Up @@ -335,13 +325,14 @@ protected function deactivate_plugin()
/**
* Adds an admin notice to be displayed.
*
* @since 0.1.0
*
* @param string $slug the slug for the notice
* @param string $class the css class for the notice
* @param string $message the notice message
*
*@since 0.1.0
*
*/
private function add_admin_notice($slug, $class, $message)
private function add_admin_notice( string $slug, string $class, string $message)
{

$this->notices[ $slug ] = array(
Expand All @@ -361,7 +352,7 @@ private function add_admin_notice($slug, $class, $message)
public function admin_notices()
{

foreach ((array) $this->notices as $notice_key => $notice) {
foreach ($this->notices as $notice_key => $notice) {
?>
<div class="<?php echo esc_attr($notice['class']); ?>">
<p><?php echo wp_kses($notice['message'], array( 'a' => array( 'href' => array() ) )); ?></p>
Expand All @@ -374,15 +365,15 @@ public function admin_notices()
/**
* Adds the Documentation URI header.
*
* @param string[] $headers original headers
*
* @return string[]
* @internal
*
* @since 0.1.0
*
* @param string[] $headers original headers
* @return string[]
*/
public function add_documentation_header($headers)
{
public function add_documentation_header( array $headers): array {

$headers[] = 'Documentation URI';

Expand All @@ -399,8 +390,7 @@ public function add_documentation_header($headers)
*
* @return bool
*/
private function is_environment_compatible()
{
private function is_environment_compatible(): bool {

return version_compare(PHP_VERSION, self::MINIMUM_PHP_VERSION, '>=');
}
Expand All @@ -413,8 +403,7 @@ private function is_environment_compatible()
*
* @return string
*/
private function get_environment_message()
{
private function get_environment_message(): string {

return sprintf(
'The minimum PHP version required for this plugin is %1$s. You are running %2$s.',
Expand Down
Binary file added cc-woocommerce-gateway-powertranz.zip
Binary file not shown.
14 changes: 8 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@
"minimum-stability" : "dev",
"require": {
"php" : "^7.4",
"skyverge/wc-plugin-framework": "5.10.13",
"skyverge/wc-plugin-framework": "^5.15.1",
"cloudcogsio/omnipay-powertranz-3ds2-gateway": "dev-master",
"guzzlehttp/psr7": "^2.7.0",
"ext-json": "*"
},
"require-dev": {
"squizlabs/php_codesniffer": "^3.7.1",
"wp-coding-standards/wpcs": "^2.3.0"
},
"autoload" : {
"psr-4" : {
"Cloudcogs\\Woocommerce\\Gateway\\PowerTranz\\" : "src"
}
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
}
2 changes: 1 addition & 1 deletion src/Api/DirectRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Omnipay\PowerTranz\Schema\ThreeDSecureRequestData;
use Omnipay\PowerTranz\Support\DataHelper;
use Ramsey\Uuid\Uuid;
use SkyVerge\WooCommerce\PluginFramework\v5_10_13 as Framework;
use SkyVerge\WooCommerce\PluginFramework\v5_15_1 as Framework;
use Omnipay\PowerTranz\Message\AbstractRequest as PowerTranzRequest;

class DirectRequest implements Framework\SV_WC_Payment_Gateway_API_Request
Expand Down
2 changes: 1 addition & 1 deletion src/Api/DirectRequest/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function create_credit_card_authorization()
$Auth = new AuthRequest([
'TransactionIdentifier' => $this->generate_transaction_identifier(),
'OrderIdentifier' => $this->generate_order_identifier(),
'TotalAmount' => $this->get_order()->payment_total,
'TotalAmount' => $this->get_order()->get_total(),
'CurrencyCode' => DataHelper::CurrencyCode($this->get_order()->get_currency()),
'ThreeDSecure' => $this->WC_Gateway->is_three_ds_enabled(),
'AddressVerification' => $this->WC_Gateway->is_avs_requested(),
Expand Down
2 changes: 1 addition & 1 deletion src/Api/DirectResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Cloudcogs\Woocommerce\Gateway\PowerTranz\Api;

use Omnipay\PowerTranz\Message\AbstractResponse;
use SkyVerge\WooCommerce\PluginFramework\v5_10_13 as Framework;
use SkyVerge\WooCommerce\PluginFramework\v5_15_1 as Framework;

class DirectResponse implements
Framework\SV_WC_API_Response,
Expand Down
4 changes: 2 additions & 2 deletions src/Api/OmniPayPowerTranz.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Omnipay\PowerTranz\Gateway;
use Omnipay\PowerTranz\Message\Response\AuthResponse;
use Omnipay\PowerTranz\Schema\PaymentResponse;
use SkyVerge\WooCommerce\PluginFramework\v5_10_13 as Framework;
use SkyVerge\WooCommerce\PluginFramework\v5_15_1 as Framework;

class OmniPayPowerTranz extends Framework\SV_WC_API_Base implements Framework\SV_WC_Payment_Gateway_API
{
Expand Down Expand Up @@ -83,7 +83,7 @@ public function do_remote_request($request_uri, $request_args)
public function handle_postback_response(
PaymentResponse $response,
string $response_handler = DirectResponse::class
) {
): DirectResponse {
$this->set_response_handler($response_handler);
return $this->handle_response($response);
}
Expand Down
Loading

0 comments on commit 7056209

Please sign in to comment.