Open Closed

Payment Module Override StripePaymentGateway #6068


User avatar
0
cangunaydin created
  • ABP Framework version: v7.4.0
  • UI Type: Angular
  • Database System: EF Core ( PostgreSQL)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes

Hello, I am using Volo.Payment module and i customized it little bit, only payment provider we use is stripe at the time. So what i want to achieve is, when the user update the plan from stripe dashboard ( modify the payment plan, changing the productid or priceid not only date) I want to be able to modify the necessary things in db. Like finding that tenant and switching to different edition. As i see from PaymentModule

it only gets the value "current_period_end" from the webhook call payload. So PaymentUpdatedEto is not holding those values. and since the method is "private protected virtual" i can not override the method so i can pass extra parameters with the event. How can i solve the problem? should i modify the PaymentRequestAppService instead?

    public override async Task<bool> HandleWebhookAsync(string paymentGateway, string payload, Dictionary<string, string> headers)
    {
        if (paymentGateway=="stripe")
        {
            //call my service and return
        }
        await PaymentGatewayResolver.Resolve(paymentGateway).HandleWebhookAsync(payload, headers);
        return true;
    }

for the next version, is it possible to change private protected methods like "HandleCustomerSubscriptionUpdatedAsync" and "HandleCustomerSubscriptionDeletedAsync" to protected only so it could be overridden.


3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    i can not override the method so i can pass extra parameters with the event. How can i solve the problem? should i modify the PaymentRequestAppService instead?

    You can replace the StripePaymentGateway service:

    [ExposeServices(typeof(StripePaymentGateway))]
    public class MyStripePaymentGateway : StripePaymentGateway
    

    for the next version, is it possible to change private protected methods like "HandleCustomerSubscriptionUpdatedAsync" and "HandleCustomerSubscriptionDeletedAsync" to protected only so it could be overridden.

    Okay, we will.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    i can not override the method so i can pass extra parameters with the event. How can i solve the problem? should i modify the PaymentRequestAppService instead?

    Sorry, try:

    public class MyStripePaymentGateway : IPaymentGateway, ITransientDependency
    {
       ...
    }
    
    Configure<PaymentOptions>(options =>
    {
        options.Gateways[StripeConsts.GatewayName] = 
                new PaymentGatewayConfiguration(
                    StripeConsts.GatewayName,
                    new FixedLocalizableString("Stripe"),
                    isSubscriptionSupported: true,
                    typeof(MyStripePaymentGateway)
                );
    });
    
  • User Avatar
    0
    cangunaydin created

    I have already replaced it, the thing was i didn't want to change whole gateway since i use some parts of the class. I override StartAsync method in that class, i was wondering can i do that for the webhook method, it seems for that i need to replace whole payment gateway. But i got the answer thank you. It would be helpful, if methods can be virtual on the next version.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15