#kashi3029
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.
- kashi3029, 16 minutes ago, 13 messages
@split sky my colleague already answered your question in the previous thread right?
I have another quetion
when user buy plan with credit stripe is not saving his card details how can I do so user can use that card in future when he update his subsciption
how are you creating the subscription? through Checkout or manually?
manually
first I am creading customer when used add payment detais I am creating subscription but when user has credit its not saving payment details
how can user's subsscription will update without payment method
then in that case you can use the pending_setup_intent on the subscription and send that to the front end
and use it with your PaymentElement
but this time instead of calling confirmPayment you would call confirmSetup
Let me check
const { error }: any = await stripe.confirmPayment({
elements,
clientSecret,
confirmParams: {
// Make sure to change this to your payment completion page
return_url: configData?.returnUrl,
},
});
// This point will only be reached if there is an immediate error when
// confirming the payment. Otherwise, your customer will be redirected to
// your `return_url`. For some payment methods like iDEAL, your customer will
// be redirected to an intermediate site first to authorize the payment, then
// redirected to the `return_url`.
if (
error.type === "card_error" ||
error.type === "validation_error"
) {
toast.error(error.message);
setMessage(error.message);
} else {
setMessage("An unexpected error occurred.");
}
setIsLoading(false); this is my current what change I neeed to make
?
it's not working
you're using confirmPayment
const { error }: any = await stripe.confirmSetup({
elements,
pending_setup_intent,
confirmParams: {
// Make sure to change this to your payment completion page
return_url: configData?.returnUrl,
},
});
ok I see
this is my current function
it's basically the client_secret of the pending_setup_intent that you need to use
same way as you use the client_secret from the latest_invoice.payment_intent
so when creating the subscription in the backend you need to expand on pending_setup_intent and sending the client_secret to the frontend
const { error }: any = await stripe.confirmSetup({
elements,
clientSecret: pending_setup_intent,
confirmParams: {
// Make sure to change this to your payment completion page
return_url: configData?.returnUrl,
},
});
like this
pending_setup_intent is the ID of the SetupIntent
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Do i need to create SetupInetnt?
onst setupIntent = await stripe.setupIntents.create({
payment_method_types: ['card'],
});
can you tell me is this code right?
const { error }: any = await stripe.confirmSetup({
elements,
clientSecret: pending_setup_intent,
confirmParams: {
// Make sure to change this to your payment completion page
return_url: configData?.returnUrl,
},
});
I am geting pending_setup_intent from subscription
IntegrationError: You must pass in a clientSecret when calling stripe.confirmSetup(). I am paasing this seti_1OMoo9GXQ7blAdt6EsMdvIsM
so when creating the subscription in the backend you need to expand on pending_setup_intent and sending the client_secret to the frontend
you need to use the pending_setup_intent.client_secret
Okay let me check
is this correct way?
expand: ["latest_invoice.payment_intent"],
expand: ["pending_setup_intent"],
I not geting expanded view
{
id: 'sub_1OMoumGXQ7blAdt6jtejttcZ',
object: 'subscription',
application: null,
application_fee_percent: null,
automatic_tax: [Object],
billing_cycle_anchor: 1702460380,
billing_thresholds: null,
cancel_at: null,
cancel_at_period_end: false,
canceled_at: null,
cancellation_details: [Object],
collection_method: 'charge_automatically',
created: 1702460380,
currency: 'usd',
current_period_end: 1705138780,
current_period_start: 1702460380,
customer: 'cus_PBA5s2x8NsY83v',
days_until_due: null,
default_payment_method: null,
default_source: null,
default_tax_rates: [],
description: null,
discount: null,
ended_at: null,
items: [Object],
latest_invoice: 'in_1OMoumGXQ7blAdt6YSrJYH80',
livemode: false,
metadata: [Object],
next_pending_invoice_item_invoice: null,
on_behalf_of: null,
pause_collection: null,
payment_settings: [Object],
pending_invoice_item_interval: null,
pending_setup_intent: 'seti_1OMoumGXQ7blAdt6ioRDfq4C',
pending_update: null,
plan: [Object],
quantity: 1,
schedule: null,
start_date: 1702460380,
status: 'active',
test_clock: null,
transfer_data: null,
trial_end: null,
trial_settings: [Object],
trial_start: null
}
expand: ["latest_invoice.payment_intent", "pending_setup_intent"]
let me know if you need any more help
how to get all transcation of perticuler cutomer?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
{
object: 'list',
data: [],
has_more: false,
url: '/v1/payment_intents'
}
I am getting empay array when user use his creding can tell me where can I find all transactions
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
still geting { object: 'list', data: [], has_more: false, url: '/v1/charges' }
cus_PBBOwKvb2jgUHm this is my customer
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Now I am getting but dose this provide one time payment as well?
no
as I have one time payment plan also
it's really complicated to have all of this information without using Report Runs
my current logic is this
async function getPaymentHistory(request) {
const { id } = request.params;
try {
const paymentIntents = await stripe.paymentIntents.list({
customer: id,
limit: 100,
});
const succeededData = paymentIntents?.data?.filter(
(el) => el.status == "succeeded"
);
const paymentWithInvoices = await Promise.all(
succeededData.map(async (payment) => {
if (payment) {
const invoice = await stripe.charges.retrieve(payment.latest_charge);
return { payment, invoice };
} else {
return { payment };
}
})
);
return paymentWithInvoices;
} catch (error) {
return Promise.reject({
statusCode: 400,
customMessage: error,
});
}
}
you can improve this drastically
because there will be duplicates
give me a second
yeh sure
instead of list payment intents I think you could use search PaymentIntents API and filter on status
https://stripe.com/docs/search#query-fields-for-payment-intents
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 can also use auto-pagination https://stripe.com/docs/api/pagination/auto to loop over more records
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 need to ignore PaymentIntents with an Invoice ID so you wouldn't have duplicates
no need for the Charges List
Okay let me try than new logic
instead use the Invoices Search to get also the payments made through an invoice https://stripe.com/docs/api/invoices/search
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Okay
Can I show creadite amout in list like If creadit customer 100 doller how can show in payment history
hi there!
I'm not sure I understand your question. can you try to re-explain it with a concrete example?
I have one customer I have added 100 doller to that customer's credit I want now show all payment history to that customer in that I also want to show creadidet amout in his list of payment history
and what your question exactly? you don't know how to do this?
yes
you can list all PaymentIntents for a Customer with this: https://stripe.com/docs/api/payment_intents/list
and you can retrieve a Customer to find its available balance here: https://stripe.com/docs/api/customers/object#customer_object-balance
I want history of credtid if creadit today 100 dollar after one month i credit 200 dollar I need that list
we don't store that information on Stripe's end. so you'll need to store this on your end
Okay cool
is this correct way to write query for stripe search query: "status==succeeded AND invoice==null",
it depends, what exactly are you trying to search for?
I want all successed status with invoice null
but of what? PaymentIntent? Invoices? Charges? soemthing else?
also your query looks wrong. it should be something like:
query: "status:'succeeded' AND invoice:null",
PaymentInetent and Invoices
here are all the fields you can query for PaymentIntents: https://stripe.com/docs/search#query-fields-for-payment-intents
so you can use status but not invoice