#myz123

1 messages · Page 1 of 1 (latest)

pure edgeBOT
#

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.

  • myz123, 2 days ago, 19 messages
  • myz123, 2 days ago, 9 messages
radiant moth
#

hello! can you elaborate a bit more? Do you mean you want to identify the corresponding payment from a refund/dispute event?

autumn monolith
#

I mean if there is a refund or dispute, I should be able to find out the related payment in my database. How can find it?

#

Could you pls show me an example?

#

I only save amount, user name, create time. How can find related transaction

#

Yes, I want to find corresponding payment from a refund or dispute event

radiant moth
#

you should save either (or both) the payment_intent and/or charge id from the refund and dispute object

#

similarly, when you create the payment, you should save the corresponding id

autumn monolith
#

I use webhook, could you give me an example?

#

in javascript

radiant moth
#

can you share your current code snippet for how you're processing webhook events?

autumn monolith
#

I mean how to get them?

#

what's in payment_intent and charge_id

radiant moth
#

you can refer to our API docs to see what parameters can be found in the respective objects :

#

When you receive the webhook event, you can also log the request body to see how it looks like

autumn monolith
#

if (event.type === "checkout.session.completed") {
const uid = metadata.firebaseUID;
const amount = metadata.amount;

    const firestore = admin.firestore();

    try {
        await firestore.runTransaction(async (transaction) => {
            const userRef = firestore.collection('Users').doc(uid);
            const userDoc = await transaction.get(userRef);
            if (userDoc.exists) {
                const userData = userDoc.data();
                const currentBalance = userData?.Readonly?.balance || 0;

                transaction.update(userRef, {
                    'Readonly.balance': parseInt(currentBalance) + parseInt(amount),
                });

                const transactionRef = firestore.collection('Transactions').doc();
                transaction.set(transactionRef, {
                    uid,
                    from: 'Bank Transfer',
                    to: 'My Balance',
                    type: 'stripe',
                    description: 'Deposit',
                    amount: parseInt(amount),
                    createdAt: admin.firestore.FieldValue.serverTimestamp()
                });
            }
        });
    } catch (error) {
        console.error("Error updating pincode: ", error);
        response.json({ received: true, success: false, error });
    }
}
#

this is my code

#

how can obtain these data

radiant moth
#

sorry, but we're not familiar with firebase so that's not something we're going to be able to help with here on this channel

autumn monolith
#

Where can I obtain payment_intent or chargeId? from event.data.object?

radiant moth
#

yep, it should be in there. You can log the event.data.object to see how it looks like

autumn monolith
#

😭

#

If a refund happens will it send me an email? What info I should use to track the payment?

radiant moth
#

As far as I know, there's no such option for an email to be sent to you when a refund occurs. Since you're the one initiating a refund, you would already know that you made a refund, is there a reason why you need an email?

autumn monolith
#

If a user claims that their credit card was stolen, their money would be reclaimed by the bank. But if they have already received services from me, what can I do to compensate for my loss?

radiant moth
#

I'd recommend you reach out to Stripe Support - https://support.stripe.com/contact, they'll be able to advise you better on your questions regarding disputes and how to manage them. We mainly help with developers who want to integrate directly with the Stripe API here on this channel