diff --git a/myfatoorah_payment_gateway/README.rst b/myfatoorah_payment_gateway/README.rst
index 220ca8f3e..841049bfc 100644
--- a/myfatoorah_payment_gateway/README.rst
+++ b/myfatoorah_payment_gateway/README.rst
@@ -18,8 +18,9 @@ Company
Credits
-------
-* Developer:
+* Developers:
(v16) Swaroop N P @ Cybrosys
+Subina P @ Cybrosys
Contacts
diff --git a/myfatoorah_payment_gateway/__manifest__.py b/myfatoorah_payment_gateway/__manifest__.py
index 49c2f113d..e8068937f 100644
--- a/myfatoorah_payment_gateway/__manifest__.py
+++ b/myfatoorah_payment_gateway/__manifest__.py
@@ -19,7 +19,6 @@
# If not, see .
#
#############################################################################
-
{
'name': 'MyFatoorah Payment Gateway',
'category': 'Accounting/Payment Acquirers',
@@ -37,7 +36,6 @@
'views/payment_myfatoorah_templates.xml',
'views/myfatoorah_payment_template.xml',
'data/payment_provider_data.xml',
-
],
'post_init_hook': 'post_init_hook',
'uninstall_hook': 'uninstall_hook',
diff --git a/myfatoorah_payment_gateway/controllers/main.py b/myfatoorah_payment_gateway/controllers/main.py
index 32c4deb5c..3181eb3c6 100644
--- a/myfatoorah_payment_gateway/controllers/main.py
+++ b/myfatoorah_payment_gateway/controllers/main.py
@@ -37,6 +37,7 @@ class PaymentMyFatoorahController(http.Controller):
website=True, methods=['POST'], csrf=False, save_session=False)
def myfatoorah_payment_response(self, **data):
"""Function to get the payment response"""
+
payment_data = ast.literal_eval(data["data"])
vals = {
'customer': payment_data["CustomerName"],
@@ -44,7 +45,7 @@ class PaymentMyFatoorahController(http.Controller):
'mobile': payment_data["CustomerMobile"],
'invoice_amount': payment_data["InvoiceValue"],
'address': payment_data["CustomerAddress"]["Address"],
- 'payment_url': payment_data["PaymentURL"],
+ 'payment_url': payment_data["InvoiceURL"],
}
return request.render(
"myfatoorah_payment_gateway.myfatoorah_payment_gateway_form", vals)
diff --git a/myfatoorah_payment_gateway/data/payment_provider_data.xml b/myfatoorah_payment_gateway/data/payment_provider_data.xml
index 8c6781ab9..f0f47cbeb 100644
--- a/myfatoorah_payment_gateway/data/payment_provider_data.xml
+++ b/myfatoorah_payment_gateway/data/payment_provider_data.xml
@@ -4,6 +4,10 @@
myfatoorah
+
diff --git a/myfatoorah_payment_gateway/models/payment_provider.py b/myfatoorah_payment_gateway/models/payment_provider.py
index aff9a272f..987751f87 100644
--- a/myfatoorah_payment_gateway/models/payment_provider.py
+++ b/myfatoorah_payment_gateway/models/payment_provider.py
@@ -19,7 +19,7 @@
# If not, see .
#
#############################################################################
-from odoo import fields, models, api, _
+from odoo import fields, models, api
class PaymentProvider(models.Model):
diff --git a/myfatoorah_payment_gateway/models/payment_transaction.py b/myfatoorah_payment_gateway/models/payment_transaction.py
index 79ee9ca22..71b5bafff 100644
--- a/myfatoorah_payment_gateway/models/payment_transaction.py
+++ b/myfatoorah_payment_gateway/models/payment_transaction.py
@@ -20,7 +20,7 @@
#############################################################################
# Import required libraries (make sure it is installed!)
import logging
-from odoo import _, api, fields, models
+from odoo import _, models
from odoo.exceptions import ValidationError
import requests
import json
@@ -36,42 +36,34 @@ class PaymentTransaction(models.Model):
res = super()._get_specific_rendering_values(processing_values)
if self.provider_code != 'myfatoorah':
return res
- return self.execute_payment()
+ return self.send_payment()
- def execute_payment(self):
- """Fetching data and Executing Payment"""
+ def send_payment(self):
base_api_url = self.env['payment.provider'].search(
[('code', '=', 'myfatoorah')])._myfatoorah_get_api_url()
- api_url = f"{base_api_url}v2/ExecutePayment"
+ api_url = f"{base_api_url}v2/SendPayment"
api_key = self.env['payment.provider'].search([('code', '=',
'myfatoorah')]).myfatoorah_token
odoo_base_url = self.env['ir.config_parameter'].get_param(
'web.base.url')
+
sale_order = self.env['payment.transaction'].search(
[('id', '=', self.id)]).sale_order_ids
-
- order_line = self.env['payment.transaction'].search(
- [('id', '=', self.id)]).sale_order_ids.order_line
- invoice_items = [
- {
- 'ItemName': rec.product_id.name,
- 'Quantity': int(rec.product_uom_qty),
- 'UnitPrice': rec.price_unit,
- }
- for rec in order_line
- ]
MobileCountryCode = self.partner_id.country_id.phone_code
phone_number = self.partner_phone
if not phone_number:
raise ValueError("Please provide the phone number.")
- if phone_number:
+ else:
phone_number = phone_number.replace(str(MobileCountryCode), '')
if phone_number.startswith('+'):
phone_number = phone_number[1:]
- currency = self.partner_id.company_id.currency_id.name
+ elif not phone_number:
+ raise ValueError(
+ "Please provide the phone number in proper format")
+ currency = self.env.company.currency_id.name
- payment_details = {
- "PaymentMethodId": 6,
+ sendpay_data = {
+ "NotificationOption": "ALL",
"CustomerName": self.partner_name,
"DisplayCurrencyIso": currency,
"MobileCountryCode": MobileCountryCode,
@@ -85,28 +77,27 @@ class PaymentTransaction(models.Model):
"CustomerAddress": {
"Address": f'{self.partner_address} ,{self.partner_city} {self.partner_zip} ,{self.partner_state_id.name} ,{self.partner_country_id.name}',
},
- "InvoiceItems":
- invoice_items
}
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': f'Bearer {api_key}',
}
- payload = json.dumps(payment_details)
- print(payload,'payload')
+ payload = json.dumps(sendpay_data)
response = requests.request("POST", api_url, headers=headers,
data=payload)
- print(response,'response...')
response_data = response.json()
if not response_data.get('IsSuccess'):
- raise ValidationError(f"{response_data.get('Message')}")
- if response_data.get('Data')['PaymentURL']:
- payment_url = response_data.get('Data')['PaymentURL']
- payment_details['PaymentURL'] = payment_url
+ validation_errors = response_data.get('ValidationErrors')
+ if validation_errors:
+ error_message = validation_errors[0].get('Error')
+ raise ValidationError(f"{error_message}")
+ if response_data.get('Data')['InvoiceURL']:
+ payment_url = response_data.get('Data')['InvoiceURL']
+ sendpay_data['InvoiceURL'] = payment_url
return {
'api_url': f"{odoo_base_url}/payment/myfatoorah/response",
- 'data': payment_details,
+ 'data': sendpay_data,
}
def _get_tx_from_notification_data(self, provider_code, notification_data):
diff --git a/myfatoorah_payment_gateway/static/description/assets/screenshots/screenshot4.png b/myfatoorah_payment_gateway/static/description/assets/screenshots/screenshot4.png
index c5f46e81a..7fba584a4 100644
Binary files a/myfatoorah_payment_gateway/static/description/assets/screenshots/screenshot4.png and b/myfatoorah_payment_gateway/static/description/assets/screenshots/screenshot4.png differ
diff --git a/myfatoorah_payment_gateway/static/description/index.html b/myfatoorah_payment_gateway/static/description/index.html
index 2402a2801..71175d0d8 100644
--- a/myfatoorah_payment_gateway/static/description/index.html
+++ b/myfatoorah_payment_gateway/static/description/index.html
@@ -100,7 +100,8 @@
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/
instead of 'localhost' to access the module.
+ testing purposes, please use http://127.0.0.1/ instead of 'localhost' to access the module.
+ Also, ensure that the phone number format and currency match the standards of the supported countries.
@@ -398,7 +399,7 @@
-
+
@@ -525,7 +526,7 @@
-
+
@@ -578,4 +579,4 @@
-
\ No newline at end of file
+
diff --git a/myfatoorah_payment_gateway/static/src/js/modal.js b/myfatoorah_payment_gateway/static/src/js/modal.js
new file mode 100644
index 000000000..5e5d5ea58
--- /dev/null
+++ b/myfatoorah_payment_gateway/static/src/js/modal.js
@@ -0,0 +1,22 @@
+//// Import the necessary dependencies
+//import { useService } from '@odoo/owl';
+//import { useRef } from '@odoo/owl';
+//
+//class YourComponent {
+// setup() {
+// this.orm = useService('orm');
+// this.preview = useRef('preview_modal');
+// this._super.apply(this, arguments);
+//
+// // Call a method to open the modal
+// this.openModal();
+// }
+//
+// openModal() {
+// // Assuming you are using Bootstrap, trigger the modal by its ID
+// const modal = new bootstrap.Modal(document.getElementById('preview_modal'));
+// modal.show();
+// }
+//}
+//
+//export default YourComponent;
diff --git a/myfatoorah_payment_gateway/views/myfatoorah_payment_template.xml b/myfatoorah_payment_gateway/views/myfatoorah_payment_template.xml
index 840f834e5..276e490f9 100644
--- a/myfatoorah_payment_gateway/views/myfatoorah_payment_template.xml
+++ b/myfatoorah_payment_gateway/views/myfatoorah_payment_template.xml
@@ -36,16 +36,6 @@
-
-
-
-
-
-
-
-
-
-
Mobile
@@ -56,9 +46,7 @@
t-att-value="mobile"
readonly="1"/>
-
-
-
+
Invoice Amount
@@ -68,6 +56,8 @@
t-att-value="invoice_amount"
readonly="1"/>
+
+
Address
diff --git a/myfatoorah_payment_gateway/views/payment_myfatoorah_templates.xml b/myfatoorah_payment_gateway/views/payment_myfatoorah_templates.xml
index 83955c59f..e84b47b0a 100644
--- a/myfatoorah_payment_gateway/views/payment_myfatoorah_templates.xml
+++ b/myfatoorah_payment_gateway/views/payment_myfatoorah_templates.xml
@@ -1,6 +1,5 @@
-
-