|
|
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>
|
|
|
|
|
|
|
Googling returns several results
fondy "1014" "invalid signature"
As a guess by briefly looking at the github example first page and from past experience with past services I am guessing the following. (Pretty strong guess.)
1. The 'signature' is generated based on the input that you are pushing in the request.
2. You are generating the signature incorrectly based on what you are actually sending.
If my guess is correct then you need to more closely read what the 'signature' means and how to generate it.
The github link in the above google search suggests and exact algorithm.
|
|
|
|
|
|
Based on Accept purchase - FONDY Documentation[^] I think you are not setting the signature correctly.
based on your code you set signature wrong, I think, it's hard to read. They are expecting a sha1 hash of password|amount|currency|merchant_id|order_id|order_desc. Maybe I am not reading your post correctly because it is all lumped together, but it seems to me that the problem is the signature is not being set to a sha1 hash of those items based on result_2 = cursor.fetchone() and signature = str(result_2[0]) it is set to payment_id.
|
|
|
|
|
which programming language is much better in AI
|
|
|
|
|
The one that creates the best answers.
|
|
|
|
|
I want to learn Python but I don't know where to start to study any programmer to help me. I tried to study on my own but it was too heavy for me.(Quiero aprender Python pero no se por donde empezar a estudiar algun programador que me ayude. Traté de estudiar por mi cuenta, pero era demasiado pesado para mí)
|
|
|
|
|
The best ways to get started are in order:
1) Go on a course. The material will be structured and organised so you get introduced to every part of the language provided you do all the exercises. In addition, if you don;t understand something, a human tutor can explain in different ways until you do.
2) Get a book. The material will be structured and organised so you get introduced to every part of the language provided you do all the exercises. Wrox an Addison Wesley do good ones on most programming languages.
3) Guess, and try to work it out on your own. You might learn something, but it probably won't be what you should be learning. Very poor method, you don't get introduced to anything that you haven't met ...
4) Grab other peoples code and try to understand it. You will learn nothing other than some people release code that doesn't actually work ...
5) Youtube videos. Generally produced by people with no idea how to make a video, how to teach, and most cases how to code; produced for the likes and subscribes as these monetize the channel. There are probably some good ones out there, but they are buried under a sea of rubbish so nobody is likely to find them.
Would I start with Python? No - I'd start with a compiled language like C#, because at least you have to get all the silly syntax errors out of the way before you can run your code. With an interpreted language like Python, something you wrote 2 weeks ago can fail to run when you add new code because that part had never actually been executed before.
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
Rookie question:
Imagine a script that replaces the vowels of curse words with *. Is it possible to match the curse words without case sensitivity but retain the case in the replacement so that the original case format (tone) is retained?
|
|
|
|
|
|
Try this:
table = str.maketrans('aeiouAEIOU', '**********')
for curseword in listofwords:
clearword = curseword.translate(table)
print(clearword)
|
|
|
|
|
Hi All,
Partial Functions I'm sorry can't see any point in them.
from functools import partial
def multiply(x, y):
return x * y
dbl = partial(multiply, 2)
print(dbl(4))
is that supposed to better than multiply(4,2)? or is just a bad example???
|
|
|
|
|
|
Hmmm, a feature that you need on occasions for runtime..?
|
|
|
|
|
I have still not come across a problem that 'needs' this feature. But maybe that's because my blue sky thinking has so many clouds in it.
|
|
|
|
|
|
|
I am sorry whats the use of them in C++ (the first place I came across them) and now in Python what? why? The examples of how to use them not why...
|
|
|
|
|
How to create a anaimations using python
|
|
|
|
|
Hi,
I want to read the pcap file and devide the data into 64byte chunks.
If you need any more info, please let me know.
|
|
|
|
|
That depends on what you're doing with the file. Are you trying to read the file without interpreting the content? Or are you interpreting the content and doing something with that?
|
|
|
|