diff --git a/.env.defaults b/.env.defaults
index bfeb12fff..5274f8c68 100644
--- a/.env.defaults
+++ b/.env.defaults
@@ -19,7 +19,7 @@ THUMBNAIL_CDN_URL=https://image-processor.vanwanet.com/optimize/
WELCOME_VERSION=1.0
# STRIPE
-STRIPE_PUBLIC_KEY='pk_test_NoL1JWL7i1ipfhVId5KfDZgo'
+# STRIPE_PUBLIC_KEY='pk_test_NoL1JWL7i1ipfhVId5KfDZgo'
# Analytics
MATOMO_URL=https://analytics.lbry.com/
diff --git a/static/app-strings.json b/static/app-strings.json
index e5f45808b..924511e61 100644
--- a/static/app-strings.json
+++ b/static/app-strings.json
@@ -2090,5 +2090,12 @@
"Expand Comments": "Expand Comments",
"Expand": "Expand",
"Load More": "Load More",
+ "You followed @Danheim!": "You followed @Danheim!",
+ "Collection": "Collection",
+ "%channelName% isn't live right now, but the chat is! Check back later to watch the stream.": "%channelName% isn't live right now, but the chat is! Check back later to watch the stream.",
+ "Show this channel your appreciation by sending a donation of Credits. ": "Show this channel your appreciation by sending a donation of Credits. ",
+ "Review": "Review",
+ "Add a Card ": "Add a Card ",
+ " Tip Creators": " Tip Creators",
"--end--": "--end--"
}
diff --git a/ui/component/commentCreate/view.jsx b/ui/component/commentCreate/view.jsx
index 008a28aa1..23b899d99 100644
--- a/ui/component/commentCreate/view.jsx
+++ b/ui/component/commentCreate/view.jsx
@@ -24,7 +24,7 @@ import { Lbryio } from 'lbryinc';
let stripeEnvironment = 'test';
// if the key contains pk_live it's a live key
// update the environment for the calls to the backend to indicate which environment to hit
-if (STRIPE_PUBLIC_KEY.indexOf('pk_live') > -1) {
+if (STRIPE_PUBLIC_KEY && STRIPE_PUBLIC_KEY.indexOf('pk_live') > -1) {
stripeEnvironment = 'live';
}
@@ -245,10 +245,13 @@ export function CommentCreate(props: Props) {
}, 1500);
doToast({
- message: __("You sent %tipAmount% LBRY Credits as a tip to %tipChannelName%, I'm sure they appreciate it!", {
- tipAmount: tipAmount, // force show decimal places
- tipChannelName,
- }),
+ message: __(
+ "You sent %tipAmount% LBRY Credits as a tip to %tipChannelName%, I'm sure they appreciate it!",
+ {
+ tipAmount: tipAmount, // force show decimal places
+ tipChannelName,
+ }
+ ),
});
setSuccessTip({ txid, tipAmount });
@@ -265,7 +268,8 @@ export function CommentCreate(props: Props) {
Lbryio.call(
'customer',
'tip',
- { // round to deal with floating point precision
+ {
+ // round to deal with floating point precision
amount: Math.round(100 * roundedAmount), // convert from dollars to cents
creator_channel_name: tipChannelName, // creator_channel_name
creator_channel_claim_id: channelClaimId,
@@ -387,12 +391,7 @@ export function CommentCreate(props: Props) {
}
}}
>
-
+
@@ -534,6 +533,7 @@ export function CommentCreate(props: Props) {
}}
/>
)}
+ {/* @if TARGET='web' */}
{!claimIsMine && (
)}
+ {/* @endif */}
{isReply && !minTip && (
-1) {
- stripeEnvironment = 'live';
-}
+import { getStripeEnvironment } from 'util/stripe';
+let stripeEnvironment = getStripeEnvironment();
const DEFAULT_TIP_AMOUNTS = [1, 5, 25, 100];
const MINIMUM_FIAT_TIP = 1;
@@ -100,7 +94,7 @@ function WalletSendTip(props: Props) {
// check if creator has a payment method saved
React.useEffect(() => {
- if (channelClaimId && isAuthenticated) {
+ if (channelClaimId && isAuthenticated && stripeEnvironment) {
Lbryio.call(
'customer',
'status',
@@ -118,16 +112,18 @@ function WalletSendTip(props: Props) {
setHasSavedCard(Boolean(defaultPaymentMethodId));
});
}
- }, [channelClaimId, isAuthenticated]);
+ }, [channelClaimId, isAuthenticated, stripeEnvironment]);
// check if creator has an account saved
React.useEffect(() => {
const tipInputElement = document.getElementById('tip-input');
- if (tipInputElement) { tipInputElement.focus() }
+ if (tipInputElement) {
+ tipInputElement.focus();
+ }
}, []);
React.useEffect(() => {
- if (channelClaimId) {
+ if (channelClaimId && stripeEnvironment) {
Lbryio.call(
'account',
'check',
@@ -149,7 +145,7 @@ function WalletSendTip(props: Props) {
// console.log(error);
});
}
- }, [channelClaimId]);
+ }, [channelClaimId, stripeEnvironment]);
const noBalance = balance === 0;
const tipAmount = useCustomTip ? customTipAmount : presetTipAmount;
@@ -175,7 +171,9 @@ function WalletSendTip(props: Props) {
let explainerText = '';
if (activeTab === TAB_BOOST) {
iconToUse = ICONS.LBC;
- explainerText = __('This refundable boost will improve the discoverability of this %claimTypeText% while active.', {claimTypeText});
+ explainerText = __('This refundable boost will improve the discoverability of this %claimTypeText% while active.', {
+ claimTypeText,
+ });
} else if (activeTab === TAB_FIAT) {
iconToUse = ICONS.FINANCE;
explainerText = __('Show this channel your appreciation by sending a donation in USD. ');
@@ -216,7 +214,7 @@ function WalletSendTip(props: Props) {
} else if (tipAmount < MINIMUM_PUBLISH_BID) {
tipError = __('Amount must be higher');
}
- // if tip fiat tab
+ // if tip fiat tab
} else {
regexp = RegExp(/^(\d*([.]\d{0,2})?)$/);
const validTipInput = regexp.test(String(tipAmount));
@@ -276,7 +274,8 @@ function WalletSendTip(props: Props) {
Lbryio.call(
'customer',
'tip',
- { // round to fix issues with floating point numbers
+ {
+ // round to fix issues with floating point numbers
amount: Math.round(100 * tipAmount), // convert from dollars to cents
creator_channel_name: tipChannelName, // creator_channel_name
creator_channel_claim_id: channelClaimId,
@@ -297,7 +296,7 @@ function WalletSendTip(props: Props) {
}),
});
})
- .catch(function(error) {
+ .catch(function (error) {
let displayError = 'Sorry, there was an error in processing your payment!';
if (error.message !== 'payment intent failed to confirm') {
@@ -316,10 +315,10 @@ function WalletSendTip(props: Props) {
}
}
- const countDecimals = function(value) {
+ const countDecimals = function (value) {
const text = value.toString();
const index = text.indexOf('.');
- return (text.length - index - 1);
+ return text.length - index - 1;
};
function handleCustomPriceChange(event: SyntheticInputEvent<*>) {
@@ -387,7 +386,9 @@ function WalletSendTip(props: Props) {
const displayAmount = !isNan(tipAmount) ? amountToShow : '';
if (activeTab === TAB_BOOST) {
- return (claimIsMine ? __('Boost Your %claimTypeText%', {claimTypeText}) : __('Boost This %claimTypeText%', {claimTypeText}));
+ return claimIsMine
+ ? __('Boost Your %claimTypeText%', { claimTypeText })
+ : __('Boost This %claimTypeText%', { claimTypeText });
} else if (activeTab === TAB_FIAT) {
return __('Send a $%displayAmount% Tip', { displayAmount });
} else if (activeTab === TAB_LBC) {
@@ -416,7 +417,16 @@ function WalletSendTip(props: Props) {
{/* if there is no LBC balance, show user frontend to get credits */}
{/* if there is lbc, the main tip/boost gui with the 3 tabs at the top */}
}
+ title={
+
+ }
subtitle={
{!claimIsMine && (
@@ -429,7 +439,9 @@ function WalletSendTip(props: Props) {
button="alt"
onClick={() => {
const tipInputElement = document.getElementById('tip-input');
- if (tipInputElement) { tipInputElement.focus() }
+ if (tipInputElement) {
+ tipInputElement.focus();
+ }
if (!isConfirming) {
setActiveTab(TAB_LBC);
}
@@ -438,20 +450,24 @@ function WalletSendTip(props: Props) {
/>
{/* tip fiat tab button */}
{/* @if TARGET='web' */}
- {
- const tipInputElement = document.getElementById('tip-input');
- if (tipInputElement) { tipInputElement.focus() }
- if (!isConfirming) {
- setActiveTab(TAB_FIAT);
- }
- }}
- className={classnames('button-toggle', { 'button-toggle--active': activeTab === TAB_FIAT })}
- />
+ {stripeEnvironment && (
+ {
+ const tipInputElement = document.getElementById('tip-input');
+ if (tipInputElement) {
+ tipInputElement.focus();
+ }
+ if (!isConfirming) {
+ setActiveTab(TAB_FIAT);
+ }
+ }}
+ className={classnames('button-toggle', { 'button-toggle--active': activeTab === TAB_FIAT })}
+ />
+ )}
{/* @endif */}
{/* tip LBC tab button */}
{
const tipInputElement = document.getElementById('tip-input');
- if (tipInputElement) { tipInputElement.focus() }
+ if (tipInputElement) {
+ tipInputElement.focus();
+ }
if (!isConfirming) {
setActiveTab(TAB_BOOST);
}
@@ -493,33 +511,29 @@ function WalletSendTip(props: Props) {
{setConfirmLabel()}
- {activeTab === TAB_FIAT ?
$ {(Math.round(tipAmount * 100) / 100).toFixed(2)}
:
}
+ {activeTab === TAB_FIAT ? (
+
$ {(Math.round(tipAmount * 100) / 100).toFixed(2)}
+ ) : (
+
+ )}
-
+
setIsConfirming(false)} />
>
- // only show the prompt to earn more if its lbc or boost tab and no balance
- // otherwise you can show the full prompt
- ) : (!((activeTab === TAB_LBC || activeTab === TAB_BOOST) && noBalance)
- ? <>
+ ) : !((activeTab === TAB_LBC || activeTab === TAB_BOOST) && noBalance) ? (
+ <>
{activeTab === TAB_FIAT && !hasCardSaved && (
-
- {' '}{__('To Tip Creators')}
+ {' '}
+ {__('To Tip Creators')}
)}
@@ -625,28 +639,36 @@ function WalletSendTip(props: Props) {
{__('The payment will be made from your saved card')}
)}
>
- // if it's LBC and there is no balance, you can prompt to purchase LBC
- : }}>Supporting content requires %lbc%}
- subtitle={
- }}>
- With %lbc%, you can send tips to your favorite creators, or help boost their content for more people to
- see.
-
- }
- actions={
-
-
-
-
-
- }
- />
+ ) : (
+ // if it's LBC and there is no balance, you can prompt to purchase LBC
+ }}>Supporting content requires %lbc%
+ }
+ subtitle={
+ }}>
+ With %lbc%, you can send tips to your favorite creators, or help boost their content for more people
+ to see.
+
+ }
+ actions={
+
+
+
+
+
+ }
+ />
)
}
/>
diff --git a/ui/component/walletTipAmountSelector/view.jsx b/ui/component/walletTipAmountSelector/view.jsx
index eeb526e39..a57c6d809 100644
--- a/ui/component/walletTipAmountSelector/view.jsx
+++ b/ui/component/walletTipAmountSelector/view.jsx
@@ -11,14 +11,8 @@ import classnames from 'classnames';
import usePersistedState from 'effects/use-persisted-state';
import WalletSpendableBalanceHelp from 'component/walletSpendableBalanceHelp';
import { Lbryio } from 'lbryinc';
-import { STRIPE_PUBLIC_KEY } from 'config';
-
-let stripeEnvironment = 'test';
-// if the key contains pk_live it's a live key
-// update the environment for the calls to the backend to indicate which environment to hit
-if (STRIPE_PUBLIC_KEY.indexOf('pk_live') > -1) {
- stripeEnvironment = 'live';
-}
+import { getStripeEnvironment } from 'util/stripe';
+let stripeEnvironment = getStripeEnvironment();
const DEFAULT_TIP_AMOUNTS = [1, 5, 25, 100];
@@ -76,45 +70,49 @@ function WalletTipAmountSelector(props: Props) {
// check if creator has a payment method saved
React.useEffect(() => {
- Lbryio.call(
- 'customer',
- 'status',
- {
- environment: stripeEnvironment,
- },
- 'post'
- ).then((customerStatusResponse) => {
- const defaultPaymentMethodId =
- customerStatusResponse.Customer &&
- customerStatusResponse.Customer.invoice_settings &&
- customerStatusResponse.Customer.invoice_settings.default_payment_method &&
- customerStatusResponse.Customer.invoice_settings.default_payment_method.id;
+ if (stripeEnvironment) {
+ Lbryio.call(
+ 'customer',
+ 'status',
+ {
+ environment: stripeEnvironment,
+ },
+ 'post'
+ ).then((customerStatusResponse) => {
+ const defaultPaymentMethodId =
+ customerStatusResponse.Customer &&
+ customerStatusResponse.Customer.invoice_settings &&
+ customerStatusResponse.Customer.invoice_settings.default_payment_method &&
+ customerStatusResponse.Customer.invoice_settings.default_payment_method.id;
- setHasSavedCard(Boolean(defaultPaymentMethodId));
- });
- }, []);
+ setHasSavedCard(Boolean(defaultPaymentMethodId));
+ });
+ }
+ }, [stripeEnvironment]);
//
React.useEffect(() => {
- Lbryio.call(
- 'account',
- 'check',
- {
- channel_claim_id: channelClaimId,
- channel_name: tipChannelName,
- environment: stripeEnvironment,
- },
- 'post'
- )
- .then((accountCheckResponse) => {
- if (accountCheckResponse === true && canReceiveFiatTip !== true) {
- setCanReceiveFiatTip(true);
- }
- })
- .catch(function (error) {
- // console.log(error);
- });
- }, []);
+ if (stripeEnvironment) {
+ Lbryio.call(
+ 'account',
+ 'check',
+ {
+ channel_claim_id: channelClaimId,
+ channel_name: tipChannelName,
+ environment: stripeEnvironment,
+ },
+ 'post'
+ )
+ .then((accountCheckResponse) => {
+ if (accountCheckResponse === true && canReceiveFiatTip !== true) {
+ setCanReceiveFiatTip(true);
+ }
+ })
+ .catch(function (error) {
+ // console.log(error);
+ });
+ }
+ }, [stripeEnvironment]);
React.useEffect(() => {
// setHasSavedCard(false);
diff --git a/ui/constants/stripe.js b/ui/constants/stripe.js
new file mode 100644
index 000000000..95f355892
--- /dev/null
+++ b/ui/constants/stripe.js
@@ -0,0 +1,2 @@
+export const TEST = 'test';
+export const LIVE = 'live';
diff --git a/ui/page/file/view.jsx b/ui/page/file/view.jsx
index 987b6bcac..20f39e38b 100644
--- a/ui/page/file/view.jsx
+++ b/ui/page/file/view.jsx
@@ -12,7 +12,6 @@ import FileRenderDownload from 'component/fileRenderDownload';
import RecommendedContent from 'component/recommendedContent';
import CollectionContent from 'component/collectionContentSidebar';
import CommentsList from 'component/commentsList';
-import { Redirect } from 'react-router';
import Button from 'component/button';
import I18nMessage from 'component/i18nMessage';
import Empty from 'component/common/empty';
@@ -145,10 +144,6 @@ function FilePage(props: Props) {
);
}
- if (!claimIsMine && isLivestream) {
- return ;
- }
-
if (obscureNsfw && isMature) {
return (
diff --git a/ui/page/settingsStripeCard/view.jsx b/ui/page/settingsStripeCard/view.jsx
index d3bef38ef..7c1903ab9 100644
--- a/ui/page/settingsStripeCard/view.jsx
+++ b/ui/page/settingsStripeCard/view.jsx
@@ -5,19 +5,14 @@ import React from 'react';
import Page from 'component/page';
import Card from 'component/common/card';
import { Lbryio } from 'lbryinc';
-import { STRIPE_PUBLIC_KEY } from 'config';
import Plastic from 'react-plastic';
import Button from 'component/button';
import * as ICONS from 'constants/icons';
import * as MODALS from 'constants/modal_types';
import * as PAGES from 'constants/pages';
-
-let stripeEnvironment = 'test';
-// if the key contains pk_live it's a live key
-// update the environment for the calls to the backend to indicate which environment to hit
-if (STRIPE_PUBLIC_KEY.indexOf('pk_live') > -1) {
- stripeEnvironment = 'live';
-}
+import { STRIPE_PUBLIC_KEY } from 'config';
+import { getStripeEnvironment } from 'util/stripe';
+let stripeEnvironment = getStripeEnvironment();
const APIS_DOWN_ERROR_RESPONSE = __('There was an error from the server, please try again later');
const CARD_SETUP_ERROR_RESPONSE = __('There was an error getting your card setup, please try again later');
@@ -79,114 +74,116 @@ class SettingsStripeCard extends React.Component {
// TODO: fix this, should be a cleaner way
setTimeout(function () {
// check if customer has card setup already
- Lbryio.call(
- 'customer',
- 'status',
- {
- environment: stripeEnvironment,
- },
- 'post'
- )
- .then((customerStatusResponse) => {
- // user has a card saved if their defaultPaymentMethod has an id
- const defaultPaymentMethod = customerStatusResponse.Customer.invoice_settings.default_payment_method;
- let userHasAlreadySetupPayment = Boolean(defaultPaymentMethod && defaultPaymentMethod.id);
+ if (stripeEnvironment) {
+ Lbryio.call(
+ 'customer',
+ 'status',
+ {
+ environment: stripeEnvironment,
+ },
+ 'post'
+ )
+ .then((customerStatusResponse) => {
+ // user has a card saved if their defaultPaymentMethod has an id
+ const defaultPaymentMethod = customerStatusResponse.Customer.invoice_settings.default_payment_method;
+ let userHasAlreadySetupPayment = Boolean(defaultPaymentMethod && defaultPaymentMethod.id);
- // show different frontend if user already has card
- if (userHasAlreadySetupPayment) {
- let card = customerStatusResponse.PaymentMethods[0].card;
+ // show different frontend if user already has card
+ if (userHasAlreadySetupPayment) {
+ let card = customerStatusResponse.PaymentMethods[0].card;
- let customer = customerStatusResponse.Customer;
+ let customer = customerStatusResponse.Customer;
- let topOfDisplay = customer.email.split('@')[0];
- let bottomOfDisplay = '@' + customer.email.split('@')[1];
+ let topOfDisplay = customer.email.split('@')[0];
+ let bottomOfDisplay = '@' + customer.email.split('@')[1];
- let cardDetails = {
- brand: card.brand,
- expiryYear: card.exp_year,
- expiryMonth: card.exp_month,
- lastFour: card.last4,
- topOfDisplay: topOfDisplay,
- bottomOfDisplay: bottomOfDisplay,
- };
+ let cardDetails = {
+ brand: card.brand,
+ expiryYear: card.exp_year,
+ expiryMonth: card.exp_month,
+ lastFour: card.last4,
+ topOfDisplay: topOfDisplay,
+ bottomOfDisplay: bottomOfDisplay,
+ };
- that.setState({
- currentFlowStage: 'cardConfirmed',
- pageTitle: 'Tip History',
- userCardDetails: cardDetails,
- paymentMethodId: customerStatusResponse.PaymentMethods[0].id,
- });
+ that.setState({
+ currentFlowStage: 'cardConfirmed',
+ pageTitle: 'Tip History',
+ userCardDetails: cardDetails,
+ paymentMethodId: customerStatusResponse.PaymentMethods[0].id,
+ });
- // otherwise, prompt them to save a card
- } else {
- that.setState({
- currentFlowStage: 'confirmingCard',
- });
+ // otherwise, prompt them to save a card
+ } else {
+ that.setState({
+ currentFlowStage: 'confirmingCard',
+ });
- // get a payment method secret for frontend
+ // get a payment method secret for frontend
+ Lbryio.call(
+ 'customer',
+ 'setup',
+ {
+ environment: stripeEnvironment,
+ },
+ 'post'
+ ).then((customerSetupResponse) => {
+ clientSecret = customerSetupResponse.client_secret;
+
+ // instantiate stripe elements
+ setupStripe();
+ });
+ }
+
+ // get customer transactions
Lbryio.call(
'customer',
- 'setup',
+ 'list',
{
environment: stripeEnvironment,
},
'post'
- ).then((customerSetupResponse) => {
- clientSecret = customerSetupResponse.client_secret;
-
- // instantiate stripe elements
- setupStripe();
+ ).then((customerTransactionsResponse) => {
+ that.setState({
+ customerTransactions: customerTransactionsResponse,
+ });
});
- }
+ // if the status call fails, either an actual error or need to run setup first
+ })
+ .catch(function (error) {
+ // errorString passed from the API (with a 403 error)
+ const errorString = 'user as customer is not setup yet';
- // get customer transactions
- Lbryio.call(
- 'customer',
- 'list',
- {
- environment: stripeEnvironment,
- },
- 'post'
- ).then((customerTransactionsResponse) => {
- that.setState({
- customerTransactions: customerTransactionsResponse,
- });
+ // if it's beamer's error indicating the account is not linked yet
+ if (error.message && error.message.indexOf(errorString) > -1) {
+ // send them to save a card
+ that.setState({
+ currentFlowStage: 'confirmingCard',
+ });
+
+ // get a payment method secret for frontend
+ Lbryio.call(
+ 'customer',
+ 'setup',
+ {
+ environment: stripeEnvironment,
+ },
+ 'post'
+ ).then((customerSetupResponse) => {
+ clientSecret = customerSetupResponse.client_secret;
+
+ // instantiate stripe elements
+ setupStripe();
+ });
+ // 500 error from the backend being down
+ } else if (error === 'internal_apis_down') {
+ doToast({ message: APIS_DOWN_ERROR_RESPONSE, isError: true });
+ } else {
+ // probably an error from stripe
+ doToast({ message: CARD_SETUP_ERROR_RESPONSE, isError: true });
+ }
});
- // if the status call fails, either an actual error or need to run setup first
- })
- .catch(function (error) {
- // errorString passed from the API (with a 403 error)
- const errorString = 'user as customer is not setup yet';
-
- // if it's beamer's error indicating the account is not linked yet
- if (error.message && error.message.indexOf(errorString) > -1) {
- // send them to save a card
- that.setState({
- currentFlowStage: 'confirmingCard',
- });
-
- // get a payment method secret for frontend
- Lbryio.call(
- 'customer',
- 'setup',
- {
- environment: stripeEnvironment,
- },
- 'post'
- ).then((customerSetupResponse) => {
- clientSecret = customerSetupResponse.client_secret;
-
- // instantiate stripe elements
- setupStripe();
- });
- // 500 error from the backend being down
- } else if (error === 'internal_apis_down') {
- doToast({ message: APIS_DOWN_ERROR_RESPONSE, isError: true });
- } else {
- // probably an error from stripe
- doToast({ message: CARD_SETUP_ERROR_RESPONSE, isError: true });
- }
- });
+ }
}, 250);
function setupStripe() {
diff --git a/ui/page/show/view.jsx b/ui/page/show/view.jsx
index 10fd38710..140468b5e 100644
--- a/ui/page/show/view.jsx
+++ b/ui/page/show/view.jsx
@@ -1,5 +1,5 @@
// @flow
-import { DOMAIN } from 'config';
+import { DOMAIN, ENABLE_NO_SOURCE_CLAIMS } from 'config';
import * as PAGES from 'constants/pages';
import React, { useEffect } from 'react';
import { lazyImport } from 'util/lazyImport';
@@ -199,7 +199,7 @@ function ShowPage(props: Props) {
/>
);
- } else if (isLivestream) {
+ } else if (isLivestream && ENABLE_NO_SOURCE_CLAIMS) {
innerContent = ;
} else {
innerContent = ;
diff --git a/ui/page/wallet/view.jsx b/ui/page/wallet/view.jsx
index 38332f361..4322275a1 100644
--- a/ui/page/wallet/view.jsx
+++ b/ui/page/wallet/view.jsx
@@ -12,8 +12,8 @@ import * as PAGES from 'constants/pages';
import Spinner from 'component/spinner';
import YrblWalletEmpty from 'component/yrblWalletEmpty';
import { Lbryio } from 'lbryinc';
-import { STRIPE_PUBLIC_KEY } from 'config';
import { Tabs, TabList, Tab, TabPanels, TabPanel } from 'component/common/tabs';
+import { getStripeEnvironment } from 'util/stripe';
const TAB_QUERY = 'tab';
@@ -23,12 +23,7 @@ const TABS = {
PAYMENT_HISTORY: 'fiat-payment-history',
};
-let stripeEnvironment = 'test';
-// if the key contains pk_live it's a live key
-// update the environment for the calls to the backend to indicate which environment to hit
-if (STRIPE_PUBLIC_KEY.indexOf('pk_live') > -1) {
- stripeEnvironment = 'live';
-}
+let stripeEnvironment = getStripeEnvironment();
type Props = {
history: { action: string, push: (string) => void, replace: (string) => void },
@@ -117,8 +112,11 @@ const WalletPage = (props: Props) => {
// calculate account transactions section
React.useEffect(() => {
- (async function() {
+ (async function () {
try {
+ if (!stripeEnvironment) {
+ return;
+ }
const response = await getAccountStatus();
setAccountStatusResponse(response);
@@ -131,23 +129,27 @@ const WalletPage = (props: Props) => {
console.log(err);
}
})();
- }, []);
+ }, [stripeEnvironment]);
// populate customer payment data
React.useEffect(() => {
- (async function() {
+ (async function () {
try {
// get card payments customer has made
+ if (!stripeEnvironment) {
+ return;
+ }
let customerTransactionResponse = await getPaymentHistory();
-
- customerTransactionResponse.reverse();
+ if (customerTransactionResponse && customerTransactionResponse.length) {
+ customerTransactionResponse.reverse();
+ }
setCustomerTransactions(customerTransactionResponse);
} catch (err) {
console.log(err);
}
})();
- }, []);
+ }, [stripeEnvironment]);
// @endif
diff --git a/ui/util/stripe.js b/ui/util/stripe.js
new file mode 100644
index 000000000..09a72308b
--- /dev/null
+++ b/ui/util/stripe.js
@@ -0,0 +1,13 @@
+// @flow
+import { STRIPE_PUBLIC_KEY } from 'config';
+import * as STRIPE_CONSTS from 'constants/stripe';
+export function getStripeEnvironment() {
+ if (STRIPE_PUBLIC_KEY) {
+ if (STRIPE_PUBLIC_KEY.indexOf('pk_live') > -1) {
+ return STRIPE_CONSTS.LIVE;
+ } else {
+ return STRIPE_CONSTS.TEST;
+ }
+ }
+ return null;
+}