Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.0] [ADD] contract_auto: Automatic Payment For Contracts #67

Merged
merged 1 commit into from
Oct 16, 2017

Conversation

lasley
Copy link
Contributor

@lasley lasley commented May 6, 2017

Contract Auto (RFC #55)

This module allows for the configuration of automatic payments on invoices that are created by a contract.

Usage

Enable Automatic Payment

  • Navigate to a customer contract
  • Check the Auto Pay? box to enable automatic payment
  • Configure the options as desired
  • Set the Payment Token to the payment token that should be used for automatic payment

Automatic Payment Settings

The following settings are available at both the contract and contract template level:

Name Description
Invoice Message Message template that is used to send invoices to customers upon creation.
Payment Retry Message Message template that is used to alert a customer that their automatic payment failed for some reason and will be retried.
Payment Fail Message Message template that is used to alert a customer that their automatic payment failed and will no longer be retried.
Auto Pay Retries Amount of times to attempt an automatic payment before discontinuing and removing the payment token from the contract/account payment method.
Auto Pay Retry Hours Amount of hours that should lapse until retrying failed payments.

Payment Token

A valid payment token is required to use this module. These tokens are typically created during the website_sale checkout process, but they can also be created manually at the acquirer.

A payment token can be defined in one of two areas:

  • Contract - Defining a payment token in the contract will allow for the use of this token for automatic payments on this contract only.
  • Partner - Defining a payment token in the partner will allow for the use of this token for automatic payments on all contracts for this partner that do not have a payment token defined.

@lasley lasley force-pushed the release/10.0/LABS-411-contract_auto branch from 4a10a9c to 8806c31 Compare May 6, 2017 14:44
@lasley lasley changed the title [ADD] contract_auto: Automatic Payment For Contracts [10.0] [ADD] contract_auto: Automatic Payment For Contracts May 6, 2017
@lasley lasley force-pushed the release/10.0/LABS-411-contract_auto branch 3 times, most recently from ab5741c to c893f0e Compare May 6, 2017 15:16
@vonpupp
Copy link

vonpupp commented May 6, 2017

Thank you @lasley. Yesterday I had some problems during installation (XML issues) but now I could install it fine. I just created a contract and I will have to wait to see if everything goes fine. I wonder a couple of things:
(1) Wouldn't be interesting to define a payment-gateway to be used on a contract?
(2) How do I define a credit card number for the person who is the contract owner?

What if the customer decides to switch to another payment method which involves switching to another payment-gateway? (this scenario is related to my first question).

I would like to test the module using stripe, which implements s2s methods, however I don't understand how a specific person will be charged for a contract. Do you know how to debug this to try to understand better the process? What first comes to my mind is to save the customer on the stripe backend and link a credit card number as primary so it can be automatically retrieved during the payment, but I will have to test that.

@lasley
Copy link
Contributor Author

lasley commented May 6, 2017

The payment token represents the credit card, which is linked to a partner and acquirer. Changing either is as easy as changing the payment token.

The catch here is that the credit card already has to be saved to the partner's account as a payment token. This happens during the website_sale checkout process if the customer checks the option to remember their card. You can also create a token at your acquirer manually and add into Odoo for use.

@rafaelbn
Copy link
Member

rafaelbn commented May 6, 2017

Hi @lasley ,

Please could you add a usage section detailed in order to know what to test?

After seeing this PR I have read again #55 and #45 (comment) but I have some doubts about how it works.

You want that contract set invoices paid base on? I read "This module adds logic to automatically pay invoices that are created by a contract" but I don't understand why you want invoices paid without knowing if they are paid o not really with a transfer, bank card, paypal or similar.

I'm interested.

Thanks

@rafaelbn rafaelbn added this to the 10.0 milestone May 6, 2017
@lasley
Copy link
Contributor Author

lasley commented May 8, 2017

@rafaelbn - readme updated & instructions added to the main comment of this PR. Let me know if this doesn't clarify.

@lasley lasley force-pushed the release/10.0/LABS-411-contract_auto branch from e4a079e to 466effc Compare May 8, 2017 16:40
@vonpupp
Copy link

vonpupp commented May 8, 2017

@lasley, thank you very much for your guidance; It makes total sense now! Stripe is missing this important feature (saving the credit card). I am trying the module using authorize, however even though I check the "remember the CC details", it doesn't seem to be remembered at all. Truth to be told I am still struggling with authorize itself (the payment gets processed properly but the return URL doesn't seem to work, I need to further dig into this). I assume that the payment.token is created prior redirecting to authorize.net website and the failed return to the odoo website has nothing to do with it (not 100% sure though).

I tried to create a payment token manually by going (with developer mode) to Accounting / Configuration / Payments / Saved Payment Data, however I am not sure how to fill the acquirer Ref. I guess it is the token which maps to the record with the payment-gateway website record (some sort of id).

Unfortunately I am having some troubles to test this out, since as for today, the only two acquirers that I am aware that support remembering the payment details are authorize and ogone. Ogone is a nightmare to setup (I need more time) and authorize doesn't seem to remember anything.

If I achieve something with authorize I will be more than happy to document it along with the readme (or in a separated folder)

@lasley
Copy link
Contributor Author

lasley commented May 8, 2017

@vonpupp - the payment token memorization definitely works with a proper Authorize setup, so I would assume it's just something in the configuration. Make sure that you're using a sandbox account set to live mode in the Authorize console, and that you set the acquirer to sandbox mode in Odoo.

Regarding Stripe, I see all of the server to server methods implemented in the v10 acquirer, such as the token creation

@vonpupp
Copy link

vonpupp commented May 9, 2017

Thank you very much @lasley. Yes indeed the problem is on my side. Apparently the payment information gets saved once it succeeds. Authorize.net does not seem to be documented. I have found this issue, which pretty much describes my problem. I have configured the URLs accordingly however the problem persists (Default Receipt URL is /shop/confirmation and Default Relay Response URL is /payment/authorize/return).

I configured also the silent URL to be a request bin, to check out the POST parameters coming back from authorize.net so I try to replicate the request using curl. The sad part is that I always get a 404 on odoo when trying to access route /payment/authorize/return/, I don't know why though so I need to investigate the issue further.

Sorry that I haven't been helpful in testing your module. Hopefully I will manage to solve all this issues soon. Unfortunately Stripe do not allow to remember the payment details.

@lasley
Copy link
Contributor Author

lasley commented May 9, 2017

Unfortunately Stripe do not allow to remember the payment details.

It does though, I linked the token creation above. I definitely see it taking credit card numbers, then turning it into a payment token. Maybe try skipping the process entirely & just use stripe_create directly

@lasley lasley force-pushed the release/10.0/LABS-411-contract_auto branch 11 times, most recently from 2df9a86 to e0d06b0 Compare May 9, 2017 22:32
@lasley
Copy link
Contributor Author

lasley commented May 9, 2017

This is ready for review if a PSC would please mark as such. I just need to fix a few missing test holes, but no functional code

@lasley lasley force-pushed the release/10.0/LABS-411-contract_auto branch from f5c19be to c5d094c Compare May 10, 2017 00:19
@vonpupp
Copy link

vonpupp commented May 18, 2017

Amazing, @lasley. Thank you very much!

I created #70 for this purpose. Please feel free to give your impressions. Just to be clear, you provided the website_portal_sale as an example, but I don't need to modify nothing there, right?

Currently I am working on the missing parts of the payment_stripe module, it seems to miss some parts to properly work with s2s. Afterwards I will dig into #70 by my own to try to contribute :). Then I would like to have a look at the #45 which seems to be the natural progression of your work here.

@rafaelbn
Copy link
Member

Hi, could I propose contract_payment_auto ? contract_auto is ambiguous IMHO.

Testing I get and error when filling Payment token in the partner check, Do you know why?:

2017-06-13_1-03-13

@lasley
Copy link
Contributor Author

lasley commented Jun 13, 2017

@rafaelbn - I agree with the rename.

Looks like I forgot to add payment_token_ids to the partner view. Should be good now!

@lasley lasley force-pushed the release/10.0/LABS-411-contract_auto branch 4 times, most recently from ca1eea9 to aca8d78 Compare June 15, 2017 00:30
@rafaelbn
Copy link
Member

rafaelbn commented Jul 1, 2017

Hi @lasley travis is red, could you take a look please?

@lasley lasley force-pushed the release/10.0/LABS-411-contract_auto branch 10 times, most recently from bcee98f to fe0cc9c Compare July 19, 2017 15:34
@lasley
Copy link
Contributor Author

lasley commented Jul 19, 2017

Alright we're 🍏 !

@lasley
Copy link
Contributor Author

lasley commented Oct 9, 2017

Any PSC have thoughts on this one?

@rafaelbn
Copy link
Member

Hi @lasley I'm rebuilding for testing but it looks runbot is broken everywhere... 😞

@lasley
Copy link
Contributor Author

lasley commented Oct 12, 2017

@rafaelbn - I rebuilt and it looks good now. must have been the space issue from earlier

Copy link
Member

@rafaelbn rafaelbn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested 👍

@lasley do you want to squash before merge?

@lasley lasley force-pushed the release/10.0/LABS-411-contract_auto branch from 894825c to 9d1ae5c Compare October 16, 2017 14:41
@lasley lasley merged commit d8ad62b into OCA:10.0 Oct 16, 2017
@lasley lasley deleted the release/10.0/LABS-411-contract_auto branch October 16, 2017 14:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants