-
- spawn new construct
-
-
+
+ {subInfo()}
+ {unsubBtn()}
);
diff --git a/client/src/components/account.status.jsx b/client/src/components/account.status.jsx
index fce012cf..422d2233 100644
--- a/client/src/components/account.status.jsx
+++ b/client/src/components/account.status.jsx
@@ -13,11 +13,18 @@ function pingColour(ping) {
const addState = connect(
function receiveState(state) {
const {
+ ws,
account,
ping,
} = state;
+ function sendAccountStates() {
+ ws.sendEmailState();
+ ws.sendSubscriptionState();
+ }
+
return {
+ sendAccountStates,
account,
ping,
};
@@ -49,10 +56,16 @@ function AccountStatus(args) {
account,
ping,
accountPage,
+ sendAccountStates,
} = args;
if (!account) return null;
+ function accountClick() {
+ sendAccountStates();
+ accountPage();
+ }
+
return (
@@ -61,7 +74,7 @@ function AccountStatus(args) {
{ping}ms
-
+
);
}
diff --git a/client/src/events.jsx b/client/src/events.jsx
index 04a4e6f6..dc00440b 100644
--- a/client/src/events.jsx
+++ b/client/src/events.jsx
@@ -19,6 +19,10 @@ function registerEvents(store) {
setNav('play');
}
+ function setSubscription(sub) {
+ store.dispatch(actions.setSubscription(sub));
+ }
+
function setConstructList(constructs) {
store.dispatch(actions.setConstructs(constructs));
}
@@ -227,6 +231,7 @@ function registerEvents(store) {
setPing,
setShop,
setTeam,
+ setSubscription,
setWs,
notify,
diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx
index 73c8e16c..35c45a64 100644
--- a/client/src/reducers.jsx
+++ b/client/src/reducers.jsx
@@ -44,6 +44,8 @@ module.exports = {
skip: createReducer(false, 'SET_SKIP'),
shop: createReducer(false, 'SET_SHOP'),
+ subscription: createReducer(null, 'SET_SUBSCRIPTION'),
+
team: createReducer([], 'SET_TEAM'),
teamPage: createReducer(0, 'SET_TEAM_PAGE'),
teamSelect: createReducer([null, null, null], 'SET_TEAM_SELECT'),
diff --git a/client/src/socket.jsx b/client/src/socket.jsx
index 02c1735d..e548ed95 100644
--- a/client/src/socket.jsx
+++ b/client/src/socket.jsx
@@ -143,6 +143,15 @@ function createSocket(events) {
function sendMtxConstructSpawn() {
send(['MtxConstructSpawn', {}]);
}
+
+ function sendEmailState() {
+ send(['EmailState', {}]);
+ }
+
+ function sendSubscriptionState() {
+ send(['SubscriptionState', {}]);
+ }
+
// -------------
// Incoming
// -------------
@@ -170,8 +179,9 @@ function createSocket(events) {
events.setTeam(constructs);
}
- function onAccountSubscription() {
- events.notify('Your account has been set to cancelled. You will no longer be billed. Thanks for playing.');
+ function onSubscriptionState(sub) {
+ // events.subscriptionState(`Subscription cancelled. Your subscription will remain active until ${exp}. Thank you for your support.`);
+ events.setSubscription(sub);
}
function onConstructSpawn(construct) {
@@ -208,7 +218,7 @@ function createSocket(events) {
AccountTeam: onAccountTeam,
AccountInstances: onAccountInstances,
AccountShop: onAccountShop,
- AccountSubscription: onAccountSubscription,
+ SubscriptionState: onSubscriptionState,
ConstructSpawn: onConstructSpawn,
GameState: onGameState,
EmailState: onEmailState,
@@ -326,6 +336,9 @@ function createSocket(events) {
sendItemInfo,
+ sendEmailState,
+ sendSubscriptionState,
+
sendMtxApply,
sendMtxBuy,
sendMtxConstructSpawn,
diff --git a/server/src/payments.rs b/server/src/payments.rs
index 2961c1f8..798563fb 100644
--- a/server/src/payments.rs
+++ b/server/src/payments.rs
@@ -3,7 +3,7 @@ use std::io::Read;
use http::State;
use iron::prelude::*;
-use iron::response::HttpResponse;
+
use iron::status;
use persistent::Read as Readable;
@@ -13,10 +13,10 @@ use postgres::transaction::Transaction;
use failure::Error;
use failure::err_msg;
-use stripe::{Client, Event, EventObject, CheckoutSession, SubscriptionStatus};
+use stripe::{Client, Event, EventObject, CheckoutSession, SubscriptionStatus, Subscription};
use http::{MnmlHttpError};
-use pg::{PgPool};
+use pg::{Db, PgPool};
use account;
use account::Account;
@@ -36,7 +36,7 @@ pub fn subscription_account(tx: &mut Transaction, sub: String) -> Result
Result