#Yousuf

1 messages · Page 1 of 1 (latest)

desert gardenBOT
dusty dock
#

Hello! What's the error?

#

Also I think it's off_session and not offSession.

dusty dock
#

Let's keep everything in this thread please. Here's your latest message:

I am still getting the same error, INTERNAL. When I remove < setup_future_usage: 'off_session',>, the error goes away but it doesnt save the payment in the payment sheet for future use. Note: I am using react native and firebase cloud functions:

exports.createStripeCharge = functions.https.onCall(async (data, context) => {
const amount = data.amount; // Amount in cents
const customer = data.customer
// const paymentMethodId = data.paymentMethodId;
console.log("customer ID: ", data.customer)
try {
const paymentIntent = await stripe.paymentIntents.create({
amount:1000,
currency: 'usd',
customer:customer,
setup_future_usage: 'off_session',

    automatic_payment_methods: {
      enabled: true,
    },
    // payment_method: paymentMethodId,
    confirm: true,
  });
  console.log("ssssssss")
  return { clientSecret: paymentIntent.client_secret };
} catch (error) {
  throw new functions.https.HttpsError('internal', 'Payment failed 4', "" +error.message);
}

});

#

There should be more information about the error beyond just "INTERNAL". Can you check your error logs or add some logging to your code to surface more details about what's going wrong, like a stack trace?

boreal adder
#

the payment failed 3 alert is going off, and this is the log that am getting LOG [Error: INTERNAL]:

This my client side function:

const onPay = async () => {

try {
  console.log(loggedUser.stripeCustomer)
  setpaymentLoading(true);
  const { data } = await functions().httpsCallable('createStripeCharge')({
    customer: loggedUser.stripeCustomer, // Provide the customer ID to fetch saved payment methods
  });

  const { error: paymentSheetError } = await initPaymentSheet({
    paymentIntentClientSecret: data.clientSecret,
  });

  if (paymentSheetError) {
    Alert.alert('Something went wrong 1', paymentSheetError.message);
    return;
  }
  const { error } = await presentPaymentSheet();
  if (error) {
    Alert.alert('Payment failed 2', error.message);
  } else {
    Alert.alert('Payment successful');
    joinMatch();
  }
} catch (error) {
  console.log(error)
  Alert.alert('Payment failed 3', error.message);
} finally {
  setpaymentLoading(false);
}

};

dusty dock
#

Right, but that's not really all that helpful. I need more details about the error. When you log the error what does that show? Can you find a stack trace?

boreal adder
#

one sec, i am trying accessss the server side logs

#

StripeInvalidRequestError: You must provide a return_url when confirming a PaymentIntent using automatic_payment_methods[enabled] set to true and automatic_payment_methods[allow_redirects] set to always.
at StripeError.generate (/workspace/node_modules/stripe/cjs/Error.js:10:20)
at res.toJSON.then.Error_js_1.StripeAPIError.message (/workspace/node_modules/stripe/cjs/RequestSender.js:105:54)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {

dusty dock
#

Ah, okay, so that error explains the issue.

boreal adder
#

.
.
.
if i remove the setup_future_usage, the payment sheet shows after the paymentIntent is created as expected.

dusty dock
#

Not sure I understand?

boreal adder
#

The error started showing up once I added
<setup_future_usage: 'off_session'> to my paymentIntent.

dusty dock
boreal adder
#

sure

#

req_7IJBGDAMVrHyYZ

dusty dock
#

I think setup_future_usage is not the only thing that's changing. Looks like you're also setting confirm to true.

boreal adder
#

yup, i just removed it and it worked

#

the payment method was added to the customer in stripe dashboard but the payment method isnt appearing in the payment sheet. Does that make sense?

dusty dock
#

Yes. I don't think exsting payment methods like that appear in the PaymentSheet.

desert gardenBOT
boreal adder
#

I am not sure though if I need to create the r Ephemeral Key everytime I create a paymentIntent?

dusty dock
#

Yeah, you would, that's how access is granted to the Customer.