doc: add buy now button with conditional rendering and error conditional rendering
This commit is contained in:
1 parent
2010f9423e
commit
1d023fd69b
1 file changed
+7
@@ -12,6 +12,8 @@ function Payment() {
|
|||||||
const stripe = useStripe();
|
const stripe = useStripe();
|
||||||
const elements = useElements();
|
const elements = useElements();
|
||||||
|
|
||||||
|
const [succeeded, setSucceed] = useState(false);
|
||||||
|
const [processing, setProcessing] = useState("");
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
const [disabled, setDisabled] = useState(true);
|
const [disabled, setDisabled] = useState(true);
|
||||||
|
|
||||||
@@ -70,7 +72,12 @@ function Payment() {
|
|||||||
thousandSeparator={true}
|
thousandSeparator={true}
|
||||||
prefix={"$"}
|
prefix={"$"}
|
||||||
/>
|
/>
|
||||||
|
<button disabled={processing || disabled || succeeded}>
|
||||||
|
<span>{processing ? <p>Processing...</p> : "Buy Now"}</span>
|
||||||
|
</button>
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
|
{error && <article>{error}</article>}
|
||||||
</form>
|
</form>
|
||||||
</article>
|
</article>
|
||||||
</article>
|
</article>
|
||||||
|
|||||||
Reference in new issue
Block a user