Files
odoo_source/addons/pos_stripe
Joren Van Onder 89c93186d4 [FIX] pos_stripe,pos_restaurant_stripe: Canadian Interac payments
Interac is the most popular Canadian debit card system [1]. To support
Interac payments in Stripe two changes were made [2]:

- "interac_present" was added as a payment_method_type when creating
  the payment intent, and
- Interac payments are never captured

interact_present should only be added if the Stripe account being used
is Canadian [3] and transactions take place in CAD [4]. If either of
these is not true Stripe will return an error when creating the
payment intent. Stripe Terminal doesn't support non-native currencies
[5], so checking the currency should be enough, but to be extra
defensive we also check the country on the company before adding the
payment_method_type. [6]

To stop capturing we check the type on the payment_method and bypass
captureAfterPayment. We also add a check on canBeAdjusted because
these payments cannot be adjusted later on.

A known limitation is that it won't be possible to refund customers
via Interac. This requires an API call (not possible via Stripe
Dashboard) and isn't feasible in a stable release. Refunding needs to
happen with cash.

Testing this is not possible with a physical reader since Stripe
refuses to send Interac test cards to non-Canadian addresses. Instead
a simulated reader was used [7]. When developing this simulated reader
discovery was explicitly enabled in the code:

await this.terminal.discoverReaders({simulated: true})

Afterwards Stripe Terminal can be configured so that the next
transaction it simulates is an Interac one. To do so the following was
executed in a browser console:

posmodel.payment_methods[{ID}].payment_terminal.terminal.setSimulatorConfiguration({testPaymentMethod: 'interac'})

This only affects the next transaction, subsequent transactions will
use the default card_present again.

[1] https://www.interac.ca/en/content/business/interac-by-the-numbers/
[2] https://stripe.com/docs/terminal/payments/regional?integration-country=CA#create-a-paymentintent
[3] {'error': {'code': 'card_present_type_not_supported',
           'message': 'The interac_present source type is not supported in US.',
           'request_log_url': 'https://dashboard.stripe.com/test/logs/xxx',
           'type': 'invalid_request_error'}}
[4] {'error': {'code': 'card_present_currency_not_supported',
           'message': 'The interac_present source type with currency usd is '
                      'not supported in CA.',
           'request_log_url': 'https://dashboard.stripe.com/test/logs/xxx',
           'type': 'invalid_request_error'}}
[5] https://support.stripe.com/questions/stripe-terminal-country-and-currency-availability
[6] Ideally the supported payment type should be determined by the
payment_icon_ids m2m on payment.provider. But since pos_stripe
currently doesn't use that field this approach was chosen.
[7] https://stripe.com/docs/terminal/payments/connect-reader

opw-3376103

closes odoo/odoo#133694

X-original-commit: d6296af29653eb46df0dff9b6a87ee6e93486a0d
Signed-off-by: Joren Van Onder (jov) <jov@odoo.com>
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2023-08-31 09:05:04 +00:00
..
…