#Daniel M.-multiple-products

1 messages · Page 1 of 1 (latest)

worn gull
#

Hi 👋 sorry, but I'm not sure I understand the question here. How are you currently integrating with Stripe (using Checkout Sessions, the Payment Element, or perhaps something else)?

abstract aurora
#
imports ...
.
.
.


const stripePromise = loadStripe(
  '...'
);

interface StripeAppearance {
  theme: 'stripe' | 'night' | 'flat' | 'none' | undefined;
}

const StripeProvider: FC = ({ children }) => {
  const dispatch = useDispatch();
  const [clientSecret, setClientSecret] = useState<string>('');

  useEffect(() => {
    // Create PaymentIntent as soon as the page loads
    createClientsecret(setClientSecret);
  }, []);

  useEffect(() => {
    dispatch(setReduxClientSecret(clientSecret));
  }, [clientSecret]);

  const appearance: StripeAppearance = {
    theme: 'stripe'
  };

  const options = {
    clientSecret,
    appearance
  };
  return (
    <>
      {clientSecret && (
        <Elements options={options} stripe={stripePromise}>
          {children}
        </Elements>
      )}
    </>
  );
};

export default StripeProvider;
#
createNewIntent = async (req, res) => {
  const paymentIntent = await stripe.paymentIntents.create({
    amount: process.env.STRIPE_AUDIT_PRICE,
    currency: "eur",
    automatic_payment_methods: {
      enabled: true,
    },
  });
  const intent = paymentIntent;
  res.send(intent);
#

the stripeprovider wraps the whole react app routes with this only clientintent for the audit price (the audit product which im selling)

#

but now I also sell something different, so I cant wrap all the app routes like i was told to do before right?

worn gull
#

Sorry, but I'm still not sure I'm following. The amount parameter there in that last snippet drives the amount for the payment, so if your code structure doesn't allow you to adjust that then you won't be able to charge for varying amounts.

abstract aurora
#

i see

#

i think you already helped me a lot with that

#

thanks!