#tarunmv30

1 messages · Page 1 of 1 (latest)

high yokeBOT
ripe ginkgo
#

IM trying to retrieve a customer to save their payment details for future payments

#

the customer ID is the cus_NhJH.... string right?

graceful hare
#

Hi, what does your request to save the Payment Method look like?

#

Yes, the customer is would start wit cus_

ripe ginkgo
#

this is my server side function for creating the payment intent

#
  const items = req.body;

  const { total, fee } = calculateOrderAmount(items);

  //retrieves the customer based on the user ID
  const customer = await stripe.customers.retrieve(
    'cus_NhJHZYH5HcMDja'
  );

   // Generate an ephemeral key for the customer
   const ephemeralKey = await stripe.ephemeralKeys.create(
    { customer: customer.id },
    { apiVersion: '2020-08-27', stripeAccount: 'acct_1MsyJPCWAlRghLO7' }
  );


    // Create a PaymentIntent with the order amount and currency
    const paymentIntent = await stripe.paymentIntents.create({
      amount: total,
      currency: 'usd',
      application_fee_amount: fee,
      customer: customer.id,
      setup_future_usage: 'off_session',
      automatic_payment_methods: {
        enabled: true,
      },
    }, {
      stripeAccount: 'acct_1MsyJPCWAlRghLO7',
    });

   

    // Return the necessary information to the client
    res.send({
      customer: customer.id,
      ephemeralKey: ephemeralKey.secret,
      paymentIntent: paymentIntent.client_secret,
      publishableKey: 'pk_test_51MSCbfJMYkCh6QmLjYSQLK5gPtmLvaUMn0KrXsbFVnqVROCRere3kLrAQnKOT2Uepb5fRqv34vjgNAArl8wzPwWd00OoOZlDFj' // replace with your own publishable key
    });
});```
graceful hare
ripe ginkgo
#

Let me see what im doing wrong just a moment

#
  const items = req.body;

  const { total, fee } = calculateOrderAmount(items);

  //retrieves the customer based on the user ID
  const customer = await stripe.customers.retrieve(
    'cus_NhJHZYH5HcMDja'
  );

   // Generate an ephemeral key for the customer
   const ephemeralKey = await stripe.ephemeralKeys.create(
    { customer: customer.id },
    { apiVersion: '2020-08-27', stripeAccount: 'acct_1MsyJPCWAlRghLO7' }
  );


    // Create a PaymentIntent with the order amount and currency
    const paymentIntent = await stripe.paymentIntents.create({
      amount: total,
      currency: 'usd',
      application_fee_amount: fee,
      customer: customer.id,
      setup_future_usage: 'on_session',
      automatic_payment_methods: {
        enabled: true,
      },
    }, {
      stripeAccount: 'acct_1MsyJPCWAlRghLO7',
    });

    // Return the necessary information to the client
    res.send({
      customer: customer.id,
      ephemeralKey: ephemeralKey.secret,
      paymentIntent: paymentIntent.client_secret,
      publishableKey: 'pk_test_51MSCbfJMYkCh6QmLjYSQLK5gPtmLvaUMn0KrXsbFVnqVROCRere3kLrAQnKOT2Uepb5fRqv34vjgNAArl8wzPwWd00OoOZlDFj' // replace with your own publishable key
    });
});```
#

this is the code

#

the error im getting is that a user with that ID does not exist even though i sent you the picture of the user daniel with that ID

#

Error: No such customer: 'cus_NhJHZYH5HcMDja'

ripe ginkgo
graceful hare
#

Can you share the request id for this error please

ripe ginkgo
#

yes

#

req_QC6kjae9M7rVoD

graceful hare
#

If you make the same request directly on your account, QmL it should work.

ripe ginkgo
#

How would I do that im confused

#

and thank you for your help by the way!

#

const customerId = 'cus_NhJHZYH5HcMDja';
const accountId = 'acct_1MsyJPCWAlRghLO7';

const customer = await stripe.customers.retrieve(customerId, {
  stripeAccount: accountId
});
#

is this fix sort of what youre talking about?

graceful hare
#

You use the API key from your QmL account, and make that request

ripe ginkgo
#

youre talking about the publishable key right?

#

Also I think im getting confused because im trying to save the customers payment detail, but im using multi party payments. Is it possible to save card details while using connect to facilitate online orders for a restaurant

graceful hare
#

Can you try that please?

ripe ginkgo
#

yes thank you