diff --git a/CHANGELOG.md b/CHANGELOG.md
index 009badfa..8437f43f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.
+## [3.7.6]
+- Fix: Charge subscriptions using the renewal order total instead of the original reserved amount.
+- Support export reconciliation data with WooCommerce High-Performance Order Storage (HPOS).
+
## [3.7.5]
- Display agreement information in the "AltaPay Payment Actions" grid.
- Show the "pending payment" status if the subscription is awaiting a charge.
diff --git a/altapay.php b/altapay.php
index 48741bcd..ae64c446 100755
--- a/altapay.php
+++ b/altapay.php
@@ -7,10 +7,10 @@
* Author URI: https://altapay.com
* Text Domain: altapay
* Domain Path: /languages
- * Version: 3.7.5
+ * Version: 3.7.6
* Name: SDM_Altapay
* WC requires at least: 3.9.0
- * WC tested up to: 9.4.3
+ * WC tested up to: 9.5.1
*
* @package Altapay
*/
@@ -41,7 +41,7 @@
}
if ( ! defined( 'ALTAPAY_PLUGIN_VERSION' ) ) {
- define( 'ALTAPAY_PLUGIN_VERSION', '3.7.5' );
+ define( 'ALTAPAY_PLUGIN_VERSION', '3.7.6' );
}
// Include the autoloader, so we can dynamically include the rest of the classes.
diff --git a/classes/core/AltapayReconciliation.php b/classes/core/AltapayReconciliation.php
index 966d602e..002ad22b 100644
--- a/classes/core/AltapayReconciliation.php
+++ b/classes/core/AltapayReconciliation.php
@@ -18,6 +18,7 @@ class AltapayReconciliation {
*/
public function registerHooks() {
add_action( 'manage_posts_extra_tablenav', array( $this, 'addReconciliationExportButton' ), 20, 1 );
+ add_action( 'woocommerce_order_list_table_extra_tablenav', array( $this, 'addReconciliationExportButtonHpos' ), 10, 2 );
add_action( 'admin_init', array( $this, 'exportReconciliationCSV' ) );
}
@@ -32,17 +33,37 @@ public function addReconciliationExportButton( $which ) {
global $typenow;
if ( 'shop_order' === $typenow && 'top' === $which ) {
- ?>
-
-
-
-
- btnExportReconciliationData();
}
}
+ /**
+ * @param string $order_type The order type.
+ * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
+ *
+ * @return void
+ */
+ public function addReconciliationExportButtonHpos( $order_type, $which ) {
+
+ if ( 'shop_order' === $order_type && 'bottom' === $which ) {
+ $this->btnExportReconciliationData();
+ }
+ }
+
+ /**
+ * @return void
+ */
+ public function btnExportReconciliationData() {
+ ?>
+
+
+
+
+ $perPage,
- 'fields' => 'ids',
- 'post_type' => 'shop_order',
- 'post_status' => array_keys( wc_get_order_statuses() ),
- 'paged' => $paged,
+ 'limit' => $perPage,
+ 'return' => 'ids',
+ 'type' => 'shop_order',
+ 'paginate' => true,
+ 'page' => $paged,
);
if ( ! empty( $_GET['_customer_user'] ) ) {
- $args['meta_query'] = array(
- array(
- 'key' => '_customer_user',
- 'value' => (int) sanitize_text_field( wp_unslash( $_GET['_customer_user'] ) ),
- 'compare' => '=',
- ),
- );
+ $args['customer'] = (int) sanitize_text_field( wp_unslash( $_GET['_customer_user'] ) );
}
if ( ! empty( $_GET['post_status'] ) ) {
@@ -144,6 +159,10 @@ public function exportReconciliationCSV() {
$args['order'] = sanitize_text_field( wp_unslash( $_GET['order'] ) );
}
+ if ( ! empty( $_GET['status'] ) ) {
+ $args['status'] = sanitize_text_field( wp_unslash( $_GET['status'] ) );
+ }
+
if ( ! empty( $_GET['m'] ) ) {
$yearMonth = sanitize_text_field( wp_unslash( $_GET['m'] ) );
@@ -152,29 +171,23 @@ public function exportReconciliationCSV() {
$year = (int) substr( $yearMonth, 0, 4 );
$month = (int) substr( $yearMonth, 4, 2 );
- $args['date_query'] = array(
- array(
- 'year' => $year,
- 'month' => $month,
- ),
- );
+ $last_day_of_month = date_create( "$year-$month" )->format( 'Y-m-t' );
+ $args['date_created'] = "$year-$month-01..." . $last_day_of_month;
}
}
- $query = new \WP_Query( $args );
-
- if ( $query->have_posts() ) {
-
- $PostToSelect = substr( str_repeat( ',%d', count( $query->posts ) ), 1 );
+ $ordersData = wc_get_orders( $args );
- $reconciliation_data =
- $wpdb->get_results(
- $wpdb->prepare(
- "SELECT orderId, identifier, transactionType FROM {$wpdb->prefix}altapayReconciliationIdentifiers WHERE orderId IN ($PostToSelect) ",
- $query->posts
- ),
- ARRAY_A
- );
+ if ( ! empty( $ordersData ) ) {
+ $orders = $ordersData->orders;
+ $orders_to_select = substr( str_repeat( ',%d', count( $orders ) ), 1 );
+ $reconciliation_data = $wpdb->get_results(
+ $wpdb->prepare(
+ "SELECT orderId, identifier, transactionType FROM {$wpdb->prefix}altapayReconciliationIdentifiers WHERE orderId IN ($orders_to_select) ",
+ $orders
+ ),
+ ARRAY_A
+ );
$output = $output . 'Order ID,Date Created,Order Total,Currency,Transaction ID,Reconciliation Identifier,Type,Payment Method,Order Status';
$output .= "\n";
diff --git a/classes/core/AltapaySettings.php b/classes/core/AltapaySettings.php
index 0e1d021d..48d7e0fe 100755
--- a/classes/core/AltapaySettings.php
+++ b/classes/core/AltapaySettings.php
@@ -100,8 +100,9 @@ public function altapayOrderStatusCompleted( $orderID ) {
if ( $pay->CapturedAmount > 0 ) {
$this->saveCaptureWarning( 'Could not capture automatically. Manual capture is required for the order: ' . $orderID );
- } else { // Order wasn't captured and must be captured now.
- $amount = $pay->ReservedAmount; // Amount to capture.
+ } else {
+ // Order wasn't captured and must be captured now.
+ $amount = $order->get_total();
try {
if ( $subscription === true ) {
diff --git a/readme.txt b/readme.txt
index 79089ba2..75200eaf 100644
--- a/readme.txt
+++ b/readme.txt
@@ -4,10 +4,10 @@ Tags: AltaPay, Gateway, Payments, WooCommerce, Payment Card Industry
Requires PHP: 7.4
Requires at least: 5.0
Tested up to: 6.7.1
-Stable tag: 3.7.5
+Stable tag: 3.7.6
License: MIT
WC requires at least: 3.9.0
-WC tested up to: 9.4.3
+WC tested up to: 9.5.1
License URI: http://www.gnu.org/licenses/gpl-2.0.html
A plugin that integrates your WooCommerce web shop to the AltaPay payments gateway.
@@ -39,6 +39,10 @@ AltaPay's Payment Gateway for WooCommerce provides merchants with access to a fu
== Changelog ==
+= 3.7.6 =
+* Fix: Charge subscriptions using the renewal order total instead of the original reserved amount.
+* Support export reconciliation data with WooCommerce High-Performance Order Storage (HPOS).
+
= 3.7.5 =
* Display agreement information in the "AltaPay Payment Actions" grid.
* Show the "pending payment" status if the subscription is awaiting a charge.
diff --git a/tests/integration-test/cypress/e2e/PageObjects/objects.cy.js b/tests/integration-test/cypress/e2e/PageObjects/objects.cy.js
index 18370a20..c2b71ef4 100644
--- a/tests/integration-test/cypress/e2e/PageObjects/objects.cy.js
+++ b/tests/integration-test/cypress/e2e/PageObjects/objects.cy.js
@@ -131,13 +131,17 @@ class Order {
cy.get("#toplevel_page_woocommerce > ul > li:nth-child(3) > a").click()
cy.get('tr').eq(1).click()
cy.get('#openCaptureModal').click().wait(2000)
- cy.get('.lh-copy > :nth-child(1) > :nth-child(7) > .form-control').click().clear().type('0').click()
- cy.get('#altapay_capture').click()
+ cy.get('.ap-order-capture-modify').first().click().clear().type('0')
+ cy.get('#altapay_capture').click().wait(3000)
+ cy.get('.payment-captured').then(($span) => {
+ const captured_amount = parseFloat($span.text().trim()); // Extract the value and convert to a number
+ expect(captured_amount).to.be.greaterThan(0); // Assert that the amount is greater than 0
+ });
+
+
}
refund() {
-
-
cy.get('#openRefundModal').click().wait(3000)
cy.get('#altapay_refund').click().wait(5000)
cy.get('body').then(($a) => {
@@ -151,19 +155,13 @@ class Order {
}
partial_refund() {
-
- cy.get('#toplevel_page_woocommerce > .wp-has-submenu > .wp-menu-name').click({force:true}).wait(3000)
- cy.get('body').then(($a) => {
-
- if ($a.find('.components-modal__header > .components-button').length) {
- cy.get('.components-modal__header > .components-button').click().wait(2000)
- }
- })
- cy.get("#toplevel_page_woocommerce > ul > li:nth-child(3) > a").click()
- cy.get('tr').eq(1).click()
- cy.get('#openRefundModal').click().wait(3000)
- cy.get('#TB_ajaxContent > [style="overflow-x:auto;"] > .responsive-table > .w-100 > :nth-child(3) > :nth-child(1) > :nth-child(7) > .form-control').click().clear().type('0').click()
- cy.get('#altapay_refund').click().wait(2000)
+ cy.get('#openRefundModal').click().wait(2000)
+ cy.get('.ap-order-refund-modify').first().click().clear().type('0')
+ cy.get('#altapay_refund').click().wait(3000)
+ cy.get('.payment-refunded').then(($span) => {
+ const refunded_amount = parseFloat($span.text().trim()); // Extract the value and convert to a number
+ expect(refunded_amount).to.be.greaterThan(0); // Assert that the amount is greater than 0
+ });
}
diff --git a/wiki.md b/wiki.md
index 19cbd5fa..bef4db6a 100644
--- a/wiki.md
+++ b/wiki.md
@@ -275,13 +275,13 @@ In order to reconcile payments please follow the steps below:
Minimum system requirements are:
- WordPress min. 5.0 – max. 6.7.1
-- WooCommerce min. 3.9.0 – max. 9.4.3
+- WooCommerce min. 3.9.0 – max. 9.5.1
- PHP 7.4 and above
- PHP-bcmath library installed.
- PHP-curl MUST be enabled.
The latest tested version is:
-- WordPress 6.7.1, WooCommerce 9.4.3 and PHP 8.1
+- WordPress 6.7.1, WooCommerce 9.5.1 and PHP 8.1
## Troubleshooting