Commit Graph
123 Commits
Author SHA1 Message Date
Saurabh Choraria de782a680d [FIX] payment_stripe: handle error for unsupported country while stripe setup
Currently, When a user tries to set up a stripe account but his country is not
supported by stripe then he receives a error message at backend side and a
ValidationError ("Stripe Proxy: An error occurred when communicating with
the proxy.") on frontend side.

After applying this commit the error message will be updated to a warning level
which will reduce the noise in sentry. I have also added a condition in
'action_stripe_connect_account' method to check whether the country is
supported by stripe or not and if it is not supported the user will be
redirected to other payment providers page.

sentry-3935758343

closes odoo/odoo#128140

X-original-commit: c7b0d8eebe686d9c38f9f5c71577c80718ffb791
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2023-07-15 04:01:14 +02:00
Antoine Vandevenne (anv) d41b7a1f48 [CLN] payment(_stripe): cleanup of ee963d10
closes odoo/odoo#127054

Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2023-07-03 15:37:37 +02:00
Florian Charlier 77f9ff50db [REF] *: use onboarding module
* = account{_payment}, base, onboarding, payment{_stripe},
sale{_management}, web, website_sale

Use the dedicated onboarding module introduced in 16.0 instead of
the res.company model to store onboarding progress.

It allows
 * onboarding steps to be reused across panels
 * to support steps that should be completed per-database or per-company
 * to clean the res.company model from many fields and methods,
 * to remove many views, controllers, actions

Module-specific notes:
* account: We also clean the remaining two steps that are not
part of an accounting panel but make the most sense to be kept here.
* account_payment: Following 8e4e8eb8, the payment provider step is
added to the invoicing onboarding panel. We apply this change here too.
Also impacts the website_sale_dashboard panel (see related ENT PR).
(The "sale tax" one is currently used for to the website sale dashboard).
* payment: Note that the step was already not part of an onboarding
panel within this module.
* website_sale: We clean
  * a field not used (The website_sale dashboard onboarding panel used
  the payment_provider_onboarding_state field).
  * a method that was only called from website_sale_dashboard, so it is
  moved there. See related ENT PR.

Includes a few tests.

Moving views/templates/styling, as well as cleaning residual onboarding-related fields and methods in base, including populate.

This also includes restoring the "onboarding_complete" overlay panel
animating it to disappear after a few seconds so that it doesn't hide
text and block buttons to re-open steps.

Task-3025136

Part-of: odoo/odoo#104223
2023-06-30 23:37:50 +02:00
Antoine Vandevenne (anv) 1ac7b728cb [FIX] payment_stripe: prevent crash if the payment intent can't be created
When the payment method was detached from the customer, trying to pay
with the linked payment token would end up with a crash because Stripe
failed to send us the payment intent, as it could not create it.

With this commit, we test for the existence of the returned payment
intent and prematurely return in `_send_payment_request` to prevent a
cursor rollback. The transaction is set in 'error' and the error
message is logged in the stdout and on the transaction's state message
field.

closes odoo/odoo#120348

X-original-commit: 4ebf0efc16ef78ca568ef93fb2c36ce404cb0c12
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2023-05-03 11:16:43 +02:00
Antoine Vandevenne (anv) 98a834a8de [FIX] payment_stripe: filter out card PMs if none is linked to the provider
Before this commit, the "Card" payment method would always be shown on
Stripe's hosted checkout form, even if there is no related payment icon
(VISA, MasterCard, Discover, American Express) set as "supported payment
icon" in Odoo.

After this commit, Stripe is instructed to hide the "Card" payment
method if all related payment icons are unset in Odoo. If at least one
related payment icon is set, the "Card" payment method is hidden. If the
"Supported payment icons" field is left completely empty, all payment
methods are available on Stripe.

closes odoo/odoo#116917

X-original-commit: d7e96a771e92020938658cdd4dc4a41c45f1644e
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2023-03-29 09:33:55 +02:00
Demesmaeker 7f2ae9ed5b [IMP] payment(_adyen): allow partial capture
Before this commit, it was not possible to partially capture a
transaction from Odoo, and doing so in the provider backend would often
result in a full capture in Odoo when capture was supported.

With this commit, partial captures are made available in Odoo directly
from the sales order or invoice, for providers that support them.
Provider can either only support full capture or also support partial
ones. It also optionally managed the automatic void of the remaining
amount at the user request when multiple captures are supported by the
provider.

As of now, the only acquirer allowing partial capture is Adyen.

task-2728768

closes odoo/odoo#87251

Related: odoo/enterprise#35205
Related: odoo/documentation#2063
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2023-03-09 10:51:29 +01:00
Anita (anko) 1d846c36d9 [IMP] payment(_*): allow specifying extra allowed states
Some providers require additional allowed states due to their refund or
transaction process justifying it. Until now, these extra states were
specified in the `payment` module, which was not ideal as it allowed
every provider in every flow to accept these additional states.

With this commit, additional states are now specified only in the
coresponding flow of a provider that requires them.

task-2869678

closes odoo/odoo#107110

Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2023-02-24 18:16:00 +01:00
Valentin Vallaeys (vava) 956d0d26a3 [IMP] payment_stripe: prevent enabling Stripe if onboarding is ongoing
For now, you can enable the Stripe payment provider while onboarding
with Stripe Connect.

This raises two issues:
- This will raise errors in online payments because Stripe is not
completely configured;
- The button to continue the onboarding is not working anymore,
preventing the user to finish the configuration of his account from
Odoo.

This commit prevents enabling Stripe if the onboarding has been
initiated but is not finished. It also changes the way constants are
read from const.py to allow patching one of them if needed.

OPW-3149159

closes odoo/odoo#111534

X-original-commit: fa3bcac71d1699aa9b9a7bc1d6b6181a70171662
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Vallaeys Valentin (vava) <vava@odoo.com>
2023-01-31 21:16:56 +01:00
Anita (anko) 5cc86c3bb1 [IMP] payment: Rename Payment Icon to Payment Method.
Payment Icon sounds confusig comparing to what it really is,
payment method name makes it clearer for user to understand
what it is.

task-2882564

closes odoo/odoo#105678

Related: odoo/enterprise#33908
Related: odoo/upgrade#4029
Related: odoo/documentation#2955
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2023-01-20 18:54:44 +01:00
Yas-Elak cea588b1ed [FIX] payment_stripe: Limit phone number to 20 characters
Before this commit, the string with the phone number sent to Stripe for the request is not checked and we got this error on the checkout page
---------------------
We are not able to process your payment.
Stripe: The communication with the API failed. Stripe gave us the following info about the problem: 'Invalid string: +1 555-555...5678456789; must be at most 20 characters'
-----------------------
The stripe API does not accept phone numbers with more than 20 characters
The problematic phone number are mostly the one with extention: +1 780-459-5656 ext. 725
But the customer can put anything in the phone field when he buys some product via eCommerce
Now I just limit the phone string to 20 characters, this doesn't affect the res.partner

If the customer had a phone with more than 20 characaters in the res.partner form, it will stay that way. It's only for the stripe request

closes odoo/odoo#109834

X-original-commit: d24cc320854f180989949328396dbbd8ac69bdc9
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2023-01-13 17:33:14 +01:00
Abdelouahab (abla) 608aa8ca88 [FIX] payment_stripe: use idempotency key only when offline
To Reproduce
============
- on a db with sales, website and Stripe payment aquirer activated
- on the portal of a user add two payment methods, an expired card
and a valid one
- create a SO and generate its payment link
- try to pay with the invalid card first -> and error (card was declined)
- try to pay with the valid card -> error (same idempotency key)

Problem
=======
the generation of the idempotency key is based only on dbuuid, transaction's
reference and the scope. So in this use case it will generate the same key.

Solution
========
The idempotency key prevents issues where the customer is charged twice for
the same thing. In this case, we don't want to prevent anything since the
customer is on the page. It's suggested to use idempotency keys only for offline
payment when the customer is not in front of the payment page (e.g. when the cron
charges the customer for his subscription)

opw-3091354

closes odoo/odoo#108163

X-original-commit: 089387087010ae917494d5072f00d72c572b7d09
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: abla001 <abla@odoo.com>
2022-12-16 14:49:58 +01:00
Valentin Chevalier 1e025adbf3 [IMP] payment_stripe: adjust the code for Stripe Connect
task-2982347

X-original-commit: fc890dc6e91a6731bf31a40ee77dad0f8697f5b4
Part-of: odoo/odoo#104387
2022-10-28 09:17:56 +02:00
mafo-odoo e9234fd52c [FIX] payment_stripe: add idempotency key to prevent multiple payments
Video 1 (Issue): https://drive.google.com/file/d/1oXYcDJgaT9gmhkjE08yJlXwIL1qPwS1Y/view?usp=sharing

Issue:
When using the register payment with a token with any of the payment acquirers,
if there is a concurrent access error during the reconciliation process,
the payment intent is sent multiple times to the acquirer, making the card charged multiple times.

Steps to reproduce:

-Have a V14 database (only tested this version) with sale_mmanagement, payment_stripe and invoicing
-Configure Stripe with your public and secret key (2FA is now enforced for Stripe accounts, therefore,
 we don't have a generic test account anymore. You have to create your own.It is quite fast and easy to do)
-Have a portal user PU with an already registered payment token PT
-Go to Invoicing
-Create a new invoice I:
-Customer PU
-Add anything in invoice lines
-Confirm I
-Register a payment for I:
-Journal: Stripe
-Saved Payment token: PT
AT THIS STEP, YOU MUST ENSURE A CONCURRENT ACCESS ERROR WILL RAISE DURING THE RECONCILIATION
-Create Payment

Log analysis:
A first payment intent is sent to Stripe. The card is charged and Stripe answers that all went as expected.
We try to process the payment, but a concurrent access error occurs.
A retry is done.
A payment intent is sent again to Stripe, The card is charged AGAIN and Stripe answers that all went as expected.
We try to process the payment, but a concurrent access error occurs.

For each retry, the intent is sent and the card is charged.

If the first retry succeeds, then Odoo can finish the process. There will be only 1 payment transaction on Odoo's side
(others have been rollbacked) but there will be 3 on Stripe's side and the card will be charged 3 times.

This PR mitigate this behaviour.
It doesn't address the root cause but by adding the idempotency key to the headers with the hash of the transaction
reference and the database UUID, we prevent mutliple payments to happen.

OPW-2662964

closes odoo/odoo#103515

X-original-commit: 5fe1c1bbba4d754eed7e8927b82752969d6f563d
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-10-20 10:19:55 +02:00
Valentin Chevalier 754570b1d8 [REF] payment(_stripe): cleanup express checkout implementation
Fine-tuning of c624ed5603.

task-3004118

closes odoo/odoo#103125

X-original-commit: 158bc7ef9e20c46a5e9870e70d76e866147662b0
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-10-12 04:35:48 +02:00
mafo-odoo dc1cddb577 [FIX] payment_stripe: allow payment for client without mail
Problem: If you have a customer assigned to an invoice/quotation
without an e-mail address and then share a payment link with
the customer. If the customer clicks on 'Pay', he won't be
redirected to Stripe's checkout page. He'll get instead 'Invalid
e-mail address: False' (see the image attached).

Explanation:
When there is no e-mail address defined, Odoo sends 'False' to
Stripe but Stripe sees it as the e-mail address which is indeed
Invalid. To solve the issue we replace False by None for the email
value of a customer without email address.

opw-3007866

closes odoo/odoo#102867

X-original-commit: 647a5fd79b88d4ea00eca2d6c1f9d9a2259a8414
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Fockedey Martin (mafo) <mafo@odoo.com>
2022-10-10 15:09:47 +02:00
Laurent Desausoi 7593c073d2 [IMP] core: use inert SQL based neutralization
Before this commit the neutralize system introduced in v16 was using ORM
methods in order to change appropriate records. Although flexible, this approach
could lead to call some methods with side effects while neutralizing
(eg: overloads of write).

This patch converts the neutralize system to a safer "inert" SQL based approach
by migrating the generic method _neutralize to SQL files exposed in the
data folder.

Task id: 2961687

closes odoo/odoo#102792

X-original-commit: e5dbded9bb363351feff7ca8a56c7f8a6860f492
Related: odoo/enterprise#32580
Signed-off-by: Fabien Meghazi <fme@odoo.com>
2022-10-09 22:04:00 +02:00
Horacio Tellez a7ddc7af78 [FIX] payment_stripe: validation operations treated incorrectly
When saving a payment method from the `my/payment_method` page
validation is used as the type of operation. In the present
validation operations were incorrectly filtered and treated as a
payment.
After this commit validation operations are processed in the
`_stripe_create_checkout_session` function as it should.

Task - 3001168

closes odoo/odoo#101923

X-original-commit: 7f371db1af160a5e89f9476540aee35f79769068
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-10-03 15:19:21 +02:00
Valentin Vallaeys (vava) 536a74b6b0 [CLN] payment(_*): remove useless refund parameter
*: adyen, authorize, demo, razorpay, stripe.

The param `create_refund_transaction` from `_send_refund_request` became
useless following this commit:
https://github.com/odoo/odoo/commit/e4c63126b45854b10f08ab14dee5eb1d4ed98bb0

It was only used for Authorize.net, which now works without calling this
param.

task-2869910

closes odoo/odoo#101105

X-original-commit: 6855d65df7a83037ee5e2202966fa4e67dae7d5a
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-09-26 13:41:47 +02:00
Horacio Tellez f7b8f07501 [IMP] payment: rename of acquirer to provider
Changing the name of model payment.acquirer to payment.provider
and everything that it touches. It is technically incorrect to
use the term "acquirer" for systems that only provide a service
of payment.
After this commit the model payment.acquirer and all related to
it will be renamed to payment.provider.

Task - 2842088

closes odoo/odoo#90899

Related: odoo/upgrade#3542
Related: odoo/documentation#1981
Related: odoo/enterprise#27131
Signed-off-by: Victor Feyens (vfe) <vfe@odoo.com>
2022-09-09 13:38:08 +02:00
Victor Feyens 4d6bd1ce33 [REF] payment_*: adapt to payment changes 2022-09-06 13:32:19 +02:00
Valentin Chevalier c624ed5603 [IMP] payment(_stripe), website_sale(_delivery): support express checkout
This commit enables eCommerce customers to pay with the express payment
methods Apple Pay and Google Pay from the cart page.

For the moment, only Stripe supports this additional feature but it
was designed to make it easy to implement with a new provider.

task-2754209

closes odoo/odoo#88374

Related: odoo/enterprise#29915
Related: odoo/documentation#2392
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-09-05 14:49:33 +02:00
Laura Schauer c1b41bcd08 [IMP] payment(_*): allow dynamic token name
Before this commit, tokens were prefixed with usually 12 X’s. To improve
readability, modernity and to shorten the length, this commit changes
token prefixes to a standard of •••• 1111.

task-2832669

closes odoo/odoo#94978

Related: odoo/upgrade#3738
Related: odoo/enterprise#29190
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-08-19 14:28:08 +02:00
Antoine Vandevenne (anv) a5ce999d76 [IMP] payment_stripe: allow passing contextual request data to the proxy
For modules that fully implement Stripe Connect, i.e. that sign requests
with their own API keys, there was no way to pass contextual data to the
proxy when making those requests.

This commit addresses the issue by populating the `proxy_data` param
present in all proxy's routes' signatures with an extendable `dict`.

task-2917229

closes odoo/odoo#96279

X-original-commit: 5df308c58e02c9ca3287c124c0df4e359817ce16
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-07-19 10:29:54 +02:00
Valentin Chevalier 930b6860d7 [IMP] payment_stripe: support refund
Allows users of Stripe to refund their customers directly from Odoo.

task-2678763

closes odoo/odoo#92235

Related: odoo/documentation#2086
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-05-25 12:46:08 +02:00
Demesmaeker 86ff8c6e8f [REF] payment(_*): compute feature fields
Computing the fields instead of storing them allows to implement the
feature for each provider more easily, without needing a migration
script.

task-2841744

closes odoo/odoo#91961

Related: odoo/enterprise#27618
Related: odoo/upgrade#3535
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-05-24 19:10:55 +02:00
Thibault LibioulleandAntoine Vandevenne 4cdc00f418 [FIX] payment_stripe: turn credentials helper methods into functions
This commit removes the access to stripe credentials through model
helper methods.

closes odoo/odoo#87972

X-original-commit: 61faa2b32880d60c8cfb7c7761cd313383c26a0b
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Thibault Libioulle (tle) <tle@odoo.com>
Co-authored-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-04-05 15:17:31 +02:00
Demesmaeker a6a8a669b9 [IMP] payment_stripe: manage async notifications
Some payments may be confirmed asynchronously, and we need to be aware
of their status, even if they are not in a "checkout session complete"
event. Relying on successful payment or setup intents instead manage
more use cases.

task-2733725

closes odoo/odoo#84150

Related: odoo/upgrade#3350
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-03-16 17:04:25 +01:00
Thibault Libioulle fe3981983e [FIX] payment_stripe: fix stripe webhook url
Prior to this commit, the url build using the concatenation between the
base url and the webhook url path produced a wrong url with two
consecutive slash.

This commit prevent from building a wrong url, using the url_join api
method.

In the commit d3f4619b , the base url was fixed but there was a
remaining url-join error.

Original commit: 4296b2653

closes odoo/odoo#86073

X-original-commit: 8b4d7fa3ae9d470bd12d5c09d6270a637311c0c4
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Thibault Libioulle (tle) <tle@odoo.com>
2022-03-09 09:24:06 +00:00
Valentin Chevalier 18cb7e44db [IMP] payment_stripe: allow separate authorization and capture
Users who select Stripe as their payment acquirer will now have the
possibility to capture manually the amount later (e.g. when delivering
the product).

task-2278434

closes odoo/odoo#69598

Related: odoo/upgrade#3290
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-03-09 09:23:46 +00:00
Thibault Libioulle 38b3fe7e51 [FIX] payment_stripe: fix base url for webhook url
This commit fixes the webhook base url to use the override defined in
the payment acquirer model.

It ensures the base url follows the same logic as the success and cancel
urls defined in the `checkout/sessions` request payload.

closes odoo/odoo#85558

X-original-commit: d3f4619b731d71ccd2af26b9fa148d2957773680
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
Signed-off-by: Thibault Libioulle (tle) <tle@odoo.com>
2022-03-01 08:06:55 +00:00
Antoine Vandevenne (anv) cd57330eb8 [IMP] payment_stripe: improve proxy requests' error handling
- Log the traceback when a proxy request raises an exception.
- Don't log the traceback returned by the proxy when an exception is
  raised on IAP.

closes odoo/odoo#85503

X-original-commit: 529608eb12082463648ded5b46e40d8ce03aab53
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-02-28 12:56:13 +00:00
Antoine Vandevenne (anv) b6c64c4e07 [FIX] payment_stripe: prevent enabling test mode for connected accounts
The Stripe Connect onboarding only allows to create production accounts.
This is problematic because, before this commit, it was possible to set
the state of an acquirer linked to a connected account to 'test', even
though the payments would actually be made on the live environment of
Stripe.

Additionally, this commit fixes a minor display issue that caused the
"Connect" button to be shown when an API key was set, while it should be
hidden as soon as an API key is set.

closes odoo/odoo#85444

X-original-commit: 4f9b19b9a9891cb0c39dcb88991de174be60cef9
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-02-26 22:26:55 +00:00
Thibault Libioulle c5198b0bab [IMP] payment{,_stripe},{,website_}sale: improve stripe onboarding
This commit lighten payment onboarding form in order to take advantage
of the Stripe Connect Onboarding Flow. It integrates the Stripe
Onboarding using the IAP proxy.

Purpose
=======
Help users easily onboard with Stripe by using the Stripe Connect API.

Specifications
==============
During the payment onboarding, if the user selects Stripe, they will
start the Stripe Onboarding. (NB: The process uses a proxy that handles
the Stripe Onboarding calls and signs them with the Stripe Connect key)
1) A call is made through the proxy to get the Stripe account token;
2) A call is made through the proxy to get the Stripe account link which
   contains the URL of the Onboarding;
3) The user is redirected to the Stripe Onboarding;
4) The user completes the Stripe Onboarding;
5) The user comes back to the acquirer form of Stripe and is able to get
   their keys.
6) The user can directly create their webhook after having copied/pasted
   their API keys.

During the website sale onboarding, the user doesn't go through the
onboarding wizard but is directly prompted to activate their account.

Note that the Onboarding status isn't stored in the database so there is
no call to Stripe API to validate the account status.

API Documentation :
- Connect Onboarding: https://stripe.com/docs/connect/standard-accounts
- Webhook creation: https://stripe.com/docs/api/webhook_endpoints/create

task-2685160
task-2691213

closes odoo/odoo#84639

X-original-commit: 085f4af4e57c43127413585a8df5b3aa47843339
Related: odoo/enterprise#24376
Signed-off-by: Yannick Tivisse (yti) <yti@odoo.com>
Signed-off-by: Thibault Libioulle (tle) <tle@odoo.com>
2022-02-15 16:51:24 +00:00
Antoine Vandevenne (anv) f4ca7290ac [IMP] payment(_*): search only once for the transaction
Before this commit, most acquirers needed to run several successive
searches for the transaction whose reference was received by a
controller in notification data. This is because the security checks
run on the notification data require access to the acquirer through the
transaction record which was immediately discarded.

Starting with this commit, all `*_feedback_data` method are no longer
decorated with `api.model` and can use the transaction record they're
called on if provided. They are also renamed to `*_notification_data`.

task-2737144

closes odoo/odoo#83850

Related: odoo/enterprise#23938
Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2022-02-02 19:50:49 +00:00
Christophe Monniez dc0baf4948 [IMP] payment*: implement _neutralize method
An overridable model method was added in a previous commit in order to
neutralize a database.

This commit introduce the implementation of this method for the payment
modules.

Also, a `_neutralize_fields` helper method is added on the
PaymentAcquirer model to simplify the neutralization of the various
payment modules.

Part-of: odoo/odoo#67825
2022-02-01 09:54:07 +00:00
Horacio Tellez 5badb3fca8 [IMP] payment(_*): normalize logs across all acquirers
The logs for payments contain the transaction reference whenever possible.
Before logs for transactions contained the reference or the id of the
transaction in an inconsitent way. No transactions are identified by
reference whenever possible.

The logs for payments for the same function on different acquirers should
have the same format. Same flow step for different acquirers had
information passed in different formats. Now at each step of a transaction
flow log messages have the same format regardless of the acquirer.

Overall the payment logs should have an uniform format. Hopefully
understanding log messages related to transactions should be easier, as
now log format is independent of the acquirer and transaction are easily
identified by reference.

Task - 2545450

closes odoo/odoo#79547

Signed-off-by: Antoine Vandevenne (anv) <anv@odoo.com>
2021-11-29 15:40:54 +00:00
Nicolas (vin) f7b45aa032 [FIX] payment: suitable payment token and acquirer fix
Fix two issues:

The search of suitable payment token was searching on the journal_id
field of the payment acquirer that is no longer stored.
Change it to now search on the acquirer_id directly, since we have
this information.

The _inverse_journal_id method on payment acquirers would create
new payment line with the manual payment method when no provider
are given to an acquirer, or no payment method is existing for
a given provider. This would cause issues with the creation of
multiple line with the same name on a same journal, which would
trigger the constrains blocking that.

closes odoo/odoo#74990

X-original-commit: a3a2fcb0b299fafbf359ec9015da5c85cdb57b3a
Related: odoo/enterprise#20193
Signed-off-by: Laurent Smet <smetl@users.noreply.github.com>
2021-08-12 07:56:16 +00:00
Antoine Vandevenne (anv) 023e2e636c [FIX] payment_stripe: never assign one currency unit to validation txs
Before this commit, the payment function `_get_validation_amount` was
overridden by Stripe to specify a validation amount of one currency unit
while that amount was in fact never passed to Stripe in the validation
flow. The amount stored on the transaction was therefore incorrect.

This commits removes the override to let the default amount of 0 being
set on validation transactions.

task-2612977

closes odoo/odoo#74543

Signed-off-by: Antoine Vandevenne (anv) <AntoineVDV@users.noreply.github.com>
2021-08-02 11:48:21 +00:00
Nasreddin Boulif (bon) 919a441178 [FIX] payment_stripe: display clearer customer description
Issue:

  Payouts reference on Stripe are display as:
  `SUB123 - ODOO_PARTNER_456789`.

Cause:

  When making a Stripe request to create new customer, the description
  is formated as : `ODOO_PARTNER_456789` .

Solution:

  Replace customer description format as :
  `Partner: Mitchel Admin (id:456789)` .
  Inspired by: https://github.com/odoo/odoo/commit/3bc1e0175d85a70806999109e928c234e8cc2ca4

opw-2593621

closes odoo/odoo#74109

X-original-commit: 07033a07ca49923a1c5095c371302fb894363c07
Signed-off-by: bon-odoo <nboulif@users.noreply.github.com>
2021-07-22 11:05:05 +00:00
Nicolas (vin) 04522f01e6 [IMP] account: allows multiple payment acquirers on a journal.
Users may want to be able to have transactions coming from multiple
payment acquirers to be registered in the same journal.

This will allows that.

Task id #2414749

closes odoo/odoo#67331

Related: odoo/upgrade#2500
Related: odoo/enterprise#17258
Signed-off-by: William André (wan) <wan@odoo.com>
2021-06-03 10:00:26 +00:00
Antoine Vandevenne (anv) a2fa71a565 [FIX] payment_stripe: fix post refactoring issues
- The acquirer reference was never saved.
- Transactions with operation 'offline' were not processed.
- If Stripe rejected an offline payment, an exception would be raised.
  This lead to Subscriptions assuming that the processing itself failed
  and prevented the transaction to be processed. Instead, the exception
  is now caught and the transaction's state set to 'error'.

task-2494916

closes odoo/odoo#71602

X-original-commit: e93b3b3c5b9bc86768a5d26ed456ef11cfb40734
Related: odoo/enterprise#18680
Signed-off-by: Antoine Vandevenne (anv) <AntoineVDV@users.noreply.github.com>
2021-06-02 13:26:23 +00:00
Romain Derie 92175d3341 [IMP] *: replace web.base.url ICP by helper method
Previous commit introduce an helper to get the most suited URL for a record
instead of always using the ICP, which is not correct in a website context.

This commit replaces calls to ICP by the helper method.

Community: https://github.com/odoo/odoo/pull/68201
Enterprise: https://github.com/odoo/enterprise/pull/17538
Upgrade: https://github.com/odoo/upgrade/pull/2372

task-2476101
2021-06-02 10:04:29 +00:00
Nicolas Lempereur 86b189bfea [FIX] payment_stripe: special character in reference
Special character in reference (eg. '#' character in invoice sequence)
might cause error after payment not showing it was successful.

With this changeset, when a payment reference is used inside an url, we
quote it.

opw-2479658

closes odoo/odoo#68585

X-original-commit: 47645c2f170d5a7c09ae80d4e0de6c3a821f7b36
Signed-off-by: Nicolas Lempereur (nle) <nle@odoo.com>
2021-03-31 11:46:27 +00:00
Prakash PrajapatiandAntoine Vandevenne 4bb840403b [REF] payment_stripe: migrate Stripe to the new payment API
This commits drops the direct payment flow supported by the SetupIntent
API in favor of the payment with redirection flow, supported by the
Checkout API only.

See the merge commit for more details.

task-2333040

Co-authored-by: Antoine Vandevenne <anv@odoo.com>
2021-03-30 09:25:51 +02:00
Goffin Simon a767c5155b [FIX] payment_stripe: Bancontact with mobile
Steps to reproduce the bug:

- Let's make a bancontact payment with Stripe on mobile from the web shop
- Stripe redirects you to Odoo
- Your phone asks on which browser you wanted to redirected to Odoo
- Choose one

Bug:

An internal error was raised.

When you clicked on a browser (the same you were using or a new one, whatever)
Odoo will resend a request to Stripe. But this request will have wrong data in it.

Stripe will answer with:

Stripe: entering form_feedback with post data {'error': {'code': 'resource_missing',
'doc_url': 'https://stripe.com/docs/error-codes/resource-missing',
'message': "No such payment_intent: 'py_1I6c4UKhH8RhRq18TJs2CP0z'",
'param': 'intent',
'type': 'invalid_request_error'},
'reference': 'S00002-1'}

opw:2422031

closes odoo/odoo#64385

X-original-commit: a42075c9f913f4a20b28f97f0f6786f5a7b2968a
Signed-off-by: Simon Goffin (sig) <sig@openerp.com>
2021-01-12 09:52:08 +00:00
Nicolas Martinelli d218b3321f [FIX] payment_stripe: icon without name
The `name` field is not required on the `payment.icon` model. Therefore,
in case the payment icon name is not set, a traceback is raised due to a
`False.lower()` statement.

opw-2409755

closes odoo/odoo#62646

X-original-commit: 54434a4fdd71b1e344255fb6f3e42d731ba91f3b
Signed-off-by: Nicolas Martinelli (nim) <nim@odoo.com>
2020-11-30 18:19:25 +00:00
Adrien Horgnies 6adac428b4 [FIX] payment_stripe: hide disabled local payment methods
If a merchants didn't enable a local Payment Method Type (PMT) on Stripe
 side (such as bancontact), his customers eligible for it (ex.: Belgian
 and paying in EUR) won't be able to pay using it.

This commit fixes this issue by adding a condition on the payment icons
 assigned to Stripe: if the payment icon related to a given payment
 method is not listed as a supported payment icon, the related payment
 method is not offered to customers, unless the payment icon does not
 exist at all.

User can enable PMTs through (Payment Acquirers > Stripe
 > Configuration > Supported Payment Icons). This concerns: ideal,
 bancontact, eps, giropay and p24.

 This solution is not entirely satisfactory but it isn't possible to
  fetch enabled PMT from Stripe.

opw-2335482

closes odoo/odoo#60740

X-original-commit: 1d0f23599bbd425c81131a5f6c1c22531ffcd0ee
Signed-off-by: Antoine Vandevenne (anv) <AntoineVDV@users.noreply.github.com>
2020-10-26 13:26:21 +00:00
Adrien Horgnies dc4f6ad04f [IMP] payment_stripe: support webhooks
Allow configuring a webhook in Stripe to send s2s notifications to Odoo
when a Checkout payment is completed. Note that SetupIntent and
PaymentIntent events are not listened to, since they are handled 'live'
with the customer actively present; the main use case for Stripe
webhooks is a Checkout session that gets interrupted before the customer
is redirected to Odoo (e.g. network loss, browser crash, closing the
tab, etc.)

The webhook should be configured to send its events to
<base_url>/payment/stripe/webhook and should only subscribe to
checkout.session.completed events to avoid spamming the Odoo server with
useless notifications.

closes odoo/odoo#52754

Signed-off-by: Damien Bouvy (dbo) <dbo@odoo.com>
2020-08-17 14:16:51 +00:00
jev c18b1598cf [FIX] payment_stripe: show correct stripe error message
Following this commit: https://github.com/odoo/odoo/commit/72e4652983d9c781fd1da8acf3e4b5d7b9acbd4a
Forgot to add this context.

See opw-2272262

closes odoo/odoo#55514

X-original-commit: bddac7937c188848f27fb507f82a2a1147d42f72
Signed-off-by: Toufik Benjaa (tbe) <tbe@odoo.com>
2020-08-06 08:19:40 +00:00
Adrien Horgnies 12be287552 [IMP] payment: add new local payment method type for Stripe
- bancontact (be; eur)
- eps (at; eur)
- giropay (de; eur)
- p24 (pl; eur, pln)

X-original-commit: 1b7da6d0fe06fcab623f06508cee1093b10273a4
2020-07-14 09:32:57 +00:00