Skip to content

Commit

Permalink
purchase testing -- fix little things
Browse files Browse the repository at this point in the history
  • Loading branch information
williamstein committed Dec 6, 2024
1 parent a9fe2a6 commit 68c9140
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/packages/server/messages/admin-alert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/packages/server/messages/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/packages/server/purchases/maintain-auto-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
12 changes: 6 additions & 6 deletions src/packages/server/purchases/maintain-automatic-payments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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",
Expand All @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion src/packages/server/purchases/maintain-subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()}`,
});
}

Expand Down Expand Up @@ -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],
);
}
10 changes: 5 additions & 5 deletions src/packages/server/purchases/stripe/process-payment-intents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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 })))}
Expand Down Expand Up @@ -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}
Expand All @@ -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}
Expand Down

0 comments on commit 68c9140

Please sign in to comment.