This commit is contained in:
parent
6d103986b7
commit
2b194a1609
|
@ -82,6 +82,7 @@ export async function upgradeUser(userId: T.UUID, subscription?: T.StripeSubscri
|
||||||
export async function downgradeUser(userId: T.UUID, subscriptionId?: string): Promise<T.DowngradeUserResponse> {
|
export async function downgradeUser(userId: T.UUID, subscriptionId?: string): Promise<T.DowngradeUserResponse> {
|
||||||
await deleteCouchDbAuthUser(userId);
|
await deleteCouchDbAuthUser(userId);
|
||||||
if (subscriptionId) {
|
if (subscriptionId) {
|
||||||
|
console.log("deleting sub id", subscriptionId);
|
||||||
stripe.subscriptions.del(subscriptionId);
|
stripe.subscriptions.del(subscriptionId);
|
||||||
}
|
}
|
||||||
const user = await updateLingdocsUser(userId, {
|
const user = await updateLingdocsUser(userId, {
|
||||||
|
|
|
@ -14,7 +14,6 @@ paymentRouter.post(
|
||||||
'/webhook',
|
'/webhook',
|
||||||
express.raw({ type: 'application/json' }),
|
express.raw({ type: 'application/json' }),
|
||||||
async (request, response) => {
|
async (request, response) => {
|
||||||
console.log("in webhook");
|
|
||||||
let event = request.body;
|
let event = request.body;
|
||||||
// Replace this endpoint secret with your endpoint's unique secret
|
// Replace this endpoint secret with your endpoint's unique secret
|
||||||
// If you are testing with the CLI, find the secret by running 'stripe listen'
|
// If you are testing with the CLI, find the secret by running 'stripe listen'
|
||||||
|
@ -24,10 +23,8 @@ paymentRouter.post(
|
||||||
// Otherwise use the basic event deserialized with JSON.parse
|
// Otherwise use the basic event deserialized with JSON.parse
|
||||||
const endpointSecret = env.stripeWebhookSecret;
|
const endpointSecret = env.stripeWebhookSecret;
|
||||||
if (endpointSecret) {
|
if (endpointSecret) {
|
||||||
console.log("endoint Secret", endpointSecret);
|
|
||||||
// Get the signature sent by Stripe
|
// Get the signature sent by Stripe
|
||||||
const signature = request.headers['stripe-signature'] || "";
|
const signature = request.headers['stripe-signature'] || "";
|
||||||
console.log("signature", signature);
|
|
||||||
try {
|
try {
|
||||||
event = stripe.webhooks.constructEvent(
|
event = stripe.webhooks.constructEvent(
|
||||||
request.body,
|
request.body,
|
||||||
|
|
|
@ -192,10 +192,9 @@ const Account = ({ user, loadUser }: { user: AT.LingdocsUser | undefined, loadUs
|
||||||
<li>Review words with Anki-style spaced repetition</li>
|
<li>Review words with Anki-style spaced repetition</li>
|
||||||
</ul>
|
</ul>
|
||||||
<UpgradePrices />
|
<UpgradePrices />
|
||||||
<p>Or enter upgrade password</p>
|
|
||||||
</Modal.Body>
|
</Modal.Body>
|
||||||
<div className="form-group px-3">
|
<div className="form-group px-3">
|
||||||
<label htmlFor="upgradePasswordForm">Upgrade token:</label>
|
<label htmlFor="upgradePasswordForm">Or enter upgrade password:</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
className="form-control"
|
className="form-control"
|
||||||
|
@ -216,7 +215,7 @@ const Account = ({ user, loadUser }: { user: AT.LingdocsUser | undefined, loadUs
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button variant="primary" onClick={handleUpgrade}>
|
<Button variant="primary" onClick={handleUpgrade}>
|
||||||
Upgrade my account
|
Upgrade with password
|
||||||
</Button>
|
</Button>
|
||||||
</Modal.Footer>
|
</Modal.Footer>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
Loading…
Reference in New Issue