Define payment currency

When a customer of your website makes a payment, all payments are issued in the default currency of your site. Even if the customer selected a custom currency, when the payment is issued, it is in the default currency. The conversion between the selected currency and the default currency is calculated according to the exchange rates you set when you configure currencies. For more information, see Currencies.

To enable your customers to make payments in a currency other than the default one, you do so by overriding the way a payment request is created.

NOTE: If you, as a merchant, want to receive 10 USD for an item and configured the Euro as a currency with exchange rate 0.9 (1 USD = 0.9 Euro), then, if you enable customers to pay in the selected Euro currency, a payment request for 9 euro is issued. If you request afterwards this amount from the payment provider in USD, it is possible that the currency is converted using a different exchange rate, which may be lower – for example, 0.88 (1 USD = 0.92 Euro). As a result, you receive only 9.78 USD instead of the desired 10 USD. Therefore, you need to be aware of these currency deviations when configuring currencies and determining the exchange rate you set for a currency.

IMPORTANT: Some payment providers may not support all kind of currencies used for the particular payment operation. This is risky, as these transactions will be issued with the default currency and not with the default amount price of the order. Before performing any payment transaction, you must verify that the selected payment provider supports the selected currency. For more information, see Change currency in payment requests for PayPal Standard and WorldPay providers.

Enable payment in non-default currencies

To enable customers to make payments in non-default currencies, you override the default payment currency. The following example demonstrates how to override the default way a payment request is created.

  1. Create a class, inheriting from the default OrderProcessor class.
    Since the OrderProcessor class has only one public constructor accepting an instance of the OrdersManager, you create a constructor that accepts this instance and passes it to the base class.
  2. Override the method that is responsible for creating a payment request.
    The method accepts the order, for which a payment is created. The order has the following 5 sets of properties in both the default and the currently selected currency:
      Total and ExchangeRateTotal - set the Amount property for the payment request
    • ShippingTotal and ExchangeRateShippingTotal - set the ShippingAmount property for the payment request
    • SubTotalDisplay and ExchangeRateSubTotalDisplay - set the SubtotalAmount property for the payment request
    • Tax and ExchangeRateTax - set the TaxAmount property for the payment request
    • The CurrencyCode for the payment request is usually set to the default currency (EcommerceSettings.Currencies.DefaultCurrency). However, in the example above you set it to the currently selected currency using the Currency property of the order

Use the following code sample:

By default, for each of properties above, the first set of properties is used. For example, Total and Tax. To create the payment request in the custom currency, you need to use the second set of sub-properties since each order has different values for both the default and the currently selected currency. For example, ExchangeRateTotal and ExchangeRateTax. Values are calculated based on the exchange rate you configured for this currency.

The following method creates a payment request in the custom currency, that is, the currency you selected. To do so, you register the CustomCurrencyOrderProcessor as the default OrderProcessor using the ObjectFactory:

Change currency in payment requests for the WorldPay provider

In case you select the WorldPay provider for payment methods, you need to apply additional code transformations because the parameters constructed for this provider are updated if the selected currency is different than the default one. You are not required to apply these code changes when working with any of the other payment providers.

To apply the code changes, add the following code snippet into your SitefinityWebApp project:

In the code above, you set the proper price amount of the order as per the currency value of the selected payment provider.

As a final step, you need to register the provider in the Sitefinity system.

IMPORTANT: To register the provider, you need to build your project first.

To register your provider:

  1. Navigate to Administration » Settings » Advanced.
    Expand the PaymentProcessorProviders item.
  2. Select the WORLDPAY item and change the value of the ProviderType input with the type of the custom provider:
    SitefinityWebApp.CustomPaymantProcessor.MultiCurrencyWorldPayProvider, SitefinityWebApp
  3. Save the changes.

Increase your Sitefinity skills by signing up for our free trainings. Get Sitefinity-certified at Progress Education Community to boost your credentials.

Web Security for Sitefinity Administrators

The free standalone Web Security lesson teaches administrators how to protect your websites and Sitefinity instance from external threats. Learn to configure HTTPS, SSL, allow lists for trusted sites, and cookie security, among others.

Foundations of Sitefinity ASP.NET Core Development

The free on-demand video course teaches developers how to use Sitefinity .NET Core and leverage its decoupled architecture and new way of coding against the platform.

Was this article helpful?