#Lbrito-update-details

1 messages ยท Page 1 of 1 (latest)

vestal cloud
#

Hi there! Taking a look!

ashen fossil
#

Thank you!

vestal cloud
#

What is happening when they can't update the details?

#

Like what are they seeing on their end.

ashen fossil
#

We catch the errors from Stripe, we can't really see which one they are getting back. It's not a card declined.

#

Wondering if those logs mean something to you

vestal cloud
#

Doing a little digging

#

I think these are just related to our fraud prevention and analytics stuff and aren't actually influential on your ability to use Elements.

#

So I don't think those are the cause of any issue that is happening... they can mostly just be ignored.

#

By "those" I mean all errors related to r.stripe

ashen fossil
#

Oh, ok

vestal cloud
#

Yep I confirmed, these shouldn't be having any affect on your integration.

ashen fossil
#

Does this one make sense?

vestal cloud
#

Ah okay yeah that is an error from Stripe.JS so that could be impactful

#

What integration flow are you using?

#

And what styling are you trying to apply to the Element?

ashen fossil
#

We are using these

vestal cloud
#

Okay and what styling?

ashen fossil
#

Not sure if it helps

vestal cloud
#

Yeah that does, in the future you can post that directly inline here using three ` so that the code is more accessible (as opposed to a screenshot)

#

Let me give it a look

ashen fossil
#
import React from 'react';
import PropTypes from 'prop-types';
import {
  CardNumberElement,
  CardExpiryElement,
  CardCvcElement,
  ElementsConsumer,
} from '@stripe/react-stripe-js';

import c from './cardDetails.scss';
import FormInput from '@atoms/FormInput';
import PaymentContext from 'contexts/PaymentContext';
import { Notification } from '@molecules';

const style = {
  base: {
    fontSize: '16px',
    color: '#373838',
    fontFamily: "'Roboto Mono', monospace",
    fontSmoothing: 'antialiased',
    '::placeholder': {
      fontFamily: "'Roboto', sans-serif",
      color: '#808383',
    },
    ':focus': {
      '::placeholder': {
        color: '#c9cdcd',
      },
    },
    '::-ms-clear': {
      display: 'none',
    },
  },
  invalid: {
    color: '#D20000',
    ':focus': {
      color: '#303238',
    },
  },
  complete: {},
};

const cardBrandToPaymentClass = {
  visa: 'card-icon-visa',
  mastercard: 'card-icon-mastercard',
  amex: 'card-icon-amex',
  discover: 'card-icon-discover',
  diners: 'card-icon-diners',
  jcb: 'card-icon-jcb',
  unknown: 'card-icon-standard',
};
class CardDetails extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      cardNumberFocused: false,
      cardNumberError: false,
      cardExpiryFocused: false,
      cardExpiryError: false,
      cardCVCFocused: false,
      cardCVCError: false,
      brandClassName: 'card-icon-standard',
      errorMessage: '',
      userInfo: {
        firstname: '',
        lastname: '',
      },
    };
#
this.setCardNumberFocused = this.setCardNumberFocused.bind(this);
    this.setCardExpiryFocused = this.setCardExpiryFocused.bind(this);
    this.setCardCVCFocused = this.setCardCVCFocused.bind(this);
    this.setFocused = this.setFocused.bind(this);
    this.handleCardNumberChange = this.handleCardNumberChange.bind(this);
    this.handleCardExpiryChange = this.handleCardExpiryChange.bind(this);
    this.handleCardCVCChange = this.handleCardCVCChange.bind(this);
    this.setBrandIcon = this.setBrandIcon.bind(this);
    this.hasError = this.hasError.bind(this);
  }

  setFocused(key, focused) {
    this.setState({ [key]: focused });
  }

  setCardNumberFocused(focused) {
    return () => {
      this.setFocused('cardNumberFocused', focused);
    };
  }

  setCardExpiryFocused(focused) {
    return () => {
      this.setFocused('cardExpiryFocused', focused);
    };
  }

  setCardCVCFocused(focused) {
    return () => {
      this.setFocused('cardCVCFocused', focused);
    };
  }

  setBrandIcon(brand) {
    var brandClassName = 'card-icon-standard';
    if (brand in cardBrandToPaymentClass) {
      brandClassName = cardBrandToPaymentClass[brand];
    }
    this.setState({ brandClassName });
  }

  handleCardNumberChange(payload) {
    const hasError = payload.error && payload.error.type === 'validation_error';
    this.setState({
      cardNumberError: hasError,
      errorMessage: payload.error ? payload.error.message : '',
    });
    if (payload.brand) {
      this.setBrandIcon(payload.brand);
    }
    if (this.props.setCardFieldsComplete) {
      this.props.setCardFieldsComplete({
        cardNumberComplete: payload.complete,
      });
    }
  }

#

  handleCardExpiryChange(payload) {
    const hasError = payload.error && payload.error.type === 'validation_error';
    this.setState({
      cardExpiryError: hasError,
      errorMessage: payload.error ? payload.error.message : '',
    });
    if (this.props.setCardFieldsComplete) {
      this.props.setCardFieldsComplete({
        cardExpiryComplete: payload.complete,
      });
    }
  }

  handleCardCVCChange(payload) {
    const hasError = payload.error && payload.error.type === 'validation_error';
    this.setState({
      cardCVCError: hasError,
      errorMessage: payload.error ? payload.error.message : '',
    });
    if (this.props.setCardFieldsComplete) {
      this.props.setCardFieldsComplete({
        cardCVCComplete: payload.complete,
      });
    }
  }

  hasError() {
    return this.state.cardCVCError || this.state.cardExpiryError || this.state.cardNumberError;
  }

  render() {
    const { firstname, lastname, showHeader, showNameAndSurname } = this.props;

    const numberClasses =
      `${this.state.cardNumberFocused ? c['card-details__input--focused'] : ''} ` +
      `${this.state.cardNumberError ? c['card-details__input--error'] : ''} ` +
      `${
        this.props.cardFieldCompleteStates.cardNumberComplete
          ? c['card-details__input--complete']
          : ''
      }`;

    const expiryClasses =
      `${this.state.cardExpiryFocused ? c['card-details__input--focused'] : ''} ` +
      `${this.state.cardExpiryError ? c['card-details__input--error'] : ''} ` +
      `${
        this.props.cardFieldCompleteStates.cardExpiryComplete
          ? c['card-details__input--complete']
          : ''
      }`;
#

Does it help? There is a short limit on characters

steep monolith
#

Hi ๐Ÿ‘‹ I'm stepping in for @vestal cloud

ashen fossil
#

Hey

steep monolith
#

Well that's an awful lot of context! Gimme a minute to catch up ๐Ÿ™‚

ashen fossil
#

Hahahah thanks

steep monolith
#

Okay so you are rendering the individual Card component elements. And I can see where you are passing the base style.

#

And this error is occurring when your users attempt to update their card information?

ashen fossil
#

Yes

steep monolith
#

So they can use the same form to enter the information?

ashen fossil
#

What do you mean enter the information?

#

They click update, but they get an error back from Stripe

steep monolith
#

Okay so it doesn't happen when they are entering the information, only once they click the update button?

ashen fossil
#

Yeah

steep monolith
#

And which part of the above code handles the action that triggers?

ashen fossil
#

Sorry it's taking me a awhile, following the trail

steep monolith
#

You and me both ๐Ÿ˜…

ashen fossil
#

So we do this:

  handleCardNumberChange(payload) {
    const hasError = payload.error && payload.error.type === 'validation_error';
    this.setState({
      cardNumberError: hasError,
      errorMessage: payload.error ? payload.error.message : '',
    });
    if (payload.brand) {
      this.setBrandIcon(payload.brand);
    }
    if (this.props.setCardFieldsComplete) {
      this.props.setCardFieldsComplete({
        cardNumberComplete: payload.complete,
      });
    }
  }
``` on the card number which I guess might trigger that error? Even though the user says it's only on submit
#

Looking for the submit code

steep monolith
#

The error message you are receiving leads me to think it has to do with changing inline styling in a way that is considered unsafe. This code snippet seams to handle notifying the user if they have mis-entered their card info (not enough numbers, etc.). I'm curious if your submit handler does any modification to inline styling

ashen fossil
#

Doesn't seem to

steep monolith
#

So is the ChangeCard the form that is being rendered? In that case I would think the this.onChangeCardClick function would be a good place to look

ashen fossil
#

No styling as far as I can find

#

Just state

steep monolith
#

Okay so this is where I'd put some logging. I'd put log statements around each of the functions just to see which get executed and where it breaks.

#

That would at least give you a place to start digging

#

Can you recreate the user failure locally?

ashen fossil
#

Nope

steep monolith
#

Well that's going to make finding any resolution kind of a shot in the dark. I haven't run across this before myself. I don't use React but the react-stripe-js package is just a React wrapper around Stripe.js functionality.

ashen fossil
#

Yeah :/

steep monolith
#

However it would not be the first time that I've seen less than helpful error messages. If you can figure out how recreate the error (create some fake customers using the Testmode API key) then I'd start logging around those state changes and see how far the code execution gets

ashen fossil
#

Ok, yeah have been trying to find a way to reproduce, but nothing from the user journey stands out

#

Thanks for the tips, I guess I will give it another go

steep monolith
#

Does the error occur with all users or only a subset?

ashen fossil
#

The specific one only one user is complaining

#

But we have been having a few having difficulties updating their card information with Stripe errors, not all give us logs though

steep monolith
#

Yeah, if the errors are occurring in Stripe.js then it won't reach the API and we won't have logs.

ashen fossil
#

Ok

#

Yeah our other issues seem to be SCA related, some users are not being prompted with the extra authentication

steep monolith
ashen fossil
#

Yeah we have being using them

#

It only seems to affect a few users

steep monolith
ashen fossil
#

Yeah I have come across them, indeed the code needs a revamp

#

Thanks for the help

steep monolith
#

Sorry we couldn't get to a quick win. Some problems need more digging.

ashen fossil
#

Yeah, no worries. At least we can check that styling more carefully and can be an extra argument to apply time to update the code