gform_stripe_payment_element_subscriptions_automatic_charge_methods

There are two methods for creating a subscription, the first is automatically charging the customer’s payment method, and the second is sending an invoice to the customer and waiting for it to be paid. Some payment methods support only the second method. This filter allows you to change the list of payment methods that support automatic charging. This can be used to add a certain payment method that later supports automatic charging or even to remove one of the hardcoded methods if they stop supporting it.

Usage

add_filter(  'gform_stripe_payment_element_subscriptions_automatic_charge_methods', function ( $methods, $feed, $form )

Parameters

Example

add_filter(  'gform_stripe_payment_element_subscriptions_automatic_charge_methods', function ( $methods, $feed, $form ) {
   
    $methods = array_merge(  $methods, array( ‘sofort’ ) )

    unset( $methods[‘sepa_debit’] );

    return $methods;
} );

Placement

This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.

See also the PHP section in this article: Where Do I Put This Code?

Since

This filter was added in Stripe version 5.0.

Source Code

return apply_filters( 'gform_stripe_payment_element_subscriptions_automatic_charge_methods', $methods, $feed, $form );

This filter is located in GF_Payment_Element_Payment::get_subscriptions_automatic_charge_methods() in class-gf-payment-element-payment.php