2021-07-05 06:04:05 +02:00
|
|
|
// restore flow
|
2021-07-03 19:19:23 +02:00
|
|
|
/* eslint-disable no-undef */
|
|
|
|
/* eslint-disable react/prop-types */
|
|
|
|
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 moment from 'moment';
|
2021-07-06 22:28:29 +02:00
|
|
|
import Plastic from 'react-plastic';
|
|
|
|
import Button from 'component/button';
|
|
|
|
import * as ICONS from 'constants/icons';
|
|
|
|
import * as MODALS from 'constants/modal_types';
|
2021-07-03 19:19:23 +02:00
|
|
|
|
|
|
|
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';
|
|
|
|
}
|
|
|
|
|
2021-07-06 22:28:29 +02:00
|
|
|
// eslint-disable-next-line flowtype/no-types-missing-file-annotation
|
|
|
|
type Props = {
|
|
|
|
disabled: boolean,
|
|
|
|
label: ?string,
|
|
|
|
email: ?string,
|
|
|
|
scriptFailedToLoad: boolean,
|
|
|
|
doOpenModal: (string, {}) => void,
|
|
|
|
openModal: (string, {}) => void,
|
|
|
|
setAsConfirmingCard: () => void,
|
|
|
|
};
|
odysee
fix replay select styling
make meme a link
Fix audio references
get newest livestream claim in livestreamLink
pin crackermilk
fix livestream banner placement
fix live page
fix rebase
fix rebase
fix error nag
fix darkmode blockquote style
break word on livestream comment text
fix dark mode snack
fix live badge
fix lint
small fixes - word wrap, live badge
wip
Fix invisible snack in Odysee Light Theme
Revert "wip"
This reverts commit d17e477fe0e6633709ea30bdc403448825db4c71.
Revert "small fixes - word wrap, live badge"
This reverts commit 0e431d4038d774079c78f0de32238aac7260e4ca.
fix blank
pinned destiny
fix badges and homepage again
only get livestreams live for less than a day
pinned hammy and olivia
multi pin
pin destiny
updated pinned videos
update tagline
Update view.jsx
pins
updated destiny's video
updated pinned videos
removed destiny, added lie likes music
pinned destiny and mason's woodshop
removed hammy and olivia
unpinned mason's woodshop
removed pins
added hammy and olivia
pinned sam seder
unpinned destiny and hammy and olivia
Fix merge on ChannelThumbnails
- sam seder, + hammy & olivia and passion for food
update tagline (#6086)
removed everyone, added kona and suba
Theme color fixes (odysee) (#6089)
* Cherry-pick master's 'base-theme.scss'
* Non-functional cleanup (remove dups, re-order, etc.)
* Dark: update positive Toast to --color-primary as well.
This follows the intention of the refactoring, which I guess was (1) reduce the number of color names (2) reduce the number of customizations needed.
The only issue I have with this is that the current Odysee primary color is pink, which can be intepreted as an error.
The original (pre-refactoring color was green).
For now, I follow the refactoring path. We can tweak this later.
* Fix text color inside '--color-card-background-highlighted'
Light: use base-theme (it was the same value anyway).
Dark: use bright text.
* Dark: add some contrast between the components
The color for the background, header, card, placeholder, etc. is almost identical -- it looks like there are all in the same component. The almost-invisible border doesn't help. One would have to crank up the monitor's contrast setting to see separation of components.
Brighten up the components a bit, somewhat following the same scale as lbry.tv's dark theme.
Overall, I still think it's too dark. The Card's background color can still be brightened up further for better contrast, but I try not to make too drastic of a change for now.
The original lbry.tv's gray theme is the most pleasant theme I've seen so far, but this is all subjective.
changed pins
removed kona and suba
added destiny
changed pins
removed destiny
pinned sgtducky
changed pins
removed sgtducky
added hammy and olivia
added chrissie mayr
added the bite shot
changed pins
removed the bite shot
added heads of tech
changed pins
removed hammy and olivia
removed chrissie mayr
changed pins
removed heads of tech
added crackermilk
changed pins
removed crackermilk
added some ordinary gamer
added passion for food
changed pins
removed some ordinary gamers
removed passion for food
added emmy hucker
changed pins
added game knights
Update view.jsx
Force rebuild
changed pins
removed emmy hucker
changed pins
removed game knights
added crackermilk
changed pins
removed crackermilk
added some ordinary gamer
changed pins
removed some ordinary gamers
added passion for food
added green renaissance
changed pins
removed passion for food
removed green renaissance
added expand love
changed pins
removed expand love
added dr nora
change tagline (#6122)
there's so much room for activities
comment out music
changed pins
removed dr nora
added kona and suba
changed pins
removed kona and suba
added destiny
changed pins
removed destiny
added crackermilk
changed pins
removed crackermilk
added someordinarygamers
change tagline
Drake, where's the door hole?
changed pins
unpinned someordinarygamers
pinned kona and suba
Add message for mature content
changed pin
changed pins
removed creative model
changed pins
added bcpov
added krish mohan
added cigarvixen
changed pins
removed krish mohan
added adrian logan
bump
fix footer
change tagline
just like the simulations
changed pins
removed:
bcpov
cigarvixen
adrian logan
added:
someordinarygamers
quick fix for reposts
oops
fix channel tabs
changed pin
removed someordinarygamers
added kona and suba
changed pins
removed kona and suba
added dirtyworkz
added crackermilk
fix channel tabs again again
changed pins
someordinarygamers
arvie's cookbook
changed pins
removed some ordinary gamers
removed arvie's cookbook
added fna van life
changed pins
removed fna vanlife
added game knights
change tagline
"this cave is not a natural formation"
changed pins
removed game knights
added some ordinary gamers
fix popup
put footer back
bump lightouse throttle
bump lighthouse throttle
changed pins
removed some orginary gamers
added adrian logan
pinned bret weinstein
fix referral
fix-superchats
changed pins
removed bret weinstein
added passion for food
added dark horse clips
fix incorrect variable being used to determine view state
changed pins
removed passion for food
changed pins
removed bret weinstein
added sgt ducky
add recsys related functionality
Create plugin to hold code for recsys
send recsys on dispose
cleanup recsys code
add userId to props validation
appease the linter
add todo note
extra characters
pinned jungle survival
fix autoplay for transcoded files
change tagline
changed pins
pinned destiny
pinned chris williamson
FIX video.js event firing issues fore RecsysPlugin
- The `rateChange` event now logs the updated speed,
not just the time at which it occurred.
- The `scrub` now (more) accurately logs the position
it came from before the destination.
- The recsys events get consolidated for logical consistency.
Wunderbar: change throttle to debounce + add min chars
6314: prevent lighthouse spam from wunderbar
- Wunderbar: change throttle to debounce + add min chars.
- useLighthouse: added option to not throttle.
Wunderbar: immediate feedback to convey status
Make immediate GUI feedback to convey the current status, which can be the following:
- typing
- waiting lighthouse results
- waiting claim resolve
- no results or failed.
pinned someordinarygamers
Wunderbar: bump debounce to 1s
per feedback
pinned jungle survival
pinned james julier
Fix compile error
Lint
summit pin
summit pin
update pins
added humblemechanic
removed everyone else
update pins
pinned samtime
FIX stop event translation and remove preprocessing
I think different browsers behave in different ways for the media
API. As a result, I think I was losing information for browsers
that weren't the same as mine (Chromium). For now, preprocessing
is removed. In the future, I'll add it again (better storage
and transmission properties).
updated pin
change pins
(cherry picked from commit 041f420416aaa890adecd78381d611375134b904)
pinned someordinarygamers
auth only for stripe
restore playlists tab
fix missing i18n on channel page
pinned zimmerhandcrafted
change tagline
big gulps, huh?
change pin
Revert lazy-loading videojs
The loading circle wasn't showing up, causing confusion.
Splitting CSS doesn't seem trivial as there seems to be a huge dependency on the load order. Pretty much similar to what this person is facing https://lihautan.com/css-code-splitting/#the-problem
This reverts videojs-specific changes from 4d638bcf.
odyrecon
use ENABLE_UI_NOTIFICATIONS
use ENABLE_MATURE
oops
use ENABLE_MATURE for fileTitleSection
pinned orf
pinned ourselves
selecthumb copy
use ENABLE_UI_NOT. on sideNav
showNoSourceClaims
changed pin
fix livestream claims display
...
fix?
fix
Fix invalid semicolon
alison morrow
Odysee: fix missing '--color-help-warning-bg' for Dark
someordinarygamers
pinned some new channels
watch guy
hotfix error returning to settings
emplemon
fix showMature
test bump parsing
better colon handling
cherrypick pins
unpin emplemon for now
delete unused components (#6531)
more recon (#6534)
emplemon
Latest changes to odysee (#6536)
* disable review button if no card saved also some cleanup
* fix flow errors
move stuff to web
Revert "move stuff to web"
This reverts commit 17b13d8b19c08dcfd9ab55e09ac53da97dba3682.
hotfix for odysee
change tagline
don't dead open inside
2021-06-11 19:47:56 +02:00
|
|
|
|
2021-07-05 06:04:05 +02:00
|
|
|
// type State = {
|
|
|
|
// open: boolean,
|
|
|
|
// currentFlowStage: string,
|
|
|
|
// customerTransactions: Array<any>,
|
|
|
|
// pageTitle: string,
|
|
|
|
// userCardDetails: any, // fill this out
|
|
|
|
// scriptFailedToLoad: boolean,
|
|
|
|
// };
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-06 03:29:46 +02:00
|
|
|
class SettingsStripeCard extends React.Component<Props, State> {
|
2021-07-05 06:04:05 +02:00
|
|
|
constructor(props) {
|
|
|
|
// :Props
|
2021-07-03 19:19:23 +02:00
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
open: false,
|
|
|
|
scriptFailedToLoad: false,
|
|
|
|
currentFlowStage: 'loading', // loading, confirmingCard, cardConfirmed
|
|
|
|
customerTransactions: [],
|
|
|
|
pageTitle: 'Add Card',
|
|
|
|
userCardDetails: {},
|
2021-07-06 22:28:29 +02:00
|
|
|
paymentMethodId: '',
|
2021-07-03 19:19:23 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
componentDidMount() {
|
2021-07-17 18:08:53 +02:00
|
|
|
let that = this;
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-06 22:28:29 +02:00
|
|
|
console.log(this.props);
|
|
|
|
|
2021-07-17 18:08:53 +02:00
|
|
|
let doToast = this.props.doToast;
|
2021-07-06 22:28:29 +02:00
|
|
|
|
2021-07-03 19:19:23 +02:00
|
|
|
const script = document.createElement('script');
|
|
|
|
script.src = 'https://js.stripe.com/v3/';
|
|
|
|
script.async = true;
|
|
|
|
|
|
|
|
// $FlowFixMe
|
|
|
|
document.body.appendChild(script);
|
|
|
|
|
|
|
|
// public key of the stripe account
|
2021-07-17 18:08:53 +02:00
|
|
|
let publicKey = STRIPE_PUBLIC_KEY;
|
2021-07-03 19:19:23 +02:00
|
|
|
|
|
|
|
// client secret of the SetupIntent (don't share with anyone but customer)
|
2021-07-17 18:08:53 +02:00
|
|
|
let clientSecret = '';
|
2021-07-03 19:19:23 +02:00
|
|
|
|
|
|
|
// setting a timeout to let the client secret populate
|
|
|
|
// TODO: fix this, should be a cleaner way
|
2021-07-17 18:08:53 +02:00
|
|
|
setTimeout(function () {
|
2021-07-03 19:19:23 +02:00
|
|
|
// check if customer has card setup already
|
2021-07-05 06:04:05 +02:00
|
|
|
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;
|
2021-07-17 18:08:53 +02:00
|
|
|
let userHasAlreadySetupPayment = Boolean(defaultPaymentMethod && defaultPaymentMethod.id);
|
2021-07-05 06:04:05 +02:00
|
|
|
|
|
|
|
// show different frontend if user already has card
|
|
|
|
if (userHasAlreadySetupPayment) {
|
2021-07-17 18:08:53 +02:00
|
|
|
let card = customerStatusResponse.PaymentMethods[0].card;
|
2021-07-05 06:04:05 +02:00
|
|
|
|
2021-07-17 18:08:53 +02:00
|
|
|
let customer = customerStatusResponse.Customer;
|
2021-07-06 22:28:29 +02:00
|
|
|
|
2021-07-17 18:08:53 +02:00
|
|
|
let topOfDisplay = customer.email.split('@')[0];
|
|
|
|
let bottomOfDisplay = '@' + customer.email.split('@')[1];
|
2021-07-06 22:28:29 +02:00
|
|
|
|
|
|
|
console.log(customerStatusResponse.Customer);
|
|
|
|
|
2021-07-17 18:08:53 +02:00
|
|
|
let cardDetails = {
|
2021-07-05 06:04:05 +02:00
|
|
|
brand: card.brand,
|
|
|
|
expiryYear: card.exp_year,
|
|
|
|
expiryMonth: card.exp_month,
|
|
|
|
lastFour: card.last4,
|
2021-07-06 22:28:29 +02:00
|
|
|
topOfDisplay: topOfDisplay,
|
|
|
|
bottomOfDisplay: bottomOfDisplay,
|
2021-07-05 06:04:05 +02:00
|
|
|
};
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-05 06:04:05 +02:00
|
|
|
that.setState({
|
|
|
|
currentFlowStage: 'cardConfirmed',
|
|
|
|
pageTitle: 'Tip History',
|
|
|
|
userCardDetails: cardDetails,
|
2021-07-06 22:28:29 +02:00
|
|
|
paymentMethodId: customerStatusResponse.PaymentMethods[0].id,
|
2021-07-05 06:04:05 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
// otherwise, prompt them to save a card
|
|
|
|
} else {
|
2021-07-03 19:19:23 +02:00
|
|
|
that.setState({
|
2021-07-05 06:04:05 +02:00
|
|
|
currentFlowStage: 'confirmingCard',
|
2021-07-05 04:28:14 +02:00
|
|
|
});
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-05 06:04:05 +02:00
|
|
|
// get a payment method secret for frontend
|
|
|
|
Lbryio.call(
|
|
|
|
'customer',
|
|
|
|
'setup',
|
|
|
|
{
|
|
|
|
environment: stripeEnvironment,
|
|
|
|
},
|
|
|
|
'post'
|
|
|
|
).then((customerSetupResponse) => {
|
|
|
|
console.log(customerSetupResponse);
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-05 06:04:05 +02:00
|
|
|
clientSecret = customerSetupResponse.client_secret;
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-05 06:04:05 +02:00
|
|
|
// instantiate stripe elements
|
|
|
|
setupStripe();
|
|
|
|
});
|
|
|
|
}
|
2021-07-06 22:28:29 +02:00
|
|
|
|
|
|
|
// get customer transactions
|
|
|
|
Lbryio.call(
|
|
|
|
'customer',
|
|
|
|
'list',
|
|
|
|
{
|
|
|
|
environment: stripeEnvironment,
|
|
|
|
},
|
|
|
|
'post'
|
|
|
|
).then((customerTransactionsResponse) => {
|
|
|
|
that.setState({
|
|
|
|
customerTransactions: customerTransactionsResponse,
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log(customerTransactionsResponse);
|
|
|
|
});
|
2021-07-05 06:04:05 +02:00
|
|
|
// if the status call fails, either an actual error or need to run setup first
|
|
|
|
})
|
2021-07-17 18:08:53 +02:00
|
|
|
.catch(function (error) {
|
2021-07-05 06:04:05 +02:00
|
|
|
console.log(error);
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-05 06:04:05 +02:00
|
|
|
// errorString passed from the API (with a 403 error)
|
|
|
|
const errorString = 'user as customer is not setup yet';
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-05 06:04:05 +02:00
|
|
|
// if it's beamer's error indicating the account is not linked yet
|
2021-07-06 22:28:29 +02:00
|
|
|
if (error.message && error.message.indexOf(errorString) > -1) {
|
2021-07-05 06:04:05 +02:00
|
|
|
// send them to save a card
|
|
|
|
that.setState({
|
|
|
|
currentFlowStage: 'confirmingCard',
|
|
|
|
});
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-05 06:04:05 +02:00
|
|
|
// get a payment method secret for frontend
|
|
|
|
Lbryio.call(
|
|
|
|
'customer',
|
|
|
|
'setup',
|
|
|
|
{
|
|
|
|
environment: stripeEnvironment,
|
|
|
|
},
|
|
|
|
'post'
|
|
|
|
).then((customerSetupResponse) => {
|
|
|
|
console.log(customerSetupResponse);
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-05 06:04:05 +02:00
|
|
|
clientSecret = customerSetupResponse.client_secret;
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-05 06:04:05 +02:00
|
|
|
// instantiate stripe elements
|
|
|
|
setupStripe();
|
|
|
|
});
|
2021-07-06 22:28:29 +02:00
|
|
|
} else if (error === 'internal_apis_down') {
|
2021-07-17 18:08:53 +02:00
|
|
|
var displayString = 'There was an error from the server, please let support know';
|
2021-07-06 22:28:29 +02:00
|
|
|
doToast({ message: displayString, isError: true });
|
2021-07-05 06:04:05 +02:00
|
|
|
} else {
|
|
|
|
console.log('Unseen before error');
|
|
|
|
}
|
|
|
|
});
|
2021-07-03 19:19:23 +02:00
|
|
|
}, 250);
|
|
|
|
|
|
|
|
function setupStripe() {
|
|
|
|
// TODO: have to fix this, using so that the script is available
|
2021-07-17 18:08:53 +02:00
|
|
|
setTimeout(function () {
|
|
|
|
var stripeElements = function (publicKey, setupIntent) {
|
2021-07-03 19:19:23 +02:00
|
|
|
var stripe = Stripe(publicKey);
|
|
|
|
var elements = stripe.elements();
|
|
|
|
|
|
|
|
// Element styles
|
|
|
|
var style = {
|
|
|
|
base: {
|
|
|
|
fontSize: '16px',
|
|
|
|
color: '#32325d',
|
2021-07-05 06:04:05 +02:00
|
|
|
fontFamily: '-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, sans-serif',
|
2021-07-03 19:19:23 +02:00
|
|
|
fontSmoothing: 'antialiased',
|
|
|
|
'::placeholder': {
|
|
|
|
color: 'rgba(0,0,0,0.4)',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
var card = elements.create('card', { style: style });
|
|
|
|
|
|
|
|
card.mount('#card-element');
|
|
|
|
|
|
|
|
// Element focus ring
|
2021-07-17 18:08:53 +02:00
|
|
|
card.on('focus', function () {
|
2021-07-03 19:19:23 +02:00
|
|
|
var el = document.getElementById('card-element');
|
|
|
|
el.classList.add('focused');
|
|
|
|
});
|
|
|
|
|
2021-07-17 18:08:53 +02:00
|
|
|
card.on('blur', function () {
|
2021-07-03 19:19:23 +02:00
|
|
|
var el = document.getElementById('card-element');
|
|
|
|
el.classList.remove('focused');
|
|
|
|
});
|
|
|
|
|
2021-07-17 18:08:53 +02:00
|
|
|
card.on('ready', function () {
|
2021-07-03 19:19:23 +02:00
|
|
|
card.focus();
|
|
|
|
});
|
|
|
|
|
|
|
|
var email = that.props.email;
|
|
|
|
|
|
|
|
function submitForm(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
// if client secret wasn't loaded properly
|
|
|
|
if (!clientSecret) {
|
|
|
|
var displayErrorText = 'There was an error in generating your payment method. Please contact a developer';
|
|
|
|
var displayError = document.getElementById('card-errors');
|
|
|
|
displayError.textContent = displayErrorText;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
changeLoadingState(true);
|
|
|
|
|
2021-07-05 06:04:05 +02:00
|
|
|
stripe
|
|
|
|
.confirmCardSetup(clientSecret, {
|
|
|
|
payment_method: {
|
|
|
|
card: card,
|
|
|
|
billing_details: { email: email },
|
|
|
|
},
|
|
|
|
})
|
2021-07-17 18:08:53 +02:00
|
|
|
.then(function (result) {
|
2021-07-05 06:04:05 +02:00
|
|
|
if (result.error) {
|
|
|
|
console.log(result);
|
|
|
|
|
|
|
|
changeLoadingState(false);
|
|
|
|
var displayError = document.getElementById('card-errors');
|
|
|
|
displayError.textContent = result.error.message;
|
|
|
|
} else {
|
|
|
|
// The PaymentMethod was successfully set up
|
|
|
|
// hide and show the proper divs
|
|
|
|
orderComplete(stripe, clientSecret);
|
|
|
|
}
|
|
|
|
});
|
2021-07-03 19:19:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Handle payment submission when user clicks the pay button.
|
|
|
|
var button = document.getElementById('submit');
|
2021-07-17 18:08:53 +02:00
|
|
|
button.addEventListener('click', function (event) {
|
2021-07-03 19:19:23 +02:00
|
|
|
submitForm(event);
|
|
|
|
});
|
|
|
|
|
|
|
|
// currently doesn't work because the iframe javascript context is different
|
|
|
|
// would be nice though if it's even technically possible
|
|
|
|
// window.addEventListener('keyup', function(event) {
|
|
|
|
// if (event.keyCode === 13) {
|
|
|
|
// submitForm(event);
|
|
|
|
// }
|
|
|
|
// }, false);
|
|
|
|
};
|
|
|
|
|
|
|
|
// TODO: possible bug here where clientSecret isn't done
|
|
|
|
stripeElements(publicKey, clientSecret);
|
|
|
|
|
|
|
|
// Show a spinner on payment submission
|
2021-07-17 18:08:53 +02:00
|
|
|
var changeLoadingState = function (isLoading) {
|
2021-07-03 19:19:23 +02:00
|
|
|
if (isLoading) {
|
2021-07-05 06:04:05 +02:00
|
|
|
// $FlowFixMe
|
2021-07-03 19:19:23 +02:00
|
|
|
document.querySelector('button').disabled = true;
|
2021-07-05 06:04:05 +02:00
|
|
|
// $FlowFixMe
|
2021-07-05 21:04:07 +02:00
|
|
|
document.querySelector('#stripe-spinner').classList.remove('hidden');
|
2021-07-05 06:04:05 +02:00
|
|
|
// $FlowFixMe
|
2021-07-03 19:19:23 +02:00
|
|
|
document.querySelector('#button-text').classList.add('hidden');
|
|
|
|
} else {
|
2021-07-05 06:04:05 +02:00
|
|
|
// $FlowFixMe
|
2021-07-03 19:19:23 +02:00
|
|
|
document.querySelector('button').disabled = false;
|
2021-07-05 06:04:05 +02:00
|
|
|
// $FlowFixMe
|
2021-07-05 21:04:07 +02:00
|
|
|
document.querySelector('#stripe-spinner').classList.add('hidden');
|
2021-07-05 06:04:05 +02:00
|
|
|
// $FlowFixMe
|
2021-07-03 19:19:23 +02:00
|
|
|
document.querySelector('#button-text').classList.remove('hidden');
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// shows a success / error message when the payment is complete
|
2021-07-17 18:08:53 +02:00
|
|
|
var orderComplete = function (stripe, clientSecret) {
|
|
|
|
stripe.retrieveSetupIntent(clientSecret).then(function (result) {
|
2021-07-05 06:04:05 +02:00
|
|
|
Lbryio.call(
|
|
|
|
'customer',
|
|
|
|
'status',
|
|
|
|
{
|
|
|
|
environment: stripeEnvironment,
|
|
|
|
},
|
|
|
|
'post'
|
|
|
|
).then((customerStatusResponse) => {
|
2021-07-17 18:08:53 +02:00
|
|
|
let card = customerStatusResponse.PaymentMethods[0].card;
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-17 18:08:53 +02:00
|
|
|
let customer = customerStatusResponse.Customer;
|
2021-07-06 22:28:29 +02:00
|
|
|
|
2021-07-17 18:08:53 +02:00
|
|
|
let topOfDisplay = customer.email.split('@')[0];
|
|
|
|
let bottomOfDisplay = '@' + customer.email.split('@')[1];
|
2021-07-06 22:28:29 +02:00
|
|
|
|
2021-07-17 18:08:53 +02:00
|
|
|
let cardDetails = {
|
2021-07-03 19:19:23 +02:00
|
|
|
brand: card.brand,
|
|
|
|
expiryYear: card.exp_year,
|
|
|
|
expiryMonth: card.exp_month,
|
|
|
|
lastFour: card.last4,
|
2021-07-06 22:28:29 +02:00
|
|
|
topOfDisplay,
|
|
|
|
bottomOfDisplay,
|
2021-07-03 19:19:23 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
that.setState({
|
|
|
|
currentFlowStage: 'cardConfirmed',
|
|
|
|
pageTitle: 'Tip History',
|
|
|
|
userCardDetails: cardDetails,
|
2021-07-06 22:28:29 +02:00
|
|
|
paymentMethodId: customerStatusResponse.PaymentMethods[0].id,
|
2021-07-03 19:19:23 +02:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
console.log(result);
|
|
|
|
|
|
|
|
changeLoadingState(false);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-06 22:28:29 +02:00
|
|
|
render() {
|
2021-07-17 18:08:53 +02:00
|
|
|
let that = this;
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-17 18:08:53 +02:00
|
|
|
function setAsConfirmingCard() {
|
2021-07-06 22:28:29 +02:00
|
|
|
that.setState({
|
|
|
|
currentFlowStage: 'confirmingCard',
|
2021-07-17 18:08:53 +02:00
|
|
|
});
|
2021-07-06 22:28:29 +02:00
|
|
|
}
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-17 18:08:53 +02:00
|
|
|
const { scriptFailedToLoad, openModal } = this.props;
|
2021-07-03 19:19:23 +02:00
|
|
|
|
2021-07-06 22:28:29 +02:00
|
|
|
const { currentFlowStage, customerTransactions, pageTitle, userCardDetails, paymentMethodId } = this.state;
|
2021-07-03 19:19:23 +02:00
|
|
|
|
|
|
|
return (
|
|
|
|
<Page backout={{ title: pageTitle, backLabel: __('Done') }} noFooter noSideNavigation>
|
|
|
|
<div>
|
|
|
|
{scriptFailedToLoad && (
|
|
|
|
<div className="error__text">There was an error connecting to Stripe. Please try again later.</div>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
|
2021-07-05 06:04:05 +02:00
|
|
|
{currentFlowStage === 'loading' && (
|
|
|
|
<div className="headerCard toConfirmCard">
|
|
|
|
<Card title={__('Connect your card with Odysee')} subtitle={__('Getting your card connection status...')} />
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
|
2021-07-06 22:28:29 +02:00
|
|
|
{/* customer has not added a card yet */}
|
2021-07-05 06:04:05 +02:00
|
|
|
{currentFlowStage === 'confirmingCard' && (
|
|
|
|
<div className="sr-root">
|
|
|
|
<div className="sr-main">
|
|
|
|
<div className="sr-payment-form card cardInput">
|
|
|
|
<div className="sr-form-row">
|
|
|
|
<label className="payment-details">Card Details</label>
|
|
|
|
<div className="sr-input sr-element sr-card-element" id="card-element" />
|
|
|
|
</div>
|
|
|
|
<div className="sr-field-error" id="card-errors" role="alert" />
|
|
|
|
<button className="linkButton" id="submit">
|
2021-07-05 21:04:07 +02:00
|
|
|
<div className="stripe__spinner hidden" id="stripe-spinner" />
|
2021-07-05 06:04:05 +02:00
|
|
|
<span id="button-text">Add Card</span>
|
|
|
|
</button>
|
2021-07-03 19:19:23 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-05 06:04:05 +02:00
|
|
|
)}
|
|
|
|
|
2021-07-06 22:28:29 +02:00
|
|
|
{/* if the user has already confirmed their card */}
|
2021-07-05 06:04:05 +02:00
|
|
|
{currentFlowStage === 'cardConfirmed' && (
|
|
|
|
<div className="successCard">
|
|
|
|
<Card
|
|
|
|
title={__('Card Details')}
|
|
|
|
body={
|
|
|
|
<>
|
2021-07-06 22:28:29 +02:00
|
|
|
<Plastic
|
|
|
|
type={userCardDetails.brand}
|
|
|
|
name={userCardDetails.topOfDisplay + ' ' + userCardDetails.bottomOfDisplay}
|
|
|
|
expiry={userCardDetails.expiryMonth + '/' + userCardDetails.expiryYear}
|
|
|
|
number={'____________' + userCardDetails.lastFour}
|
|
|
|
/>
|
|
|
|
<br />
|
|
|
|
<Button
|
|
|
|
button="secondary"
|
|
|
|
label={__('Remove Card')}
|
|
|
|
icon={ICONS.DELETE}
|
|
|
|
onClick={(e) => {
|
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
|
|
|
openModal(MODALS.CONFIRM_REMOVE_CARD, {
|
|
|
|
paymentMethodId: paymentMethodId,
|
|
|
|
setAsConfirmingCard: setAsConfirmingCard,
|
|
|
|
});
|
|
|
|
}}
|
2021-07-17 18:08:53 +02:00
|
|
|
/>
|
2021-07-05 06:04:05 +02:00
|
|
|
</>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
<br />
|
|
|
|
|
2021-07-06 22:28:29 +02:00
|
|
|
{/* if a user has no transactions yet */}
|
2021-07-05 06:04:05 +02:00
|
|
|
{(!customerTransactions || customerTransactions.length === 0) && (
|
|
|
|
<Card
|
|
|
|
title={__('Tip History')}
|
|
|
|
subtitle={__('You have not sent any tips yet. When you do they will appear here. ')}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
)}
|
2021-07-06 22:28:29 +02:00
|
|
|
|
|
|
|
{/* customer already has transactions */}
|
|
|
|
{customerTransactions && customerTransactions.length > 0 && (
|
|
|
|
<Card
|
|
|
|
title={__('Tip History')}
|
|
|
|
body={
|
|
|
|
<>
|
|
|
|
<div className="table__wrapper">
|
|
|
|
<table className="table table--transactions">
|
|
|
|
<thead>
|
2021-07-17 18:08:53 +02:00
|
|
|
<tr>
|
|
|
|
<th className="date-header">{__('Date')}</th>
|
|
|
|
<th>{<>{__('Receiving Channel Name')}</>}</th>
|
|
|
|
<th>{__('Tip Location')}</th>
|
|
|
|
<th>{__('Amount (USD)')} </th>
|
|
|
|
<th>{__('Anonymous')}</th>
|
|
|
|
</tr>
|
2021-07-06 22:28:29 +02:00
|
|
|
</thead>
|
|
|
|
<tbody>
|
2021-07-17 18:08:53 +02:00
|
|
|
{customerTransactions &&
|
|
|
|
customerTransactions.reverse().map((transaction) => (
|
|
|
|
<tr key={transaction.name + transaction.created_at}>
|
|
|
|
<td>{moment(transaction.created_at).format('LLL')}</td>
|
|
|
|
<td>
|
|
|
|
<Button
|
|
|
|
className="stripe__card-link-text"
|
|
|
|
navigate={'/' + transaction.channel_name + ':' + transaction.channel_claim_id}
|
|
|
|
label={transaction.channel_name}
|
|
|
|
button="link"
|
|
|
|
/>
|
|
|
|
</td>
|
|
|
|
<td>
|
|
|
|
<Button
|
|
|
|
className="stripe__card-link-text"
|
|
|
|
navigate={'/' + transaction.channel_name + ':' + transaction.source_claim_id}
|
|
|
|
label={
|
|
|
|
transaction.channel_claim_id === transaction.source_claim_id
|
|
|
|
? 'Channel Page'
|
|
|
|
: 'File Page'
|
|
|
|
}
|
|
|
|
button="link"
|
|
|
|
/>
|
|
|
|
</td>
|
|
|
|
<td>${transaction.tipped_amount / 100}</td>
|
|
|
|
<td>{transaction.private_tip ? 'Yes' : 'No'}</td>
|
|
|
|
</tr>
|
|
|
|
))}
|
2021-07-06 22:28:29 +02:00
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
)}
|
2021-07-03 19:19:23 +02:00
|
|
|
</Page>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-06 03:29:46 +02:00
|
|
|
export default SettingsStripeCard;
|
2021-07-03 19:19:23 +02:00
|
|
|
/* eslint-enable no-undef */
|
|
|
|
/* eslint-enable react/prop-types */
|