import React from 'react'; import axios from 'axios'; import Modal from 'react-responsive-modal'; import braintree from 'braintree-web-drop-in'; import BraintreeDropin from 'braintree-dropin-react'; import Help from '../common/Help.jsx'; export default class Upgrade extends React.Component { constructor(props) { super(props); this.state = { fetching: false, plans: null, error: '', modalOpen: false, customerToken: '', plan: null, processingPayment: false, paymentError: null, }; } async componentDidMount() { this.setState({ fetching: true }); try { let request = await axios.get('/upgrade/plans'); this.setState({ plans: request.data.plans }); } catch (e) { this.setState({ error: 'Failed to load plans, try again later.' }); } this.setState({ fetching: false }); } async subscribe(plan) { let tokenRequest = await axios.post('/upgrade/token'); this.setState({ token: tokenRequest.data.token, plan, modalOpen: true }); } closeModal = () => { if (this.state.processingPayment) return; this.setState({ token: '', plan: null, modalOpen: false }); } handlePaymentMethod = async (payload) => { this.setState({ processingPayment: true }); const { plan } = this.state; const planId = plan.id; console.log('payload', payload); this.setState({ paymentError: null }); try { let result = await axios.post('/upgrade/process', { paymentMethodNonce: payload.nonce, planId: planId, }); if (result.data && result.data.success) { this.setState({ processingPayment: false }); this.closeModal(); window.location.href = '/account'; } } catch (err) { this.setState({ paymentError: { ...err.response.data, retry: false } }); setTimeout(_ => { this.setState({ paymentError: { ...this.state.paymentError, retry: true }, processingPayment: false }) }, 5000); } } renderSubmitButton = ({ onClick, isDisabled, text }) => { if (this.state.processingPayment) { text = 'Processing payment...'; } if (this.state.paymentError !== null && this.state.paymentError.retry === false) { text = 'Error processing payment!' } return ( ); } render() { if (this.state.fetching || this.state.plans === null) { return (

Please wait...

); } if (this.state.error !== '') { return (

{this.state.error}

); } const paypal = { flow: 'vault', }; const modalClasses = { modal: 'upgrade-modal', }; return (

Priority Support

Our staff is always ready to help you with any matters. From setting up the bot, to figuring out how to use it, we got you covered.

Embed editor

Use our intuitive and feature rich embed editor to post pretty looking messages, announcements, rules, or whatever you like! Edit the embeds & send them directly from the dashboard.

Voice Text Linking

Create channels that can only be seen when a member is in voice chat. Dyno will automatically reveal the channel once they join voice, and will remove it once they leave it

Auto purge

Keep your channels clean by automatically purging them every once in a while. Configure once and Dyno will do it for you.

Slow mode

Busy chat? Dyno can limit the number of messages your users can send on an interval, fully customizable with per-channel rules, user slowmode and channel slowmode!

Premium music

Enjoy your tunes with volume control, exclusive premium voice nodes with guaranteed uptime and no song length limits!

And more!

Premium users have all feature limits lifted, near perfect uptime, faster response times, better server specs, 2 minutes restarts and faster updates! You also get an exclusive role on the Dyno servers & access to an exclusive channel!
Premium Plans
{this.state.plans.premiumPlans.map((plan, i) => (
{plan.name}
Premium for {plan.qty} server
${plan.price} / month
${(plan.price / plan.qty).toFixed(2)} / server
this.subscribe(plan)} className={'button is-info'}>Subscribe now
))} {/* {this.state.plans.premiumPlans.map(plan => ())} {this.state.plans.premiumPlans.map(plan => ())} {this.state.plans.premiumPlans.map(plan => ( ))} {this.state.plans.premiumPlans.map(plan => ())}
{plan.name}
Number of Servers{plan.qty}
Price ${(plan.price / plan.qty).toFixed(2)} / server
${plan.price} / month
this.subscribe(plan)} className={'button is-info'}>Subscribe now
*/}

Payment

{this.state.paymentError !== null && this.state.paymentError.processorResponse !== undefined ? (

Payment failed! — {this.state.paymentError.error}

Code {this.state.paymentError.processorResponse.code} - {this.state.paymentError.processorResponse.text}

{this.state.paymentError.processorResponse.additional !== '' ? (

{this.state.paymentError.processorResponse.additional}

) : ''}

Transaction ID: {this.state.paymentError.transaction}

You have not been charged.

) : ''} {this.state.paymentError !== null && this.state.paymentError.processorResponse === undefined ? (

Payment failed!

{this.state.paymentError.error}

You have not been charged.

) : ''}
{this.state.plan ? (

Purchasing {this.state.plan.name} at a monthly recurring cost of USD$ {this.state.plan.price}

) : ''}
); } }