How to get PaymentIntent next_action.type = redirect_to_url instead of use_stripe_sdk for Subscription

In my understanding, the next_action.type will be equal to redirect_to_url only if you choose to manually handle 3D Secure authentication https://stripe.com/docs/payments/payment-intents/verifying-status#manual-3ds-auth

As per documentation:

To handle 3D Secure authentication manually, you can redirect the customer. This approach is used when you manually confirm the PaymentIntent and provide a return_url destination to indicate where the customer should be sent once authentication is complete. Manual PaymentIntent confirmation can be performed on the server or on the client with Stripe.js.

Example using Stripe.js:

stripe.confirmPaymentIntent(
  '{PAYMENT_INTENT_CLIENT_SECRET}',
  {
    payment_method: '{PAYMENT_METHOD_ID}',
    return_url: 'https://example.com/return_url'
  }
).then(function(result) {
  // Handle result.error or result.paymentIntent
});

Example using Stripe Python:

intent = stripe.PaymentIntent.confirm(
  '{PAYMENT_INTENT_ID}',
  payment_method='{PAYMENT_METHOD_ID}',
  return_url='https://example.com/return_url'
)

EDIT: as per @karllekko's comment the {PAYMENT_INTENT_ID} will in your case be latest_invoice.payment_intent.id.