refactor(server): payment service (#8906)

This commit is contained in:
forehalo
2024-12-05 08:31:00 +00:00
parent 4fe1b5ba93
commit 4055e3aa67
26 changed files with 1934 additions and 1537 deletions
@@ -63,8 +63,8 @@ export class ScheduleManager {
}
async fromSubscription(
idempotencyKey: string,
subscription: string | Stripe.Subscription
subscription: string | Stripe.Subscription,
idempotencyKey?: string
) {
if (typeof subscription === 'string') {
subscription = await this.stripe.subscriptions.retrieve(subscription, {
@@ -88,7 +88,7 @@ export class ScheduleManager {
* Cancel a subscription by marking schedule's end behavior to `cancel`.
* At the same time, the coming phase's price and coupon will be saved to metadata for later resuming to correction subscription.
*/
async cancel(idempotencyKey: string) {
async cancel(idempotencyKey?: string) {
if (!this._schedule) {
throw new Error('No schedule');
}
@@ -129,7 +129,7 @@ export class ScheduleManager {
);
}
async resume(idempotencyKey: string) {
async resume(idempotencyKey?: string) {
if (!this._schedule) {
throw new Error('No schedule');
}
@@ -188,7 +188,7 @@ export class ScheduleManager {
});
}
async update(idempotencyKey: string, price: string) {
async update(price: string, idempotencyKey?: string) {
if (!this._schedule) {
throw new Error('No schedule');
}