subscription_protocol; return wp_kses_post( Component::tag( 'sc-payment-methods-list' ) ->id( 'sc-customer-payment-methods-list' ) ->with( [ 'isCustomer' => User::current()->isCustomer(), 'canDetachDefaultPaymentMethod' => $protocol->default_payment_method_detach_enabled ?? false, 'query' => [ 'customer_ids' => array_values( User::current()->customerIds() ), 'page' => 1, 'per_page' => 100, 'reusable' => true, ], ] )->render( ( $attributes['title'] ?? __( 'Payment Methods', 'surecart' ) ) ? "" . ( $attributes['title'] ?? __( 'Payment Methods', 'surecart' ) ) . '' : '' ) ); } public function getProcessors() { return array_values( array_filter( Processor::get() ?? [], function ( $processor ) { return $processor->live_mode === $this->isLiveMode() && $processor->recurring_enabled && $processor->enabled; } ) ); } /** * Get the processor by type. * * @param string $type The processor type. * @param array $processors Array of processors. * * @return \SureCart/Models/Processor|null; */ protected function getProcessorByType( $type ) { $processors = $this->getProcessors(); if ( empty( $processors ) ) { return null; } $key = array_search( $type, array_column( (array) $processors, 'processor_type' ), true ); if ( ! is_int( $key ) ) { return null; } return $processors[ $key ] ?? null; } /** * Get the success url. * * @param array $attributes The block attributes. * * @return string */ public function getSuccessUrl( $attributes = [] ) { // attribute. if ( ! empty( $attributes['success_url'] ) ) { return esc_url( $attributes['success_url'] ); } // url parameter. if ( ! empty( $_GET['success_url'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended return esc_url( $_GET['success_url'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended } // default. return home_url( add_query_arg( [ 'tab' => $this->getTab() ], remove_query_arg( array_keys( $_GET ) ) ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended } /** * Show a view to add a payment method. * * @param array $attributes The block attributes. * * @return string */ public function create( $attributes = [] ) { // get the success url. $success_url = $this->getSuccessUrl( $attributes ); if ( empty( User::current()->customerId( $this->isLiveMode() ? 'live' : 'test' ) ) ) { ob_start(); ?> isLiveMode() && ! empty( User::current()->customerId( 'test' ) ) ) { ?>
isLiveMode() && ! empty( User::current()->customerId( 'live' ) ) ) { ?>
processor_type; }, $this->getProcessors() ?? [] ) ) ); if ( empty( $processor_names ) ) { return '' . __( 'You cannot currently add a payment method. Please contact us for support.', 'surecart' ) . ''; } ob_start(); ?> isLiveMode() ? '' . esc_html__( 'Test Mode', 'surecart' ) . '' : ''; ?> getProcessorByType( 'mollie' ); if ( $mollie ) : ?> find( User::current()->customerId( $this->isLiveMode() ? 'live' : 'test' ) ); ?>