#razvi073

1 messages · Page 1 of 1 (latest)

idle swiftBOT
jade prairie
#

hi! you wouldn't use confirmCardSetup.

sharp falcon
#

I tried but I am receiving this error: { "error": { "message": "Payment details were collected through Stripe Elements using automatic payment methods and cannot be confirmed with a Setup Intent configured with payment_method_types.", "request_log_url": "https://dashboard.stripe.com/test/logs/req_UmzR6VlVJVqVh6?t=1695201380", "setup_intent": { "id": "seti_1NsMVwHPmb4c2WP9ZBkezBXB", "object": "setup_intent", "automatic_payment_methods": null, "cancellation_reason": null, "client_secret": "seti_1NsMVwHPmb4c2WP9ZBkezBXB_secret_Ofhv0nmeJDDx2AmTAyKFYxvMP5FDmrj", "created": 1695201368, "description": null, "last_setup_error": null, "livemode": false, "next_action": null, "payment_method": null, "payment_method_types": [ "card" ], "status": "requires_payment_method", "usage": "off_session" }, "type": "invalid_request_error" } }

#

The setup intent is for a subscription that has a 3 day trial period

jade prairie
#

looking. I just tested this on my account and it works though, but as I recall from yesterday there's something special you're doing, I'll have to look more closely

sharp falcon
#

It works in test mode?

jade prairie
#

for me yes but maybe I'm doing someething different than you

sharp falcon
#

`const customer = await stripe.customers.create(params);
const ephemeralKey = await stripe.ephemeralKeys.create(
{
customer: customer.id,
},
{ apiVersion: '2022-11-15' }
);

let weeklySubscription: any = await stripe.subscriptions.create({
customer: customer.id,
items: [
{
price: weeklyPrice,
},
],
payment_behavior: 'default_incomplete',
payment_settings: {
save_default_payment_method: 'on_subscription',
},
expand: ['latest_invoice.payment_intent', 'pending_setup_intent'],
trial_end: weeklyTrialEndDate,
});`

#

this is how i get the pending_setup_intent

#

after that i return return { paymentIntent: yearlySubscription.latest_invoice['payment_intent'].client_secret, pendingIntent: weeklySubscription.pending_setup_intent['client_secret'], ephemeralKey: ephemeralKey.secret, customer: customer.id, yearlySubscriptionId: yearlySubscription.id, weeklySubscriptionId: weeklySubscription.id, };

#

don't mind the yearlySubscription, that works

jade prairie
#

ah the difference I think is you use the deferred flow

sharp falcon
#

I use this for both payment element and the payment request button

jade prairie
#

as in you don't pass the client_secret when initialising Elements, you use mode:"setup" and create the Subscription/return back the client_secret later when the submit button is pressed right?

sharp falcon
#

yes

jade prairie
#

yeah then it seems like that integration is not compatible with using the SetupIntent you get from a Subscription, which is something we have to fix really, I'll file some internal feedback later(and you should raise through https://support.stripe.com/?contact=true as well)

sharp falcon
#

ok, i guess i could first get the intent and create the element after that

#

do you have a doc at hand?

jade prairie
#

but in the meantime to get this to work you would have to use a different approach, like use the non-deferred flow (create the Subscription when the page loads and set the client secret when creating the Element), or use Checkout, or use CardElement with confirmCardSetup instead of PaymentElement

jade prairie
sharp falcon
#

ok

#

and one more unrelated question

#

i am also using the Payment Request Button

#

is there a way to control which paymentMethod shows up

#

so that i can choose if the person has both googlePay and link enabled, to show applePay on one button and link on the other

#

?

jade prairie
#

not really, no, the PaymentRequestButton can only show one option at a time

sharp falcon
#

yes, but can i choose which one of the three to show?

jade prairie
#

no, it uses its own logic, per the table in the docs

#

the ExpressCheckoutElement is supposed to be the new thing you use if you want multiple buttons or more options(but as we discussed yesterday and today, seems like the experience is broken when integrating with Subscriptions and we need to improve things)

sharp falcon
#

ok

#

thanks for the help

jade prairie
#

oh wait

#

can you try something? apparently if you pass payment_method_types to the Element that might make it work

var elements = stripe.elements({
  mode: 'setup',
  // .... 
  // ....
  payment_method_types:["card"]
});
#

I think it's not a great solution, but it might work/help here

sharp falcon
#

sure, gimme a sec

#

it worked

#

thank you very much