Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v 1.7.10 #351

Merged
merged 13 commits into from
Oct 30, 2024
7 changes: 6 additions & 1 deletion 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.6.1
Requires PHP: 7.4
Stable tag: 1.7.9.3
Stable tag: 1.7.10
License: GPL
License URI: http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html

Expand All @@ -18,6 +18,11 @@ 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.10
- [Fix] - Discount coupons for regular products couldn't be used if a Billwerk subscription product was also in the cart.
- [Fix] - The order confirmation page now shows a list of split orders (for regular and subscription products) with correct total amounts.
- [Improvement] - Remove Resurs Bank payment method.

v 1.7.9.3
- [Fix] - Vipps Recurring could not save card.

Expand Down
Binary file removed assets/images/resurs.png
Binary file not shown.
1 change: 0 additions & 1 deletion assets/images/svg/resurs.logo.svg

This file was deleted.

50 changes: 44 additions & 6 deletions assets/js/thankyou.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,44 @@
jQuery(function ($) {
'use strict'

let attempts = 0;
const maxAttempts = 10;
const delayBetweenRequests = 2000;

var status_elm = $('#order-status-checking'),
success_elm = $('#order-success'),
failed_elm = $('#order-failed')

function checkOrderStatus() {
if (attempts >= maxAttempts) {
return;
}

$.ajax({
type: 'POST',
url: WC_Reepay_Thankyou.ajax_url,
data: {
action: 'reepay_order_descriptions',
order_id: WC_Reepay_Thankyou.order_id,
order_key: WC_Reepay_Thankyou.order_key,
},
success: function(response) {
if (response.success) {
status_elm.hide()
success_elm.show()
success_elm.find('#reepay-order-details').html(response.data);
} else {
attempts++;
setTimeout(checkOrderStatus, delayBetweenRequests);
}
},
error: function() {
attempts++;
setTimeout(checkOrderStatus, delayBetweenRequests);
}
});
}

window.wc_reepay_thankyou = {
xhr: false,
attempts: 0,
Expand All @@ -10,14 +48,14 @@ jQuery(function ($) {
*/
init: function () {
this.checkPayment(function (err, data) {
var status_elm = $('#order-status-checking'),
success_elm = $('#order-success'),
failed_elm = $('#order-failed')

switch (data.state) {
case 'paid':
status_elm.hide()
success_elm.show()
if(WC_Reepay_Thankyou.order_contain_rp_subscription == true && WC_Reepay_Thankyou.order_is_rp_subscription == false){
checkOrderStatus();
}else{
status_elm.hide()
success_elm.show()
}
break
case 'reload':
$('.woocommerce-order').block({
Expand Down
4 changes: 2 additions & 2 deletions bin/install-wp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ install_dependencies() {
php wp-cli.phar plugin install https://github.com/reepay/reepay-woocommerce-subscriptions/archive/refs/heads/main.zip --activate --force
mv ./wp-content/plugins/reepay-woocommerce-subscriptions ./wp-content/plugins/reepay-subscriptions-for-woocommerce

php wp-cli.phar plugin install https://git.one-pix.com/onepix/woocommerce-subscriptions-for-phpunit/-/archive/main/woocommerce-subscriptions-for-phpunit-main.zip --activate --force
php wp-cli.phar plugin install http://billwerkwoodev.phhw-190202.cust.powerhosting.dk/subdomains/assets/woocommerce-subscriptions-for-phpunit-main.zip --activate --force
mv ./wp-content/plugins/woocommerce-subscriptions-for-phpunit-main ./wp-content/plugins/woocommerce-subscriptions

php wp-cli.phar plugin list
Expand All @@ -208,4 +208,4 @@ install_dependencies() {
install_wp
install_test_suite
install_db
install_dependencies
install_dependencies
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,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.",
"type": "wordpress-plugin",
"license": "GPL",
"version": "1.7.9.3",
"version": "1.7.10",
"autoload": {
"psr-4": {
"Reepay\\Checkout\\": "includes/",
Expand Down
2 changes: 0 additions & 2 deletions includes/Gateways.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class Gateways {
'reepay_mobilepay',
'reepay_mobilepay_subscriptions',
'reepay_paypal',
'reepay_resurs',
'reepay_swish',
'reepay_viabill',
'reepay_vipps',
Expand Down Expand Up @@ -87,7 +86,6 @@ class Gateways {
Gateways\Mobilepay::class,
Gateways\MobilepaySubscriptions::class,
Gateways\Paypal::class,
Gateways\Resurs::class,
Gateways\Swish::class,
Gateways\Viabill::class,
Gateways\Vipps::class,
Expand Down
2 changes: 0 additions & 2 deletions includes/Gateways/ReepayCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ public function init_form_fields() {
'klarna_pay_later' => 'Klarna Pay Later',
'klarna_pay_now' => 'Klarna Pay Now',
'klarna_slice_it' => 'Klarna Slice It',
'resurs' => 'Resurs Bank',
'swish' => 'Swish',
'diners' => 'Diners Club',
'maestro' => 'Maestro',
Expand Down Expand Up @@ -360,7 +359,6 @@ public function init_form_fields() {
'applepay' => __( 'ApplePay', 'reepay-checkout-gateway' ),
'klarna' => __( 'Klarna', 'reepay-checkout-gateway' ),
'viabill' => __( 'Viabill', 'reepay-checkout-gateway' ),
'resurs' => __( 'Resurs Bank', 'reepay-checkout-gateway' ),
'forbrugsforeningen' => __( 'Forbrugsforeningen', 'reepay-checkout-gateway' ),
'amex' => __( 'AMEX', 'reepay-checkout-gateway' ),
'jcb' => __( 'JCB', 'reepay-checkout-gateway' ),
Expand Down
2 changes: 0 additions & 2 deletions includes/Gateways/ReepayGateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ abstract class ReepayGateway extends WC_Payment_Gateway {
'klarna-pay-later',
'klarna-pay-now',
'klarna',
'resursbank',
);

/**
Expand Down Expand Up @@ -1670,7 +1669,6 @@ public function get_logo( string $card_type ): string {
'viabill' => 'viabill',
'klarna_pay_later' => 'klarna',
'klarna_pay_now' => 'klarna',
'resurs' => 'resurs',
'china_union_pay' => 'cup',
'paypal' => 'paypal',
'applepay' => 'applepay',
Expand Down
53 changes: 0 additions & 53 deletions includes/Gateways/Resurs.php

This file was deleted.

76 changes: 71 additions & 5 deletions includes/OrderFlow/ThankyouPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Exception;
use Reepay\Checkout\Utils\LoggingTrait;
use WC_Order_Item_Product;
use WC_Reepay_Renewals as WCRR;

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

Expand Down Expand Up @@ -38,6 +39,9 @@ public function __construct() {

add_action( 'wp_ajax_reepay_check_payment', array( $this, 'ajax_check_payment' ) );
add_action( 'wp_ajax_nopriv_reepay_check_payment', array( $this, 'ajax_check_payment' ) );

add_action( 'wp_ajax_reepay_order_descriptions', array( $this, 'ajax_order_descriptions' ) );
add_action( 'wp_ajax_nopriv_reepay_order_descriptions', array( $this, 'ajax_order_descriptions' ) );
}

/**
Expand Down Expand Up @@ -99,15 +103,28 @@ public function thankyou_scripts() {
true
);

$order_rp_subscription = false;
if ( class_exists( WCRR::class ) && WCRR::is_order_contain_subscription( $order ) ) {
$order_rp_subscription = true;
}

$order_is_rp_subscription = false;
$reepay_is_subscription = $order->get_meta( '_reepay_is_subscription' );
if ( ! empty( $reepay_is_subscription ) ) {
$order_is_rp_subscription = true;
}

wp_localize_script(
'wc-gateway-reepay-thankyou',
'WC_Reepay_Thankyou',
array(
'order_id' => $order->get_id(),
'order_key' => $order_key,
'nonce' => wp_create_nonce( 'reepay' ),
'ajax_url' => admin_url( 'admin-ajax.php' ),
'check_message' => __(
'order_id' => $order->get_id(),
'order_key' => $order_key,
'order_contain_rp_subscription' => $order_rp_subscription,
'order_is_rp_subscription' => $order_is_rp_subscription,
'nonce' => wp_create_nonce( 'reepay' ),
'ajax_url' => admin_url( 'admin-ajax.php' ),
'check_message' => __(
'Please wait. We\'re checking the payment status.',
'reepay-checkout-gateway'
),
Expand Down Expand Up @@ -195,4 +212,53 @@ public function ajax_check_payment() {

wp_send_json_success( apply_filters( 'woocommerce_reepay_check_payment', $ret ?? array(), $order->get_id() ) );
}

/**
* Ajax: get order description on mix order.
*/
public function ajax_order_descriptions() {

$order_id = isset( $_POST['order_id'] ) ? wc_clean( $_POST['order_id'] ) : '';
$order_key = isset( $_POST['order_key'] ) ? wc_clean( $_POST['order_key'] ) : '';

if ( empty( $order_id ) || empty( $order_key ) ) {
wp_send_json_error( 'Invalid order' );
}

$order = wc_get_order( $order_id );
if ( empty( $order ) || ! $order->key_is_valid( $order_key ) ) {
wp_send_json_error( 'Invalid order' );
}

$another_orders = $order->get_meta( '_reepay_another_orders' );

if ( ! empty( $another_orders ) && is_array( $another_orders ) ) {
ob_start();

reepay()->get_template(
'checkout/order-details.php',
array(
'order' => $order,
)
);

foreach ( $another_orders as $order_id ) {
if ( $order->get_id() === $order_id ) {
continue;
}

reepay()->get_template(
'checkout/order-details.php',
array(
'order' => wc_get_order( $order_id ),
)
);
}
$order_details = ob_get_clean();
wp_send_json_success( $order_details );
wp_die();
} else {
wp_send_json_error( 'Order data not ready yet' );
}
}
}
8 changes: 0 additions & 8 deletions languages/reepay-checkout-gateway-en_US.po
Original file line number Diff line number Diff line change
Expand Up @@ -604,10 +604,6 @@ msgstr ""
msgid "Viabill"
msgstr ""

#: ../includes/Gateways/ReepayCheckout.php:363
msgid "Resurs Bank"
msgstr ""

#: ../includes/Gateways/ReepayCheckout.php:364
msgid "Forbrugsforeningen"
msgstr ""
Expand Down Expand Up @@ -744,10 +740,6 @@ msgstr ""
msgid "Unable to retrieve the webhook settings. Wrong api credentials?"
msgstr ""

#: ../includes/Gateways/Resurs.php:42
msgid "Billwerk+ Pay - Resurs Bank"
msgstr ""

#: ../includes/Gateways/Swish.php:42
msgid "Billwerk+ Pay - Swish"
msgstr ""
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.9.3
* Version: 1.7.10
* Text Domain: reepay-checkout-gateway
* Domain Path: /languages
* WC requires at least: 3.0.0
Expand Down
7 changes: 6 additions & 1 deletion templates/checkout/order-details.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@
<?php esc_html_e( 'Total:', 'woocommerce' ); ?>
<strong>
<?php
echo $order->get_formatted_order_total(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
if ( (float) $order->get_total() > 0.00 ) {
echo wc_price( $order->get_total() );
} else {
$real_total = $order->get_meta( '_real_total' );
echo wc_price( $real_total );
}
?>
</strong>
</li>
Expand Down
Loading
Loading