Payment Director allows a store owner to conditionally determine which payment methods to show the customer and to calculate additional payment fees. Let’s start with the basics…
By default, all Payment Methods that are marked Active in admin > Configuration > Payment Methods are available to your customers. Then, you set up Payment Director Option records as needed to hide options and calculate fees. Each option’s Expression field is evaluated, and if ‘true’ (or ‘Show’) then the option will be presented to the customer. If ‘false’ (or ‘Hide’), then the payment option is removed. You can include an Option record for all your active payment methods, but if only some are conditional, then it’s easiest to just have Option records for those; if an active payment method is not included in payment director, then it will automatically be shown to the customer.
Here are some example scenarios for offering payment methods, and their Option records/expressions:
Offer 'payment in store' method only when "In-Store Pickup" shipping method selected:
Option Payments.PayInStore ShippingOptionName = "In-Store Pickup"
Local Deliveries can include CashOnDelivery:
Option Payments.CashOnDelivery Customer.ShippingAddress.ZipPostalCode.StartsWith("100")
Customers in role "Members" can include PurchaseOrder (use the role's System Name):
Option Payments.PurchaseOrder Customer.IsInCustomerRole("Members")
If an admin is impersonating a Customer, then use Manual Credit Card, otherwise the customer enters a credit card that Authorize.Net will process:
Option Payments.Manual OriginalCustomerIfImpersonated != null
Option Payments.AuthorizeNet OriginalCustomerIfImpersonated = null
Only offer Paypal if a FedEx shipping method was selected (a method that has tracking :)
Option Payments.PayPalStandard ShippingOptionName.StartsWith("FedEx")
Only offer credit card if there are no Gift Cards in the cart
Option Payments.Manual NOT Items.Any(Product.IsGiftCard)
When entering records in the Add new 'Payment Director' record dialog, select Option in the Type field drop down, and then the Payment Name field will present a drop down with only active payment methods.
Then, enter an expression that evaluates to a Boolean (true or false) using one or more or more of the following operands:
- Customer (also has function IsInRole("systemname") )
- ShippingAddress
- ShippingOption (.ShippingRateComputationMethodSystemName, .Rate, .Name, .Description)
- ShippingOptionName
- Items (shopping cart items collection)
- OriginalCustomerIfImpersonated (if != null then you are impersonating)
- WorkingLanguage (.Name, and .LanguageCulture)
- WorkingCurrency (.Name, .CurrencyCode, .Rate, and .DisplayLocale)
- TaxDisplayType (IncludingTax = 0, ExcludingTax = 10)
- CreditCardType (e.g. for Authorize.NET : "Visa", "MasterCard", "Discover", "Amex")
- PurchaseOrderNumber
- OrderTotalWithoutPaymentFee
- FriendlyName
(UPDATE: Here are more operands added added from 3.60 and on)
- CurrentStoreId
- CurrentStoreName
- IsImpersonating (Boolean)
- CustomValues
- (The nopC PaymentInfoCustomValues is a Dictionary of Key/Values set by other payment plugins. This variable converts that dictionary to a string of "key:value|key:value|...". You can use CustomValues.StringBetween("key:","|") to get a value.
Here are some examples:
We'll introduce more features in the next blog :)