get_payment_method(), [ Gateway_Card::ID, Gateway_Wallet::ID ], true ) || ! $order->has_status( [ 'pending', 'on-hold' ] ) || $order->is_paid() || '' !== (string) $order->get_meta( Meta::PAID_INVOICE ) ) { return $text; } return __( 'We are waiting for ePay.bg to confirm your payment.', 'syntopia-pay' ); } public static function cancel_notice(): void { if ( ! isset( $_GET['syntopia_pay_cancelled'], $_GET['key'] ) || '1' !== $_GET['syntopia_pay_cancelled'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- the order key is the capability; nothing is written. return; } $order = wc_get_order( absint( get_query_var( 'order-pay' ) ) ); $key = sanitize_text_field( wp_unslash( $_GET['key'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- see above. if ( ! $order instanceof \WC_Order || ! Receipt_Page::key_matches( $order, $key ) || ! $order->needs_payment() ) { return; } wc_print_notice( __( 'Payment was not completed. You can try again or choose another method.', 'syntopia-pay' ), 'notice' ); } public static function keep_unpaid( bool $cancel, \WC_Order $order ): bool { if ( ! in_array( $order->get_payment_method(), Plugin::gateway_ids(), true ) || $order->is_paid() || '' !== (string) $order->get_meta( Meta::PAID_INVOICE ) ) { return $cancel; } $entry = Attempts::entry( $order, Attempts::current_invoice( $order ) ); return null !== $entry && (int) ( $entry['expires'] ?? 0 ) > time() ? false : $cancel; } }