Skip to content

Commit

Permalink
Version 5.8.1 Release
Browse files Browse the repository at this point in the history
Version 5.8.1 Release
  • Loading branch information
tubiz authored Nov 28, 2023
2 parents 610cae5 + 4e0d8bc commit 8cdb647
Show file tree
Hide file tree
Showing 45 changed files with 2,018 additions and 1,648 deletions.
2 changes: 1 addition & 1 deletion assets/js/blocks/frontend/blocks.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wc-blocks-registry', 'wc-settings', 'wp-element', 'wp-html-entities', 'wp-i18n'), 'version' => '56849d74fd092513b4dd');
<?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-html-entities', 'wp-i18n'), 'version' => '4c764c6a3000337eb113');
2 changes: 1 addition & 1 deletion assets/js/blocks/frontend/blocks.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions assets/js/blocks/frontend/blocks/paystack-five.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-html-entities', 'wp-i18n'), 'version' => 'd3243b6728f8e007d06d');
1 change: 1 addition & 0 deletions assets/js/blocks/frontend/blocks/paystack-five.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions assets/js/blocks/frontend/blocks/paystack-four.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-html-entities', 'wp-i18n'), 'version' => '565b2d7366411bcf4728');
1 change: 1 addition & 0 deletions assets/js/blocks/frontend/blocks/paystack-four.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions assets/js/blocks/frontend/blocks/paystack-one.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-html-entities', 'wp-i18n'), 'version' => '8169d4004807519e68e0');
1 change: 1 addition & 0 deletions assets/js/blocks/frontend/blocks/paystack-one.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions assets/js/blocks/frontend/blocks/paystack-three.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-html-entities', 'wp-i18n'), 'version' => '719042969f22177a35b1');
1 change: 1 addition & 0 deletions assets/js/blocks/frontend/blocks/paystack-three.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions assets/js/blocks/frontend/blocks/paystack-two.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('react', 'wc-blocks-registry', 'wc-settings', 'wp-html-entities', 'wp-i18n'), 'version' => '33f5ee1a90862c137f1c');
1 change: 1 addition & 0 deletions assets/js/blocks/frontend/blocks/paystack-two.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion includes/class-wc-gateway-paystack-blocks-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function get_payment_method_data() {
'description' => $this->get_setting( 'description' ),
'supports' => array_filter( $gateway->supports, array( $gateway, 'supports' ) ),
'allow_saved_cards' => $gateway->saved_cards && is_user_logged_in(),
'logo_url' => array( $payment_gateways['paystack']->get_logo_url() ),
'logo_urls' => array( $payment_gateways['paystack']->get_logo_url() ),
);
}

Expand Down
2 changes: 1 addition & 1 deletion includes/class-wc-gateway-paystack-subscriptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function process_subscription_payment( $order, $amount ) {

$body = array(
'email' => $customer_email,
'amount' => $order_amount,
'amount' => absint( $order_amount ),
'metadata' => $metadata,
'authorization_code' => $auth_code,
'reference' => $txnref,
Expand Down
16 changes: 8 additions & 8 deletions includes/class-wc-gateway-paystack.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,9 @@ public function __construct() {
*/
public function is_valid_for_use() {

if ( ! in_array( get_woocommerce_currency(), apply_filters( 'woocommerce_paystack_supported_currencies', array( 'NGN', 'USD', 'ZAR', 'GHS', 'KES', 'XOF', 'EGP' ) ) ) ) {
if ( ! in_array( get_woocommerce_currency(), apply_filters( 'woocommerce_paystack_supported_currencies', array( 'NGN', 'USD', 'ZAR', 'GHS', 'KES', 'XOF', 'EGP', 'RWF' ) ) ) ) {

$this->msg = sprintf( __( 'Paystack does not support your store currency. Kindly set it to either NGN (&#8358), GHS (&#x20b5;), USD (&#36;), KES (KSh), ZAR (R), XOF (CFA), or EGP (E£) <a href="%s">here</a>', 'woo-paystack' ), admin_url( 'admin.php?page=wc-settings&tab=general' ) );
$this->msg = sprintf( __( 'Paystack does not support your store currency. Kindly set it to either NGN (&#8358), GHS (&#x20b5;), USD (&#36;), KES (KSh), RWF (R₣), ZAR (R), XOF (CFA), or EGP (E£) <a href="%s">here</a>', 'woo-paystack' ), admin_url( 'admin.php?page=wc-settings&tab=general' ) );

return false;

Expand Down Expand Up @@ -684,7 +684,7 @@ public function payment_scripts() {
if ( $the_order_id == $order_id && $the_order_key == $order_key ) {

$paystack_params['email'] = $email;
$paystack_params['amount'] = $amount;
$paystack_params['amount'] = absint( $amount );
$paystack_params['txnref'] = $txnref;
$paystack_params['currency'] = $currency;

Expand Down Expand Up @@ -881,7 +881,7 @@ public function process_redirect_payment_option( $order_id ) {
$payment_channels = $this->get_gateway_payment_channels( $order );

$paystack_params = array(
'amount' => $amount,
'amount' => absint( $amount ),
'email' => $order->get_billing_email(),
'currency' => $order->get_currency(),
'reference' => $txnref,
Expand Down Expand Up @@ -982,7 +982,7 @@ public function process_token_payment( $token, $order_id ) {

$body = array(
'email' => $customer_email,
'amount' => $order_amount,
'amount' => absint( $order_amount ),
'metadata' => $metadata,
'authorization_code' => $auth_code,
'reference' => $txnref,
Expand Down Expand Up @@ -1024,7 +1024,7 @@ public function process_token_payment( $token, $order_id ) {
$gateway_symbol = get_woocommerce_currency_symbol( $payment_currency );

// check if the amount paid is equal to the order amount.
if ( $amount_paid < $order_total ) {
if ( $amount_paid < absint( $order_total ) ) {

$order->update_status( 'on-hold', '' );

Expand Down Expand Up @@ -1191,7 +1191,7 @@ public function verify_paystack_transaction() {
$gateway_symbol = get_woocommerce_currency_symbol( $payment_currency );

// check if the amount paid is equal to the order amount.
if ( $amount_paid < $order_total ) {
if ( $amount_paid < absint( $order_total ) ) {

$order->update_status( 'on-hold', '' );

Expand Down Expand Up @@ -1341,7 +1341,7 @@ public function process_webhooks() {
$gateway_symbol = get_woocommerce_currency_symbol( $payment_currency );

// check if the amount paid is equal to the order amount.
if ( $amount_paid < $order_total ) {
if ( $amount_paid < absint( $order_total ) ) {

$order->update_status( 'on-hold', '' );

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php

use Automattic\WooCommerce\Blocks\Payments\Integrations\AbstractPaymentMethodType;
use Automattic\WooCommerce\StoreApi\Payments\PaymentContext;
use Automattic\WooCommerce\StoreApi\Payments\PaymentResult;

class WC_Gateway_Custom_Paystack_Blocks_Support extends AbstractPaymentMethodType {

/**
* Initializes the payment method type.
*/
public function initialize() {
$paystack_gateway_settings = get_option( 'woocommerce_paystack_settings', array() );
$custom_paystack_gateway_settings = get_option( "woocommerce_{$this->name}_settings", array() );

$this->settings = wp_parse_args( $custom_paystack_gateway_settings, $paystack_gateway_settings );

add_action( 'woocommerce_rest_checkout_process_payment_with_context', array( $this, 'failed_payment_notice' ), 8, 2 );
}

/**
* Returns if this payment method should be active. If false, the scripts will not be enqueued.
*
* @return boolean
*/
public function is_active() {
$payment_gateways_class = WC()->payment_gateways();
$payment_gateways = $payment_gateways_class->payment_gateways();
if ( ! isset( $payment_gateways[ $this->name ] ) ) {
return false;
}

return $payment_gateways[ $this->name ]->is_available();
}

/**
* Returns an array of scripts/handles to be registered for this payment method.
*
* @return array
*/
public function get_payment_method_script_handles() {
$script_asset_path = plugins_url( "/assets/js/blocks/frontend/blocks/{$this->name}.asset.php", WC_PAYSTACK_MAIN_FILE );
$script_asset = file_exists( $script_asset_path )
? require $script_asset_path
: array(
'dependencies' => array(),
'version' => WC_PAYSTACK_VERSION,
);

$script_url = plugins_url( "/assets/js/blocks/frontend/blocks/{$this->name}.js", WC_PAYSTACK_MAIN_FILE );

wp_register_script(
"wc-{$this->name}-blocks",
$script_url,
$script_asset['dependencies'],
$script_asset['version'],
true
);

if ( function_exists( 'wp_set_script_translations' ) ) {
wp_set_script_translations( "wc-{$this->name}-blocks", 'woo-paystack', );
}

return array( "wc-{$this->name}-blocks" );
}

/**
* Returns an array of key=>value pairs of data made available to the payment methods script.
*
* @return array
*/
public function get_payment_method_data() {
$payment_gateways_class = WC()->payment_gateways();
$payment_gateways = $payment_gateways_class->payment_gateways();
$gateway = $payment_gateways[ $this->name ];

$payment_icons = $this->get_setting( 'payment_icons' );
if ( empty( $payment_icons ) ) {
$payment_icons = array( 'paystack' );
}

$payment_icons_url = array();
foreach ( $payment_icons as $payment_icon ) {
$payment_icons_url[] = WC_HTTPS::force_https_url( plugins_url( "assets/images/{$payment_icon}.png", WC_PAYSTACK_MAIN_FILE ) );
}

return array(
'title' => $this->get_setting( 'title' ),
'description' => $this->get_setting( 'description' ),
'supports' => array_filter( $gateway->supports, array( $gateway, 'supports' ) ),
'allow_saved_cards' => $gateway->saved_cards && is_user_logged_in(),
'logo_urls' => $payment_icons_url,
);
}

/**
* Add failed payment notice to the payment details.
*
* @param PaymentContext $context Holds context for the payment.
* @param PaymentResult $result Result object for the payment.
*/
public function failed_payment_notice( PaymentContext $context, PaymentResult &$result ) {
if ( $this->name === $context->payment_method ) {
add_action(
'wc_gateway_paystack_process_payment_error',
function( $failed_notice ) use ( &$result ) {
$payment_details = $result->payment_details;
$payment_details['errorMessage'] = wp_strip_all_tags( $failed_notice );
$result->set_payment_details( $payment_details );
}
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ public function payment_scripts() {
if ( $the_order_id == $order_id && $the_order_key == $order_key ) {

$paystack_params['email'] = $email;
$paystack_params['amount'] = $amount;
$paystack_params['amount'] = absint( $amount );
$paystack_params['txnref'] = $txnref;
$paystack_params['currency'] = $currency;

Expand Down Expand Up @@ -612,4 +612,25 @@ public function add_gateway_to_checkout( $available_gateways ) {

}

/**
* Check if the custom Paystack gateway is enabled.
*
* @return bool
*/
public function is_available() {

if ( 'yes' == $this->enabled ) {

if ( ! ( $this->public_key && $this->secret_key ) ) {

return false;

}

return true;

}

return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

final class WC_Gateway_Paystack_Five_Blocks_Support extends WC_Gateway_Custom_Paystack_Blocks_Support {

/**
* Payment method id.
*
* @var string
*/
protected $name = 'paystack-five';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

final class WC_Gateway_Paystack_Four_Blocks_Support extends WC_Gateway_Custom_Paystack_Blocks_Support {

/**
* Payment method id.
*
* @var string
*/
protected $name = 'paystack-four';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

final class WC_Gateway_Paystack_One_Blocks_Support extends WC_Gateway_Custom_Paystack_Blocks_Support {

/**
* Payment method id.
*
* @var string
*/
protected $name = 'paystack-one';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

final class WC_Gateway_Paystack_Three_Blocks_Support extends WC_Gateway_Custom_Paystack_Blocks_Support {

/**
* Payment method id.
*
* @var string
*/
protected $name = 'paystack-three';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

final class WC_Gateway_Paystack_Two_Blocks_Support extends WC_Gateway_Custom_Paystack_Blocks_Support {

/**
* Payment method id.
*
* @var string
*/
protected $name = 'paystack-two';
}
Loading

0 comments on commit 8cdb647

Please sign in to comment.