#ahmed99 - payment error

1 messages · Page 1 of 1 (latest)

full peak
#

Where are you seeing an error? Can you share a request or event id I can look at?

lofty breach
#

req_jbL3cI99bHhi4H

full peak
#

Did you look at the error message?

#

You cannot use the test ID 'pm_card_visa' in livemode. If you are testing your integration, please use your testmode API keys instead.

lofty breach
full peak
#

You can't use test payment methods in live mode

#

What do you expect to happen here? What are you trying to do?

lofty breach
#

i think i already changed it.. but still nothing going through

full peak
#

You need to review your integration to figure out why you are supplying a test payment method ID in live mode

lofty breach
#

@broken crow

lofty breach
#

@full peak

full peak
#

Yes but if you look at the error you are sending a test payment method while using your live key

#

Instead of real payment details

#

Can you share the snippet of code you're using to make that request?

lofty breach
#

the problem is that we already seems we fixed that error but still facing payment failed and there are no more logs provided on the dashboard on stripe logs

#

So it's very strange and we been trying to troubleshoot this whole day today and still unable to do so

full peak
#

What are you unable to trouble shoot?

#

Do you have any examples failing where you correctly supply non-test payment info?

broken crow
# full peak Can you share the snippet of code you're using to make that request?
export const stripePayment = functions.https.onCall(async (request: any, response: any) => {
    const { amount, email, customerId } = request;
    try {
        functions.logger.info("user information", email);
        functions.logger.error('details are ', amount, email, customerId);
        var paymentIntent = await stripe.paymentIntents.create({
            amount: amount,
            currency: 'myr',
            receipt_email: email,
            // payment_method: 'card',
            confirm: true,
            customer: customerId,
            payment_method_types: ['card']
        });
        return ({
            status: 200,
            message: "Payment Successful",
            client_secret: paymentIntent.client_secret,
            payment_intent: paymentIntent.id,
        });
    } catch (error) {
        functions.logger.error("Error while creating payment intent", error);
        return ({
            status: 500,
            message: `Payment Failed`,
            data: error
        });
    }
});
full peak
#

That code does not match the request you shared -- there is no payment_method specified

broken crow
full peak
#

It's not optional, no, it needs to be provided as the source of the payment. It looks like you're sending the client secret back to your client. If you're following the recommended guide for client-side confirmation with Stripe.js & Elements, then you should not use confirm when creating the payment intent.

#

Can you share more about your integration, how you're collecting payment details?

broken crow
#
await Stripe.instance.dangerouslyUpdateCardDetails(card);
      final billingDetails = BillingDetails(
        email: user!.email,
        name: user.fullName,
        phone: user.mobileNumber,
      );
      await Stripe.instance.createPaymentMethod(PaymentMethodParams.card(
        billingDetails: billingDetails,
      ));
      final paymentIntentResult = await callPaymentHook(
        amount: amount,
        customerId: user.stripeCustomerId,
        email: user.email,
      );
full peak
#

Ah gotcha

#

But if you are confirming client side then you should not be confirming when you create the payemtn intent

broken crow
#

should i need to add payment_method: confirm..?

full peak
#

No, that's no valid

lofty breach
#

then what do you suggest/propose to solve this error? @full peak

full peak
#

I suggest reviewing our "accept a payment" guide using React Native as a comparison/analog for flutter to following along the steps to complete this payment

#

At a high level:
1/ Create a payment intent on the server
2/ Send the client_secret back to the client
3/ Colelct payment details & confirm the payment on the client using the client secret