Stripe (Other Methods)
// Attribute the purchase to the logged-in customer
window.Humblytics.trackCustomer(customerEmail);Example Implementation
"use client";
import { useState } from "react";
import {
useStripe,
useElements,
PaymentElement,
} from "@stripe/react-stripe-js";
export default function CheckoutForm({ customerEmail, clientSecret }) {
const stripe = useStripe();
const elements = useElements();
const [isSubmitting, setIsSubmitting] = useState(false);
const handleSubmit = async (event) => {
event.preventDefault();
if (!stripe || !elements) return;
setIsSubmitting(true);
// Attribute the revenue right before confirming the payment
window.Humblytics.trackCustomer(customerEmail);
const { error } = await stripe.confirmPayment({
elements,
clientSecret,
confirmParams: {
return_url: `${window.location.origin}/welcome`,
},
});
setIsSubmitting(false);
if (error) {
// handle error state
} else {
// Optionally confirm again after capture if you redirect instead of using return_url
// window.Humblytics.trackCustomer(customerEmail);
}
};
return (
<form onSubmit={handleSubmit}>
<PaymentElement />
<button type="submit" disabled={!stripe || isSubmitting}>
Pay
</button>
</form>
);
}When to Use This Method
Important Notes

Key Benefits
Benefit
Detail
Setting Up Split Tests with Revenue Goals

Troubleshooting
Last updated