#nick_51639

1 messages · Page 1 of 1 (latest)

cinder torrentBOT
nimble temple
#

This channel is for developers and technical integration questions. For Dashboard related queries, our Support team will be able to assist you better than I can: https://support.stripe.com/contact

wise trench
#

Thanks @nimble temple I will follow up via that channel, could I clarify a different technical issue I'm experiencing instead.

Currently we're configuring a Clients custom Woocommerce page to use the Stripe Checkout Element for it's payments.
Currently we have this setup and working for Credit Card Payments however we want to use BECS Direct Debit (AU) as well.
We've gone through the steps of enabling this in the Stripe Dashboard and updated our code in WooCommerce to contain the payment_method_type for it.

When we test after these steps we still get the following error and I'm unsure how to debug it:
""The provided payment_method_types (["card", "link"]) does not match the expected payment_method_types (["au_becs_debit", "card"]). Try confirming with a Payment Intent that is configured to use the same parameters as Stripe Elements."
"

nimble temple
wise trench
#

One moment I'll get it now

#

I can provide our code as well if that helps

nimble temple
#

The Payment Intent is created from the Subscription: https://dashboard.stripe.com/test/logs/req_e8TceusDgwXaPb

payment_method_types should be set in payment_settings.payment_method_types parameter of the Subscription request: https://stripe.com/docs/api/subscriptions/create#create_subscription-payment_settings-payment_method_types

wise trench
#

Hey @nimble temple following the doc we updated our code to the following:
$subscription = $stripe->subscriptions->create([
'customer' => $customerId,
'cancel_at_period_end' => true,
'payment_behavior' => 'default_incomplete',
'items' => [[
'price' => $price_id,
]],
'payment_settings' => [
'save_default_payment_method' => 'on_subscription',
'payment_method_types' =>[
'au_becs_debit',
'card'
]
],
'expand' => [
'latest_invoice.payment_intent', 'pending_setup_intent'
]
]);

#

However it still returned the error
"message": "The provided payment_method_types (["card"]) does not match the expected payment_method_types (["au_becs_debit", "card"]). Try confirming with a Payment Intent that is configured to use the same parameters as Stripe Elements.",

#

@nimble temple based on the information above are we still missing something? Let me know if you need more of our code it review it

nimble temple
#

Thanks for waiting! Checking it now

#

How do you create the Subscription and payment method now? Do you create payment method then create a subscription with deferred intent flow, or create a subscription first and use its payment intent?

wise trench
#

@nimble temple We create a subscription first and then use the payment intent

nimble temple
#

Thanks for sharing! Can you share the code how you initialise the Elements? It looks like you're using deferred intent flow that isn't meant for such a Subscription use case

wise trench
#

Payment Element Initialise (JS)
const options = {
mode: modeType,
amount: 1099,
currency: 'aud',
'setup_future_usage' : 'off_session',
paymentMethodTypes : [
'au_becs_debit',
//'link',
'card'
],
appearance: {/.../},
};
// Set up Stripe.js and Elements to use in checkout form
elements = stripe.elements(options);

#

PHP Create Payment Intent
$intent = $stripe->paymentIntents->create([
'amount' => $upfront_amount ,
'currency' => 'aud',
'description' => 'Upfront payment for '. $product->get_title(),
'customer' => $customerID,
'setup_future_usage' => 'off_session',
'payment_method_types'=>[
'au_becs_debit',
//'link',
'card'

            ]
        ]);
nimble temple
#

Based on the options setting, you're using deferred intent flow for the Payment Intent created from Subscription. Parameters such as mode, amount, currency, setup_future_usage, paymentMethodTypes are not required

wise trench
#

To summarise the process we:

  • Create the Customer
  • Find the Price in Stripe
  • Create the Subscription
  • Subscription returns Client Secret
  • We use Client Secret for confirming the payment
  • After these steps is when we get the current issue
nimble temple
#

More specifically at step 5 of the guide

#

The elements initialisation isn't correct

wise trench
#

I'll have a look now

#

Thanks for the assistance so far @nimble temple, I'll need to spend some time updating and retesting our code with this latest info in mind.
If I have additional questions in a few hours time or potentially tomorrow can I message again here or should I start a new chat?

nimble temple
#

This is a short-lived thread. Feel free to come back with a new chat with reference to this thread, so that my team will be able to further assist you 🙂

wise trench
#

Great thanks River