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> {
|
||||
await deleteCouchDbAuthUser(userId);
|
||||
if (subscriptionId) {
|
||||
console.log("deleting sub id", subscriptionId);
|
||||
stripe.subscriptions.del(subscriptionId);
|
||||
}
|
||||
const user = await updateLingdocsUser(userId, {
|
||||
|
|
|
@ -14,7 +14,6 @@ paymentRouter.post(
|
|||
'/webhook',
|
||||
express.raw({ type: 'application/json' }),
|
||||
async (request, response) => {
|
||||
console.log("in webhook");
|
||||
let event = request.body;
|
||||
// Replace this endpoint secret with your endpoint's unique secret
|
||||
// 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
|
||||
const endpointSecret = env.stripeWebhookSecret;
|
||||
if (endpointSecret) {
|
||||
console.log("endoint Secret", endpointSecret);
|
||||
// Get the signature sent by Stripe
|
||||
const signature = request.headers['stripe-signature'] || "";
|
||||
console.log("signature", signature);
|
||||
try {
|
||||
event = stripe.webhooks.constructEvent(
|
||||
request.body,
|
||||
|
|
|
@ -192,10 +192,9 @@ const Account = ({ user, loadUser }: { user: AT.LingdocsUser | undefined, loadUs
|
|||
<li>Review words with Anki-style spaced repetition</li>
|
||||
</ul>
|
||||
<UpgradePrices />
|
||||
<p>Or enter upgrade password</p>
|
||||
</Modal.Body>
|
||||
<div className="form-group px-3">
|
||||
<label htmlFor="upgradePasswordForm">Upgrade token:</label>
|
||||
<label htmlFor="upgradePasswordForm">Or enter upgrade password:</label>
|
||||
<input
|
||||
type="text"
|
||||
className="form-control"
|
||||
|
@ -216,7 +215,7 @@ const Account = ({ user, loadUser }: { user: AT.LingdocsUser | undefined, loadUs
|
|||
Cancel
|
||||
</Button>
|
||||
<Button variant="primary" onClick={handleUpgrade}>
|
||||
Upgrade my account
|
||||
Upgrade with password
|
||||
</Button>
|
||||
</Modal.Footer>
|
||||
</Modal>
|
||||
|
|
Loading…
Reference in New Issue