@@ -88,19 +88,18 @@ public function subscription_after_payment_success( $confirm_payload, $confirm_p
8888 /**
8989 * Refund that cent.
9090 */
91- MoneiPaymentServices:: refund_payment ( $ confirm_payment ->getId (), 1 );
91+ $ this -> moneiPaymentServices -> refund_payment ( $ confirm_payment ->getId (), 1 );
9292 }
9393
9494 /**
9595 * It adds subscription configuration to the payload.
9696 *
97- * @param $order_id
97+ * @param $order
9898 * @param $payment_method
9999 *
100100 * @return array
101101 */
102- public function create_subscription_payload ( WC_Order $ order_id , $ payment_method , $ payload ): array {
103- $ order = new WC_Order ( $ order_id );
102+ public function create_subscription_payload ( WC_Order $ order , $ payment_method , $ payload ): array {
104103 $ payload ['sequence ' ] = array (
105104 'type ' => 'recurring ' ,
106105 'recurring ' => array (
@@ -112,7 +111,7 @@ public function create_subscription_payload( WC_Order $order_id, $payment_method
112111 * If there is a free trial, (first payment for free) and user has selected a tokenized card,
113112 * We hit a monei limitation, so we need to charge the customer 1 cent, that will be refunded afterwards.
114113 */
115- if ( 0 === monei_price_format ( $ order ->get_total () ) && $ this -> get_payment_token_id_if_selected ( ) ) {
114+ if ( 0 === monei_price_format ( $ order ->get_total () ) && isset ( $ payload [ ' paymentToken ' ] ) ) {
116115 $ payload ['amount ' ] = 1 ;
117116 }
118117
@@ -213,7 +212,7 @@ public function update_subscription_meta_data($subscriptions, $payment): void
213212
214213 public function init_subscriptions ( array $ supports , string $ gateway_id ): array {
215214 add_action ( 'wc_gateway_monei_create_payment_success ' , array ( $ this , 'subscription_after_payment_success ' ), 1 , 3 );
216- add_action ( 'woocommerce_scheduled_subscription_payment_ ' . $ gateway_id , array ( $ this , 'scheduled_subscription_payment ' ), 1 , 3 );
215+ add_action ( 'woocommerce_scheduled_subscription_payment_ ' . $ gateway_id , array ( $ this , 'scheduled_subscription_payment ' ), 1 , 2 );
217216
218217 // Add Payment information to Payment method name in "Subscription" Tab.
219218 add_filter ( 'woocommerce_my_subscriptions_payment_method ' , array ( $ this , 'add_extra_info_to_subscriptions_payment_method_title ' ), 10 , 2 );
@@ -270,7 +269,7 @@ public function get_parent_for_renewal_order_id( $renewal_order ) {
270269 $ subscriptions = wcs_get_subscriptions_for_renewal_order ( $ renewal_order );
271270 $ subscription = array_pop ( $ subscriptions );
272271
273- if ( false === $ subscription ->get_parent_id () ) {
272+ if ( 0 === $ subscription ->get_parent_id () ) {
274273 $ parent_order = null ;
275274 } else {
276275 $ parent_order = $ subscription ->get_parent ();
@@ -280,9 +279,9 @@ public function get_parent_for_renewal_order_id( $renewal_order ) {
280279 /**
281280 * Retrieves parent order from a subscription order.
282281 *
283- * @param WC_Subscription $subscription_order
282+ * @param \WCS_Subscription $subscription_order
284283 *
285- * @return mixed WC_Order|bool
284+ * @return \ WC_Order|false
286285 */
287286 public function get_parent_for_subscription_id ( $ subscription_order ) {
288287 return $ subscription_order ->get_parent ();
@@ -322,6 +321,6 @@ public function cart_has_subscription() {
322321 if (!$ this ->is_subscriptions_addon_enabled ()) {
323322 return false ;
324323 }
325- return is_array ( WC ()->cart ->recurring_carts ) ? count ( WC ()->cart ->recurring_carts ) : 0 ;
324+ return is_array ( WC ()->cart ->recurring_carts ) && count ( WC ()->cart ->recurring_carts ) > 0 ;
326325 }
327326}
0 commit comments