Giter Site home page Giter Site logo

paymentservice's Introduction

PaymentService

ABP version NuGet NuGet Download Discord online GitHub stars

An abp application module that provides payment service.

Installation

  1. Install the following NuGet packages. (see how)

    • EasyAbp.PaymentService.Application
    • EasyAbp.PaymentService.Application.Contracts
    • EasyAbp.PaymentService.Domain
    • EasyAbp.PaymentService.Domain.Shared
    • EasyAbp.PaymentService.EntityFrameworkCore
    • EasyAbp.PaymentService.HttpApi
    • EasyAbp.PaymentService.HttpApi.Client
    • (Optional) EasyAbp.PaymentService.MongoDB
    • (Optional) EasyAbp.PaymentService.Web
  2. Add DependsOn(typeof(PaymentServiceXxxModule)) attribute to configure the module dependencies. (see how)

  3. Add builder.ConfigurePaymentService(); to the OnModelCreating() method in MyProjectMigrationsDbContext.cs.

  4. Add EF Core migrations and update your database. See: ABP document.

Usage

  1. Register the Free payment method, it is used to pay when the amount is 0.00:

    Configure<PaymentServiceOptions>(options =>
    {
        options.Providers.Configure<FreePaymentServiceProvider>(FreePaymentServiceProvider.PaymentMethod);
        // options.Providers.Configure<PrepaymentPaymentServiceProvider>(PrepaymentPaymentServiceProvider.PaymentMethod);
        // options.Providers.Configure<WeChatPayPaymentServiceProvider>(WeChatPayPaymentServiceProvider.PaymentMethod);
    });
  2. Choose the payment service providers you want:

Payment

Roadmap

  • Prepayment.
  • Support WeChatPay.
  • Support Paypal.
  • Support Alipay.
  • Support Bitcoin payment.
  • Unit tests.

paymentservice's People

Contributors

ericeric284 avatar gdlcf88 avatar hueifeng avatar lginc avatar slarkerino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

paymentservice's Issues

Add PaymentCanceledEto

Publish a PaymentCanceledEto after the IPaymentManager.CompleteCancelAsync() method executed.

PaymentApprovedEventEto should be published before paying

Relate to: EasyAbp/EShop#40
This measure was added to reduce invalid payments.

  • Set Payment.ApprovedTime by handling the PaymentApprovedEventEto event.
  • Check the Payment.ApprovedTime is not null in IPaymentServiceProvider.PayAsync().
  • Check the Payment.ApprovedTime is not null before other modules sync the Payment entity data.

Problem on Tenant Database

In a multi-tenant environment, the payment entity is always inserted into the host database instead of the tenant db. The problem only occurs in paymentservicecontext and not exist in wechat or prepayment context db.

Get payment ExtraProperties in PayAsync

In the previous design, we get ExtraProperties from the user's input during the Payment entity creation and insert it into the entity without validation so users may input bad ExtraProperties.

In the new design, we create Payment entities without ExtraProperties input and get it in IPaymentAppService.PayAsync method.

Remove IPaymentAuthorizer

  • Allow any payment request and handle the payment events if the request is valid.
  • Should reject payment requests that are already in progress with the same payment items.
  • Copy ExtraProperties from input DTO to Payment entity.

Create a payment request with event

It is a good way to resolve: #8

  • Delete the CreateAsync method in PaymentAppService.
  • Add a CreatePaymentEto event and handle it to create a new Payment entity.
  • Add a PayAsync method in PaymentAppService to Execute the IPaymentServiceProvider.PayAsync(...) method.

评估微信支付退款业务流程

需评估:

  • WeChatPayRefundEventHandler的两个if (dict.GetOrDefault("result_code") != "SUCCESS")仅能留下一个,是选择抛错,还是选择回滚退款请求?
  • 微信支付的RefundRecord实体,是否遗漏了记录回调时返回的return_codereturn_msg

Free payment service adjustment

  • When the payment amount is 0, the free payment service can be used.
  • App developers should register the free payment service themself.

微信支付退款:发起退款异常

在EasyAbp.Eshop.Payments 版本3.5.0中发起退款/api/e-shop/payments/refund,抛出异常:
System.ObjectDisposedException: Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it (or one of its parent scopes) has already been disposed.
at Autofac.Core.Lifetime.LifetimeScope.ThrowDisposedException()
at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(ResolveRequest request)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable1 parameters)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Volo.Abp.ObjectMapping.DefaultObjectMapper.Map[TSource,TDestination](TSource source)
at Volo.Abp.BackgroundJobs.BackgroundJobStore.InsertAsync(BackgroundJobInfo jobInfo)
at Volo.Abp.BackgroundJobs.DefaultBackgroundJobManager.EnqueueAsync(String jobName, Object args, BackgroundJobPriority priority, Nullable1 delay) at Volo.Abp.BackgroundJobs.DefaultBackgroundJobManager.EnqueueAsync[TArgs](TArgs args, BackgroundJobPriority priority, Nullable1 delay)
at EasyAbp.PaymentService.WeChatPay.WeChatPayPaymentServiceProvider.<>c__DisplayClass17_0.<b__0>d.MoveNext()
--- End of stack trace from previous location ---
at Volo.Abp.Uow.UnitOfWork.OnCompletedAsync()
at Volo.Abp.Uow.UnitOfWork.CompleteAsync(CancellationToken cancellationToken)
at Volo.Abp.AspNetCore.Uow.AbpUnitOfWorkMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)
at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<b__1>d.MoveNext()
--- End of stack trace from previous location ---
at Volo.Abp.AspNetCore.ExceptionHandling.AbpExceptionHandlingMiddleware.InvokeAsync(HttpContext context, RequestDelegate next)

Provide a preset "Manual" withdrawal method

  • Using this withdrawal method, users can request a withdrawal, and wait for administrator review.
  • This preset withdrawal method is not enabled by default, application developers should configure it themself.

Missing IMultiTenant interface on Payment and Refund Entity

Recently using this module with a multi-tenant project I found when I split tenant database, no entries were found in tenant database. It should be caused by Missing IMultiTenant interface on Payment and Refund Entity.

public class Payment : FullAuditedAggregateRoot<Guid>, IPayment

Redesign Refund aggregate

  • Remove PaymentItemId from Refund aggregate root.
  • Add RefundItem entities to the Refund aggregate root.

Prepayment模块中Account Balance应该可以减成负数

一些先使用后付费的场景很容易让余额低于0。比如云服务之类的。

        public void ChangeBalance(decimal changedBalance)
        {
            var newBalance = decimal.Add(Balance, changedBalance);

            if (!newBalance.IsBetween(PrepaymentConsts.AccountMinBalance, PrepaymentConsts.AccountMaxBalance))
            {
                throw new AmountOverflowException(PrepaymentConsts.AccountMinBalance,
                    PrepaymentConsts.AccountMaxBalance);
            }
            
            if (newBalance < LockedBalance)
            {
                throw new LockedBalanceIsGreaterThenBalanceException(LockedBalance, newBalance);
            }

            Balance = newBalance;
        }

这里限制死了感觉会不太方便

Automatically cancel overtime payments

  • Record payment vouchers in Payment entities, users can get them from on their next visit.
  • Automatically cancel overtime (maybe 15 mins by default) payments.

Add GetTransactionListInput

  • It has an AccountId property.
  • TransactionAppService.GetListAsync() should user this DTO.
  • Add an index for AccountId column.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.