Skip to content

Commit

Permalink
Merge pull request #331 from reepay/pre-1.7.6
Browse files Browse the repository at this point in the history
Update version to 1.7.6
  • Loading branch information
ponddeja authored Jul 16, 2024
2 parents a73e539 + 8af7162 commit d30dde7
Show file tree
Hide file tree
Showing 8 changed files with 184 additions and 72 deletions.
8 changes: 6 additions & 2 deletions Readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: billwerk+, visa, mastercard, dankort, mobilepay
Requires at least: 4.0
Tested up to: 6.5.3
Requires PHP: 7.4
Stable tag: 1.7.5
Stable tag: 1.7.6
License: GPL
License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html

Expand All @@ -18,8 +18,12 @@ The Billwerk+ Pay plugin extends WooCommerce allowing you to take payments on yo
See installation guide right here: https://docu.billwerk.plus/help/en/apps/woocommerce/setup-woocommerce-plugin.html

== Changelog ==
v 1.7.6 -
* [Fix] - Allow the activation of Santander and enforce a redirect for this payment.
* [Compatibility] - Billwerk+ Optimize version 1.2.6

v 1.7.5 -
* [Improvement] - Product namechange to "Billwerk+ Pay".
* [Improvement] - Product name change to "Billwerk+ Pay".
* [Fix] - Including card fee in the order line prevented the order from being auto-captured.
* [Fix] - WooCommerce subscription renewal orders were not auto-captured and their status remained incomplete.

Expand Down
6 changes: 3 additions & 3 deletions bin/zip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -ex

# Change to the expected directory.
DIR=$(pwd)
BUILD_DIR="$DIR/build/reepay-woocommerce-payment"
BUILD_DIR="$DIR/build/reepay-checkout-gateway"

# Enable nicer messaging for build status.
BLUE_BOLD='\033[1;34m';
Expand Down Expand Up @@ -79,12 +79,12 @@ then
status "Creating archive... 🎁"

cd ./build
zip -r -q reepay-woocommerce-payment.zip reepay-woocommerce-payment
zip -r -q reepay-checkout-gateway.zip reepay-checkout-gateway

# remove the source directory
# rm -rf ./reepay-woocommerce-payment
else
warning "zip command not found. Create archive by yourself ./build/reepay-woocommerce-payment"
warning "zip command not found. Create archive by yourself ./build/reepay-checkout-gateway"
fi

success "Done. You've built plugin! 🎉 "
68 changes: 58 additions & 10 deletions includes/Functions/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,21 @@ function rp_get_order_handle( WC_Order $order, bool $unique = false ): ?string {
* @return false|WC_Order
*/
function rp_get_order_by_handle( string $handle ) {
$order_id = wp_cache_get( $handle, 'reepay_order_by_handle' );

if ( empty( $order_id ) ) {
if ( rp_hpos_enabled() ) {
$orders = wc_get_orders(
array(
'limit' => 1,
'meta_query' => array( //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
array(
'key' => '_reepay_order',
'value' => $handle,
),

),
)
);
} else {
$orders = wc_get_orders(
array(
'limit' => 1,
Expand All @@ -61,18 +73,54 @@ function rp_get_order_by_handle( string $handle ) {
'meta_compare' => '=',
)
);
}

if ( ! empty( $orders ) ) {
$order_id = reset( $orders )->get_id();
wp_cache_set( $handle, $order_id, 'reepay_order_by_handle' );
} else {
return false;
}
if ( ! empty( $orders ) ) {
$order_id = reset( $orders )->get_id();
clean_post_cache( $order_id );

return wc_get_order( $order_id );
}

clean_post_cache( $order_id );
return false;
}
}

if ( ! function_exists( 'rp_get_not_subs_order_by_handle' ) ) {
/**
* Get not subscription order by reepay order handle.
*
* @param string $handle reepay order handle.
*
* @return false|WC_Order
*/
function rp_get_not_subs_order_by_handle( string $handle ) {

$orders = wc_get_orders(
array(
'limit' => 1,
'meta_query' => array( //phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query
array(
'key' => '_reepay_order',
'value' => $handle,
),
array(
'key' => '_reepay_is_subscription',
'compare' => 'NOT EXISTS',
),

),
)
);

if ( ! empty( $orders ) ) {
$order_id = reset( $orders )->get_id();
clean_post_cache( $order_id );

return wc_get_order( $order_id );
}

return wc_get_order( $order_id );
return false;
}
}

Expand Down
4 changes: 2 additions & 2 deletions includes/Gateways.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Gateways {
'reepay_pp_trustly',
'reepay_pp_verkkopankki',
'reepay_pp_wechatpay',
'reepay_pp_santander',
'reepay_pe_santander',
'reepay_offline_bank_transfer',
'reepay_offline_cash',
'reepay_offline_other',
Expand Down Expand Up @@ -114,7 +114,7 @@ class Gateways {
Gateways\PPTrustly::class,
Gateways\PPVerkkoPankki::class,
Gateways\PPWeChatPay::class,
Gateways\PPSantander::class,
Gateways\PESantander::class,
Gateways\OfflineTransfer::class,
Gateways\OfflineCash::class,
Gateways\Other::class,
Expand Down
102 changes: 102 additions & 0 deletions includes/Gateways/PESantander.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?php
/**
* PE Santander gateway
*
* @package Reepay\Checkout\Gateways
*/

namespace Reepay\Checkout\Gateways;

use Reepay\Checkout\Frontend\Assets;

defined( 'ABSPATH' ) || exit();

/**
* Class PESantander
*
* @package Reepay\Checkout\Gateways
*/
class PESantander extends ReepayGateway {
/**
* Logos
*
* @var array
*/
public array $logos = array(
'santander',
);

/**
* Payment methods.
*
* @var array
*/
public array $payment_methods = array(
'pe_santander',
);

/**
* PESantander constructor.
*/
public function __construct() {
$this->id = 'reepay_pe_santander';
$this->has_fields = true;
$this->method_title = __( 'Billwerk+ Pay - Santander', 'reepay-checkout-gateway' );
$this->supports = array(
'products',
'refunds',
);

parent::__construct();

$this->apply_parent_settings();

if ( 'yes' === $this->enabled ) {
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_additional_assets' ), 10000 );
}
}

/**
* Additional gateway assets
*/
public function enqueue_additional_assets() {
wp_add_inline_script(
Assets::SLUG_CHECKOUT_JS,
"
(function($) {
$(document).ready(function() {
let payment_type = WC_Gateway_Reepay_Checkout.payment_type;
setTimeout(function() {
$('[name=radio-control-wc-payment-method-options], [name=payment_method]').each(function() {
if( '" . $this->id . "' === $(this).val() && $(this).is(':checked') ){
WC_Gateway_Reepay_Checkout.payment_type = 'WINDOW';
}
});
}, 3000);
// Script for WC Block
$('body').on('click', '[name=radio-control-wc-payment-method-options]', function() {
let option_value = $(this).val();
if( '" . $this->id . "' === option_value ){
WC_Gateway_Reepay_Checkout.payment_type = 'WINDOW';
}else{
WC_Gateway_Reepay_Checkout.payment_type = payment_type;
}
});
// Script for short code check out
$('body').on('click', '.wc_payment_method', function() {
let option_value = $(this).find('.input-radio').val();
if( '" . $this->id . "' === option_value ){
WC_Gateway_Reepay_Checkout.payment_type = 'WINDOW';
}else{
WC_Gateway_Reepay_Checkout.payment_type = payment_type;
}
});
});
})(jQuery);
"
);
}
}
52 changes: 0 additions & 52 deletions includes/Gateways/PPSantander.php

This file was deleted.

14 changes: 12 additions & 2 deletions includes/OrderFlow/Webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,12 @@ public function process( array $data ) {
throw new Exception( 'Missing Invoice parameter' );
}

$order = rp_get_order_by_handle( $data['invoice'] );
if ( isset( $data['subscription'] ) ) {
$order = rp_get_not_subs_order_by_handle( $data['invoice'] );
} else {
$order = rp_get_order_by_handle( $data['invoice'] );
}

if ( ! $order ) {
$this->log( sprintf( 'WebHook: Order is not found. Invoice: %s', $data['invoice'] ) );

Expand Down Expand Up @@ -208,7 +213,12 @@ public function process( array $data ) {
throw new Exception( 'Missing Invoice parameter' );
}

$order = rp_get_order_by_handle( $data['invoice'] );
if ( isset( $data['subscription'] ) ) {
$order = rp_get_not_subs_order_by_handle( $data['invoice'] );
} else {
$order = rp_get_order_by_handle( $data['invoice'] );
}

if ( ! $order ) {
$this->log( sprintf( 'WebHook: Order is not found. Invoice: %s', $data['invoice'] ) );

Expand Down
2 changes: 1 addition & 1 deletion reepay-woocommerce-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Get a plug-n-play payment solution for WooCommerce, that is easy to use, highly secure and is built to maximize the potential of your e-commerce.
* Author: Billwerk+
* Author URI: http://billwerk.plus
* Version: 1.7.5
* Version: 1.7.6
* Text Domain: reepay-checkout-gateway
* Domain Path: /languages
* WC requires at least: 3.0.0
Expand Down

0 comments on commit d30dde7

Please sign in to comment.