#formigueiro
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- formigueiro, 1 day ago, 23 messages
- formigueiro, 2 days ago, 17 messages
- formigueiro, 2 days ago, 3 messages
Hello
You can't list for both of those in one request, you would make two requests -- one with each desired status
But yes, this is possible
In short, my backend would have to handle this for me so, right with the two calls
Yep that's correct
by the way
is there an endpoint that brings me data from the card used in the purchase, for example **** **** **** 1234 ?
You can see the last4 by looking at the Card object, yes. Or looking at a Charge's payment_method_details
Mostly depends on what object you are working from to be able to see that
But yes it is available
i was seeim this
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
is right?
just here or directly in the client endpoit? I didn't find this payment_method_details field in the response body
You likely want to use https://stripe.com/docs/api/payment_methods/customer
Are you working backward from a PaymentMethod ID?
nice
If the user uses several cards in different subscriptions, will only one always be returned?
Another question, what would this value be?
If they use different cards in Subs then you would want to look at the PaymentMethod used for that Sub specifically
It is likely set as the default_payment_method
And then you can retrieve that for last4
When bringing subscriptions, would it be best to bring their payment method so?
Not sure what you mean by that?
I need to bring the client's subscriptions and bring their payment methods
https://stripe.com/docs/api/payment_methods/customer_list is that ideal?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
You want to show a UI with all of a Customer's Subscriptions and PaymentMethods?
yes some like this. And in the user interface the user will be able to update their payment method.
Okay then yeah you can use the above API to list all of a Customer's attached PaymentMethods and then https://stripe.com/docs/api/subscriptions/list to list all of their Subscriptions.
perfect
In terms of updating the PaymentMethod, you'll likely want to render Payment Element using a SetupIntent
stripe element do you mean?
Yep
You could also use Stripe Checkout
Totally up to you
Basically you want one of the options in this flow: https://stripe.com/docs/payments/save-and-reuse
As the user will have several subscriptions and possibly several cards.
How would I update this payment method? I just found this, but I saw that no payment data in question is passed: https://stripe.com/docs/api/payment_methods/update
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
For payment I am using stripe checkout, but for editing I am not using
oh, i also could use some with await stripe.billingPortal.sessions.create({
to edit directly on stripe page, right?
To update the PaymentMethod for a Subscription you need to collect a new PaymentMethod for the Customer and then set that PaymentMethod as the new default_payment_method for the Subscription
Yes, this could also be fully handled by the Customer Portal if you want to use that
Basically everything you are doing right now can be done for you by Customer Portal
That's what I didn't understand. Let's suppose, I listed all the payments and in the UI the user clicks and opens the modal with the form to enter new data. How will I make this post
Yes, I know, it's just that the design was inspired and certain things he wants on the platform 😉
This depends what flow you want to use. Are you okay redirecting the customer to Stripe Checkout? Or do you want to embed the payment method collection right in your webpage?
I want to incorporate this case into my panel even without using the stripe flow.
Okay so you want to use https://stripe.com/docs/payments/save-and-reuse?platform=web&ui=elements then
So you create a SetupIntent on your backend, and then you render Payment Element in a form on your frontend
Take a read through that guide
At the moment I don't understand why I would use this SetupIntent. Wouldn't there be a PaymentMethod.modify or PaymentMethod.update to update a payment method for a certain subscription?:
I thought you are trying to collect a new PaymentMethod
Are you only trying to switch what PaymentMethod would be charged based on previously-collected PaymentMethods?
let me explai better: On my page, as I mentioned, I will bring all the subscriptions and all these payment methods for a user (the back will bring everything as needed). When listing payment methods (which have subscriptions), I will have the option to update the payment method or cancel. By clicking on change I will open a modal with also like this in the image. My question is how do I update this payment method that has a subscription attached?
You can't update PaymentMethods themselves (other than select information like the billing_details ) after they have been created.
You have to create a new PaymentMethod in that case.
To do that without charging it immediately, you use a SetupIntent
Like I showed you in the above guide.
That said, looks like you may be using Split Card Elements already based on your screenshot?
But how will I create a new Payment Methods that has a signature attached. So will I cancel the current one and create a new subscription?
yes
im using stripe elements
You don't have to cancel and create a new one. You use a SetupIntent and call confirmCardSetup() (https://stripe.com/docs/js/setup_intents/confirm_card_setup) on the frontend. This will create a new PaymentMethod and attach it to the Customer. Then you update the Subsription to set that new PaymentMehtod as the default_payment_method: https://stripe.com/docs/api/subscriptions/update#update_subscription-default_payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
So my backend needs to create a SetupIntent and return the client_secret. So on the frontend side, before displaying the modal, I need to call the backend route to create a SetupIntent and get the client_secret. Is this necessary to configure the Stripe Elements modal.?
Im using vuejs so something like this? ```js
<template>
<div>
<form @submit.prevent="handleFormSubmit">
<div>
<label for="card-element">Credit card</label>
<div id="card-element"></div>
<div id="card-errors" role="alert"></div>
</div>
<button type="submit">Update</button>
</form>
</div>
</template>
<script>
export default {
setup() {
const stripe = ref(null);
const elements = ref(null);
onMounted(async () => {
const stripePromise = await loadStripe('key');
stripe.value = stripePromise;
elements.value = stripePromise.elements();
});
const handleFormSubmit = async () => {
try {
const response = await fetch('/create_setup_intent', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
customer_id: 'client_id',
}),
});
const data = await response.json();
const { setupIntentClientSecret } = data;
const cardElement = elements.value.create('card');
await stripe.value.confirmCardSetup(setupIntentClientSecret, {
payment_method: {
card: cardElement,
},
});
const updateSubscriptionResponse = await fetch('/update_subscription_payment', {
method: 'PUT',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
subscription_id: 'id_subscription',
new_payment_method_id: setupIntentClientSecret.payment_method,
}),
});
const updateSubscriptionData = await updateSubscriptionResponse.json();
} catch (error) {
console.error(error);
}
};
return {
handleFormSubmit,
};
},
};
</script>```
the /update_subscription_payment endpoint would do something like this? js stripe.Subscription.modify( subscription_id, default_payment_method=new_payment_method_id, )
Yep
Happy to help
Sorry to bother you, just to finish
When bringing signatures, is it possible on my webpage to make the user download any file from the invoice?
https://stripe.com/docs/api/subscriptions/list i saw there isnt some file
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
i would like to allow user download invoice about that subscription
as a PDF for example equal we have on stripe dashboard
Hi there
You have to get it from the invoice object not subscription object: https://stripe.com/docs/api/invoices/object#invoice_object-invoice_pdf
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
So you could either list invoices by subscription id or retrieve a specific invoice if you have its id
So I can keep getting all these subscriptions and when I click on the download button, I pass this "latest_invoice": "in_1MowQWLkdIwHu7ixuzkSPfKd" to the back, and the back does the const invoice = await stripe.invoices.retrieve('in_1MtHbELkdIwHu7ixl4OzzPMv');
Yeah if that's the invoice you need
So the back needs to generate this PDF?
from the object?
So can it be a personalized PDF?
No it's not personalizable
Stripe creates
You don't generate anything. We include it on the invoice object already
sure? wich key?
thats the same body that we have on https://stripe.com/docs/api/invoices/retrieve ?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
What I linked is the invoice_pdf param on the invoice object. The invoice object is what will be returned when you call retrieve
um i think i found
You guys are too much. Thank you very much for your help, open my mind
@pale blaze and @formal abyss ty
Yeah that's the exact param I linked earlier
hehe sorry
No problem