Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
Angular and Stripe - Expanding Customer Retrieve to get Sources

I'm trying to integrate Angular 8 with Stripe. Reading the documentation, I did see that I need to expand the Customer retrieve to get the Sources data, but I didn't get yet:

customers.ts

// Read the stripe customer ID from firestore, or create a new one if missing
export const getOrCreateCustomer = async (uid: string) => {
  const user = await getUser(uid);
  const customerId = user && user.stripeCustomerId;
  const listOptions = {limit: 100};

  // If missing customerID, create it
  if (!customerId) {
    return createCustomer(uid);
  } else {
    const params = stripe.customers.listSources(customerId, listOptions); // -> this is my start approach, but I don't know how to include it into Customer Retrieve
    const customer = stripe.customers.retrieve(customerId);
    console.log(customer);
    return customer;
  }
};

sources.ts

// Attaches a payment source to a stripe customer account.
export const attachSource = async (uid: string, source: string) => {

    const customer = await getOrCreateCustomer(uid);

    const existingSource = customer.sources.data.filter((s) => s.id === source).pop();// -> here there is an error

    if (existingSource) {
        return existingSource;
    } else {
        await stripe.customers.createSource(customer.id, { source });
        return await stripe.customers.update(customer.id, { default_source: source });
    }
};

Since I couldn't expand the Customer retrieve, the sources.ts file displays the error:

Property 'sources' does not exist on type 'Response | (DeletedCustomer & { lastResponse: { headers: { [key: string]: string; }; requestId: string; statusCode: number; apiVersion?: string; idempotencyKey?: string; stripeAccount?: string; }; })'. Property 'sources' does not exist on type 'DeletedCustomer & { lastResponse: { headers: { [key: string]: string; }; requestId: string; statusCode: number; apiVersion?: string; idempotencyKey?: string; stripeAccount?: string; }; }'.ts(2339)

I found in a post something similar, but in PHP, that mentions about cards. But I didn't understand if it would be the same thing I'm looking for (furthermore, it doesn't explain how to get the data I need).

How can I do this?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda