#razvi073
1 messages · Page 1 of 1 (latest)
hi! you wouldn't use confirmCardSetup.
you would use confirmSetup. https://stripe.com/docs/js/setup_intents/confirm_setup
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
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
It works in test mode?
for me yes but maybe I'm doing someething different than you
`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
ah the difference I think is you use the deferred flow
I use this for both payment element and the payment request button
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?
yes
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)
ok, i guess i could first get the intent and create the element after that
do you have a doc at hand?
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
just the guide at https://stripe.com/docs/payments/save-and-reuse?platform=web&ui=elements , though for the backend you are using your code for creating a Subscription and returning it's pending_setup_intent, instead of creating a new one
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
?
not really, no, the PaymentRequestButton can only show one option at a time
yes, but can i choose which one of the three to show?
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)