#kashi3029

1 messages · Page 1 of 1 (latest)

heavy belfryBOT
#

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.

copper spoke
#

@split sky my colleague already answered your question in the previous thread right?

split sky
#

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

copper spoke
#

how are you creating the subscription? through Checkout or manually?

split sky
#

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

copper spoke
#

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

split sky
#

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
copper spoke
#

?

split sky
#

it's not working

copper spoke
#

you're using confirmPayment

split sky
#

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,
},
});

copper spoke
#

ok I see

split sky
#

this is my current function

copper spoke
#

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

split sky
#

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

copper spoke
#

pending_setup_intent is the ID of the SetupIntent

split sky
#

Do i need to create SetupInetnt?

#

onst setupIntent = await stripe.setupIntents.create({
payment_method_types: ['card'],
});

copper spoke
#

no

#

it's on the Subscription object

split sky
#

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

copper spoke
#

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

split sky
#

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
}

copper spoke
#

no that's not correct

#

you need to add both expansions

#

in one array

split sky
#

I don't know how to add

#

Okay

copper spoke
#

expand: ["latest_invoice.payment_intent", "pending_setup_intent"]

split sky
#

let me try

#

Thanks it's working

copper spoke
#

let me know if you need any more help

split sky
#

how to get all transcation of perticuler cutomer?

copper spoke
split sky
#

{
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

copper spoke
split sky
#

still geting { object: 'list', data: [], has_more: false, url: '/v1/charges' }

copper spoke
#

hmmm interesting

#

since these are coming from an invoice

split sky
#

cus_PBBOwKvb2jgUHm this is my customer

copper spoke
split sky
#

Now I am getting but dose this provide one time payment as well?

copper spoke
#

no

split sky
#

as I have one time payment plan also

copper spoke
#

it's really complicated to have all of this information without using Report Runs

split sky
#

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,
});
}
}

copper spoke
#

you can improve this drastically

#

because there will be duplicates

#

give me a second

split sky
#

yeh sure

copper spoke
#

you need to ignore PaymentIntents with an Invoice ID so you wouldn't have duplicates

#

no need for the Charges List

split sky
#

Okay let me try than new logic

copper spoke
split sky
#

Okay

heavy belfryBOT
split sky
#

Can I show creadite amout in list like If creadit customer 100 doller how can show in payment history

native herald
#

hi there!

#

I'm not sure I understand your question. can you try to re-explain it with a concrete example?

split sky
#

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

native herald
#

and what your question exactly? you don't know how to do this?

split sky
#

yes

native herald
split sky
#

I want history of credtid if creadit today 100 dollar after one month i credit 200 dollar I need that list

native herald
#

we don't store that information on Stripe's end. so you'll need to store this on your end

split sky
#

Okay cool

#

is this correct way to write query for stripe search query: "status==succeeded AND invoice==null",

native herald
#

it depends, what exactly are you trying to search for?

split sky
#

I want all successed status with invoice null

native herald
#

but of what? PaymentIntent? Invoices? Charges? soemthing else?

#

also your query looks wrong. it should be something like:

query: "status:'succeeded' AND invoice:null",
split sky
#

PaymentInetent and Invoices

native herald
#

so you can use status but not invoice