| @@ -498,36 +498,11 @@ | ||
| 498 | 498 | * @return array Array of payment method configurations. |
| 499 | 499 | * @since 2.4.0 |
| 500 | 500 | */ |
| 501 | 501 | private function get_registered_payment_methods() { |
| 502 | - $methods = []; | |
| 503 | - | |
| 504 | - // Get enabled payment methods from block attributes. | |
| 505 | - $enabled_methods = $this->payment_methods; | |
| 506 | - | |
| 507 | - // Filter to get method configurations - start with Stripe as default. | |
| 508 | - $available_methods = apply_filters( | |
| 509 | - 'srfm_payment_methods_registry', | |
| 510 | - [ | |
| 511 | - 'stripe' => [ | |
| 512 | - 'id' => 'stripe', | |
| 513 | - 'label' => __( 'Stripe', 'sureforms' ), | |
| 514 | - 'description' => __( 'Pay with credit or debit card', 'sureforms' ), | |
| 515 | - 'icon' => 'credit-card', | |
| 516 | - 'enabled' => $this->stripe_connected, | |
| 517 | - 'container_class' => 'srfm-stripe-payment-element', | |
| 518 | - ], | |
| 519 | - ] | |
| 520 | - ); | |
| 521 | - | |
| 522 | - // Filter enabled methods. | |
| 523 | - foreach ( $enabled_methods as $method_id ) { | |
| 524 | - if ( isset( $available_methods[ $method_id ] ) && $available_methods[ $method_id ]['enabled'] ) { | |
| 525 | - $methods[ $method_id ] = $available_methods[ $method_id ]; | |
| 526 | - } | |
| 527 | - } | |
| 528 | - | |
| 529 | - return $methods; | |
| 502 | + // Shared with the submission-side guard (Front_End::validate_payment_fields), so | |
| 503 | + // the renderer and the guard can never disagree about whether this field is usable. | |
| 504 | + return Payment_Helper::get_registered_payment_methods( [ 'paymentMethods' => $this->payment_methods ] ); | |
| 530 | 505 | } |
| 531 | 506 | |
| 532 | 507 | // BOTH MODE: start — helper renderers for the dual-mode chooser and amount displays. |
| 533 | 508 | |