Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_liqpay_sign(payment_data, action):
- import base64
- import hashlib
- """
- action == 'to_send' when use sign for submit form to PB
- action == 'to_validate' when use sign to validate PB response
- """
- str_for_sign = ''
- if action == "to_send":
- keys_for_sign = ['private_key', 'amount', 'currency', 'public_key',
- 'order_id', 'type', 'description', 'result_url',
- 'server_url']
- elif action == "to_validate":
- keys_for_sign = ['private_key', 'amount', 'currency', 'public_key',
- 'order_id', 'type', 'description', 'status',
- 'transaction_id', 'sender_phone']
- for key in keys_for_sign:
- str_for_sign += str(payment_data[key])
- result = base64.b64encode(
- hashlib.sha1(str_for_sign).digest()
- )
- return result
- ----
- payment_data = {
- "public_key": merchant_data.get("merchant_id"),
- "private_key": merchant_data.get("merchant_sign"),
- "amount": temp_order.pay_total(),
- "currency": temp_order.currency,
- "order_id": temp_order.id,
- "type": "buy",
- "order": temp_order,
- "description": "Oplata zakaza #%s" % temp_order.number,
- "result_url": result_url,
- "server_url": server_url,
- }
- signature = get_liqpay_sign(payment_data, 'to_send')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement