Skip to content

Commit c23050e

Browse files
committed
Fix subscription check when no subscription present
1 parent 790b5f6 commit c23050e

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Gateways/Abstracts/WCMoneiPaymentGatewayComponent.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ abstract class WCMoneiPaymentGatewayComponent extends WCMoneiPaymentGateway {
3434
public function process_payment( $order_id, $allowed_payment_method = null ) {
3535
$order = new WC_Order( $order_id );
3636
$payload = $this->create_payload( $order, $allowed_payment_method );
37-
$payload = ( $this->handler->is_subscription_order( $order_id ) ) ? $this->handler->create_subscription_payload( $order, $allowed_payment_method, $payload ) : $payload;
37+
$payload = $this->handler === null || ! ( $this->handler->is_subscription_order( $order_id ) ) ? $payload : $this->handler->create_subscription_payload( $order, $allowed_payment_method, $payload );
3838

3939
/**
4040
* If payment is tokenized ( saved cc ) we just need to create_payment with token and everything will work fine.

src/Gateways/PaymentMethods/WCGatewayMoneiCC.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ public function payment_fields() {
269269
esc_html_e( 'Pay via MONEI: you can add your payment method for future payments.', 'monei' );
270270
// Always use component form in Add Payment method page.
271271
$this->render_monei_form();
272-
} elseif ( $this->handler->is_subscription_change_payment_page() ) {
272+
} elseif ( $this->handler !== null && $this->handler->is_subscription_change_payment_page() ) {
273273
// On subscription change payment page, we always use component CC.
274274
echo esc_html( $this->description );
275275
if ( $this->tokenization ) {
@@ -341,7 +341,7 @@ class="wc-block-components-validation-error"
341341
*/
342342
public function monei_scripts() {
343343
// If merchant wants Component CC or is_add_payment_method_page that always use this component method.
344-
if ( $this->redirect_flow && ! is_checkout() && ! is_add_payment_method_page() && ! $this->handler->is_subscription_change_payment_page() ) {
344+
if ( $this->redirect_flow && ! is_checkout() && ! is_add_payment_method_page() && ($this->handler && ! $this->handler->is_subscription_change_payment_page() ) ) {
345345
return;
346346
}
347347

0 commit comments

Comments
 (0)