Allow payments to be converted to another currency. This can be useful when a payment amount is in a particular currency, but the customer wants to use a payment method that does not support that currency. See how this overlaps with #1844850: Add support for Dynamic Currency Conversion (DCC), and how we make this feature transparent for the merchant, who expects the original currency, and the customer, who wants to see the currency he paid in, and perhaps the original as well.

Postponed to 8.x-2.x.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Xano’s picture

Title: Allow » Allow payments to be converted to another currency
Xano’s picture

Version: 7.x-1.x-dev » 8.x-2.x-dev
Status: Postponed » Active
Xano’s picture

Xano’s picture

Issue summary: View changes

The original philosophy behind Payment is that payment entities reflect real-world payments/transactions and they are not invoices. There amounts that are charged, are set on the line items. The amount that is paid, is the payment amount itself. The latter can change, depending on the real-world payment the entity reflects. This is also why we cannot fix #2334237: Consider removing line item's currencies, because line items contain the amounts that are charged, and they may be dynamically based on referenced data, such as orders.

Instead, allow payment methods to change a payment's amount and currency, and add line items after payment execution to balance out any differences between the charged amounts and the paid amount. This way the line items still contain the original charged amounts, but the payment amount and currency reflect reality.

Xano’s picture

Status: Active » Needs review
FileSize
1.97 KB

Status: Needs review » Needs work

The last submitted patch, 5: payment_1905902_5.patch, failed testing.

Xano’s picture

Add a PaymentLineItemCollectionInterface that gets the methods for the charged amount, as that's what line items represents. Keep the methods for the paid amount on PaymentInterface.

Xano’s picture

Payment types, however, must be able to work with the paid amounts. If they charge in EUR, but are paid in USD, they may not be able to figure out if the charged amount was paid completely. How will we deal with that?

Xano’s picture

So there are three types of amounts we have to deal with:

  1. The amount that is charged. This is contained in the line items and may have to be converted to a single currency for further processing, as line items can specify amounts in different currencies.
  2. The amount that is paid in a currency of the payer's preference: the charged amount may be in EUR, but if the payer would rather like to pay in UAH and the payment method allows that, this amount is different from the oher amounts.
  3. The amount that is paid in a currency of the payment type's preference. This is needed to find out if the payer paid enough to cover the originally charged amount.

In essence only 1 and 3 are necessary for the system to function. 2 is really more of a reference for the payer to match a payment entity to a transaction on their back account. We can start by implementing 1 and 3, and add 2 later if there is a need for it.

Xano’s picture

Status: Needs work » Needs review
FileSize
41.04 KB

Status: Needs review » Needs work

The last submitted patch, 10: payment_1905902_10.patch, failed testing.

Xano’s picture

Status: Needs work » Needs review
FileSize
41.07 KB

Status: Needs review » Needs work

The last submitted patch, 12: payment_1905902_12.patch, failed testing.

Xano’s picture

Status: Needs work » Needs review
FileSize
6.91 KB
47.58 KB

Status: Needs review » Needs work

The last submitted patch, 14: payment_1905902_14.patch, failed testing.

Xano’s picture

Status: Needs work » Needs review
FileSize
23.83 KB
60.61 KB

Status: Needs review » Needs work

The last submitted patch, 16: payment_1905902_16.patch, failed testing.

Status: Needs work » Needs review

Xano queued 16: payment_1905902_16.patch for re-testing.

Status: Needs review » Needs work

The last submitted patch, 16: payment_1905902_16.patch, failed testing.

Xano’s picture

Status: Needs work » Needs review
FileSize
60.41 KB

Status: Needs review » Needs work

The last submitted patch, 20: payment_1905902_20.patch, failed testing.

Xano’s picture

Status: Needs work » Needs review
FileSize
3.88 KB
64.09 KB

Status: Needs review » Needs work

The last submitted patch, 22: payment_1905902_22.patch, failed testing.

Xano’s picture

Status: Needs work » Needs review
FileSize
64.16 KB

Re-roll.

Status: Needs review » Needs work

The last submitted patch, 24: payment_1905902_24.patch, failed testing.

Xano’s picture

Status: Needs work » Needs review
FileSize
1.79 KB
65.04 KB

Status: Needs review » Needs work

The last submitted patch, 26: payment_1905902_26.patch, failed testing.