#satyra1

1 messages · Page 1 of 1 (latest)

vagrant elbowBOT
modest spoke
#

👋 happy to help

#

would you mind elaborating?

civic rain
#

so im trying to use

const account = await stripe.accounts.create({
    type: 'standard',
  });
#
export const retriveCustomer = async (
  accountId: string,
  address: IAddress,
  first_name: string,
  last_name: string,
  email: string,
  phone: string
) => {
  const account = await stripe.accounts.retrieve(
    accountId, // ID of the connected account
    { expand: ['external_accounts'] } // Optional parameters to expand the response
  );
  if (!account) {
    throw new Error('no account found');
  }

  const testPaymentMethod = await stripe.paymentMethods.create({
    type: 'card',
    card: {
      number: '4242424242424242',
      exp_month: 12,
      exp_year: 2034,
      cvc: '314',
    },
  });

  return await stripe.customers.create({
    name: `${first_name} ${last_name}`,
    email: account.email ? account.email : email,
    address: {
      city: address.city.toUpperCase(),
      country: address.country.toUpperCase(),
      postal_code: address.postcode.toUpperCase(),
      state: address.state.toUpperCase(),
      line1: `${address.street.toUpperCase()} ${address.buildingnumber.toUpperCase()}`,
    },
    payment_method: testPaymentMethod.id,
    phone: phone,
  });

  // o${ something with the customer
};
modest spoke
#

why do you need to create an Account though?

civic rain
#

ymm its more complex app im trying to make something like uber eats so my users can pay each other

#

ill try to implement stuff like split cost of payment between two users and stuff like this

#

and i hope that connected account will help me make billing easiet etc

modest spoke
#

so my users can pay each other
depending on where your platform is located there would be different restrictions on onboarding individual Accounts

#

in all cases Standard shouldn't be the type for that

civic rain
#

so how should i go with that

modest spoke
#

what exactly?

civic rain
#

lets start with creating standard connected account

#

ymm sorry customer

#

for me its running like this ```js
export const retriveCustomer = async (
accountId: string,
address: IAddress,
first_name: string,
last_name: string,
email: string,
phone: string
) => {
const account = await stripe.accounts.retrieve(
accountId, // ID of the connected account
{ expand: ['external_accounts'] } // Optional parameters to expand the response
);
if (!account) {
throw new Error('no account found');
}

const testPaymentMethod = await stripe.paymentMethods.create({
type: 'card',
card: {
number: '4242424242424242',
exp_month: 12,
exp_year: 2034,
cvc: '314',
},
});

return await stripe.customers.create({
name: ${first_name} ${last_name},
email: account.email ? account.email : email,
address: {
city: address.city.toUpperCase(),
country: address.country.toUpperCase(),
postal_code: address.postcode.toUpperCase(),
state: address.state.toUpperCase(),
line1: ${address.street.toUpperCase()} ${address.buildingnumber.toUpperCase()},
},
payment_method: testPaymentMethod.id,
phone: phone,
});

// o${ something with the customer
};

#

and getting in return "error": "Sending credit card numbers directly to the Stripe API is generally unsafe. We suggest you use test tokens that map to the test card you are using, see https://stripe.com/docs/testing. To enable raw card data APIs in test mode, see https://support.stripe.com/questions/enabling-access-to-raw-card-data-apis.",

modest spoke
#

I'm not sure what you're doing here

#

if you just want to create a customer all you need is the await stripe.customers.create({}) bit

#

you shouldn't be creating the Payment Method like this though

#

instead you can use SetupIntents for example to collect a Payment Method for a customer

civic rain
#

ohh ok i get it now

modest spoke
civic rain
#

the main problem is that i am using react native and there is really not that much docs about

modest spoke
#

that's not true