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

[14.0][MIG] payment_cielo: Migration to 14.0 #3423

Open
wants to merge 54 commits into
base: 14.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
ab2e67c
[WIP] payment_cielo
DiegoParadeda Aug 27, 2020
b47d922
[FIX] Cielo icon
DiegoParadeda Aug 27, 2020
3866ef3
[FIX] One class - one file
DiegoParadeda Aug 28, 2020
b86b210
[ADD] Test/prod API URL
DiegoParadeda Aug 28, 2020
e4bf94a
[ADD] Test/prod cielo headers
DiegoParadeda Aug 28, 2020
dc9e382
[FIX] Cielo error message interpreter
DiegoParadeda Aug 28, 2020
6323c0b
[FIX] Copyright
DiegoParadeda Aug 31, 2020
3887fa5
[REF] Cleaner code
DiegoParadeda Aug 31, 2020
825c9b7
[FIX] Manifest version
DiegoParadeda Aug 31, 2020
aacbf45
[FIX] Delete card information and set active false (not using saved p…
DiegoParadeda Aug 31, 2020
aaeff72
[ADD] New test structure
DiegoParadeda Aug 31, 2020
32fe25a
[REF] Clean code
DiegoParadeda Aug 31, 2020
73f838e
[ADD] Website object to cielo route
DiegoParadeda Sep 18, 2020
46c5416
[ADD] Tokenize
DiegoParadeda Oct 6, 2020
26d2660
[RMV] Unused client side JS
DiegoParadeda Oct 7, 2020
606bf14
[FIX] Flake 8
DiegoParadeda Oct 9, 2020
8c82f74
[REF] Flake 8
DiegoParadeda Oct 22, 2020
33c2b99
[ADD] Manual capture and void
DiegoParadeda Oct 23, 2020
f931d9d
[ADD] Capture/void log
DiegoParadeda Oct 26, 2020
5a964fd
[ADD] Better tests
DiegoParadeda Oct 26, 2020
214f4bf
[REF] Describe functions and refactor
DiegoParadeda Oct 27, 2020
bcd69d9
[FIX] Card expiry year needs '/20' between mm and yy (mm/20yy)
DiegoParadeda Oct 27, 2020
01c11e3
[FIX] Better parameter structure
DiegoParadeda Oct 27, 2020
94cd9f2
[FIX] Return false if not CardToken
DiegoParadeda Oct 27, 2020
ffd62b7
[ADD] Test bad expiry date
DiegoParadeda Oct 27, 2020
ab85db2
[FIX] Lint
DiegoParadeda Oct 27, 2020
73918a8
[FIX] OrderId and SoftDescriptor
DiegoParadeda Oct 27, 2020
3834669
[FIX] Lint
DiegoParadeda Oct 27, 2020
ad9ab23
[FIX] SoftDescriptor max 13 characters
DiegoParadeda Oct 27, 2020
330529b
[FIX] Lint
DiegoParadeda Oct 27, 2020
454c4c2
[FIX] Website in manifest
DiegoParadeda Oct 29, 2020
2c972e4
[FIX] Use logger instead of print
DiegoParadeda Oct 29, 2020
7b6ba89
[ADD] OCA readme
DiegoParadeda Oct 29, 2020
fb45a6b
[UPD] Update payment_cielo.pot
oca-travis Oct 31, 2020
653dcb7
[UPD] README.rst
OCA-git-bot Oct 31, 2020
7edf4ca
[FIX] Cielo intermitent test fail
DiegoParadeda Nov 18, 2020
fc07c14
[ADD] Cielo test with VCR
DiegoParadeda Nov 24, 2020
1c0a0e8
Added translation using Weblate (Portuguese (Brazil))
marcelsavegnago Dec 17, 2020
40e0398
Translated using Weblate (Portuguese (Brazil))
marcelsavegnago Dec 17, 2020
1ef4ab5
[FIX] payment_cielo tests
DiegoParadeda Jan 6, 2021
936a556
[REF] Standard OCA website payment_cielo
mileo May 31, 2021
237f10e
[SECURITY] cielo security hotfix
rvalyi Aug 12, 2021
d960f5c
payment_cielo 12.0.3.2.1
OCA-git-bot Aug 12, 2021
dbec5f3
[UPD] Update payment_cielo.pot
oca-travis Apr 5, 2022
75d9999
Update translation files
oca-transbot Apr 6, 2022
66b0192
[UPD] Update payment_cielo.pot
oca-travis Jun 3, 2022
adcada1
Update translation files
oca-transbot Jun 3, 2022
6804125
[UPD] Update payment_cielo.pot
Oct 27, 2022
dd1a650
Update translation files
weblate Oct 27, 2022
a1057a3
[UPD] Update payment_cielo.pot
Nov 30, 2022
922459b
Update translation files
weblate Nov 30, 2022
c6971f3
[UPD] README.rst
OCA-git-bot Sep 3, 2023
6325545
[IMP] payment_cielo: apply pre-commit auto fixes
corredato Oct 7, 2024
808d135
[MIG] payment_cielo: Migration to 14.0
corredato Oct 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions payment_cielo/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
=============
Payment Cielo
=============

..
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! This file is generated by oca-gen-addon-readme !!
!! changes will be overwritten. !!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!! source digest: sha256:503ec16d8edb4f6914c0f58fd1b78ed0f162e867eb689ae399979c3fe81dffe5
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
:target: https://odoo-community.org/page/development-status
:alt: Alpha
.. |badge2| image:: https://img.shields.io/badge/licence-AGPL--3-blue.png
:target: http://www.gnu.org/licenses/agpl-3.0-standalone.html
:alt: License: AGPL-3
.. |badge3| image:: https://img.shields.io/badge/github-OCA%2Fl10n--brazil-lightgray.png?logo=github
:target: https://github.com/OCA/l10n-brazil/tree/14.0/payment_cielo
:alt: OCA/l10n-brazil
.. |badge4| image:: https://img.shields.io/badge/weblate-Translate%20me-F47D42.png
:target: https://translation.odoo-community.org/projects/l10n-brazil-14-0/l10n-brazil-14-0-payment_cielo
:alt: Translate me on Weblate
.. |badge5| image:: https://img.shields.io/badge/runboat-Try%20me-875A7B.png
:target: https://runboat.odoo-community.org/builds?repo=OCA/l10n-brazil&target_branch=14.0
:alt: Try me on Runboat

|badge1| |badge2| |badge3| |badge4| |badge5|

Payment Acquirer: Cielo Implementation

.. IMPORTANT::
This is an alpha version, the data model and design can change at any time without warning.
Only for development or testing purpose, do not use in production.
`More details on development status <https://odoo-community.org/page/development-status>`_

**Table of contents**

.. contents::
:local:

Installation
============

This module depends on:

* payment

Configuration
=============

This module will require registering in eCommerce Cielo https://www.cielo.com.br/e-commerce/api/

To configure your API keys go to Invoicing -> Configuration -> Payment Acquirers -> Cielo.

The credentials MerchantId and MerchantKey are secret and can only be acquired by contacting Cielo via e-mail.


* full manual for API:

https://developercielo.github.io/manual/cielo-ecommerce#vis%C3%A3o-geral-api-cielo-ecommerce

Bug Tracker
===========

Bugs are tracked on `GitHub Issues <https://github.com/OCA/l10n-brazil/issues>`_.
In case of trouble, please check there if your issue has already been reported.
If you spotted it first, help us to smash it by providing a detailed and welcomed
`feedback <https://github.com/OCA/l10n-brazil/issues/new?body=module:%20payment_cielo%0Aversion:%2014.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.

Do not contact contributors directly about support or help with technical issues.

Credits
=======

Authors
~~~~~~~

* KMEE INFORMATICA LTDA

Contributors
~~~~~~~~~~~~

* Diego Paradeda <[email protected]>

Other credits
~~~~~~~~~~~~~

The development of this module has been supported by:

`KMEE INFORMATICA LTDA <https:/www.kmee.com.br>`__

Maintainers
~~~~~~~~~~~

This module is maintained by the OCA.

.. image:: https://odoo-community.org/logo.png
:alt: Odoo Community Association
:target: https://odoo-community.org

OCA, or the Odoo Community Association, is a nonprofit organization whose
mission is to support the collaborative development of Odoo features and
promote its widespread use.

.. |maintainer-DiegoParadeda| image:: https://github.com/DiegoParadeda.png?size=40px
:target: https://github.com/DiegoParadeda
:alt: DiegoParadeda

Current `maintainer <https://odoo-community.org/page/maintainer-role>`__:

|maintainer-DiegoParadeda|

This module is part of the `OCA/l10n-brazil <https://github.com/OCA/l10n-brazil/tree/14.0/payment_cielo>`_ project on GitHub.

You are welcome to contribute. To learn how please visit https://odoo-community.org/page/Contribute.
13 changes: 13 additions & 0 deletions payment_cielo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright 2020 KMEE INFORMATICA LTDA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import models
from . import controllers
from odoo.addons.payment.models.payment_acquirer import (
create_missing_journal_for_acquirers,
)
from odoo.addons.payment import reset_payment_provider


def uninstall_hook(cr, registry):
reset_payment_provider(cr, registry, "cielo")

Check warning on line 13 in payment_cielo/__init__.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/__init__.py#L13

Added line #L13 was not covered by tests
24 changes: 24 additions & 0 deletions payment_cielo/__manifest__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright 2020 KMEE INFORMATICA LTDA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

{
"name": "Payment Cielo",
"summary": """
Payment Acquirer: Cielo Implementation""",
"version": "14.0.1.0.0",
"development_status": "Alpha",
"license": "AGPL-3",
"author": "KMEE INFORMATICA LTDA,Odoo Community Association (OCA)",
"maintainers": ["DiegoParadeda"],
"website": "https://github.com/OCA/l10n-brazil",
"depends": ["payment"],
"data": [
"views/payment_views.xml",
"views/payment_cielo_templates.xml",
"data/payment_acquirer_data.xml",
],
"images": ["static/description/icon.png"],
"installable": True,
"post_init_hook": "create_missing_journal_for_acquirers",
"uninstall_hook": "uninstall_hook",
}
4 changes: 4 additions & 0 deletions payment_cielo/controllers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright 2020 KMEE INFORMATICA LTDA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

from . import main
104 changes: 104 additions & 0 deletions payment_cielo/controllers/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Copyright 2020 KMEE INFORMATICA LTDA
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

import logging
import pprint

import werkzeug

from odoo import http
from odoo.http import request

from odoo.addons.payment.controllers.portal import PaymentProcessing

_logger = logging.getLogger(__name__)


class CieloController(http.Controller):
@http.route(
["/payment/cielo/s2s/create_json_3ds"],
type="json",
auth="public",
csrf=False,
website=True,
)
def cielo_s2s_create_json_3ds(self, verify_validity=False, **kwargs):
if not kwargs.get("partner_id"):
kwargs["partner_id"] = request.env.user.partner_id.id
token = (

Check warning on line 28 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L27-L28

Added lines #L27 - L28 were not covered by tests
request.env["payment.acquirer"]
.browse(int(kwargs.get("acquirer_id")))
.s2s_process(kwargs)
)

if not token:
res = {

Check warning on line 35 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L35

Added line #L35 was not covered by tests
"result": False,
}
return res

Check warning on line 38 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L38

Added line #L38 was not covered by tests

res = {

Check warning on line 40 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L40

Added line #L40 was not covered by tests
"result": True,
"id": token.id,
"short_name": token.short_name,
"3d_secure": False,
"verified": False,
}

if verify_validity is not False:
token.validate()
res["verified"] = token.verified

Check warning on line 50 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L49-L50

Added lines #L49 - L50 were not covered by tests

return res

Check warning on line 52 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L52

Added line #L52 was not covered by tests

@http.route(["/payment/cielo/create_charge"], type="json", auth="public")
def cielo_create_charge(self, **post):
"""Create a payment transaction.
Expect the result from the user input from checkout.js popup."""
TX = request.env["payment.transaction"]
tx = None

Check warning on line 59 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L58-L59

Added lines #L58 - L59 were not covered by tests
if post.get("tx_ref"):
tx = TX.sudo().search([("reference", "=", post["tx_ref"])])

Check warning on line 61 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L61

Added line #L61 was not covered by tests
if not tx:
tx_id = (

Check warning on line 63 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L63

Added line #L63 was not covered by tests
post.get("tx_id")
or request.session.get("sale_transaction_id")
or request.session.get("website_payment_tx_id")
)
tx = TX.sudo().browse(int(tx_id))

Check warning on line 68 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L68

Added line #L68 was not covered by tests
if not tx:
raise werkzeug.exceptions.NotFound()

Check warning on line 70 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L70

Added line #L70 was not covered by tests

cielo_token = post["token"]
response = None

Check warning on line 73 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L72-L73

Added lines #L72 - L73 were not covered by tests
if tx.type == "form_save" and tx.partner_id:
payment_token_id = (

Check warning on line 75 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L75

Added line #L75 was not covered by tests
request.env["payment.token"]
.sudo()
.create(
{
"acquirer_id": tx.acquirer_id.id,
"partner_id": tx.partner_id.id,
"cielo_token": cielo_token,
}
)
)
tx.payment_token_id = payment_token_id
response = tx._create_cielo_charge(

Check warning on line 87 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L86-L87

Added lines #L86 - L87 were not covered by tests
acquirer_ref=payment_token_id.acquirer_ref, email=cielo_token["email"]
)
else:
response = tx._create_cielo_charge(

Check warning on line 91 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L91

Added line #L91 was not covered by tests
tokenid=cielo_token["id"], email=cielo_token["email"]
)
_logger.info(

Check warning on line 94 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L94

Added line #L94 was not covered by tests
"Cielo: entering form_feedback with post data %s", pprint.pformat(response)
)
if response:
request.env["payment.transaction"].sudo().with_context(

Check warning on line 98 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L98

Added line #L98 was not covered by tests
lang=None
).form_feedback(response, "cielo")
# Add the payment transaction into the session to let the page
# /payment/process handle it.
PaymentProcessing.add_payment_transaction(tx)
return "/payment/process"

Check warning on line 104 in payment_cielo/controllers/main.py

View check run for this annotation

Codecov / codecov/patch

payment_cielo/controllers/main.py#L103-L104

Added lines #L103 - L104 were not covered by tests
25 changes: 25 additions & 0 deletions payment_cielo/data/payment_acquirer_data.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8" ?>
<odoo>
<data noupdate="0">
<record id="payment_acquirer_cielo" model="payment.acquirer">
<field name="name">Cielo</field>
<field
name="image_128"
type="base64"
file="payment_cielo/static/src/img/cielo_icon.png"
/>
<field name="provider">cielo</field>
<field name="payment_flow">s2s</field>
<field name="company_id" ref="base.main_company" />
<field name="view_template_id" ref="cielo_form" />
<field name="registration_view_template_id" ref="cielo_s2s_form" />
<field name="state">test</field>
<field
name="pre_msg"
><![CDATA[
<p>You will be prompted with Cielo Payment page for payment information.</p>]]></field>
<field name="cielo_merchant_id">dummy</field>
<field name="cielo_merchant_key">dummy</field>
</record>
</data>
</odoo>
Loading
Loading