How do I set a rule for adding the fee for a payment method? pls, write me a simple guide.

I try this rule:
Event->Select available payment methods for an order
Condition->Selected payment method comparison
Parameter: Order: [commerce_order], Payment method: Card to driver + 4% fee

and now
Action->Multiply the unit price by some amount
BUT whitch data selector?
I can choose from this only:

site:current-user:roles:
site:current-cart-order:owner:
site:current-cart-order:commerce-line-items:
site:current-cart-order:commerce-order-total:	Order total
commerce-order:owner:roles:
commerce-order:commerce-line-items:0
commerce-order:commerce-line-items:1
commerce-order:commerce-line-items:2
commerce-order:commerce-line-items:3
commerce-order:commerce-line-items:0:
commerce-order:commerce-line-items:1:
commerce-order:commerce-line-items:2:
commerce-order:commerce-line-items:3:

Neither of them is not a field price, total order ends in a colon, so it throws an error.

:(

Comments

rszrama’s picture

Category: task » support
Priority: Critical » Normal
Status: Active » Fixed

You have to use product pricing rules to affect the price of products on the order. The event to enable payment methods on an order has nothing to do with this. Unfortunately, I don't think there will be a great way using Rules unless you're using a redirected payment method to increase the price based on the payment method selected (and it's typically against payment gateway rules). There is a condition to check the currently selected payment method, but you'll need to have an intermediate step where the user can see the fee added to their order total.

Prague man’s picture

Can you please be specific, how to set a Condition and Action for this rule, you speak about?
Thank you very much.

rszrama’s picture

It's only available on the latest dev version, but you'd just go to Store > Configuration > Product pricing rules and add a new rule for it. I don't have time to go deeper into it, but ultimately I'm not sure you'll be satisfied with a Rules based approach. You'll likely need a custom line item being added based on a selected payment method... I'd check with folks in #drupal-commerce on IRC to see if anyone's done it before.

If you need general Rules support, check out the Rules video series produced by Node One.

Prague man’s picture

Thanks, it looks like there was any change. Payment I made to the first step. However, this price not multiplied by the selected value, but will replace it. :) Maybe any bug.

Prague man’s picture

I have now entered the following options whitch works:
1) Install Tax module
2) in: admin/commerce/config/taxes set your special tax
1) Product pricing rules -> Condition -> Selected payment method comparison -> (Choose your payment method)
2) Action -> Apply a tax rate to a line item:
data selector: commerce_line_item
Tax rate: choose your new tax and save.

in admin/commerce/config/checkout/form push "payment" from Review pane to Checkout.

It works, but after changing the method of payment in Checkout pane, the change to appear in the Review pane only. It would take to refresh views immediately after change the payment methods. Maybe some jquery code.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mmncs’s picture

Status: Closed (fixed) » Active

--

mmncs’s picture

Status: Active » Closed (fixed)
ioanmar’s picture

Prague man you're right, the extra fee is kept even after selecting a different payment method afterwards. Have you solved this problem yet?

Prague man’s picture

Not yet.

playfulwolf’s picture

I am looking at the same problem myself: my task is even harder, but for the beginning it would be ok to have different fees while paying through PayPal and sm other merchant.

So, is this fixed or not?

dmidkiff’s picture

I have had an issue with this action as well.

My first attempt to add a fee to a paypal transaction was to create a Product Pricing Rule based on the "payment method comparison". This option did add the appropriate fee to the purchase. However, it added the fee after the paypal transaction was processed. Leaving a "balance due" on the order. I have not been able to make this rule work properly. Any advise would be appreciated.

My second attempt is working by adding the fee to the cart with an event "Calculating the sell price of a product" and no conditions. My problem here is having the fee removed if a different payment method is selected.

I have tried to use the Commerce Remove Tax Module with the Product Pricing Rule based on the "payment method comparison" which should remove any tax if payment method is not "paypal", but it does not seem to remove the tax. This is odd because the Product Pricing Rule based on the "payment method comparison" to add the fee in my first attempt added the fee after the paypal transaction was processed.

I am at a loss here. My only solution to remove the fee is to manually invoice payments by check, removing the fee and resending the invoice.

Any thoughts?

playfulwolf’s picture

dmidkiff, you mentioned pretty much everything that came to my mind and even more.
Marking this as active. The alternate title could be "Extra fixed/percentage fee (tax) depending on payment method".
I will look for the ideas at shipping rules and modules.

playfulwolf’s picture

Issue summary: View changes
Status: Closed (fixed) » Active
rszrama’s picture

Status: Active » Closed (fixed)

Please see my comment #1. The condition in question is in place, but your issue seems to be the exact situation I described as incompatible due to your checkout / payment workflow.

dmidkiff’s picture

thanks for the feedback.

I have posted in another area for Commerce Remove Tax Module to see if there is anything that can be done there. Issue 1

Another idea I was playing around with was the addition of a select option (check or credit card) to the billing information. Since you can add/remove taxes with rules based on address info, I thought by adding it here I might be able to use the new fields to effect the tax/fee. It does not look like additional fields are exposed to rules. Any tips here?

playfulwolf’s picture

My project is simple: there are virtual goods, which are sold for X$ amount. Payment is either through local payment merchant (he supplies with the module) or through Paypal. If user pays with one payment method - he pays X$, and pays X+Y$ if pays with other.

rszrama, if looking from site builder perspective, is there anything I can do? Any reasonable method is ok.

rszrama’s picture

You might get away with putting the payment method selection on the checkout page and just leaving the review pane on the review page.

a.ross’s picture

Seems like this module is a perfect fit: https://drupal.org/project/commerce_fees

playfulwolf’s picture

Thank you a.ross, from module description another headache is gone!

Alexanderz80’s picture

Is commerce fees still maintaining ? I still a bit confuse to adding credit card fee with percentage and adding to checkout pane. Anyone can help with step by step, i'm newbie. Thanks in advance.

leramulina’s picture

Did you succeed somehow?

I tried
1) To use Commerce Fees. Cannot set a fee with percents. Looks like it works only with flat fees.
2) Tried to multiply the price through "Multiply the unit price by some amount". But it did not multiply
3) Finally used taxes and understood that it adds a tax no matter what payment method is used. Event if I set the condition.
So, I tried to use Commerce Remove Tax Module but it does not remove the tax if I use the methods other than PayPal.

Do you have any other solutions?

Thank you in advance!

leramulina’s picture

I fixed it! Just needed to move Shopping cart contents to review
/admin/commerce/config/checkout

hockey2112’s picture

Is there an implementation to add a fee based on payment method for Drupal 8 / Commerce 2?

hsponner’s picture

Also would be interested in D8 / Commerce 2 solution for this.

devnyc’s picture

hockey2112 and hsponner, any luck with a D8 / Commerce 2 solution for your sites?

Looking for the same

Thanks!

hockey2112’s picture

Yes! The version listed in this reply: https://www.drupal.org/project/commerce/issues/2903716#comment-13557704

Direct link to the module, but do visit that first link for notes etc: https://github.com/jacobembree/commerce_fee/tree/fixes