feat: add payment options on student portal
This commit is contained in:
@@ -19,6 +19,7 @@ import { logger } from '@/logger';
|
||||
import { PlanGuard } from '@/modules/billing/lib/entitlements';
|
||||
import { getMpAccessToken } from '@/modules/mp';
|
||||
import { createCheckoutPreference, getWebOrigin, MpApiError } from '@/modules/mp/lib';
|
||||
import { CHECKOUT_BACK_PATH } from '../../lib';
|
||||
|
||||
type BatchDeps = {
|
||||
db?: Pick<PrismaClient, 'group' | 'attendee' | 'payment' | 'user'>;
|
||||
@@ -95,7 +96,7 @@ export class CreatePaymentBatch {
|
||||
return token;
|
||||
}
|
||||
|
||||
const backUrl = `${this.deps.webOrigin ?? getWebOrigin()}/payments`;
|
||||
const backUrl = `${this.deps.webOrigin ?? getWebOrigin()}${CHECKOUT_BACK_PATH}`;
|
||||
const dueDate = new Date(input.dueDate);
|
||||
const title = input.description?.trim() || group.name;
|
||||
const createPreference = this.deps.createPreference ?? createCheckoutPreference;
|
||||
|
||||
@@ -12,7 +12,7 @@ import { logger } from '@/logger';
|
||||
import { PlanGuard } from '@/modules/billing/lib/entitlements';
|
||||
import { getMpAccessToken } from '@/modules/mp';
|
||||
import { createCheckoutPreference, getWebOrigin } from '@/modules/mp/lib';
|
||||
import { type PaymentRecord, toPaymentDto } from '../../lib';
|
||||
import { CHECKOUT_BACK_PATH, type PaymentRecord, toPaymentDto } from '../../lib';
|
||||
|
||||
type RenewDeps = {
|
||||
db?: Pick<PrismaClient, 'payment' | 'user'>;
|
||||
@@ -83,7 +83,7 @@ export class RenewPaymentLink {
|
||||
return token;
|
||||
}
|
||||
|
||||
const backUrl = `${this.deps.webOrigin ?? getWebOrigin()}/payments`;
|
||||
const backUrl = `${this.deps.webOrigin ?? getWebOrigin()}${CHECKOUT_BACK_PATH}`;
|
||||
const createPreference = this.deps.createPreference ?? createCheckoutPreference;
|
||||
|
||||
let preference: { initPoint: string; id: string };
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import type { PaymentDto } from '@gruperly/shared';
|
||||
|
||||
/* Where Mercado Pago sends whoever paid a Checkout Pro link: the student app
|
||||
(without a student session it falls through to /access). */
|
||||
export const CHECKOUT_BACK_PATH = '/student/payments';
|
||||
|
||||
export type PaymentRecord = {
|
||||
id: string;
|
||||
groupId: string;
|
||||
|
||||
@@ -1 +1 @@
|
||||
export { type PaymentRecord, toPaymentDto } from './helpers';
|
||||
export { CHECKOUT_BACK_PATH, type PaymentRecord, toPaymentDto } from './helpers';
|
||||
|
||||
Reference in New Issue
Block a user