Browse Source

Dec 8 : [FIX] Bug Fixed 'myfatoorah_payment_gateway'

pull/295/head
AjmalCybro 1 year ago
parent
commit
f9a30a6906
  1. 2
      myfatoorah_payment_gateway/controllers/main.py
  2. 1
      myfatoorah_payment_gateway/data/payment_provider_data.xml
  3. 15
      myfatoorah_payment_gateway/models/payment_transaction.py

2
myfatoorah_payment_gateway/controllers/main.py

@ -19,8 +19,6 @@
# If not, see <http://www.gnu.org/licenses/>.
#
#############################################################################
import logging
import pprint
import json

1
myfatoorah_payment_gateway/data/payment_provider_data.xml

@ -7,5 +7,4 @@
<field name="company_id" ref="base.main_company"/>
<field name="redirect_form_view_id" ref="redirect_form"/>
</record>
</odoo>

15
myfatoorah_payment_gateway/models/payment_transaction.py

@ -62,13 +62,18 @@ class PaymentTransaction(models.Model):
]
MobileCountryCode = self.partner_id.country_id.phone_code
phone_number = self.partner_phone
phone_number = phone_number.replace(str(MobileCountryCode), '')
if phone_number.startswith('+'):
phone_number = phone_number[1:]
if not phone_number:
raise ValueError("Please provide the phone number.")
if phone_number:
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
payment_details = {
"PaymentMethodId": 6,
"CustomerName": self.partner_name,
"DisplayCurrencyIso": self.currency_id.name,
"DisplayCurrencyIso": currency,
"MobileCountryCode": MobileCountryCode,
"CustomerMobile": phone_number,
"CustomerEmail": self.partner_email,
@ -89,8 +94,10 @@ class PaymentTransaction(models.Model):
'Authorization': f'Bearer {api_key}',
}
payload = json.dumps(payment_details)
print(payload,'payload')
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')}")

Loading…
Cancel
Save