#0xgrind

1 messages · Page 1 of 1 (latest)

celest widgetBOT
#

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.

silk linden
#

hi! you can store it in your DB yes, or list the customer's payment methods.

plain steppe
#

More specifically, i can share my current route controller:

        const stripeCustomerId = user.stripe_customer_id;
        if (!stripeCustomerId) {
            return res.status(400).json({ message: "User has not onboarded" });
        }

        const customer_obj = await stripe.customers.retrieve(stripeCustomerId);
        if (customer_obj.deleted) {
            return res.status(400).json({ message: "Customer object has been deleted" });
        }

        const payment_method = await stripe.customers.listPaymentMethods(customer_obj.id)
        if (payment_method.data.length == 0) {
            return res.status(400).json({ message: "No payment method found" });
        }

        const paymentIntent = await stripe.paymentIntents.create({
            amount: amount,
            currency: "eur",
            customer: stripeCustomerId,
            payment_method: payment_method.data[0].id, //Note here the data[0].id
            off_session: true,
            confirm: true,
        });

But then i'm not sure which one was the first paymentmethod found

silk linden
#

the list is ordered by most-recently-created-first

plain steppe
#

thank you for you response. I will store the paymentMethodId in db for convenience 🙂

#

can you confirm that this:

const paymentIntent = await stripe.paymentIntents.create({
    amount: amount,
    currency: "eur",
    customer: stripe_customer_id,
    payment_method: payment_method.id,
    confirm: true,
});

Will indeed add the money to the customer balance ?

silk linden
#

no, it will charge the specified payment method for the specified amount.

plain steppe
#

to the specified customer_id no ?

silk linden
#

no.

plain steppe
#

what is the purpose of customer key here

silk linden
#

it's to associate the payment with that customer so that it shows up in their Dashboard page or when you list Charges/PaymentIntents in the API filtered by that customer ID.

#

you are the merchant charging the end-customer's card, you get the money(the amount of the charge minus the Stripe fees is added to the balance of your Stripe account).

plain steppe
#

can i use

transfer_data: {
    destination: customer_id 
}

? or the destination can only be a stripe account/express account

silk linden
#

the destination can only be a connected account yes, not a Customer

plain steppe
#

i understood that the balance of customer_object will only be updated when invoices / subscriptions are made. But is there a way to topup a customer balance ?

#

my main goal would be to sync stripe to our in-app balance, we would like the user to be able to top-up amount in the app and then use the in-app balance for future payment

#

and i don't want to mess up by syncing only our db data, i would like a transactionnal customer object provided by stripe that keep track of payments and balance

silk linden
#

you can manually set the balance (https://stripe.com/docs/api/customers/update?lang=dotnet#update_customer-balance) based on having performed some successful payment I think. But overall Stripe is not a wallet, these are not native concepts. Usually you do something like you maintain a concept of a balance in your system and don't call Stripe to process a payment if they are paying with their balance and instead just decrement it in your database, and when they need to topup you process a real PaymentIntent and update your database with the amount of the payment