Skip to content

Instantly share code, notes, and snippets.

@apotdevin
Created January 4, 2019 14:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apotdevin/09436ba0e5eb8724fc0e9cf4f2392037 to your computer and use it in GitHub Desktop.
Save apotdevin/09436ba0e5eb8724fc0e9cf4f2392037 to your computer and use it in GitHub Desktop.
Final PaymentBox Component
import React from "react";
import { Input, Checkbox, Button, message } from "antd";
export class PaymentBox extends React.Component {
constructor(props) {
super(props);
this.state = {
email: "",
confirm: false
};
}
handleInput = e => {
this.setState({ email: e.target.value });
};
handleCheckbox = e => {
this.setState({ confirm: e.target.checked });
};
render() {
const disabled =
this.state.email !== "" &&
this.state.confirm &&
this.state.email.match(/^([\w.%+-]+)@([\w-]+\.)+([\w]{2,})$/i)
? false
: true;
return (
<div style={{ padding: "15px" }}>
<form
method="POST"
action="https://testnet.demo.btcpayserver.org/apps/37NLaNoSEjz6J39eHUKMdgKYz7gv/pos"
>
<Input
placeholder="Please input your email"
style={{ marginBottom: "10px" }}
onChange={this.handleInput}
onBlur={() =>
!this.state.email.match(/^([\w.%+-]+)@([\w-]+\.)+([\w]{2,})$/i)
? message.warning("Email is not valid")
: null
}
/>
<Checkbox
style={{ marginBottom: "10px" }}
onChange={this.handleCheckbox}
>
I Accept the Terms and Conditions
</Checkbox>
<input type="hidden" name="email" value={this.state.email} />
<input type="hidden" name="orderId" value="CustomSockShopId" />
<input
type="hidden"
name="redirectUrl"
value="https://example.com/thankyou"
/>
<Button
disabled={disabled}
style={{ width: "150px" }}
value={this.props.coin}
htmlType="submit"
name="choiceKey"
>
{`To Payment ($${this.props.price})`}
</Button>
</form>
</div>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment