feat(payment): support user-bound seven-discount offers
This commit is contained in:
@@ -24,10 +24,10 @@ export class PaymentRepository implements IPaymentRepository {
|
||||
constructor(private readonly api: PaymentApi) {}
|
||||
|
||||
/** 获取套餐列表。 */
|
||||
async getPlans(): Promise<Result<PaymentPlansResponse>> {
|
||||
async getPlans(commercialOfferId?: string): Promise<Result<PaymentPlansResponse>> {
|
||||
return Result.wrap(async () => {
|
||||
const response = await this.api.getPlans();
|
||||
await PaymentPlansStorage.setPlans(response);
|
||||
const response = await this.api.getPlans(commercialOfferId);
|
||||
if (!commercialOfferId) await PaymentPlansStorage.setPlans(response);
|
||||
return response;
|
||||
});
|
||||
}
|
||||
@@ -62,12 +62,14 @@ export class PaymentRepository implements IPaymentRepository {
|
||||
payChannel: PayChannel,
|
||||
autoRenew: boolean,
|
||||
recipientCharacterId?: string,
|
||||
commercialOfferId?: string,
|
||||
): Promise<Result<CreatePaymentOrderResponse>> {
|
||||
const request = CreatePaymentOrderRequestSchema.parse({
|
||||
planId,
|
||||
payChannel,
|
||||
autoRenew,
|
||||
...(recipientCharacterId ? { recipientCharacterId } : {}),
|
||||
...(commercialOfferId ? { commercialOfferId } : {}),
|
||||
});
|
||||
return Result.wrap(() => this.api.createOrder(request));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user