Click here to Skip to main content
15,889,281 members
Home / Discussions / Python
   

Python

 
AnswerRe: Which technique to apply if function Y changes with values of X variables other than linear regression Pin
Dave Kreskowiak7-Aug-23 12:57
mveDave Kreskowiak7-Aug-23 12:57 
GeneralRe: Which technique to apply if function Y changes with values of X variables other than linear regression Pin
Andre Oosthuizen7-Aug-23 23:18
mveAndre Oosthuizen7-Aug-23 23:18 
QuestionFile memory usage issues Pin
DevilDuck1236-Jul-23 20:26
DevilDuck1236-Jul-23 20:26 
AnswerRe: File memory usage issues Pin
Maverick49426-Aug-23 13:05
Maverick49426-Aug-23 13:05 
QuestionRoom arrangements Pin
ajay singh May20232-Jul-23 8:53
ajay singh May20232-Jul-23 8:53 
AnswerRe: Room arrangements Pin
Richard MacCutchan2-Jul-23 21:52
mveRichard MacCutchan2-Jul-23 21:52 
AnswerRe: Room arrangements Pin
Andre Oosthuizen3-Jul-23 0:43
mveAndre Oosthuizen3-Jul-23 0:43 
QuestionInvalid signature - Fondy payment gateway Pin
Kostiantyn Lahutin27-Jun-23 4:04
Kostiantyn Lahutin27-Jun-23 4:04 
I am creating a bot (Python, aiogram) with a paid subscription using the Fondy payment gateway. I am using the principle of checking the payment status, but after sending the request, I receive the following error: "{'response': {'error_code': 1014, 'error_message': 'Invalid signature signature: 8dccc7a9e053c3cdc1efddb13f906bc866239ae6; response_signature_string: **********|1396424|85cceedc-e54a-43f5-a9fd-e39dc6f15c1a', 'request_id': 'ZKIukrDkwZDz9', 'response_status': 'failure'}}". Even though the order_id (85cceedc-e54a-43f5-a9fd-e39dc6f15c1a) is displayed correctly, the signature is still incorrect. Please help me find the error. Here is the payment code. <pre>0 @dp.message_handler(commands ='FONDY')
async def order_fondy(message: types.Message):
people_id = message.chat.id
base = sqlite3.connect('users.db')
cursor = base.cursor()

order_id = str(uuid.uuid4())
print(order_id)
cursor.execute(f"UPDATE users_id SET order_id == ? WHERE user_id == ?",
(order_id, people_id))
base.commit()

def generate_signature( order_id):
params1 = {

'merchant_id': '1396424',
'order_desc': 'demo order',
'currency': 'USD',
'amount': '125',
'order_id': f'{order_id}'
}
password = 'test'

# Generating a list of values sorted by key
values = []
for key in sorted(params1.keys()):
value = params1[key]
# Skipping empty values
if value:
values.append(str(value))

# Adding a parameter named "password" with the value 'test' to the beginning of the list of values
values.insert(0, password)

# Generating a string of values separated by a delimiter "|"
signature_string = "|".join(values)
print(signature_string)
# Applying the SHA1 function to a string and returning the result in the format of a hexadecimal string
signature = hashlib.sha1(signature_string.encode('utf-8')).hexdigest()

return signature

signature = generate_signature(order_id)
print(signature) # Displaying the signature

api = Api(merchant_id=1396424,
secret_key='test')
checkout = Checkout(api=api)
data = {
'order_desc': 'demo order',
'currency': 'USD',
'amount': '125',
'order_id': f'{order_id}'
}

payment_url = checkout.url(data).get('checkout_url')

# Sending payment links to the user
await message.reply(f"To make a payment, please follow the link: {payment_url}")

# Checking the payment status
@dp.callback_query_handler(text='check')
async def check_payment_status(call: CallbackQuery):
people_id = call.message.chat.id
connect = sqlite3.connect('users.db')
cursor = connect.cursor()
cursor.execute(f"SELECT order_id FROM users_id WHERE user_id = {people_id}")
result_1 = cursor.fetchone()
order_id = str(result_1[0])
print(order_id)
cursor.execute(f"SELECT payment_id FROM users_id WHERE user_id = {people_id}")
result_2 = cursor.fetchone()
signature = str(result_2[0])
print(signature)
url = 'https://pay.fondy.eu/api/status/order_id'
headers = {'Content-Type': 'application/json'}
data = {
"request": {
'currency': 'USD',
'amount': '125',
'order_id': f'{order_id}',
'merchant_id': '1396424',
'signature': f'{signature}',
'order_desc': 'demo order',
"response_url": "https://pay.fondy.eu/responsepage/"
}
}

async with aiohttp.ClientSession() as session:
async with session.post(url, headers=headers, data=json.dumps(data)) as response:
response_data = await response.json()
print(response_data)


if response.status == 200:
# Handling a successful response</pre>
AnswerRe: Invalid signature - Fondy payment gateway Pin
Richard MacCutchan27-Jun-23 5:23
mveRichard MacCutchan27-Jun-23 5:23 
GeneralRe: Invalid signature - Fondy payment gateway Pin
Kostiantyn Lahutin29-Jun-23 0:15
Kostiantyn Lahutin29-Jun-23 0:15 
AnswerRe: Invalid signature - Fondy payment gateway Pin
jschell28-Jun-23 6:15
jschell28-Jun-23 6:15 
GeneralRe: Invalid signature - Fondy payment gateway Pin
Kostiantyn Lahutin29-Jun-23 0:13
Kostiantyn Lahutin29-Jun-23 0:13 
AnswerRe: Invalid signature - Fondy payment gateway Pin
Maverick49426-Aug-23 13:40
Maverick49426-Aug-23 13:40 
Questionfor machin software's Pin
pilot choice18-May-23 6:31
pilot choice18-May-23 6:31 
AnswerRe: for machin software's Pin
Richard MacCutchan18-May-23 6:33
mveRichard MacCutchan18-May-23 6:33 
QuestionClosed. This question is not written in English. It is not currently accepting answers. Stack Overflow is an English-only site. If you are confident that you will be able to understand and respond to answers and comments in English, please edit your Pin
Member 1599162128-Apr-23 23:38
Member 1599162128-Apr-23 23:38 
AnswerRe: Closed. This question is not written in English. It is not currently accepting answers. Stack Overflow is an English-only site. If you are confident that you will be able to understand and respond to answers and comments in English, please edit y Pin
OriginalGriff28-Apr-23 23:48
mveOriginalGriff28-Apr-23 23:48 
AnswerRe: Closed. This question is not written in English. It is not currently accepting answers. Stack Overflow is an English-only site. If you are confident that you will be able to understand and respond to answers and comments in English, please edit y Pin
Richard MacCutchan29-Apr-23 0:20
mveRichard MacCutchan29-Apr-23 0:20 
QuestionInsensitive Match with Sensitive Substitute? Pin
Philip Derrida14-Apr-23 2:22
Philip Derrida14-Apr-23 2:22 
AnswerRe: Insensitive Match with Sensitive Substitute? Pin
OriginalGriff14-Apr-23 2:23
mveOriginalGriff14-Apr-23 2:23 
AnswerRe: Insensitive Match with Sensitive Substitute? Pin
Richard MacCutchan14-Apr-23 2:46
mveRichard MacCutchan14-Apr-23 2:46 
QuestionPartial Functions? Pin
glennPattonWork35-Apr-23 6:16
professionalglennPattonWork35-Apr-23 6:16 
AnswerRe: Partial Functions? Pin
Richard MacCutchan5-Apr-23 6:24
mveRichard MacCutchan5-Apr-23 6:24 
GeneralRe: Partial Functions? Pin
glennPattonWork35-Apr-23 21:38
professionalglennPattonWork35-Apr-23 21:38 
GeneralRe: Partial Functions? Pin
Richard MacCutchan5-Apr-23 22:52
mveRichard MacCutchan5-Apr-23 22:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.