如何编辑此 Gravity form stripe 插件代码以便我也可以从信用卡中扣款?

How to edit this Gravity form stripe addon code so that I can charge the credit card as well?

Gravity Forms 有一个连接到 Stripe 的 Stripe 插件,允许一次性和重复购买。该功能运行良好,除了对于一次性购买,它不会在 Stripe 中创建客户。 (相比之下,它确实为重复购买创建了 Stripe 客户。)

https://docs.gravityforms.com/create-customer-stripe-without-payment/.

这段代码的问题在于它只允许您创建客户。我需要创建一个客户并从信用卡中扣款。 代码片段如下:

add_filter( 'gform_stripe_customer_id', function ( $customer_id, $feed, $entry, $form ) {
GFCommon::log_debug( __METHOD__ . '(): running.' );
if ( rgars( $feed, 'meta/transactionType' ) == 'product' && rgars( $feed, 'meta/feedName' ) == 'feed name goes here' ) {
    GFCommon::log_debug( __METHOD__ . '(): Working for feed ' . rgars( $feed, 'meta/feedName' ) );
    $customer_meta = array();

    $email_field = rgars( $feed, 'meta/receipt_field' );
    if ( ! empty( $email_field ) && strtolower( $email_field ) !== 'do not send receipt' ) {
        $customer_meta['email'] = gf_stripe()->get_field_value( $form, $entry, $email_field );
    }

    $customer = gf_stripe()->create_customer( $customer_meta, $feed, $entry, $form );
    GFCommon::log_debug( __METHOD__ . '(): Returning Customer ID ' . $customer->id );

    return $customer->id;
}

return $customer_id;
}, 10, 4 );

add_filter( 'gform_stripe_charge_authorization_only', function ( $authorization_only, $feed ) 
{
if ( rgars( $feed, 'meta/feedName' ) == 'feed name goes here' ) {
    GFCommon::log_debug( __METHOD__ . '(): running for feed ' . rgars( $feed, 'meta/feedName' ) );
    return true;
}

return $authorization_only;
}, 10, 2 );

add_filter( 'gform_stripe_charge_pre_create', function( $charge_meta, $feed, $submission_data, $form, $entry ) {
if ( rgars( $feed, 'meta/feedName' ) == 'feed name goes here' ) {
    GFCommon::log_debug( __METHOD__ . '(): running for feed ' . rgars( $feed, 'meta/feedName' ) );
    $charge_meta['setup_future_usage'] = 'off_session';
}

return $charge_meta;
}, 10, 5 );

你总是可以 create the customer yourself and then provide it when creating a payment intent (or a charge)。 Gravity是否支持传入客户我不知道。您必须联系我们,询问是否支持以及如何支持。