Repository navigation
Show the payment method in the customer's language in order e-mails and PDF - #942
Merged
Merged
Conversation
…nd PDF
IPaymentProvider gets GetFriendlyName(languageId), defaulting to FriendlyName so
external plugins keep working; the shipped payment plugins translate it into the
given language. The {{Order.PaymentMethod}} token and the PDF invoice pass
Order.CustomerLanguageId instead of following the request language. Tax and
shipping provider errors are logged with SystemName.
Order e-mails and PDFs now get the payment method name through GetPaymentMethodName(order): the name in the order's language, the friendly name when the order has no language or no translation, and the system name when the provider is missing or gives no name. An order without a language no longer throws, a missing translation no longer shows the resource key, and the Vendor order PDF uses the same name.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type: bugfix
Issue
Payment plugins translate
FriendlyNamewith the current request's language. Business code reads it for the customer, though: the{{Order.PaymentMethod}}message token and the PDF invoice (whose other texts already useOrder.CustomerLanguageId). When an admin changes an order status, or a scheduled task sends the e-mail, the customer gets the payment method name in the admin's or the default language.TaxServiceandShippingServicealso translated the provider name just to write it to the log.Follow-up to #940 (architecture backlog M1, PR 6b).
Solution
IPaymentProvider.GetFriendlyName(string languageId): a default interface method returningFriendlyName, overridden by BrainTree, Cash on delivery and Stripe Checkout withGetResource(key, languageId).GetOrderTokensCommandHandlerandOrderPdfTemplate.cshtmlcall it withOrder.CustomerLanguageId.SystemName.IProvider.FriendlyNameandIPaymentProvider.Description(). Only Web reads them, inside a request, where the request language is the right one.Breaking changes
None. The new method has a default implementation; external payment plugins keep their current behavior until they override it.
Testing
GetOrderTokensCommandHandlerTests.Handle_PaymentMethodNameInTheCustomerLanguage.Payments.CashOnDelivery.FriendlyNamedifferently, place an order with Cash on delivery in language B.{{Order.PaymentMethod}}is queued. The queued e-mail shows the name in language B.