Browse Source

Oct 18 : [FIX] Bug Fixed 'myfatoorah_payment_gateway'

pull/295/head
AjmalCybro 2 years ago
parent
commit
73d8562b20
  1. 2
      myfatoorah_payment_gateway/controllers/__init__.py
  2. 7
      myfatoorah_payment_gateway/controllers/main.py
  3. 4
      myfatoorah_payment_gateway/doc/RELEASE_NOTES.md
  4. 4
      myfatoorah_payment_gateway/models/__init__.py
  5. 2
      myfatoorah_payment_gateway/models/payment_provider.py
  6. 20
      myfatoorah_payment_gateway/models/payment_transaction.py
  7. 6
      myfatoorah_payment_gateway/static/description/index.html

2
myfatoorah_payment_gateway/controllers/__init__.py

@ -19,6 +19,4 @@
# If not, see <http://www.gnu.org/licenses/>. # If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################# #############################################################################
from . import main from . import main

7
myfatoorah_payment_gateway/controllers/main.py

@ -38,11 +38,11 @@ class PaymentMyFatoorahController(http.Controller):
@http.route('/payment/myfatoorah/response', type='http', auth='public', @http.route('/payment/myfatoorah/response', type='http', auth='public',
website=True, methods=['POST'], csrf=False, save_session=False) website=True, methods=['POST'], csrf=False, save_session=False)
def myfatoorah_payment_response(self, **data): def myfatoorah_payment_response(self, **data):
"""Function to get the payment response"""
payment_data = ast.literal_eval(data["data"]) payment_data = ast.literal_eval(data["data"])
vals = { vals = {
'customer': payment_data["CustomerName"], 'customer': payment_data["CustomerName"],
'currency': payment_data["DisplayCurrencyIso"], 'currency': payment_data["DisplayCurrencyIso"],
# 'country_code': payment_data["MobileCountryCode"],
'mobile': payment_data["CustomerMobile"], 'mobile': payment_data["CustomerMobile"],
'invoice_amount': payment_data["InvoiceValue"], 'invoice_amount': payment_data["InvoiceValue"],
'address': payment_data["CustomerAddress"]["Address"], 'address': payment_data["CustomerAddress"]["Address"],
@ -54,6 +54,7 @@ class PaymentMyFatoorahController(http.Controller):
@http.route(_return_url, type='http', auth='public', @http.route(_return_url, type='http', auth='public',
methods=['GET']) methods=['GET'])
def myfatoorah_checkout(self, **data): def myfatoorah_checkout(self, **data):
""" Function to redirect to the payment checkout"""
_logger.info("Received MyFatoorah return data:\n%s", _logger.info("Received MyFatoorah return data:\n%s",
pprint.pformat(data)) pprint.pformat(data))
tx_sudo = request.env[ tx_sudo = request.env[
@ -64,7 +65,7 @@ class PaymentMyFatoorahController(http.Controller):
@http.route('/payment/myfatoorah/failed', type='http', auth='user', @http.route('/payment/myfatoorah/failed', type='http', auth='user',
website=True, ) website=True, )
def payment_failed(self, redirect=None, **data): def payment_failed(self, redirect=None, **data):
# self.myfatoorah_checkout(data = data) """ Function to render the payment failed cases"""
return request.render( return request.render(
"myfatoorah_payment_gateway.myfatoorah_payment_gateway_failed_form") "myfatoorah_payment_gateway.myfatoorah_payment_gateway_failed_form")

4
myfatoorah_payment_gateway/doc/RELEASE_NOTES.md

@ -5,3 +5,7 @@
#### ADD #### ADD
Initial Commit Initial Commit
#### 18.10.2023
#### Version 16.0.1.0.1
#### ADD
The payment fail issue is fixed

4
myfatoorah_payment_gateway/models/__init__.py

@ -19,9 +19,5 @@
# If not, see <http://www.gnu.org/licenses/>. # If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################# #############################################################################
from . import payment_provider from . import payment_provider
from . import payment_transaction from . import payment_transaction

2
myfatoorah_payment_gateway/models/payment_provider.py

@ -19,8 +19,6 @@
# If not, see <http://www.gnu.org/licenses/>. # If not, see <http://www.gnu.org/licenses/>.
# #
############################################################################# #############################################################################
from odoo import fields, models, api, _ from odoo import fields, models, api, _

20
myfatoorah_payment_gateway/models/payment_transaction.py

@ -32,6 +32,7 @@ class PaymentTransaction(models.Model):
_inherit = 'payment.transaction' _inherit = 'payment.transaction'
def _get_specific_rendering_values(self, processing_values): def _get_specific_rendering_values(self, processing_values):
""" Function to fetch the values of the payment gateway"""
res = super()._get_specific_rendering_values(processing_values) res = super()._get_specific_rendering_values(processing_values)
if self.provider_code != 'myfatoorah': if self.provider_code != 'myfatoorah':
return res return res
@ -59,17 +60,17 @@ class PaymentTransaction(models.Model):
} }
for rec in order_line for rec in order_line
] ]
if len(self.partner_phone.replace('-', "").rsplit(' ', 1)[1]) > 11: MobileCountryCode = self.partner_id.country_id.phone_code
raise ValidationError( phone_number = self.partner_phone
_("Phone number must not be greater than 11 characters")) phone_number = phone_number.replace(str(MobileCountryCode), '')
if phone_number.startswith('+'):
phone_number = phone_number[1:]
payment_details = { payment_details = {
"PaymentMethodId": 6, "PaymentMethodId": 6,
"CustomerName": self.partner_name, "CustomerName": self.partner_name,
"DisplayCurrencyIso": self.currency_id.name, "DisplayCurrencyIso": self.currency_id.name,
# "MobileCountryCode": "964", "MobileCountryCode": MobileCountryCode,
# "CustomerMobile": "78589587458", "CustomerMobile": phone_number,
"CustomerMobile":
self.partner_phone.replace('-', "").rsplit(' ', 1)[1],
"CustomerEmail": self.partner_email, "CustomerEmail": self.partner_email,
"InvoiceValue": (self.amount - sale_order.amount_tax), "InvoiceValue": (self.amount - sale_order.amount_tax),
"CallBackUrl": f"{odoo_base_url}/payment/myfatoorah/_return_url", "CallBackUrl": f"{odoo_base_url}/payment/myfatoorah/_return_url",
@ -78,7 +79,6 @@ class PaymentTransaction(models.Model):
"CustomerReference": self.reference, "CustomerReference": self.reference,
"CustomerAddress": { "CustomerAddress": {
"Address": f'{self.partner_address} ,{self.partner_city} {self.partner_zip} ,{self.partner_state_id.name} ,{self.partner_country_id.name}', "Address": f'{self.partner_address} ,{self.partner_city} {self.partner_zip} ,{self.partner_state_id.name} ,{self.partner_country_id.name}',
}, },
"InvoiceItems": "InvoiceItems":
invoice_items invoice_items
@ -129,7 +129,7 @@ class PaymentTransaction(models.Model):
reference = "" reference = ""
if response_data["Data"]["CustomerReference"]: if response_data["Data"]["CustomerReference"]:
reference = response_data["Data"]["CustomerReference"] reference = response_data["Data"]["CustomerReference"]
domain.append(reference) domain.append(('reference', '=', str(reference)))
if tx := self.search(domain): if tx := self.search(domain):
return tx return tx
else: else:
@ -140,6 +140,7 @@ class PaymentTransaction(models.Model):
) )
def _handle_notification_data(self, provider_code, notification_data): def _handle_notification_data(self, provider_code, notification_data):
"""Function to handle the notification data """
tx = self._get_tx_from_notification_data(provider_code, tx = self._get_tx_from_notification_data(provider_code,
notification_data) notification_data)
tx._process_notification_data(notification_data) tx._process_notification_data(notification_data)
@ -147,6 +148,7 @@ class PaymentTransaction(models.Model):
return tx return tx
def _process_notification_data(self, notification_data): def _process_notification_data(self, notification_data):
""" Function to process the notification data"""
super()._process_notification_data(notification_data) super()._process_notification_data(notification_data)
if self.provider_code != 'myfatoorah': if self.provider_code != 'myfatoorah':
return return

6
myfatoorah_payment_gateway/static/description/index.html

@ -97,7 +97,11 @@
</h2> </h2>
</div> </div>
<div class="row" style="font-family: 'Montserrat', sans-serif; font-weight: 400; font-size: 14px; line-height: 200%;"> <div class="row" style="font-family: 'Montserrat', sans-serif; font-weight: 400; font-size: 14px; line-height: 200%;">
<div class="col-sm-12 py-4">This module allows us to add and enable MyFatoorah payment acquirer on our website.</div> <div class="col-sm-12 py-4">This module allows us to add and enable MyFatoorah payment acquirer on our website.
Please ensure that your system is configured to use HTTPS instead of localhost to maintain a secure connection
and protect sensitive information during interactions with the module.In case you are utilizing localhost for
testing purposes, please use http://127.0.0.1/<portnumber> instead of 'localhost' to access the module.
</div>
</div> </div>
<!-- END OF OVERVIEW SECTION --> <!-- END OF OVERVIEW SECTION -->

Loading…
Cancel
Save