From 68c91406d4abe84e9d60d53b52351f80d5c76d4c Mon Sep 17 00:00:00 2001 From: William Stein Date: Fri, 6 Dec 2024 05:08:56 +0000 Subject: [PATCH] purchase testing -- fix little things --- src/packages/server/messages/admin-alert.ts | 4 ++-- src/packages/server/messages/send.ts | 2 +- .../server/purchases/maintain-auto-balance.ts | 2 +- .../server/purchases/maintain-automatic-payments.ts | 12 ++++++------ .../server/purchases/maintain-subscriptions.ts | 2 +- .../purchases/stripe/create-subscription-payment.ts | 10 +++++----- .../purchases/stripe/process-payment-intents.ts | 10 +++++----- 7 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/packages/server/messages/admin-alert.ts b/src/packages/server/messages/admin-alert.ts index fbe18fdb19..22c2cd7a9e 100644 --- a/src/packages/server/messages/admin-alert.ts +++ b/src/packages/server/messages/admin-alert.ts @@ -66,10 +66,10 @@ export default async function adminAlert({ logger.debug("no admins so nothing to do"); return; } - const { support_account_id, site_name } = await getServerSettings(); + const { support_account_id } = await getServerSettings(); const from_id = support_account_id ? support_account_id : to_ids[0]; await send({ - subject: `${site_name} Admin Alert - ${subject}`, + subject: `Admin Alert - ${subject}`, body: toString(body) + "\n\n---\n" + "```js\n" + stack + "\n```\n", from_id, to_ids, diff --git a/src/packages/server/messages/send.ts b/src/packages/server/messages/send.ts index 3ae4c1e4d1..00ecc7df5d 100644 --- a/src/packages/server/messages/send.ts +++ b/src/packages/server/messages/send.ts @@ -86,7 +86,7 @@ export async function support() { ? ` email us at [${help_email}](mailto:${help_email}), ` : ""; return `\n\n---\n\nThank you for using and supporting ${site_name}! If you have questions, reply to this message, ${help} -or [create a support ticket](${url("support", "new")}).\n\n---\n\n`; +or [create a support ticket](${await url("support", "new")}).\n\n---\n\n`; } // Given a URL like /support/new, this returns something like https://cocalc.com/support/new, diff --git a/src/packages/server/purchases/maintain-auto-balance.ts b/src/packages/server/purchases/maintain-auto-balance.ts index 7ab5b714ce..02b384bbcd 100644 --- a/src/packages/server/purchases/maintain-auto-balance.ts +++ b/src/packages/server/purchases/maintain-auto-balance.ts @@ -266,7 +266,7 @@ Dear ${name}, You have automatic deposits setup, which just did the following: ${description} -${url("settings", "payments")} +${await url("settings", "payments")} -- ${siteName} diff --git a/src/packages/server/purchases/maintain-automatic-payments.ts b/src/packages/server/purchases/maintain-automatic-payments.ts index c1e240aa51..927c40df4e 100644 --- a/src/packages/server/purchases/maintain-automatic-payments.ts +++ b/src/packages/server/purchases/maintain-automatic-payments.ts @@ -128,9 +128,9 @@ The amount due on your monthly statement is ${currency(amount)}. However, this is below the minimum payment size of ${currency(pay_as_you_go_min_payment)}. You will not be billed this month, and your balance will roll over to your next statement. -- [Your Statements](${url("settings", "statements")}) +- [Your Statements](${await url("settings", "statements")}) -${support()} +${await support()} `, }); continue; @@ -163,11 +163,11 @@ ${support()} body: ` ${site_name} issued an invoice for the balance of ${currency(amount)} that is due on your monthly statement id=${statement_id}. -- Statements: ${url("settings", "statements")} +- Statements: ${await url("settings", "statements")} - Hosted Invoice: ${hosted_invoice_url} -${support()}`, +${await support()}`, }); await pool.query( "UPDATE statements SET automatic_payment_intent_id=$1 WHERE id=$2", @@ -185,9 +185,9 @@ When attempting to automatically charge you, an error occured. ${err} -- [Your Statements](${url("settings", "statements")}) +- [Your Statements](${await url("settings", "statements")}) -${support()} +${await support()} `, }); adminAlert({ diff --git a/src/packages/server/purchases/maintain-subscriptions.ts b/src/packages/server/purchases/maintain-subscriptions.ts index d15a2e0a13..5ef0af8884 100644 --- a/src/packages/server/purchases/maintain-subscriptions.ts +++ b/src/packages/server/purchases/maintain-subscriptions.ts @@ -162,7 +162,7 @@ You have a ${interval}ly subscription that will **automatically renew** in ${cut If you do nothing you will be automatically billed and may continue using your subscription. You can also make a payment right now, pay in a different way, cancel, change or pause your subscription or modify the renewal date: -${url("subscriptions", id)} +${await url("subscriptions", id)} ### Details diff --git a/src/packages/server/purchases/stripe/create-subscription-payment.ts b/src/packages/server/purchases/stripe/create-subscription-payment.ts index 1a86b7d0e5..de68fd8e10 100644 --- a/src/packages/server/purchases/stripe/create-subscription-payment.ts +++ b/src/packages/server/purchases/stripe/create-subscription-payment.ts @@ -177,13 +177,13 @@ export default async function createSubscriptionPayment({ body: ` ${site_name} has started renewing your subscription (id=${subscription_id}). -- [Subscription Status](${url("subscriptions", subscription_id)}) +- [Subscription Status](${await url("subscriptions", subscription_id)}) -- Your Account: [Subscriptions](${url("settings", "subscriptions")}), [Payments](${url("settings", "payments")}) and [Purchases](${url("settings", "purchases")}) +- Your Account: [Subscriptions](${await url("settings", "subscriptions")}), [Payments](${await url("settings", "payments")}) and [Purchases](${await url("settings", "purchases")}) - Hosted Invoice: ${hosted_invoice_url} -${support()}`, +${await support()}`, }); } @@ -324,7 +324,7 @@ export async function processSubscriptionRenewalFailure({ paymentIntent }) { : subscription_id; const pool = getPool(); await pool.query( - `UPDATE subscriptions SET payment = jsonb_set(payment, '{status}', $2) WHERE id=$1`, - [id, "canceled"], + `UPDATE subscriptions SET payment = jsonb_set(payment, '{status}', '"canceled"') WHERE id=$1`, + [id], ); } diff --git a/src/packages/server/purchases/stripe/process-payment-intents.ts b/src/packages/server/purchases/stripe/process-payment-intents.ts index bb86e6849f..e23ee18e70 100644 --- a/src/packages/server/purchases/stripe/process-payment-intents.ts +++ b/src/packages/server/purchases/stripe/process-payment-intents.ts @@ -178,7 +178,7 @@ customer. So we don't know what to do with this. Please manually investigate. let result = "we did NOT add credit to your account"; try { if (paymentIntent.metadata.purpose == SHOPPING_CART_CHECKOUT) { - result = "put the items you were buying back in your cart"; + result = "the items you were buying were put back in your cart"; // free up the items so they can be purchased again. // The purpose of this payment was to buy certain items from the store. We use the credit we just got above // to provision each of those items. @@ -209,10 +209,10 @@ customer. So we don't know what to do with this. Please manually investigate. send({ to_ids: [account_id], subject: `Canceled ${currency(amount)} Payment`, - body: `You canceled a payment of ${currency(amount)}, and as a result ${result}. + body: `A payment of ${currency(amount)} was canceled, and as a result ${result}. - Payment id: ${paymentIntent.id} -- Your payments: ${url("settings", "payments")} +- Your payments: ${await url("settings", "payments")} - Account Balance: ${currency(round2down(await getBalance({ account_id })))} @@ -328,7 +328,7 @@ Thank you! - Payment id: ${paymentIntent.id} -- Your payments: ${url("settings", "payments")} +- Your payments: ${await url("settings", "payments")} - Credit id: ${credit_id} @@ -351,7 +351,7 @@ support if you are concerned (see below). - Account Balance: ${currency(round2down(await getBalance({ account_id })))} -- Your payments: ${url("settings", "payments")} +- Your payments: ${await url("settings", "payments")} - ERROR: ${err}