cancel
Showing results for 
Search instead for 
Did you mean: 

How to get payment method fee amount

SOLVED

How to get payment method fee amount

Hi, I want to get payment fee amount at checkout. I got shipping amount by following code:

$this->_cart->getQuote()->getShippingAddress()->getShippingAmount();
1422.png

Thank you.

1 ACCEPTED SOLUTION

Accepted Solutions

Re: How to get payment method fee amount

Hi @f45879 ,

 

I don't have that Amasty's module available with me.

 

So, I can't debug particular code without that module.

But if you check some files that you will definitely find code for collection taken for amasty_cash_on_delivery_fee_quote and than you just need to apply filter with current quote id and after that you will get amount that you want.

 

Or Amasty is already displaying fee in order review sidebar on checkout page's payment step by using Knockout. You can check and get help from that part.

 

Problem solved? Click Kudos and "Accept as Solution".

 

Hope it helps!

Thanks

Ankit Jasani

View solution in original post

12 REPLIES 12

Re: How to get payment method fee amount

Hi @f45879 ,

 

Have you used any custom extension to add custom payment fee for customers based on Payment Method selection?

Ankit Jasani

Re: How to get payment method fee amount

Hi @Ankit Jasani, I'm using Cash on delivery module by Amasty.

Re: How to get payment method fee amount

Hi @f45879 ,

 

Please check sales_order and quote table from database and let me know if there is any new column added by Amasty?

 

As its paid module I cant check the exact code but may be they have added new column named amcodfee_amount and base_amcodfee_amount (or may be with any other column name) in sales_order and quote table. If yes than you can easily get value from your $quote object.

 

Like

$quote->getAmcodfeeAmount();

 

Please check and let me know after that.

 

Hope it helps!

Thanks

Ankit Jasani

Re: How to get payment method fee amount

Hi @Ankit Jasani

these columns are in amasty_cash_on_delivery_fee_order

entity_id,order_id,amount,base_amount,tax_amount,base_tax_amount

these columns are in amasty_cash_on_delivery_fee_quote

entity_id,quote_id,amount,base_amount,tax_amount,base_tax_amount

these columns are in sales_order

entity_id,state,status,coupon_code,protect_code,shipping_description,is_virtual,store_id,
customer_id,base_discount_amount,base_discount_canceled,base_discount_invoiced,
base_discount_refunded,base_grand_total,base_shipping_amount,base_shipping_canceled,
base_shipping_invoiced,base_shipping_refunded,base_shipping_tax_amount,
base_shipping_tax_refunded,base_subtotal,base_subtotal_canceled,base_subtotal_invoiced,
base_subtotal_refunded,base_tax_amount,base_tax_canceled,base_tax_invoiced,
base_tax_refunded,base_to_global_rate,base_to_order_rate,base_total_canceled,
base_total_invoiced,base_total_invoiced_cost,base_total_offline_refunded,
base_total_online_refunded,base_total_paid,base_total_qty_ordered,base_total_refunded,
discount_amount,discount_canceled,discount_invoiced,discount_refunded,grand_total,
shipping_amount,shipping_canceled,shipping_invoiced,shipping_refunded,shipping_tax_amount,
shipping_tax_refunded,store_to_base_rate,store_to_order_rate,subtotal,subtotal_canceled,
subtotal_invoiced,subtotal_refunded,tax_amount,tax_canceled,tax_invoiced,tax_refunded,
total_canceled,total_invoiced,total_offline_refunded,total_online_refunded,total_paid,
total_qty_ordered,total_refunded,can_ship_partially,can_ship_partially_item,
customer_is_guest,customer_note_notify,billing_address_id,customer_group_id,
edit_increment,email_sent,send_email,forced_shipment_with_invoice,payment_auth_expiration,
quote_address_id,quote_id,shipping_address_id,adjustment_negative,adjustment_positive,
base_adjustment_negative,base_adjustment_positive,base_shipping_discount_amount,
base_subtotal_incl_tax,base_total_due,payment_authorization_amount,
shipping_discount_amount,subtotal_incl_tax,total_due,weight,customer_dob,increment_id,
applied_rule_ids,base_currency_code,customer_email,customer_firstname,customer_lastname,
customer_middlename,customer_prefix,customer_suffix,customer_taxvat,discount_description,
ext_customer_id,ext_order_id,global_currency_code,hold_before_state,hold_before_status,
order_currency_code,original_increment_id,relation_child_id,relation_child_real_id,
relation_parent_id,relation_parent_real_id,remote_ip,shipping_method,store_currency_code,
store_name,x_forwarded_for,customer_note,created_at,updated_at,total_item_count,
customer_gender,discount_tax_compensation_amount,base_discount_tax_compensation_amount,
shipping_discount_tax_compensation_amount,base_shipping_discount_tax_compensation_amnt,
discount_tax_compensation_invoiced,base_discount_tax_compensation_invoiced,
discount_tax_compensation_refunded,base_discount_tax_compensation_refunded,
shipping_incl_tax,base_shipping_incl_tax,coupon_rule_name,gift_message_id,
paypal_ipn_customer_notified,mp_smtp_email_marketing_synced,mp_smtp_email_marketing_order_created,
delivery_timestamp,delivery_utc_offset,exclude_import_pending,exclude_import_complete

I hope that it will help you.

Re: How to get payment method fee amount

Hi @f45879 ,

 

Two ways:

 

1) You can add filter on amasty_cash_on_delivery_fee_quote collection by using quote_id.

So, you can get particular raw's data.

 

2) Amasty is already displaying fee in order review sidebar on checkout page's payment step by using Knockout. So, review that code and you will get more idea from that step.

 

Hope it helps!

Thanks

Ankit Jasani

Re: How to get payment method fee amount

Hello @f45879 

 

Kindly refer by below example code:

    /**
     * Initialize all order totals relates with tax
     *
     * @return \Magento\Tax\Block\Sales\Order\Tax
     */
    public function initTotals()
    {
        $parent = $this->getParentBlock();
        $this->_order = $parent->getOrder();
        $fee = new \Magento\Framework\DataObject(
            [
                'code' => 'fee',
                'strong' => false,
                'value' => $this->_order->getFee(),
                'label' => __('Fee'),
            ]
        );

        $parent->addTotal($fee, 'fee');
        return $this;
    }

It may help you to get Fee value!

Thank you.

Problem solved? Click Accept as Solution!

Re: How to get payment method fee amount

Hi @Ankit Jasani ,

I am new in Magento, so I don't have many experiencies. Can this help you ?133910.png

Re: How to get payment method fee amount

Hi @f45879 ,

 

Do you have idea about getting collection from amasty_cash_on_delivery_fee_quote table?

 

Ankit Jasani

Re: How to get payment method fee amount

Hi @Ankit Jasani ,

I don't know how to get collection. But it wouldn't be better to get order_id from amasty_cash_on_delivery_fee_order, because in amasty_cash_on_delivery_fee_quote are values that don't match with order ids.