示例#1
0
        public async Task <string> GetPaymentUrlAsync(int courseId)
        {
            CourseDetailViewModel viewModel = await GetCourseAsync(courseId);

            CoursePayInputModel inputModel = new()
            {
                CourseId    = courseId,
                UserId      = httpContextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier),
                Description = viewModel.Title,
                Price       = viewModel.CurrentPrice,
                ReturnUrl   = linkGenerator.GetUriByAction(httpContextAccessor.HttpContext,
                                                           action: nameof(CoursesController.Subscribe),
                                                           controller: "Courses",
                                                           values: new { id = courseId }),
                CancelUrl = linkGenerator.GetUriByAction(httpContextAccessor.HttpContext,
                                                         action: nameof(CoursesController.Detail),
                                                         controller: "Courses",
                                                         values: new { id = courseId })
            };

            return(await paymentGateway.GetPaymentUrlAsync(inputModel));
        }