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

Fix MobilePay Subscription Payment. #105

Merged
merged 3 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All notable changes to this project will be documented in this file.

## [3.6.6]
- Fix MobilePay Subscription Payment.

## [3.6.5]
- Improve UI for AltaPay Payment Actions grid and move it to the top right side for easy access.

Expand Down
6 changes: 3 additions & 3 deletions altapay.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Payment Gateway to use with WordPress WooCommerce
* Author: AltaPay
* Author URI: https://altapay.com
* Version: 3.6.5
* Version: 3.6.6
* Name: SDM_Altapay
* WC requires at least: 3.9.0
* WC tested up to: 9.0.2
Expand Down Expand Up @@ -39,7 +39,7 @@
}

if ( ! defined( 'ALTAPAY_PLUGIN_VERSION' ) ) {
define( 'ALTAPAY_PLUGIN_VERSION', '3.6.5' );
define( 'ALTAPAY_PLUGIN_VERSION', '3.6.6' );
}

// Include the autoloader, so we can dynamically include the rest of the classes.
Expand Down Expand Up @@ -246,7 +246,7 @@ function altapayAddMetaBoxes() {
: 'shop_order';

add_meta_box(
'altapay-actions',
'altapay-actions-side',
__( 'AltaPay Payment Actions', 'altapay' ),
'altapay_meta_box_side',
$screen,
Expand Down
14 changes: 9 additions & 5 deletions classes/util/UtilMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ public function createOrderLines( $order, $products = array(), $wcRefund = false
if ( ! $cartItems ) {
return new WP_Error( 'error', __( 'There are no items in the cart ', 'altapay' ) );
}

$i = 0;

// generate order lines product by product
foreach ( $cartItems as $key => $item ) {

Expand All @@ -55,7 +58,7 @@ public function createOrderLines( $order, $products = array(), $wcRefund = false
$couponDiscountPercentage = $this->getCouponDiscount( $appliedCouponItems, $item );
}
// get product details for each order line
$productDetails = $this->getProductDetails( $item, $couponDiscountPercentage, $isSubscription );
$productDetails = $this->getProductDetails( $item, $couponDiscountPercentage, ( ( $i == 0 ) ? $isSubscription : 0 ) );

if ( $wcRefund ) {
$orderlineDetails[ $key ] = array(
Expand All @@ -71,13 +74,14 @@ public function createOrderLines( $order, $products = array(), $wcRefund = false
if ( ! $wcRefund && isset( $productDetails['compensation'] ) ) {
$orderlineDetails [] = $productDetails['compensation'];
}

$i++;
}
// get the shipping Details
$shippingDetails = $this->getShippingDetails(
$order,
$products,
$wcRefund,
$isSubscription
$wcRefund
);

if ( $shippingDetails ) {
Expand Down Expand Up @@ -256,7 +260,7 @@ public function compensationAmountOrderline( $productId, $compensationAmount ) {
* @param bool $wcRefund
* @return array|bool
*/
private function getShippingDetails( $order, $products, $wcRefund, $isSubscription = false ) {
private function getShippingDetails( $order, $products, $wcRefund ) {
// Get the shipping method
$orderShippingMethods = $order->get_shipping_methods();
$shippingID = 'NaN';
Expand Down Expand Up @@ -293,7 +297,7 @@ private function getShippingDetails( $order, $products, $wcRefund, $isSubscripti
);
$orderLine->taxAmount = round( $totalShippingTax, 2 );
$orderLine->taxPercent = round( ( $totalShippingTax / $totalShipping ) * 100, 2 );
$goodsType = ( $isSubscription ) ? 'subscription_model' : 'shipment';
$goodsType = 'shipment';
$orderLine->setGoodsType( $goodsType );
$shippingDetails[] = $orderLine;
}
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: AltaPay, Gateway, Payments, WooCommerce, Payment Card Industry
Requires PHP: 7.4
Requires at least: 5.0
Tested up to: 6.5.5
Stable tag: 3.6.5
Stable tag: 3.6.6
License: MIT
WC requires at least: 3.9.0
WC tested up to: 9.0.2
Expand Down Expand Up @@ -39,6 +39,9 @@ AltaPay's Payment Gateway for WooCommerce provides merchants with access to a fu

== Changelog ==

= 3.6.6 =
* Fix MobilePay Subscription Payment.

= 3.6.5 =
* Improve UI for AltaPay Payment Actions grid and move it to the top right side for easy access.

Expand Down
Loading