Change GetAdditionalHandlingFee() after Selected PaymentMethod. ( Plugins PaymentMethod Related )

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
9 yıl önce
Hello dear friends,

I'm working on a new payment plugin.  Everything works fine up to now.

My QUESTION is :
"I want to change GetAdditionalHandlingFee() after the customer selected paymentmethod. "

*** I have dropdown list where a page the customer enter credit cart information. *** As follows;

-MyDropDownList
-CardType
-CardName
-CardNumber
-Expire Date
-Card Code

Want to change "PaymentSettings.AdditionalFee"  when the dropdown list changed and also got effect to GetAdditionalHandlingFee() and also show the FEE to the customer when he/she select a value from my dropdown list.

I have no problem to get my data when dropdown selection changed. (or you offer other method )

I think, have to do this in my controller, if so how can I change GetAdditionalHandlingFee() from anywhere in the my controler.

If not while the dropdown list selection changed  , how  can do this process and from which class to change GetAdditionalHandlingFee().

Thank you everyone who will help me.
9 yıl önce
On the client side, the 'value' attribute of your drop down items should probably be the fee.  
As for server side...

GetAdditionalHandlingFee() is in your IPaymentMethod class. You'll have to modify it there, not in your controller.

You can see that the core CheckoutController stores Payment Info in the Session:

    public ActionResult EnterPaymentInfo(FormCollection form)
    ...
        //get payment info
        var paymentInfo = paymentController.GetPaymentInfo(form);
        //session save
        _httpContext.Session["OrderPaymentInfo"] = paymentInfo;
                
In your GetPaymentInfo() (which is in your Controller), store your custom values (fee from the form/dropdown) in the paymentInfo.CustomValues dictionary.

Then in your GetAdditionalHandlingFee(), retrieve those items from the dictionary in the Session:

var processPaymentRequest = _httpContext.Session["OrderPaymentInfo"] as ProcessPaymentRequest;
...processPaymentRequest.CustomValues["..."]   ....
                
You'll need to inject HttpContextBase _httpContext in your constructor, and you should also check that _httpContext and  _httpContext.Session are not null before you reference the dictionary.
9 yıl önce
Thank you , I'm trying to do.

But in MyPaymentProcessor ;

in my codet _httpContext and also procesPaymentRequest are always come null. ? why and help please. Thank you.
9 yıl önce
Thank you. I solve this.

You show me the right way , thank you so much again.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.